Skip to content

Commit

Permalink
Dev Removed obsolete function
Browse files Browse the repository at this point in the history
Dev Added MD5 hash when checking for updates
  • Loading branch information
c-schmitz committed Nov 16, 2012
1 parent 2782749 commit 45bc1ca
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 75 deletions.
74 changes: 0 additions & 74 deletions application/controllers/InstallerController.php
Expand Up @@ -1186,78 +1186,4 @@ function _dbConnect($aDbConfig = array(), $aData = array())
}
}

/**
* Function to install the LimeSurvey database from the command line
* Call it like:
* php index.php installer cmd_install_db
* from your command line
* The function assumes that /config/database.php is already configured and the database controller
* is added in autoload.php in the libraries array
*
*/
function cmd_install_db()
{
if (php_sapi_name() != 'cli')
{
die('This function can only be run from the command line');
}

$sDbType = $this->db->dbdriver;
if (!in_array($sDbType, InstallerConfigForm::supported_db_types)) {
throw new Exception(sprintf('Unkown database type "%s".', $sDbType));
}

$aDbConfig = array(
'sDatabaseName' => $this->db->database,
'sDatabaseLocation' => $this->db->hostname,
'sDatabaseUser' => $this->db->username,
'sDatabasePwd' => $this->db->password,
'sDatabaseType' => $sDbType,
'sDatabasePort' => $this->db->port,
);

$sDbPrefix= $this->db->dbprefix;
self::_dbConnect($aDbConfig);
$aErrors = self::_setup_tables(Yii::app()->getConfig('rootdir').'/installer/sql/create-'.$sFileName.'.sql',$aDbConfig,$sDbPrefix);

foreach ($aErrors as $sError)
{
echo $sError.PHP_EOL;
}

$sPasswordHash=hash('sha256', Yii::app()->getConfig('defaultpass'));

try {
$this->connection->createCommand()->insert("{{settings_global}}", array('stg_name' => 'SessionName', 'stg_value' => 'ls'.self::_getRandomID().self::_getRandomID().self::_getRandomID()));
$this->connection->createCommand()->insert('{{users}}', array(
'users_name'=>Yii::app()->getConfig('defaultuser'),
'password'=>$sPasswordHash,
'full_name'=>Yii::app()->getConfig('siteadminname'),
'parent_id'=>0,
'lang'=>'auto',
'email'=>Yii::app()->getConfig('siteadminemail'),
'create_survey'=>1,
'participant_panel'=>1,
'create_user'=>1,
'delete_user'=>1,
'superadmin'=>1,
'configurator'=>1,
'manage_template'=>1,
'manage_label'=>1
));
} catch (Exception $e) {
$aErrors[] = $e;
}

if (count($aErrors)>0) {
echo "There were errors during the installation.\n";
foreach ($aErrors as $sError) {
echo "Error: " . $sError . "\n";
}
} else {
echo "Installation was successful.\n";

}
}

}
2 changes: 1 addition & 1 deletion application/helpers/common_helper.php
Expand Up @@ -5649,7 +5649,7 @@ function getUpdateInfo()
$http->timeout=0;
$http->data_timeout=0;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$http->GetRequestArguments("http://update.limesurvey.org?build=".Yii::app()->getConfig("buildnumber"),$arguments);
$http->GetRequestArguments("http://update.limesurvey.org?build=".Yii::app()->getConfig("buildnumber").'&id='.md5(getGlobalSetting('SessionName')),$arguments);

$updateinfo=false;
$error=$http->Open($arguments);
Expand Down

0 comments on commit 45bc1ca

Please sign in to comment.