diff --git a/application/config/config.php b/application/config/config.php
index 916fc209c88..a7c9d7da53a 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -1,8 +1,30 @@
- dirname(dirname(__FILE__)),
'name' => 'LimeSurvey',
+ 'defaultController' => 'survey',
'import' => array(
'application.core.*',
@@ -10,77 +32,29 @@
'application.controllers.*',
),
- 'defaultController' => 'survey',
-
'components' => array(
+ /*
'db' => array(
- 'connectionString' => 'mysql:host=localhost;dbname=limesurvey_yii',
+ 'connectionString' => 'mysql:host=localhost;port=3306;dbname=limesurvey',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'tablePrefix' => 'lime_',
),
- /**
- Uncomment after implementing the error controller
- 'errorHandler' => array(
- 'errorAction' => 'error',
+
+ 'session' => array (
+ 'class' => 'system.web.CDbHttpSession',
+ 'connectionID' => 'db',
+ 'sessionTableName' => '{{sessions}}',
),
- */
+ */
'urlManager' => array(
'urlFormat' => 'path',
- 'rules' => require('routes.php'), //!!! Completely move it here
- ),
- 'session' => array (
- 'class' => 'system.web.CDbHttpSession',
- 'connectionID' => 'db',
- 'sessionTableName' => 'YiiSession',
+ 'rules' => require('routes.php'),
),
+
),
);
-?>
-
-
/* End of file config.php */
-/* Location: ./application/config/config.php */
-
-stepWelcome();
+ break;
+
+ case 'license':
+ $this->stepLicense();
+ break;
+
+ case 'viewlicense':
+ $this->stepViewLicense();
+ break;
+
+ case 'precheck':
+ $this->stepPreInstallationCheck();
+ break;
+
+ case 'database':
+ $this->stepDatabaseConfiguration();
+ break;
+
+ case 'createdb':
+ $this->stepCreateDb();
+ break;
+
+ case 'populatedb':
+ $this->stepPopulateDb();
+ break;
+
+ case 'optional':
+ $this->stepOptionalConfiguration();
+ break;
+
+ case 'index' :
+ default :
+ $this->redirect($this->createUrl('installer/welcome'));
+ break;
+
+ }
+ }
+
+ /**
+ * Installer::_checkInstallation()
+ *
+ * Based on existance of 'sample_installer_file.txt' file, check if
+ * installation should proceed further or not.
+ * @return
+ */
+ function _checkInstallation()
+ {
+ if (!file_exists(Yii::app()->getConfig('rootdir').'/tmp/sample_installer_file.txt'))
+ {
+ throw new CHttpException(500, 'Installation has been done already. Installer disabled. Please delete the file ' . Yii::app()->getConfig('rootdir').'/tmp/sample_installer_file.txt');
+ exit();
+ }
+ }
+
+ /**
+ * Load and set session vars
+ *
+ * @access protected
+ * @return void
+ */
+ protected function _sessioncontrol()
+ {
+ if (!empty(Yii::app()->session['installerLang']))
+ Yii::app()->session['installerLang'] = 'en';
+
+ Yii::import('application.libraries.Limesurvey_lang');
+ $this->lang = new Limesurvey_lang(array('langcode' => Yii::app()->session['installerLang']));
+ Yii::app()->setLang($this->lang);
+ }
+
+ /**
+ * welcome and language selection install step
+ */
+ private function stepWelcome()
+ {
+ $aData['clang'] = $clang = $this->lang;
+ // $aData array contain all the information required by view.
+ $aData['title'] = $clang->gT('Welcome');
+ $aData['descp'] = $clang->gT('Welcome to the LimeSurvey installation wizard. This wizard will guide you through the installation, database setup and initial configuration of LimeSurvey.');
+ $aData['classesForStep'] = array('on','off','off','off','off','off');
+ $aData['progressValue'] = 0;
+
+ if (!empty($_POST['installerLang']))
+ {
+ Yii::app()->session['installerLang'] = $_POST['installerLang'];
+ $this->redirect($this->createUrl('installer/license'));
+ }
+
+ $this->loadHelper('surveytranslator');
+ $this->render('/installer/welcome_view',$aData);
+ }
+
+ /**
+ * Display license
+ */
+ private function stepLicense()
+ {
+ $aData['clang'] = $clang = $this->lang;
+ // $aData array contain all the information required by view.
+ $aData['title'] = $clang->gT('License');
+ $aData['descp'] = $clang->gT('GNU General Public License:');
+ $aData['classesForStep'] = array('off','on','off','off','off','off');
+ $aData['progressValue']=0;
+
+ if (strtolower($_SERVER['REQUEST_METHOD']) == 'post')
+ {
+ $this->redirect($this->createUrl('installer/precheck'));
+ }
+
+ $this->render('/installer/license_view',$aData);
+ }
+
+ /**
+ * display the license file as IIS for example
+ * does not display it via the server.
+ */
+ public function stepViewLicense()
+ {
+ $filename = dirname(BASEPATH) . '/COPYING';
+ header('Content-Type: text/plain;');
+ readfile($filename);
+ exit;
+ }
+
+ /**
+ * check a few writing permissions and optional settings
+ */
+ private function stepPreInstallationCheck()
+ {
+ $aData['clang'] = $clang = $this->lang;
+ //usual data required by view
+ $aData['title'] = $clang->gT('Pre-installation check');
+ $aData['descp'] = $clang->gT('Pre-installation check for LimeSurvey ').Yii::app()->getConfig('versionnumber');
+ $aData['classesForStep'] = array('off','off','on','off','off','off');
+ $aData['progressValue'] = 20;
+ $aData['phpVersion'] = phpversion();
+ // variable storing next button link.initially null
+ $aData['next'] = '';
+
+ $bProceed = $this->_check_requirements($aData);
+
+ // after all check, if flag value is true, show next button and sabe step2 status.
+ if ($bProceed)
+ {
+ $aData['next'] = true;
+ Yii::app()->session['step2'] = true;
+ }
+
+ $this->render('/installer/precheck_view',$aData);
+ }
+
+ /**
+ * Configure database screen
+ */
+ private function stepDatabaseConfiguration()
+ {
+ $this->loadHelper('surveytranslator');
+
+ $aData['clang'] = $clang = $this->lang;
+ // usual data required by view
+ $aData['title'] = $clang->gT('Database configuration');
+ $aData['descp'] = $clang->gT('Please enter the database settings you want to use for LimeSurvey:');
+ $aData['classesForStep'] = array('off','off','off','on','off','off');
+ $aData['progressValue'] = 40;
+ $aData['model'] = $model = new InstallerConfigForm;
+
+ if(isset($_POST['InstallerConfigForm']))
+ {
+ $model->attributes = $_POST['InstallerConfigForm'];
+
+ //run validation, if it fails, load the view again else proceed to next step.
+ if($model->validate()) {
+ $sDatabaseType = $model->dbtype;
+ $sDatabaseName = $model->dbname;
+ $sDatabaseUser = $model->dbuser;
+ $sDatabasePwd = $model->dbpwd;
+ $sDatabasePrefix = $model->dbprefix;
+ $sDatabaseLocation = $model->dblocation;
+ $sDatabasePort = '';
+ if (strpos($sDatabaseLocation, ':')!==false)
+ {
+ list($sDatabasePort, $sDatabaseLocation) = explode(':', $sDatabaseLocation, 2);
+ }
+ $sDatabasePort = self::_getDbPort($sDatabaseType, $sDatabasePort);
+
+ $bDBExists = false;
+ $bDBConnectionWorks = false;
+ $aDbConfig = compact('sDatabaseType', 'sDatabaseName', 'sDatabaseUser', 'sDatabasePwd', 'sDatabasePrefix', 'sDatabaseLocation', 'sDatabasePort');
+
+ if (self::_dbConnect($aDbConfig, array())) {
+ $bDBExists = true;
+ $bDBConnectionWorks = true;
+ } else {
+ $aDbConfig['sDatabaseName'] = '';
+ if (self::_dbConnect($aDbConfig, array())) {
+ $bDBConnectionWorks = true;
+ } else {
+ $model->addError('dblocation', $clang->gT('Try again! Connection with database failed.'));
+ }
+ }
+
+ //if connection with database fail
+ if ($bDBConnectionWorks)
+ {
+ //saving the form data
+ foreach(array('dbname', 'dbtype', 'dbpwd', 'dbuser', 'dbprefix') as $sStatusKey) {
+ Yii::app()->session[$sStatusKey] = $model->$sStatusKey;
+ }
+ Yii::app()->session['dbport'] = $sDatabasePort;
+ Yii::app()->session['dblocation'] = $sDatabaseLocation;
+
+ //check if table exists or not
+ $sTestTablename = 'surveys';
+ $bTablesDoNotExist = false;
+
+ // Check if the surveys table exists or not
+ if ($bDBExists == true) {
+ try {
+ $this->connection->createCommand()->select()->from('{{surveys}}')->queryAll();
+ $bTablesDoNotExist = false;
+ } catch(Exception $e) {
+ $bTablesDoNotExist = true;
+ }
+ }
+
+ $dbexistsbutempty = ($bDBExists && $bTablesDoNotExist);
+
+ //store them in session
+ Yii::app()->session['databaseexist'] = $bDBExists;
+ Yii::app()->session['tablesexist'] = !$bTablesDoNotExist;
+
+ // If database is up to date, redirect to administration screen.
+ if ($bDBExists && !$bTablesDoNotExist)
+ {
+ Yii::app()->session['optconfig_message'] = sprintf('%s ', $clang->gT('The database you specified is up to date.'));
+ Yii::app()->session['step3'] = true;
+
+ //$this->redirect($this->createUrl("installer/loadOptView"));
+ header("refresh:5;url=".$this->createUrl("/admin"));
+ echo sprintf( $clang->gT('The database you specified is up to date. You\'ll be redirected in 5 seconds. If not, click here .', 'unescaped'), $this->createUrl("/admin"));
+ exit();
+ }
+
+ if (in_array($model->dbtype, array('mysql', 'mysqli'))) {
+ //for development - use mysql in the strictest mode //Checked)
+ if (Yii::app()->getConfig('debug')>1) {
+ $this->connection->createCommand("SET SESSION SQL_MODE='STRICT_ALL_TABLES,ANSI'")->execute();
+ }
+ $versioninfo = $this->connection->getServerVersion();
+ if (version_compare($versioninfo,'4.1','<'))
+ {
+ die(" Error: You need at least MySQL version 4.1 to run LimeSurvey. Your version:".$versioninfo);
+ }
+ @$this->connection->createCommand("SET CHARACTER SET 'utf8'")->execute(); //Checked
+ @$this->connection->createCommand("SET NAMES 'utf8'")->execute(); //Checked
+ }
+
+ // Setting dateformat for mssql driver. It seems if you don't do that the in- and output format could be different
+ if (in_array($model->dbtype, array('odbc_mssql', 'odbtp', 'mssql_n', 'mssqlnative'))) {
+ @$this->connection->createCommand('SET DATEFORMAT ymd;')->execute(); //Checked
+ @$this->connection->createCommand('SET QUOTED_IDENTIFIER ON;')->execute(); //Checked
+ }
+
+ //$aData array won't work here. changing the name
+ $values['title'] = $clang->gT('Database settings');
+ $values['descp'] = $clang->gT('Database settings');
+ $values['classesForStep'] = array('off','off','off','off','on','off');
+ $values['progressValue'] = 60;
+
+ //it store text content
+ $values['adminoutputText'] = '';
+ //it store the form code to be displayed
+ $values['adminoutputForm'] = '';
+
+ //if DB exist, check if its empty or up to date. if not, tell user LS can create it.
+ if (!$bDBExists)
+ {
+ Yii::app()->session['databaseDontExist'] = true;
+
+ $values['adminoutputText'].= "\t
"
+ ."\n"
+ .$clang->gT("Database has been created.")." \n"
+ .$clang->gT("Please continue with populating the database.")." \n";
+ $aData['adminoutputForm'] = "";
+ }
+ else
+ {
+ $model->addError('dblocation', $clang->gT('Try again! Connection with database failed.'));
+ $this->render('/installer/dbconfig_view',$aData);
+ }
+
+ $aData['title'] = $clang->gT("Database settings");
+ $aData['descp'] = $clang->gT("Database settings");
+ $aData['classesForStep'] = array('off','off','off','off','on','off');
+ $aData['progressValue'] = 60;
+ $this->render('/installer/dbsettings_view',$aData);
+ }
+
+ /**
+ * Installer::stepPopulateDb()
+ * Function to populate the database.
+ * @return
+ */
+ function stepPopulateDb()
+ {
+ if (!Yii::app()->session['populatedatabase'])
+ {
+ $this->redirect($this->createUrl('installer/welcome'));
+ }
+
+ $aData['clang'] = $clang = $this->lang;
+ $aData['model'] = $model = new InstallerConfigForm;
+ $aData['title'] = $clang->gT("Database configuration");
+ $aData['descp'] = $clang->gT("Please enter the database settings you want to use for LimeSurvey:");
+ $aData['classesForStep'] = array('off','off','off','on','off','off');
+ $aData['progressValue'] = 40;
+
+ $aDbConfig = self::_getDatabaseConfig();
+ extract($aDbConfig);
+ self::_dbConnect($aDbConfig, $aData);
+
+ /* @todo Use Yii as it supports various db types and would better handle this process */
+
+ switch ($sDatabaseType)
+ {
+ case 'mysqli':
+ case 'mysql':
+ $sql_file = 'mysql';
+ break;
+ case 'odbc':
+ case 'mssql':
+ $sql_file = 'mssql';
+ break;
+ case 'pgsql':
+ $sql_file = 'pgsql';
+ break;
+ default:
+ throw new Exception(sprintf('Unkown database type "%s".', $sDatabaseType));
+ }
+
+ //checking DB Connection
+ $aErrors = self::_setup_tables(dirname(APPPATH).'/installer/sql/create-'.$sql_file.'.sql');
+ if ($aErrors === false)
+ {
+ $model->addError('dblocation', $clang->gT('Try again! Connection with database failed. Reason: ').implode(', ', $aErrors));
+ $this->render('/installer/dbconfig_view', $aData);
+ }
+ elseif (count($aErrors)==0)
+ {
+ //$data1['adminoutput'] = '';
+ //$data1['adminoutput'] .= sprintf("Database `%s` has been successfully populated.",$dbname)." \n";
+ //$data1['adminoutput'] .= " ";
+ $confirmation = sprintf($clang->gT("Database %s has been successfully populated."), sprintf('%s ', Yii::app()->session['dbname']));
+ }
+ else
+ {
+ $confirmation = $clang->gT('Database was populated but there were errors:').'
';
+ foreach ($aErrors as $sError)
+ {
+ $confirmation.=''.htmlspecialchars($sError).' ';
+ }
+ $confirmation.=' ';
+ }
+
+ Yii::app()->session['tablesexist'] = true;
+ Yii::app()->session['step3'] = true;
+ Yii::app()->session['optconfig_message'] = $confirmation;
+ unset(Yii::app()->session['populatedatabase']);
+
+ $this->redirect($this->createUrl('installer/optional'));
+ }
+
+ /**
+ * Optional settings screen
+ */
+ private function stepOptionalConfiguration()
+ {
+ $aData['clang'] = $clang = $this->lang;
+ $aData['confirmation'] = Yii::app()->session['optconfig_message'];
+ $aData['title'] = $clang->gT("Optional settings");
+ $aData['descp'] = $clang->gT("Optional settings to give you a head start");
+ $aData['classesForStep'] = array('off','off','off','off','off','on');
+ $aData['progressValue'] = 80;
+
+ $this->loadHelper('surveytranslator');
+ $aData['model'] = $model = new InstallerConfigForm('optional');
+
+ if(isset($_POST['InstallerConfigForm']))
+ {
+ $model->attributes = $_POST['InstallerConfigForm'];
+
+ //run validation, if it fails, load the view again else proceed to next step.
+ if($model->validate()) {
+ $adminLoginPwd = $model->adminLoginPwd;
+ $confirmPwd = $model->confirmPwd;
+ $defaultuser = $model->adminLoginName;
+ $defaultpass = $model->adminLoginPwd;
+ $siteadminname = $model->adminName;
+ $siteadminbounce = $siteadminemail = $model->adminEmail;
+ $sitename = $model->siteName;
+ $defaultlang = $model->surveylang;
+
+ $aData['title'] = $clang->gT("Database configuration");
+ $aData['descp'] = $clang->gT("Please enter the database settings you want to use for LimeSurvey:");
+ $aData['classesForStep'] = array('off','off','off','on','off','off');
+ $aData['progressValue'] = 40;
+
+ //config file is written, and we've a db in place
+ $this->connection = Yii::app()->db;
+
+ //checking DB Connection
+ if ($this->connection->getActive() == true) {
+ $this->loadLibrary('admin/sha256','sha256');
+ $this->sha256 = new SHA256;
+ $password_hash = $this->sha256->hashing($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' => $defaultuser, 'password' => $password_hash, 'full_name' => $siteadminname, 'parent_id' => 0, 'lang' => $defaultlang, 'email' => $siteadminemail, 'create_survey' => 1, 'create_user' => 1, 'participant_panel' => 1, 'delete_user' => 1, 'superadmin' => 1, 'configurator' => 1, 'manage_template' => 1, 'manage_label' => 1));
+ foreach(array('sitename', 'siteadminname', 'siteadminemail', 'siteadminbounce', 'defaultlang') as $insert) {
+ $this->connection->createCommand()->insert("{{settings_global}}", array('stg_name' => $insert, 'stg_value' => $$insert));
+ }
+ // only continue if we're error free otherwise setup is broken.
+ } catch (Exception $e) {
+ throw new Exception(sprintf('Could not add optional settings: %s.', $e));
+ }
+
+ Yii::app()->session['deletedirectories'] = true;
+
+ //DELETE SAMPLE INSTALLER FILE. If we can't, notify user of the same.
+ $installer_file = Yii::app()->getConfig('rootdir').'/tmp/sample_installer_file.txt';
+ if (is_writable($installer_file))
+ {
+ rename($installer_file, $installer_file.'.removed');
+ } else {
+ $aData['error'] = true;
+ }
+
+ $aData['title'] = $clang->gT("Success!");
+ $aData['descp'] = $clang->gT("LimeSurvey has been installed successfully.");
+ $aData['classesForStep'] = array('off','off','off','off','off','off');
+ $aData['progressValue'] = 100;
+ $aData['user'] = $defaultuser;
+ $aData['pwd'] = $defaultpass;
+
+ $this->render('/installer/success_view', $aData);
+ exit();
+ }
+ } else {
+ // if passwords don't match, redirect to proper link.
+ Yii::app()->session['optconfig_message'] = sprintf('%s ', $clang->gT("Passwords don't match."));
+ $this->redirect($this->createUrl('installer/optional'));
+ }
+ } elseif(empty(Yii::app()->session['configFileWritten'])) {
+ $this->_writeConfigFile();
+ }
+
+ $this->render('/installer/optconfig_view', $aData);
+ }
+
+ /**
+ * Loads a helper
+ *
+ * @access public
+ * @param string $helper
+ * @return void
+ */
+ public function loadHelper($helper)
+ {
+ Yii::import('application.helpers.' . $helper . '_helper', true);
+ }
+
+ /**
+ * Loads a library
+ *
+ * @access public
+ * @param string $helper
+ * @return void
+ */
+ public function loadLibrary($library)
+ {
+ Yii::import('application.libraries.'.$library, true);
+ }
+
+ /**
+ * check requirements
+ *
+ * @param array $data return theme variables
+ * @return bool requirements met
+ */
+ private function _check_requirements(&$data)
+ {
+ // proceed variable check if all requirements are true. If any of them is false, proceed is set false.
+ $bProceed = true; //lets be optimistic!
+
+ /**
+ * check image HTML template
+ *
+ * @param bool $result
+ */
+ function check_HTML_image($result)
+ {
+ $label = array('wrong', 'right');
+ return sprintf(' ', Yii::app()->baseUrl, $label[$result]);
+ }
+
+ /**
+ * check for a specific PHPFunction, return HTML image
+ *
+ * @param string $function
+ * @param string $image return
+ * @return bool result
+ */
+ function check_PHPFunction($function, &$image)
+ {
+ $result = function_exists($function);
+ $image = check_HTML_image($result);
+ return $result;
+ }
+
+ /**
+ * check if file or directory exists and is writeable, returns via parameters by reference
+ *
+ * @param string $path file or directory to check
+ * @param int $type 0:undefined (invalid), 1:file, 2:directory
+ * @param string $data to manipulate
+ * @param string $base key for data manipulation
+ * @param string $keyError key for error data
+ * @return bool result of check (that it is writeable which implies existance)
+ */
+ function check_PathWriteable($path, $type, &$data, $base, $keyError)
+ {
+ $result = false;
+ $data[$base.'Present'] = 'Not Found';
+ $data[$base.'Writable'] = '';
+ switch($type) {
+ case 1:
+ $exists = is_file($path);
+ break;
+ case 2:
+ $exists = is_dir($path);
+ break;
+ default:
+ throw new Exception('Invalid type given.');
+ }
+ if ($exists)
+ {
+ $data[$base.'Present'] = 'Found';
+ if (is_writable($path))
+ {
+ $data[$base.'Writable'] = 'Writable';
+ $result = true;
+ }
+ else
+ {
+ $data[$base.'Writable'] = 'Unwritable';
+ }
+ }
+ $result || $data[$keyError] = true;
+
+ return $result;
+ }
+
+ /**
+ * check if file exists and is writeable, returns via parameters by reference
+ *
+ * @param string $file to check
+ * @param string $data to manipulate
+ * @param string $base key for data manipulation
+ * @param string $keyError key for error data
+ * @return bool result of check (that it is writeable which implies existance)
+ */
+ function check_FileWriteable($file, &$data, $base, $keyError)
+ {
+ return check_PathWriteable($file, 1, $data, $base, $keyError);
+ }
+
+ /**
+ * check if directory exists and is writeable, returns via parameters by reference
+ *
+ * @param string $directory to check
+ * @param string $data to manipulate
+ * @param string $base key for data manipulation
+ * @param string $keyError key for error data
+ * @return bool result of check (that it is writeable which implies existance)
+ */
+ function check_DirectoryWriteable($directory, &$data, $base, $keyError)
+ {
+ return check_PathWriteable($directory, 2, $data, $base, $keyError);
+ }
+
+ // version check
+ if (version_compare(PHP_VERSION, '5.1.6', '<'))
+ $bProceed = !$data['verror'] = true;
+
+ // mbstring library check
+ if (!check_PHPFunction('mb_convert_encoding', $data['mbstringPresent']))
+ $bProceed = false;
+
+ // ** file and directory permissions checking **
+
+ // config file
+ if (!check_FileWriteable(Yii::app()->getConfig('rootdir').'/application/config/config.php', $data, 'config', 'derror') )
+ $bProceed = false;
+
+ // tmp directory check
+ if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir').'/tmp/', $data, 'tmpdir', 'terror') )
+ $bProceed = false;
+
+ // templates directory check
+ if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir').'/templates/', $data, 'templatedir', 'tperror') )
+ $bProceed = false;
+
+ //upload directory check
+ if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir').'/upload/', $data, 'uploaddir', 'uerror') )
+ $bProceed = false;
+
+ // ** optional settings check **
+
+ // gd library check
+ $data['gdPresent'] = check_HTML_image(array_key_exists('FreeType Support', gd_info()));
+
+ // ldap library check
+ check_PHPFunction('ldap_connect', $data['ldapPresent']);
+
+ // php zip library check
+ check_PHPFunction('zip_open', $data['zipPresent']);
+
+ // zlib php library check
+ check_PHPFunction('zlib_get_coding_type', $data['zlibPresent']);
+
+ return $bProceed;
+ }
+
+ /**
+ * Installer::_setup_tables()
+ * Function that actually modify the database. Read $sqlfile and execute it.
+ * @param string $sqlfile
+ * @return Empty string if everything was okay - otherwise the error messages
+ */
+ function _setup_tables($sFileName, $aDbConfig = array(), $sDatabasePrefix = '')
+ {
+ extract(empty($aDbConfig) ? self::_getDatabaseConfig() : $aDbConfig);
+
+ switch ($sDatabaseType) {
+ case 'mysql':
+ case 'mysqli':
+ $this->connection->createCommand("ALTER DATABASE `{$sDatabaseName}` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;")->execute();
+ break;
+ case 'pgsql':
+ if ($this->connection->getClientVersion() == '9') {
+ $this->connection->createCommand("ALTER DATABASE {$sDatabaseName} SET bytea_output='escape';")->execute();
+ }
+ break;
+ }
+
+ return $this->_executeSQLFile($sFileName, $sDatabasePrefix);
+ }
+
+ /**
+ * Executes an SQL file using ADODB
+ *
+ * @param string $sFileName
+ * @param string $sDatabasePrefix
+ */
+ function _executeSQLFile($sFileName, $sDatabasePrefix)
+ {
+ $aMessages = array();
+ $sCommand = '';
+
+ if (!is_readable($sFileName)) {
+ return false;
+ } else {
+ $aLines = file($sFileName);
+ }
+ foreach ($aLines as $sLine) {
+ $sLine = rtrim($sLine);
+ $iLineLength = strlen($sLine);
+
+ if ($iLineLength && $sLine[0] != '#' && substr($sLine,0,2) != '--') {
+ if (substr($sLine, $iLineLength-1, 1) == ';') {
+ $line = substr($sLine, 0, $iLineLength-1);
+ $sCommand .= $sLine;
+ $sCommand = str_replace('prefix_', $sDatabasePrefix, $sCommand); // Table prefixes
+
+ try {
+ $this->connection->createCommand($sCommand)->execute();
+ } catch(Exception $e) {
+ $aMessages[] = "Executing: ".$sCommand." failed! Reason: ".$e;
+ }
+
+ $sCommand = '';
+ } else {
+ $sCommand .= $sLine;
+ }
+ }
+ }
+ return $aMessages;
+ }
+
+ /**
+ * Installer::_writeConfigFile()
+ * Function to write given database settings in APPPATH.'application/config/config.php'
+ * @return
+ */
+ function _writeConfigFile()
+ {
+ $aData['clang'] = $clang = $this->lang;
+ //write database.php if database exists and has been populated.
+ if (Yii::app()->session['databaseexist'] && Yii::app()->session['tablesexist'])
+ {
+ //write variables in database.php
+ $this->loadHelper('file');
+
+ extract(self::_getDatabaseConfig());
+ $sDsn = sprintf(self::_getDsn($sDatabaseType, $sDatabasePort), $sDatabaseLocation, $sDatabaseName, $sDatabasePort);
+
+ $dbdata = " dirname(dirname(__FILE__))," . "\n"
+ ."\t" . "'name' => 'LimeSurvey'," . "\n"
+ ."\t" . "'defaultController' => 'survey'," . "\n"
+ ."\t" . "" . "\n"
+
+ ."\t" . "'import' => array(" . "\n"
+ ."\t\t" . "'application.core.*'," . "\n"
+ ."\t\t" . "'application.models.*'," . "\n"
+ ."\t\t" . "'application.controllers.*'," . "\n"
+ ."\t" . ")," . "\n"
+ ."\t" . "" . "\n"
+
+ ."\t" . "'components' => array(" . "\n"
+ ."\t\t" . "'db' => array(" . "\n"
+ ."\t\t\t" . "'connectionString' => '$sDsn'," . "\n"
+ ."\t\t\t" . "'emulatePrepare' => true," . "\n"
+ ."\t\t\t" . "'username' => '$sDatabaseUser'," . "\n"
+ ."\t\t\t" . "'password' => '$sDatabasePwd'," . "\n"
+ ."\t\t\t" . "'charset' => 'utf8'," . "\n"
+ ."\t\t\t" . "'tablePrefix' => '$sDatabasePrefix'," . "\n"
+ ."\t\t" . ")," . "\n"
+ ."\t\t" . "" . "\n"
+
+ ."\t\t" . "'session' => array (" . "\n"
+ ."\t\t\t" . "'class' => 'system.web.CDbHttpSession'," . "\n"
+ ."\t\t\t" . "'connectionID' => 'db'," . "\n"
+ ."\t\t\t" . "'sessionTableName' => '{{sessions}}'," . "\n"
+ ."\t\t" . ")," . "\n"
+ ."\t\t" . "" . "\n"
+
+ /** @todo Uncomment after implementing the error controller */
+ /*
+ ."\t\t" . "'errorHandler' => array(" . "\n"
+ ."\t\t\t" . "'errorAction' => 'error'," . "\n"
+ ."\t\t" . ")," . "\n"
+ ."\t\t" . "" . "\n"
+ */
+
+ ."\t\t" . "'urlManager' => array(" . "\n"
+ ."\t\t\t" . "'urlFormat' => 'path'," . "\n"
+ ."\t\t\t" . "'rules' => require('routes.php')," . "\n"
+ ."\t\t" . ")," . "\n"
+ ."\t" . "" . "\n"
+
+ ."\t" . ")," . "\n"
+ . ");" . "\n"
+ . "/* End of file config.php */" . "\n"
+ . "/* Location: ./application/config/config.php */";
+
+ if (is_writable(APPPATH . 'config/config.php')) {
+ write_file(APPPATH . 'config/config.php', $dbdata);
+ Yii::app()->session['configFileWritten'] = true;
+ } else {
+ header('refresh:5;url='.$this->createUrl("installer/welcome"));
+ echo "".$clang->gT("Configuration file directory is not writable")." ";
+ printf($clang->gT('You will be redirected in about 5 secs. If not, click here .' ,'unescaped'), $this->createUrl('installer/welcome'));
+ }
+ }
+ }
+
+ /**
+ * Create a random survey ID
+ *
+ * based on code from Ken Lyle
+ *
+ * @return string
+ */
+ function _getRandomID()
+ {
+ // Create a random survey ID -
+ // Random sid/ question ID generator...
+ $totalChar = 5; // number of chars in the sid
+ $salt = "123456789"; // This is the char. that is possible to use
+ srand((double)microtime()*1000000); // start the random generator
+ $sid=""; // set the inital variable
+ for ($i=0;$i<$totalChar;$i++) // loop and create sid
+ $sid = $sid . substr ($salt, rand() % strlen($salt), 1);
+ return $sid;
+ }
+
+ /**
+ * Get the dsn for the database connection
+ *
+ * @param string $sDatabaseType
+ * @param string $sDatabasePort
+ */
+ function _getDsn($sDatabaseType, $sDatabasePort = '')
+ {
+ switch ($sDatabaseType) {
+ case 'mysql':
+ case 'mysqli':
+ $dsn = 'mysql:host=%1$s;port=%3$s;dbname=%2$s';
+ break;
+ case 'pgsql':
+ $dsn = 'pgsql:host=%1$s;port=%3$s;dbname=%2$s';
+ break;
+ case 'sqlite':
+ $dsn = 'sqlite:%1$s/%2$s.sq3';
+ case 'sqlite2':
+ $dsn = 'sqlite2:%1$s/%2$s.sq2';
+ break;
+ case 'mssql' :
+ case 'dblib' :
+ case 'sqlsrv':
+ case 'sybase':
+ $dsn = $sDatabaseType.':host=%1$s;dbname=%2$s';
+ break;
+ case 'oci':
+ $dsn = 'oci:dbname=//%1$s:%3$s/%2$s';
+ break;
+ default:
+ throw new Exception(sprintf('Unknown database type "%s".', $sDatabaseType));
+ }
+
+ return $dsn;
+ }
+
+ /**
+ * Get the default port if database port is not set
+ *
+ * @param string $sDatabaseType
+ * @param string $sDatabasePort
+ * @return string
+ */
+ function _getDbPort($sDatabaseType, $sDatabasePort = '')
+ {
+ if (is_numeric($sDatabasePort))
+ return $sDatabasePort;
+
+ switch ($sDatabaseType) {
+ case 'mysql':
+ case 'mysqli':
+ $sDatabasePort = '3306';
+ break;
+ case 'pgsql':
+ $sDatabasePort = '5432';
+ break;
+ case 'oci':
+ $sDatabasePort = '1521';
+ break;
+ case 'mssql' :
+ case 'dblib' :
+ case 'sqlsrv':
+ case 'sybase':
+ case 'sqlite':
+ case 'sqlite2':
+ default:
+ $sDatabasePort = '';
+ }
+
+ return $sDatabasePort;
+ }
+
+ /**
+ * Gets the database configuration from the session
+ *
+ * @return array Database Config
+ */
+ function _getDatabaseConfig()
+ {
+ $sDatabaseType = Yii::app()->session['dbtype'];
+ $sDatabasePort = Yii::app()->session['dbport'];
+ $sDatabaseName = Yii::app()->session['dbname'];
+ $sDatabaseUser = Yii::app()->session['dbuser'];
+ $sDatabasePwd = Yii::app()->session['dbpwd'];
+ $sDatabasePrefix = Yii::app()->session['dbprefix'];
+ $sDatabaseLocation = Yii::app()->session['dblocation'];
+
+ return compact('sDatabaseLocation', 'sDatabaseName', 'sDatabasePort', 'sDatabasePrefix', 'sDatabasePwd', 'sDatabaseType', 'sDatabaseUser');
+ }
+
+ /**
+ * Connect to the database
+ *
+ * Throw an error if there's an error
+ */
+ function _dbConnect($aDbConfig = array(), $aData = array())
+ {
+ extract(empty($aDbConfig) ? self::_getDatabaseConfig() : $aDbConfig);
+ $dsn = self::_getDsn($sDatabaseType, $sDatabasePort);
+ $sDatabaseName = empty($sDatabaseName) ? '' : $sDatabaseName;
+ $sDatabasePort = empty($sDatabasePort) ? '' : $sDatabasePort;
+
+ try {
+ $sDsn = sprintf($dsn, $sDatabaseLocation, $sDatabaseName, $sDatabasePort);
+ $this->connection = new CDbConnection($sDsn, $sDatabaseUser, $sDatabasePwd);
+ $this->connection->emulatePrepare = true;
+ $this->connection->active = true;
+ $this->connection->tablePrefix = $sDatabasePrefix;
+ return true;
+ } catch(Exception $e) {
+ if (!empty($aData['model']) && !empty($aData['clang'])) {
+ $aData['model']->addError('dblocation', $aData['clang']->gT('Try again! Connection with database failed. Reason: ') . $e);
+ $this->render('/installer/dbconfig_view', $aData);
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ $this->loadLibrary('admin/sha256','sha256');
+ $this->sha256 = new SHA256;
+ $sPasswordHash = $this->sha256->hashing(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";
+
+ }
+ }
+
+}
diff --git a/application/core/LSYii_Application.php b/application/core/LSYii_Application.php
index 928e1bd6489..55ae1767fb6 100644
--- a/application/core/LSYii_Application.php
+++ b/application/core/LSYii_Application.php
@@ -40,11 +40,6 @@ public function __construct($config = null)
$settings = array_merge($app_config, $ls_config);
foreach ($settings as $key => $value)
$this->setConfig($key, $value);
-
- $this->loadHelper('globalsettings');
- $this->loadHelper('common');
- $this->loadHelper('expressions.em_manager');
- $this->loadHelper('replacements');
}
/**
diff --git a/application/core/LSYii_Controller.php b/application/core/LSYii_Controller.php
index cb3dd922444..c5ad53aa3a2 100644
--- a/application/core/LSYii_Controller.php
+++ b/application/core/LSYii_Controller.php
@@ -28,7 +28,14 @@ public function __construct($id, $module = null)
{
parent::__construct($id, $module);
$this->_checkinstallation();
- require_once(APPPATH . '/libraries/LS/LS' . EXT);
+
+ //require_once(APPPATH . '/libraries/LS/LS' . EXT);
+ $this->loadLibrary('LS.LS');
+ $this->loadHelper('globalsettings');
+ $this->loadHelper('common');
+ $this->loadHelper('expressions.em_manager');
+ $this->loadHelper('replacements');
+
$this->_init();
}
@@ -42,14 +49,37 @@ public function __construct($id, $module = null)
*/
protected function _checkinstallation()
{
- $file_name = '/tmp/sample_installer_file.txt';
- $installer_file = ROOT . $file_name;
- if (is_file($installer_file))
- {
+ $file_name = Yii::app()->getConfig('rootdir').'/tmp/sample_installer_file.txt';
+ if (file_exists($file_name))
+ {
$message = 'Use the LimeSurvey Web Installer to set-up LimeSurvey.
'
- ."
If you are already done with installation, please delete the file lock file (...{$file_name} ).";
- throw new CException($message);
- }
+ ."
If you are already done with installation, please delete the file lock file ({$file_name} ).";
+ throw new CHttpException($message);
+ }
+ }
+
+ /**
+ * Loads a helper
+ *
+ * @access public
+ * @param string $helper
+ * @return void
+ */
+ public function loadHelper($helper)
+ {
+ Yii::import('application.helpers.' . $helper . '_helper', true);
+ }
+
+ /**
+ * Loads a library
+ *
+ * @access public
+ * @param string $helper
+ * @return void
+ */
+ public function loadLibrary($library)
+ {
+ Yii::import('application.libraries.'.$library.'', true);
}
protected function _init()
diff --git a/application/helpers/file_helper.php b/application/helpers/file_helper.php
new file mode 100644
index 00000000000..c256ab1796a
--- /dev/null
+++ b/application/helpers/file_helper.php
@@ -0,0 +1,479 @@
+ 0)
+ {
+ $data =& fread($fp, filesize($file));
+ }
+
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return $data;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Write File
+ *
+ * Writes data to the file specified in the path.
+ * Creates a new file if non-existent.
+ *
+ * @access public
+ * @param string path to file
+ * @param string file data
+ * @return bool
+ */
+if ( ! function_exists('write_file'))
+{
+ function write_file($path, $data, $mode = 'wb')
+ {
+ if ( ! $fp = @fopen($path, $mode))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_EX);
+ fwrite($fp, $data);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return TRUE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Delete Files
+ *
+ * Deletes all files contained in the supplied directory path.
+ * Files must be writable or owned by the system in order to be deleted.
+ * If the second parameter is set to TRUE, any directories contained
+ * within the supplied base directory will be nuked as well.
+ *
+ * @access public
+ * @param string path to file
+ * @param bool whether to delete any directories found in the path
+ * @return bool
+ */
+if ( ! function_exists('delete_files'))
+{
+ function delete_files($path, $del_dir = FALSE, $level = 0)
+ {
+ // Trim the trailing slash
+ $path = rtrim($path, DIRECTORY_SEPARATOR);
+
+ if ( ! $current_dir = @opendir($path))
+ {
+ return FALSE;
+ }
+
+ while (FALSE !== ($filename = @readdir($current_dir)))
+ {
+ if ($filename != "." and $filename != "..")
+ {
+ if (is_dir($path.DIRECTORY_SEPARATOR.$filename))
+ {
+ // Ignore empty folders
+ if (substr($filename, 0, 1) != '.')
+ {
+ delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
+ }
+ }
+ else
+ {
+ unlink($path.DIRECTORY_SEPARATOR.$filename);
+ }
+ }
+ }
+ @closedir($current_dir);
+
+ if ($del_dir == TRUE AND $level > 0)
+ {
+ return @rmdir($path);
+ }
+
+ return TRUE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Filenames
+ *
+ * Reads the specified directory and builds an array containing the filenames.
+ * Any sub-folders contained within the specified path are read as well.
+ *
+ * @access public
+ * @param string path to source
+ * @param bool whether to include the path as part of the filename
+ * @param bool internal variable to determine recursion status - do not use in calls
+ * @return array
+ */
+if ( ! function_exists('get_filenames'))
+{
+ function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE)
+ {
+ static $_filedata = array();
+
+ if ($fp = @opendir($source_dir))
+ {
+ // reset the array and make sure $source_dir has a trailing slash on the initial call
+ if ($_recursion === FALSE)
+ {
+ $_filedata = array();
+ $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
+ }
+
+ while (FALSE !== ($file = readdir($fp)))
+ {
+ if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0)
+ {
+ get_filenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
+ }
+ elseif (strncmp($file, '.', 1) !== 0)
+ {
+ $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
+ }
+ }
+ return $_filedata;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Get Directory File Information
+ *
+ * Reads the specified directory and builds an array containing the filenames,
+ * filesize, dates, and permissions
+ *
+ * Any sub-folders contained within the specified path are read as well.
+ *
+ * @access public
+ * @param string path to source
+ * @param bool Look only at the top level directory specified?
+ * @param bool internal variable to determine recursion status - do not use in calls
+ * @return array
+ */
+if ( ! function_exists('get_dir_file_info'))
+{
+ function get_dir_file_info($source_dir, $top_level_only = TRUE, $_recursion = FALSE)
+ {
+ static $_filedata = array();
+ $relative_path = $source_dir;
+
+ if ($fp = @opendir($source_dir))
+ {
+ // reset the array and make sure $source_dir has a trailing slash on the initial call
+ if ($_recursion === FALSE)
+ {
+ $_filedata = array();
+ $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
+ }
+
+ // foreach (scandir($source_dir, 1) as $file) // In addition to being PHP5+, scandir() is simply not as fast
+ while (FALSE !== ($file = readdir($fp)))
+ {
+ if (@is_dir($source_dir.$file) AND strncmp($file, '.', 1) !== 0 AND $top_level_only === FALSE)
+ {
+ get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, TRUE);
+ }
+ elseif (strncmp($file, '.', 1) !== 0)
+ {
+ $_filedata[$file] = get_file_info($source_dir.$file);
+ $_filedata[$file]['relative_path'] = $relative_path;
+ }
+ }
+
+ return $_filedata;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+/**
+* Get File Info
+*
+* Given a file and path, returns the name, path, size, date modified
+* Second parameter allows you to explicitly declare what information you want returned
+* Options are: name, server_path, size, date, readable, writable, executable, fileperms
+* Returns FALSE if the file cannot be found.
+*
+* @access public
+* @param string path to file
+* @param mixed array or comma separated string of information returned
+* @return array
+*/
+if ( ! function_exists('get_file_info'))
+{
+ function get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date'))
+ {
+
+ if ( ! file_exists($file))
+ {
+ return FALSE;
+ }
+
+ if (is_string($returned_values))
+ {
+ $returned_values = explode(',', $returned_values);
+ }
+
+ foreach ($returned_values as $key)
+ {
+ switch ($key)
+ {
+ case 'name':
+ $fileinfo['name'] = substr(strrchr($file, DIRECTORY_SEPARATOR), 1);
+ break;
+ case 'server_path':
+ $fileinfo['server_path'] = $file;
+ break;
+ case 'size':
+ $fileinfo['size'] = filesize($file);
+ break;
+ case 'date':
+ $fileinfo['date'] = filemtime($file);
+ break;
+ case 'readable':
+ $fileinfo['readable'] = is_readable($file);
+ break;
+ case 'writable':
+ // There are known problems using is_weritable on IIS. It may not be reliable - consider fileperms()
+ $fileinfo['writable'] = is_writable($file);
+ break;
+ case 'executable':
+ $fileinfo['executable'] = is_executable($file);
+ break;
+ case 'fileperms':
+ $fileinfo['fileperms'] = fileperms($file);
+ break;
+ }
+ }
+
+ return $fileinfo;
+ }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Get Mime by Extension
+ *
+ * Translates a file extension into a mime type based on config/mimes.php.
+ * Returns FALSE if it can't determine the type, or open the mime config file
+ *
+ * Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience
+ * It should NOT be trusted, and should certainly NOT be used for security
+ *
+ * @access public
+ * @param string path to file
+ * @return mixed
+ */
+if ( ! function_exists('get_mime_by_extension'))
+{
+ function get_mime_by_extension($file)
+ {
+ $extension = strtolower(substr(strrchr($file, '.'), 1));
+
+ global $mimes;
+
+ if ( ! is_array($mimes))
+ {
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ }
+ elseif (is_file(APPPATH.'config/mimes'.EXT))
+ {
+ include(APPPATH.'config/mimes'.EXT);
+ }
+
+ if ( ! is_array($mimes))
+ {
+ return FALSE;
+ }
+ }
+
+ if (array_key_exists($extension, $mimes))
+ {
+ if (is_array($mimes[$extension]))
+ {
+ // Multiple mime types, just give the first one
+ return current($mimes[$extension]);
+ }
+ else
+ {
+ return $mimes[$extension];
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Symbolic Permissions
+ *
+ * Takes a numeric value representing a file's permissions and returns
+ * standard symbolic notation representing that value
+ *
+ * @access public
+ * @param int
+ * @return string
+ */
+if ( ! function_exists('symbolic_permissions'))
+{
+ function symbolic_permissions($perms)
+ {
+ if (($perms & 0xC000) == 0xC000)
+ {
+ $symbolic = 's'; // Socket
+ }
+ elseif (($perms & 0xA000) == 0xA000)
+ {
+ $symbolic = 'l'; // Symbolic Link
+ }
+ elseif (($perms & 0x8000) == 0x8000)
+ {
+ $symbolic = '-'; // Regular
+ }
+ elseif (($perms & 0x6000) == 0x6000)
+ {
+ $symbolic = 'b'; // Block special
+ }
+ elseif (($perms & 0x4000) == 0x4000)
+ {
+ $symbolic = 'd'; // Directory
+ }
+ elseif (($perms & 0x2000) == 0x2000)
+ {
+ $symbolic = 'c'; // Character special
+ }
+ elseif (($perms & 0x1000) == 0x1000)
+ {
+ $symbolic = 'p'; // FIFO pipe
+ }
+ else
+ {
+ $symbolic = 'u'; // Unknown
+ }
+
+ // Owner
+ $symbolic .= (($perms & 0x0100) ? 'r' : '-');
+ $symbolic .= (($perms & 0x0080) ? 'w' : '-');
+ $symbolic .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
+
+ // Group
+ $symbolic .= (($perms & 0x0020) ? 'r' : '-');
+ $symbolic .= (($perms & 0x0010) ? 'w' : '-');
+ $symbolic .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
+
+ // World
+ $symbolic .= (($perms & 0x0004) ? 'r' : '-');
+ $symbolic .= (($perms & 0x0002) ? 'w' : '-');
+ $symbolic .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
+
+ return $symbolic;
+ }
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Octal Permissions
+ *
+ * Takes a numeric value representing a file's permissions and returns
+ * a three character string representing the file's octal permissions
+ *
+ * @access public
+ * @param int
+ * @return string
+ */
+if ( ! function_exists('octal_permissions'))
+{
+ function octal_permissions($perms)
+ {
+ return substr(sprintf('%o', $perms), -3);
+ }
+}
+
+
+/* End of file file_helper.php */
+/* Location: ./system/helpers/file_helper.php */
\ No newline at end of file
diff --git a/application/helpers/update/update_helper.php b/application/helpers/update/update_helper.php
index f6a13cc643b..fd9d5b90223 100644
--- a/application/helpers/update/update_helper.php
+++ b/application/helpers/update/update_helper.php
@@ -20,14 +20,13 @@
*/
function CheckForDBUpgrades($subaction = null)
{
- global $connect;
- $CI =& get_instance();
- $clang = $CI->limesurvey_lang;
- $dbversionnumber = $CI->config->item('dbversionnumber');
+ $connect = Yii::app()->db;
+ $clang = Yii::app()->getController()->lang;
+ $dbversionnumber = Yii::app()->getConfig('dbversionnumber');
$currentDBVersion=GetGlobalSetting('DBVersion');
- $dbprefix = $CI->db->dbprefix;
- $usertemplaterootdir = $CI->config->item('usertemplaterootdir');
- $standardtemplaterootdir = $CI->config->item('standardtemplaterootdir');
+ $dbprefix = Yii::app()->tablePrefix;
+ $usertemplaterootdir = Yii::app()->getConfig('usertemplaterootdir');
+ $standardtemplaterootdir = Yii::app()->getConfig('standardtemplaterootdir');
if (intval($dbversionnumber)>intval($currentDBVersion))
{
if(isset($subaction) && $subaction=="continue")
@@ -39,7 +38,7 @@ function CheckForDBUpgrades($subaction = null)
if ($upgradedbtype=='mysqli') $upgradedbtype='mysql';
$CI->load->helper('update/upgrade-'.$upgradedbtype);
$CI->load->helper('update/upgrade-all');
- $tables = $connect->MetaTables();
+ $tables = $connect->getSchema()->getTableNames();
db_upgrade_all(intval($currentDBVersion));
db_upgrade(intval($currentDBVersion));
$CI->db->update('settings_global',array('stg_value' => intval($dbversionnumber)),array('stg_name' => 'DBVersion'));
@@ -56,14 +55,14 @@ function ShowDBUpgradeNotice() {
$error=false;
$CI =& get_instance();
$clang = $CI->limesurvey_lang;
- $sitename = $CI->config->item('sitename');
+ $sitename = Yii::app()->getConfig('sitename');
echo '
';
echo "
';
echo $clang->gT('Please verify the following information before continuing with the database upgrade:').'
';
echo "" .$clang->gT('Database type') . ": " . $CI->db->dbdriver . " ";
echo "" .$clang->gT('Database name') . ": " . $CI->db->database . " ";
- echo "" .$clang->gT('Table prefix') . ": " . $CI->db->dbprefix . " ";
- echo "" .$clang->gT('Site name') . ": " . $CI->config->item("sitename") . " ";
+ echo "" .$clang->gT('Table prefix') . ": " . Yii::app()->tablePrefix . " ";
+ echo "" .$clang->gT('Site name') . ": " . Yii::app()->getConfig("sitename") . " ";
echo "" .$clang->gT('Root URL') . ": " . site_url() . " ";
echo ' ';
echo "
";
diff --git a/application/models/InstallerConfigForm.php b/application/models/InstallerConfigForm.php
new file mode 100644
index 00000000000..71d09924b1b
--- /dev/null
+++ b/application/models/InstallerConfigForm.php
@@ -0,0 +1,95 @@
+ 'MySQL',
+ 'mysqli' => 'MySQLi',
+ 'sqlite' => 'SQLite',
+ 'sqlite2' => 'SQLite2',
+ 'mssql' => 'Microsoft SQL Server',
+ 'dblib' => 'Microsoft SQL Server (dblib)',
+ 'sqlsrv' => 'Microsoft SQL Server (sqlsrv)',
+ 'sybase' => 'Microsoft SQL Server (sybase)',
+ 'pgsql' => 'PostgreSQL',
+ 'oci' => 'Oracle'
+ );
+
+ // Optional
+ public $adminLoginPwd = 'password';
+ public $confirmPwd = 'password';
+ public $adminLoginName = 'admin';
+ public $adminName = 'Your name';
+ public $adminEmail = 'your-email@example.net';
+ public $siteName = 'LimeSurvey';
+ public $surveylang = 'en';
+
+ public function __construct($scenario = 'database') {
+ $drivers = CDbConnection::getAvailableDrivers();
+ foreach($drivers as $driver) {
+ if (isset($this->db_names[$driver]))
+ $this->supported_db_types[$driver] = $this->db_names[$driver];
+ else
+ $this->supported_db_types[$driver] = $driver;
+ }
+
+ asort($this->supported_db_types);
+
+ parent::__construct();
+
+ // Default is database
+ $this->setScenario($scenario);
+ }
+
+ public function rules()
+ {
+ return array(
+ // Database
+ array('dbtype, dblocation, dbname, dbuser', 'required', 'on' => 'database'),
+ array('dbpwd, dbprefix', 'safe', 'on' => 'database'),
+ array('dbtype', 'in', 'range' => array_keys(CDbConnection::getAvailableDrivers()), 'on' => 'database'),
+
+ //Optional
+ array('adminLoginName, adminName, siteName, confirmPwd', 'safe', 'on' => 'optional'),
+ array('adminEmail', 'email', 'on' => 'optional'),
+ array('surveylang', 'in', 'range' => array_keys(getlanguagedata(true, true)), 'on' => 'optional'),
+ array('adminLoginPwd', 'compare', 'compareAttribute' => 'confirmPwd', 'message' => Yii::app()->getController()->lang->gT('Passwords do not match!'), 'strict' => true, 'on' => 'optional'),
+ );
+ }
+
+ public function attributeLabels()
+ {
+ return array(
+ 'dbtype' => 'Database type',
+ 'dblocation' => 'Database location',
+ 'dbname' => 'Database name',
+ 'dbuser' => 'Database user',
+ 'dbpwd' => 'Database password',
+ 'dbprefix' => 'Database prefix',
+ );
+ }
+}
+?>
diff --git a/application/views/installer/dbconfig_view.php b/application/views/installer/dbconfig_view.php
index 2a1cec0e617..d9393dc0042 100644
--- a/application/views/installer/dbconfig_view.php
+++ b/application/views/installer/dbconfig_view.php
@@ -1,17 +1,10 @@
-limesurvey_lang;
-$this->load->view("installer/header_view",array('progressValue' => $progressValue));
-?>
+render("/installer/header_view", compact('progressValue', 'clang')); ?>
-
+createUrl('installer/database')); ?>
-load->view('installer/sidebar_view', array(
- 'progressValue' => $progressValue,
- 'classesForStep' => $classesForStep
- ));
-?>
+render('/installer/sidebar_view', compact('progressValue', 'classesForStep', 'clang')); ?>
@@ -20,7 +13,9 @@
-
+
+ 'errors')); ?>
+
gT("Note: All fields marked with (*) are required."); ?>
@@ -30,52 +25,47 @@
- gT("Database type"); ?> *
+ $clang->gT("Database type"))); ?>
gT("This is the database type."); ?>
-
- >MySQL
- >MySQL (old driver)
- >Microsoft SQL Server
- >PostgreSQL
-
+ supported_db_types, array('style' => 'width: 147px')); ?>
- gT("Database Location"); ?> *
+ $clang->gT("Database location"))); ?>
gT('Set this to the IP/net location of your database server. In most cases "localhost" will work.'); ?>
- ".form_error('dblocation'); ?>
+ 'localhost')) ?>
- gT("Database Name"); ?> *
+ $clang->gT("Database name"))); ?>
gT("If you provide an existing database name make sure the database does not contain old tables of LimeSurvey."); ?>
- ".form_error('dbname'); ?>
+
- gT("Database User"); ?> *
+ $clang->gT("Database user"))); ?>
gT('Your Database server user name. In most cases "root" will work.'); ?>
- ".form_error('dbuser'); ?>
+
- gT("Database Password"); ?>
+ $clang->gT("Database password"))); ?>
gT("Your Database server password."); ?>
- ".form_error('dbpwd'); ?>
+
- gT("Database Prefix"); ?>
+ $clang->gT("Database prefix"))); ?>
gT('If your database is shared, recommended prefix is "lime_" else you can leave this setting blank.'); ?>
-
+ 'lime_')) ?>
@@ -95,15 +85,15 @@
-
+
-load->view("installer/footer_view"); ?>
+render("/installer/footer_view"); ?>
diff --git a/application/views/installer/dbsettings_view.php b/application/views/installer/dbsettings_view.php
index 4dba2a935a9..baf2c1a7e6f 100644
--- a/application/views/installer/dbsettings_view.php
+++ b/application/views/installer/dbsettings_view.php
@@ -1,24 +1,18 @@
-load->view("installer/header_view",array('progressValue' => $progressValue)); ?>
+render("/installer/header_view", compact('progressValue', 'clang')); ?>
- load->view('installer/sidebar_view', array(
- 'progressValue' => $progressValue,
- 'classesForStep' => $classesForStep
- ));
- ?>
+ render('/installer/sidebar_view', compact('progressValue', 'classesForStep', 'clang')); ?>
-load->view("installer/footer_view"); ?>
\ No newline at end of file
+render("/installer/footer_view"); ?>
\ No newline at end of file
diff --git a/application/views/installer/footer_view.php b/application/views/installer/footer_view.php
index 0b45c623591..7c4a5002bc8 100644
--- a/application/views/installer/footer_view.php
+++ b/application/views/installer/footer_view.php
@@ -5,7 +5,7 @@
-
+
diff --git a/application/views/installer/header_view.php b/application/views/installer/header_view.php
index 6ad09ce70b2..dc8b70d21c8 100644
--- a/application/views/installer/header_view.php
+++ b/application/views/installer/header_view.php
@@ -1,18 +1,14 @@
-lang;
-?>
-
-
-
+
+
-
-
+
+
@@ -33,14 +29,14 @@
});
-
+
LimeSurvey Installer
-
gT("LimeSurvey Installer"); ?>
+
gT("LimeSurvey Installer"); ?>
diff --git a/application/views/installer/language_options_view.php b/application/views/installer/language_options_view.php
deleted file mode 100644
index 5411c9d34f7..00000000000
--- a/application/views/installer/language_options_view.php
+++ /dev/null
@@ -1,17 +0,0 @@
-
- *
- * Used By:
- * - optconfig_view.php
- * - welcome_view.php
- */
- $langauges = getlanguagedata(true,true);
- foreach($langauges as $langkey => $languagekind)
- {
- $selected = $langkey === 'en';
- $value = $langkey;
- $label = sprintf('%s - %s', $languagekind['nativedescription'], $languagekind['description']);
- echo '
",
- $label, ' ', "\n";
- }
\ No newline at end of file
diff --git a/application/views/installer/license_view.php b/application/views/installer/license_view.php
index 8ae3ef1fe24..4ba803c6b02 100644
--- a/application/views/installer/license_view.php
+++ b/application/views/installer/license_view.php
@@ -1,15 +1,8 @@
-limesurvey_lang;
-$this->load->view("installer/header_view", array('progressValue' => $progressValue));
-?>
+render("/installer/header_view", compact('progressValue', 'clang')); ?>
-load->view('installer/sidebar_view', array(
- 'progressValue' => $progressValue,
- 'classesForStep' => $classesForStep
- ));
-?>
+render('/installer/sidebar_view', compact('progressValue', 'classesForStep', 'clang')); ?>
@@ -21,7 +14,7 @@
@@ -32,17 +25,17 @@
-load->view("installer/footer_view"); ?>
\ No newline at end of file
+render("/installer/footer_view"); ?>
\ No newline at end of file
diff --git a/application/views/installer/optconfig_view.php b/application/views/installer/optconfig_view.php
index 9e3ab28a51a..5246d8b8a59 100644
--- a/application/views/installer/optconfig_view.php
+++ b/application/views/installer/optconfig_view.php
@@ -1,28 +1,23 @@
-limesurvey_lang;
-$this->load->view("installer/header_view",array('progressValue' => $progressValue));
-?>
+render("/installer/header_view", compact('progressValue', 'clang')); ?>
-
PHP5 GD library
-
+
PHP5 LDAP library
-
+
PHP5 zip library
-
+
PHP5 zlib library
-
+
@@ -141,11 +131,11 @@ function dirReport($dir,$write)
-load->view("installer/footer_view"); ?>
\ No newline at end of file
+render("/installer/footer_view"); ?>
\ No newline at end of file
diff --git a/application/views/installer/sidebar_view.php b/application/views/installer/sidebar_view.php
index d0d256b3f24..885d3b4fb54 100644
--- a/application/views/installer/sidebar_view.php
+++ b/application/views/installer/sidebar_view.php
@@ -2,8 +2,6 @@
/**
* Web Installer Sidebar (Progressbar and Step-Listing) Viewscript
*/
-
-$clang = Yii::app()->lang;
?>
Progress
diff --git a/application/views/installer/success_view.php b/application/views/installer/success_view.php
index d86f265b11e..4b3ff9c1e64 100644
--- a/application/views/installer/success_view.php
+++ b/application/views/installer/success_view.php
@@ -1,15 +1,8 @@
-limesurvey_lang;
-$this->load->view("installer/header_view",array('progressValue' => $progressValue));
-?>
+render("/installer/header_view", compact('progressValue', 'clang')); ?>
-load->view('installer/sidebar_view', array(
- 'progressValue' => $progressValue,
- 'classesForStep' => $classesForStep
- ));
-?>
+render('/installer/sidebar_view', compact('progressValue', 'classesForStep', 'clang')); ?>
-load->view("installer/footer_view"); ?>
\ No newline at end of file
+render("/installer/footer_view"); ?>
\ No newline at end of file
diff --git a/application/views/installer/welcome_view.php b/application/views/installer/welcome_view.php
index 1e185e5f89f..14d3a249164 100644
--- a/application/views/installer/welcome_view.php
+++ b/application/views/installer/welcome_view.php
@@ -1,17 +1,10 @@
-lang;
-$this->getController()->render("installer/header_view",array('progressValue' => $progressValue));
-?>
+render("/installer/header_view", compact('progressValue', 'clang')); ?>
-
-
-getController()->render('installer/language_options_view'); ?>
-
+ $languagekind)
+{
+ $languages[htmlspecialchars($langkey)] = sprintf('%s - %s', $languagekind['nativedescription'], $languagekind['description']);
+}
+echo CHtml::dropDownList('installerLang', 'en', $languages, array('style' => 'width: 190px', 'id' => 'installerLang', 'encode' => false));
+?>
@@ -62,4 +59,4 @@
-getController()->render("installer/footer_view"); ?>
+render("/installer/footer_view"); ?>
diff --git a/installer/sql/create-mssql.sql b/installer/sql/create-mssql.sql
index bc2f046f821..b7cb811df2c 100644
--- a/installer/sql/create-mssql.sql
+++ b/installer/sql/create-mssql.sql
@@ -1,6 +1,6 @@
---
+--
-- Table structure for table answers
---
+--
CREATE TABLE [prefix_answers] (
[qid] INT NOT NULL default '0',
[code] VARCHAR(5) NOT NULL default '',
@@ -10,13 +10,13 @@ CREATE TABLE [prefix_answers] (
[language] VARCHAR(20) default 'en',
[scale_id] tinyint NOT NULL default '0',
PRIMARY KEY ([qid],[code],[language],[scale_id])
-)
+)
;
---
+--
-- Table structure for table assessments
---
+--
CREATE TABLE [prefix_assessments] (
[id] INT NOT NULL IDENTITY (1,1),
[sid] INT NOT NULL default '0',
@@ -28,14 +28,14 @@ CREATE TABLE [prefix_assessments] (
[message] text NOT NULL,
[language] VARCHAR(20) NOT NULL default 'en',
PRIMARY KEY ([id],[language])
-)
+)
;
---
+--
-- Table structure for table conditions
---
+--
CREATE TABLE [prefix_conditions] (
[cid] INT NOT NULL IDENTITY (1,1),
[qid] INT NOT NULL default '0',
@@ -45,13 +45,13 @@ CREATE TABLE [prefix_conditions] (
[method] char(5) NOT NULL default '',
[value] VARCHAR(255) NOT NULL default '',
PRIMARY KEY ([cid])
-)
+)
;
---
+--
-- Table structure for table defaultvalues
---
+--
CREATE TABLE [prefix_defaultvalues] (
[qid] integer NOT NULL default '0',
[scale_id] tinyint NOT NULL default '0',
@@ -60,7 +60,7 @@ CREATE TABLE [prefix_defaultvalues] (
[specialtype] varchar(20) NOT NULL default '',
[defaultvalue] text,
CONSTRAINT pk_defaultvalues_qlss PRIMARY KEY ([qid] , [scale_id], [language], [specialtype], [sqid]))
-
+
--
-- Table structure for table expression_errors
--
@@ -79,10 +79,10 @@ CREATE TABLE [prefix_expression_errors] (
PRIMARY KEY ([id])
);
-
---
+
+--
-- Table structure for table groups
---
+--
CREATE TABLE [prefix_groups] (
[gid] INT NOT NULL IDENTITY (1,1),
[sid] INT NOT NULL default '0',
@@ -92,13 +92,13 @@ CREATE TABLE [prefix_groups] (
[language] VARCHAR(20) default 'en',
[randomization_group] VARCHAR(20) NOT NULL default '',
PRIMARY KEY ([gid],[language])
-)
+)
;
---
+--
-- Table structure for table labels
---
+--
CREATE TABLE [prefix_labels] (
[lid] INT NOT NULL default '0',
[code] VARCHAR(5) NOT NULL default '',
@@ -107,29 +107,29 @@ CREATE TABLE [prefix_labels] (
[language] VARCHAR(20) default 'en',
[assessment_value] INT NOT NULL default '0',
PRIMARY KEY ([lid],[sortorder],[language]),
-)
+)
;
-CREATE INDEX labels_code_idx
+CREATE INDEX labels_code_idx
ON [prefix_labels] ([code])
;
---
+--
-- Table structure for table labelsets
---
+--
CREATE TABLE [prefix_labelsets] (
[lid] INT NOT NULL IDENTITY (1,1),
[label_name] VARCHAR(100) NOT NULL default '',
[languages] VARCHAR(200) default 'en',
PRIMARY KEY ([lid])
-)
+)
;
---
+--
-- Table structure for table question_attributes
---
+--
CREATE TABLE [prefix_question_attributes] (
[qaid] INT NOT NULL IDENTITY (1,1),
[qid] INT NOT NULL default '0',
@@ -137,13 +137,13 @@ CREATE TABLE [prefix_question_attributes] (
[value] TEXT default NULL,
[language] VARCHAR(20) default NULL,
PRIMARY KEY ([qaid])
-)
+)
;
---
+--
-- Table structure for table quota
---
+--
CREATE TABLE [prefix_quota] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int ,
@@ -155,9 +155,9 @@ CREATE TABLE [prefix_quota] (
PRIMARY KEY ([id])
);
---
+--
-- Table structure for table quota_languagesettings
---
+--
CREATE TABLE [prefix_quota_languagesettings] (
[quotals_id] int NOT NULL IDENTITY (1,1),
[quotals_quota_id] int,
@@ -170,9 +170,9 @@ CREATE TABLE [prefix_quota_languagesettings] (
);
---
+--
-- Table structure for table quota_members
---
+--
CREATE TABLE [prefix_quota_members] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int ,
@@ -183,9 +183,9 @@ CREATE TABLE [prefix_quota_members] (
);
---
+--
-- Table structure for table questions
---
+--
CREATE TABLE [prefix_questions] (
[qid] INT NOT NULL IDENTITY (1,1),
[parent_qid] INT NOT NULL default '0',
@@ -204,15 +204,15 @@ CREATE TABLE [prefix_questions] (
[same_default] tinyint NOT NULL default '0',
[relevance] text NULL,
PRIMARY KEY ([qid],[language])
-)
+)
;
-- --------------------------------------------------------
---
+--
-- Table structure for table saved_control
---
+--
CREATE TABLE [prefix_saved_control] (
[scid] INT NOT NULL IDENTITY (1,1),
[sid] INT NOT NULL default '0',
@@ -223,26 +223,22 @@ CREATE TABLE [prefix_saved_control] (
[ip] text NOT NULL,
[saved_thisstep] text NOT NULL,
[status] char(1) NOT NULL default '',
- [saved_date] datetime,
+ [saved_date] datetime,
[refurl] text NULL,
PRIMARY KEY ([scid])
-)
+)
;
---
+--
-- Table structure for table sessions
---
-CREATE TABLE prefix_sessions(
- sesskey VARCHAR( 64 ) NOT NULL DEFAULT '',
- expiry DATETIME NOT NULL ,
- expireref VARCHAR( 250 ) DEFAULT '',
- created DATETIME NOT NULL ,
- modified DATETIME NOT NULL ,
- sessdata text,
- CONSTRAINT pk_sessions_sesskey PRIMARY KEY ( [sesskey] ));
-create index [idx_expiry] on [prefix_sessions] ([expiry]);
-create index [idx_expireref] on [prefix_sessions] ([expireref]);
+--
+CREATE TABLE [prefix_sessions] (
+ [id] char(32) NOT NULL,
+ [expire] int(11) default NULL,
+ [data] text,
+ PRIMARY KEY ([id])
+);
--
@@ -255,9 +251,9 @@ CREATE TABLE [prefix_settings_global] (
);
---
+--
-- Table structure for table surveys
---
+--
CREATE TABLE [prefix_surveys] (
[sid] INT NOT NULL,
[owner_id] INT NOT NULL,
@@ -315,17 +311,17 @@ CREATE TABLE [prefix_surveys] (
[navigationdelay] tinyint default '0',
[nokeyboard] char(1) default 'N',
[alloweditaftercompletion] char(1) default 'N',
-
+
PRIMARY KEY ([sid])
-)
+)
;
---
+--
-- Table structure for table surveys_languagesettings
---
+--
CREATE TABLE [prefix_surveys_languagesettings] (
- [surveyls_survey_id] INT NOT NULL DEFAULT 0,
+ [surveyls_survey_id] INT NOT NULL DEFAULT 0,
[surveyls_language] VARCHAR(45) NOT NULL DEFAULT 'en',
[surveyls_title] VARCHAR(200) NOT NULL,
[surveyls_description] TEXT NULL,
@@ -346,71 +342,71 @@ CREATE TABLE [prefix_surveys_languagesettings] (
[email_admin_notification] TEXT NULL,
[email_admin_responses_subj] VARCHAR(255) NULL,
[email_admin_responses] TEXT NULL,
- [surveyls_numberformat] INT NOT NULL DEFAULT 0,
+ [surveyls_numberformat] INT NOT NULL DEFAULT 0,
PRIMARY KEY ([surveyls_survey_id],[surveyls_language])
)
;
---
+--
-- Table structure for table survey_permissions
---
+--
CREATE TABLE [prefix_survey_permissions] (
- [sid] INT NOT NULL,
- [uid] INT NOT NULL,
- [permission] VARCHAR(20) NOT NULL,
- [create_p] TINYINT NOT NULL default '0',
- [read_p] TINYINT NOT NULL default '0',
- [update_p] TINYINT NOT NULL default '0',
- [delete_p] TINYINT NOT NULL default '0',
- [import_p] TINYINT NOT NULL default '0',
- [export_p] TINYINT NOT NULL default '0',
+ [sid] INT NOT NULL,
+ [uid] INT NOT NULL,
+ [permission] VARCHAR(20) NOT NULL,
+ [create_p] TINYINT NOT NULL default '0',
+ [read_p] TINYINT NOT NULL default '0',
+ [update_p] TINYINT NOT NULL default '0',
+ [delete_p] TINYINT NOT NULL default '0',
+ [import_p] TINYINT NOT NULL default '0',
+ [export_p] TINYINT NOT NULL default '0',
PRIMARY KEY ([sid], [uid],[permission])
);
-
---
+
+--
-- Table structure for table survey_url_parameters
--
CREATE TABLE prefix_survey_url_parameters (
- [id] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
+ [id] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[sid] INT NOT NULL,
[parameter] VARCHAR(50) NOT NULL,
[targetqid] INT NULL,
[targetsqid] INT NULL
-);
-
-
---
+);
+
+
+--
-- Table structure for table user_groups
---
+--
CREATE TABLE [prefix_user_groups] (
- [ugid] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
+ [ugid] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[name] VARCHAR(20) NOT NULL UNIQUE,
[description] TEXT NOT NULL default '',
- [owner_id] INT NOT NULL
+ [owner_id] INT NOT NULL
);
---
+--
-- Table structure for table user_in_groups
---
+--
CREATE TABLE [prefix_user_in_groups] (
- [ugid] INT NOT NULL,
- [uid] INT NOT NULL
-)
+ [ugid] INT NOT NULL,
+ [uid] INT NOT NULL
+)
;
---
+--
-- Table structure for table users
---
+--
CREATE TABLE [prefix_users] (
[uid] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[users_name] VARCHAR(64) NOT NULL UNIQUE default '',
- [password] varchar(8000) NOT NULL default '',
+ [password] varchar(8000) NOT NULL default '',
[full_name] VARCHAR(50) NOT NULL,
- [parent_id] INT NOT NULL,
+ [parent_id] INT NOT NULL,
[lang] VARCHAR(20),
[email] VARCHAR(320) NOT NULL UNIQUE,
[create_survey] TINYINT NOT NULL default '0',
@@ -428,7 +424,7 @@ CREATE TABLE [prefix_users] (
[dateformat] INT NOT NULL DEFAULT 1
);
-
+
--
-- Table structure for table templates_rights
--
@@ -510,7 +506,7 @@ CREATE TABLE [prefix_survey_links] (
);
--
-- Table structure for table templates
---
+--
CREATE TABLE [prefix_templates] (
[folder] varchar(255) NOT NULL,
[creator] int NOT NULL,
@@ -529,7 +525,7 @@ CREATE TABLE [prefix_failed_login_attempts] (
);
--
--- Secondary indexes
+-- Secondary indexes
--
create index [answers_idx2] on [prefix_answers] ([sortorder]);
create index [assessments_idx2] on [prefix_assessments] ([sid]);
@@ -545,7 +541,7 @@ create index [questions_idx4] on [prefix_questions] ([type]);
create index [quota_idx2] on [prefix_quota] ([sid]);
create index [saved_control_idx2] on [prefix_saved_control] ([sid]);
create index [user_in_groups_idx1] on [prefix_user_in_groups] ([ugid], [uid]);
-create index [parent_qid_idx] on [prefix_questions] ([parent_qid]);
+create index [parent_qid_idx] on [prefix_questions] ([parent_qid]);
--
-- Version Info
diff --git a/installer/sql/create-mssqlnative.sql b/installer/sql/create-mssqlnative.sql
index 8faf35eccef..7ca97f2350e 100644
--- a/installer/sql/create-mssqlnative.sql
+++ b/installer/sql/create-mssqlnative.sql
@@ -1,6 +1,6 @@
---
+--
-- Table structure for table answers
---
+--
CREATE TABLE [prefix_answers] (
[qid] INT NOT NULL default '0',
@@ -11,13 +11,13 @@ CREATE TABLE [prefix_answers] (
[language] VARCHAR(20) default 'en',
[scale_id] tinyint NOT NULL default '0',
PRIMARY KEY ([qid],[code],[language],[scale_id])
-)
+)
;
---
+--
-- Table structure for table assessments
---
+--
CREATE TABLE [prefix_assessments] (
[id] INT NOT NULL IDENTITY (1,1),
@@ -30,14 +30,14 @@ CREATE TABLE [prefix_assessments] (
[message] varchar(max) NOT NULL,
[language] VARCHAR(20) NOT NULL default 'en',
PRIMARY KEY ([id],[language])
-)
+)
;
---
+--
-- Table structure for table conditions
---
+--
CREATE TABLE [prefix_conditions] (
[cid] INT NOT NULL IDENTITY (1,1),
@@ -48,13 +48,13 @@ CREATE TABLE [prefix_conditions] (
[method] char(5) NOT NULL default '',
[value] VARCHAR(255) NOT NULL default '',
PRIMARY KEY ([cid])
-)
+)
;
---
+--
-- Table structure for table defaultvalues
---
+--
CREATE TABLE [prefix_defaultvalues] (
[qid] integer NOT NULL default '0',
[scale_id] tinyint NOT NULL default '0',
@@ -81,11 +81,11 @@ CREATE TABLE [prefix_expression_errors] (
[prettyprint] varchar(max),
PRIMARY KEY ([id])
);
-
-
---
+
+
+--
-- Table structure for table groups
---
+--
CREATE TABLE [prefix_groups] (
[gid] INT NOT NULL IDENTITY (1,1),
@@ -96,13 +96,13 @@ CREATE TABLE [prefix_groups] (
[language] VARCHAR(20) default 'en',
[randomization_group] VARCHAR(20) NOT NULL default '',
PRIMARY KEY ([gid],[language])
-)
+)
;
---
+--
-- Table structure for table labels
---
+--
CREATE TABLE [prefix_labels] (
[lid] INT NOT NULL default '0',
@@ -112,30 +112,30 @@ CREATE TABLE [prefix_labels] (
[language] VARCHAR(20) default 'en',
[assessment_value] INT NOT NULL default '0',
PRIMARY KEY ([lid],[sortorder],[language]),
-)
+)
;
-CREATE INDEX labels_code_idx
+CREATE INDEX labels_code_idx
ON [prefix_labels] ([code])
;
---
+--
-- Table structure for table labelsets
---
+--
CREATE TABLE [prefix_labelsets] (
[lid] INT NOT NULL IDENTITY (1,1),
[label_name] VARCHAR(100) NOT NULL default '',
[languages] VARCHAR(200) default 'en',
PRIMARY KEY ([lid])
-)
+)
;
---
+--
-- Table structure for table question_attributes
---
+--
CREATE TABLE [prefix_question_attributes] (
[qaid] INT NOT NULL IDENTITY (1,1),
@@ -144,13 +144,13 @@ CREATE TABLE [prefix_question_attributes] (
[value] varchar(max) default NULL,
[language] VARCHAR(20) default NULL,
PRIMARY KEY ([qaid])
-)
+)
;
---
+--
-- Table structure for table quota
---
+--
CREATE TABLE [prefix_quota] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int ,
@@ -162,9 +162,9 @@ CREATE TABLE [prefix_quota] (
PRIMARY KEY ([id])
);
---
+--
-- Table structure for table quota_languagesettings
---
+--
CREATE TABLE [prefix_quota_languagesettings] (
[quotals_id] int NOT NULL IDENTITY (1,1),
[quotals_quota_id] int,
@@ -177,9 +177,9 @@ CREATE TABLE [prefix_quota_languagesettings] (
);
---
+--
-- Table structure for table quota_members
---
+--
CREATE TABLE [prefix_quota_members] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int ,
@@ -191,9 +191,9 @@ CREATE TABLE [prefix_quota_members] (
---
+--
-- Table structure for table questions
---
+--
CREATE TABLE [prefix_questions] (
[qid] INT NOT NULL IDENTITY (1,1),
[parent_qid] INT NOT NULL default '0',
@@ -212,15 +212,15 @@ CREATE TABLE [prefix_questions] (
[same_default] tinyint NOT NULL default '0',
[relevance] varchar(max),
PRIMARY KEY ([qid],[language])
-)
+)
;
-- --------------------------------------------------------
---
+--
-- Table structure for table saved_control
---
+--
CREATE TABLE [prefix_saved_control] (
[scid] INT NOT NULL IDENTITY (1,1),
@@ -232,26 +232,21 @@ CREATE TABLE [prefix_saved_control] (
[ip] varchar(max) NOT NULL,
[saved_thisstep] varchar(max) NOT NULL,
[status] char(1) NOT NULL default '',
- [saved_date] datetime,
+ [saved_date] datetime,
[refurl] varchar(max),
PRIMARY KEY ([scid])
-)
+)
;
-
---
+--
-- Table structure for table sessions
---
-CREATE TABLE prefix_sessions(
- sesskey VARCHAR( 64 ) NOT NULL DEFAULT '',
- expiry DATETIME NOT NULL ,
- expireref VARCHAR( 250 ) DEFAULT '',
- created DATETIME NOT NULL ,
- modified DATETIME NOT NULL ,
- sessdata varchar(max),
- CONSTRAINT pk_sessions_sesskey PRIMARY KEY ( [sesskey] ));
-create index [idx_expiry] on [prefix_sessions] ([expiry]);
-create index [idx_expireref] on [prefix_sessions] ([expireref]);
+--
+CREATE TABLE [prefix_sessions] (
+ [id] char(32) NOT NULL,
+ [expire] int(11) default NULL,
+ [data] TEXT,
+ PRIMARY KEY ( [id] )
+);
--
@@ -264,9 +259,9 @@ CREATE TABLE [prefix_settings_global] (
);
---
+--
-- Table structure for table surveys
---
+--
CREATE TABLE [prefix_surveys] (
[sid] INT NOT NULL,
[owner_id] INT NOT NULL,
@@ -324,17 +319,17 @@ CREATE TABLE [prefix_surveys] (
[navigationdelay] tinyint default '0',
[nokeyboard] char(1) default 'N',
[alloweditaftercompletion] char(1) default 'N',
-
+
PRIMARY KEY ([sid])
-)
+)
;
---
+--
-- Table structure for table surveys_languagesettings
---
+--
CREATE TABLE [prefix_surveys_languagesettings] (
- [surveyls_survey_id] INT NOT NULL DEFAULT 0,
+ [surveyls_survey_id] INT NOT NULL DEFAULT 0,
[surveyls_language] VARCHAR(45) NOT NULL DEFAULT 'en',
[surveyls_title] VARCHAR(200) NOT NULL,
[surveyls_description] varchar(max) NULL,
@@ -361,67 +356,67 @@ CREATE TABLE [prefix_surveys_languagesettings] (
;
---
+--
-- Table structure for table survey_permissions
---
+--
CREATE TABLE [prefix_survey_permissions] (
- [sid] INT NOT NULL,
- [uid] INT NOT NULL,
- [permission] VARCHAR(20) NOT NULL,
- [create_p] TINYINT NOT NULL default '0',
- [read_p] TINYINT NOT NULL default '0',
- [update_p] TINYINT NOT NULL default '0',
- [delete_p] TINYINT NOT NULL default '0',
- [import_p] TINYINT NOT NULL default '0',
- [export_p] TINYINT NOT NULL default '0',
+ [sid] INT NOT NULL,
+ [uid] INT NOT NULL,
+ [permission] VARCHAR(20) NOT NULL,
+ [create_p] TINYINT NOT NULL default '0',
+ [read_p] TINYINT NOT NULL default '0',
+ [update_p] TINYINT NOT NULL default '0',
+ [delete_p] TINYINT NOT NULL default '0',
+ [import_p] TINYINT NOT NULL default '0',
+ [export_p] TINYINT NOT NULL default '0',
PRIMARY KEY ([sid], [uid],[permission])
);
---
+--
-- Table structure for table survey_url_parameters
--
CREATE TABLE prefix_survey_url_parameters (
- [id] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
+ [id] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[sid] INT NOT NULL,
[parameter] VARCHAR(50) NOT NULL,
[targetqid] INT NULL,
[targetsqid] INT NULL
-);
-
-
---
+);
+
+
+--
-- Table structure for table user_groups
---
+--
CREATE TABLE [prefix_user_groups] (
- [ugid] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
+ [ugid] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[name] VARCHAR(20) NOT NULL UNIQUE,
[description] varchar(max) NOT NULL default '',
- [owner_id] INT NOT NULL
-)
+ [owner_id] INT NOT NULL
+)
;
---
+--
-- Table structure for table user_in_groups
---
+--
CREATE TABLE [prefix_user_in_groups] (
- [ugid] INT NOT NULL,
- [uid] INT NOT NULL
-)
+ [ugid] INT NOT NULL,
+ [uid] INT NOT NULL
+)
;
---
+--
-- Table structure for table users
---
+--
CREATE TABLE [prefix_users] (
[uid] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[users_name] VARCHAR(64) NOT NULL UNIQUE default '',
- [password] varchar(8000) NOT NULL default '',
+ [password] varchar(8000) NOT NULL default '',
[full_name] VARCHAR(50) NOT NULL,
- [parent_id] INT NOT NULL,
+ [parent_id] INT NOT NULL,
[lang] VARCHAR(20),
[email] VARCHAR(320) NOT NULL UNIQUE,
[create_survey] TINYINT NOT NULL default '0',
@@ -449,7 +444,7 @@ CREATE TABLE [prefix_templates_rights] (
[use] int NOT NULL,
PRIMARY KEY ([uid],[folder])
);
-
+
--
-- Table structure for table participants
--
@@ -471,16 +466,16 @@ CREATE TABLE [prefix_participant_attribute] (
[attribute_id] int(11) NOT NULL,
[value] varchar(50) NOT NULL,
PRIMARY KEY ([participant_id],[attribute_id])
- );
+ );
--
-- Table structure for table participant attribute names lang
--
-CREATE TABLE [prefix_participant_attribute_names_lang] (
+CREATE TABLE [prefix_participant_attribute_names_lang] (
[attribute_id] int(11) NOT NULL,
[attribute_name] varchar(30) NOT NULL,
[lang] varchar(20) NOT NULL,
PRIMARY KEY ([attribute_id],[lang])
- );
+ );
--
-- Table structure for table participant attribute names
--
@@ -489,7 +484,7 @@ CREATE TABLE [prefix_participant_attribute_names] (
[attribute_type] varchar(30) NOT NULL,
[visible] char(5) NOT NULL,
PRIMARY KEY ([attribute_id],[attribute_type])
- );
+ );
--
-- Table structure for table participant attribute values
@@ -499,7 +494,7 @@ CREATE TABLE [prefix_participant_attribute_values] (
[value_id] int(11) NOT NULL AUTO_INCREMENT,
[value] varchar(20) NOT NULL,
PRIMARY KEY ([value_id])
- );
+ );
--
-- Table structure for table participant shares
--
@@ -508,8 +503,8 @@ CREATE TABLE [prefix_participant_shares] (
[shared_uid] int(11) NOT NULL,
[date_added] datetime,
[can_edit] varchar(5) NOT NULL,
- PRIMARY KEY ([participant_id],[shared_uid])
- );
+ PRIMARY KEY ([participant_id],[shared_uid])
+ );
--
-- Table structure for table survey links
--
@@ -518,13 +513,13 @@ CREATE TABLE [prefix_survey_links] (
[token_id] int(11) NOT NULL,
[survey_id] int(11) NOT NULL,
[date_created] datetime,
- PRIMARY KEY ([participant_id],[token_id],[survey_id])
- );
+ PRIMARY KEY ([participant_id],[token_id],[survey_id])
+ );
--
-- Table structure for table templates
---
+--
CREATE TABLE [prefix_templates] (
[folder] varchar(255) NOT NULL,
[creator] int NOT NULL,
@@ -545,7 +540,7 @@ CREATE TABLE [prefix_failed_login_attempts] (
--
--- Secondary indexes
+-- Secondary indexes
--
create index [answers_idx2] on [prefix_answers] ([sortorder]);
create index [assessments_idx2] on [prefix_assessments] ([sid]);
@@ -561,7 +556,7 @@ create index [questions_idx4] on [prefix_questions] ([type]);
create index [quota_idx2] on [prefix_quota] ([sid]);
create index [saved_control_idx2] on [prefix_saved_control] ([sid]);
create index [user_in_groups_idx1] on [prefix_user_in_groups] ([ugid], [uid]);
-create index [parent_qid_idx] on [prefix_questions] ([parent_qid]);
+create index [parent_qid_idx] on [prefix_questions] ([parent_qid]);
--
-- Version Info
diff --git a/installer/sql/create-mysql.sql b/installer/sql/create-mysql.sql
index b4c6520570d..56c8a0cda0a 100644
--- a/installer/sql/create-mysql.sql
+++ b/installer/sql/create-mysql.sql
@@ -1,6 +1,6 @@
---
+--
-- Table structure for table answers
---
+--
CREATE TABLE `prefix_answers` (
`qid` int(11) NOT NULL default '0',
`code` varchar(5) NOT NULL default '',
@@ -13,9 +13,9 @@ CREATE TABLE `prefix_answers` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table assessments
---
+--
CREATE TABLE `prefix_assessments` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) NOT NULL default '0',
@@ -30,9 +30,9 @@ CREATE TABLE `prefix_assessments` (
) ENGINE=MYISAM AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table conditions
---
+--
CREATE TABLE `prefix_conditions` (
`cid` int(11) NOT NULL auto_increment,
`qid` int(11) NOT NULL default '0',
@@ -45,9 +45,9 @@ CREATE TABLE `prefix_conditions` (
) ENGINE=MYISAM AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table defaultvalues
---
+--
CREATE TABLE `prefix_defaultvalues` (
`qid` int(11) NOT NULL default '0',
`specialtype` varchar(20) NOT NULL default '',
@@ -76,9 +76,9 @@ CREATE TABLE `prefix_expression_errors` (
PRIMARY KEY (`id`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table groups
---
+--
CREATE TABLE `prefix_groups` (
`gid` int(11) NOT NULL auto_increment,
`sid` int(11) NOT NULL default '0',
@@ -91,9 +91,9 @@ CREATE TABLE `prefix_groups` (
) ENGINE=MYISAM AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table labels
---
+--
CREATE TABLE `prefix_labels` (
`lid` int(11) NOT NULL default '0',
`code` varchar(5) NOT NULL default '',
@@ -106,9 +106,9 @@ CREATE TABLE `prefix_labels` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table labelsets
---
+--
CREATE TABLE `prefix_labelsets` (
`lid` int(11) NOT NULL auto_increment,
`label_name` varchar(100) NOT NULL default '',
@@ -117,9 +117,9 @@ CREATE TABLE `prefix_labelsets` (
) ENGINE=MYISAM AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table question_attributes
---
+--
CREATE TABLE `prefix_question_attributes` (
`qaid` int(11) NOT NULL auto_increment,
`qid` int(11) NOT NULL default '0',
@@ -130,9 +130,9 @@ CREATE TABLE `prefix_question_attributes` (
) ENGINE=MYISAM AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table quota
---
+--
CREATE TABLE `prefix_quota` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) default NULL,
@@ -145,9 +145,9 @@ CREATE TABLE `prefix_quota` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table quota_languagesettings
---
+--
CREATE TABLE `prefix_quota_languagesettings` (
`quotals_id` int(11) NOT NULL auto_increment,
`quotals_quota_id` int(11) NOT NULL default '0',
@@ -160,9 +160,9 @@ CREATE TABLE `prefix_quota_languagesettings` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table quota_members
---
+--
CREATE TABLE `prefix_quota_members` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) default NULL,
@@ -174,9 +174,9 @@ CREATE TABLE `prefix_quota_members` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table questions
---
+--
CREATE TABLE `prefix_questions` (
`qid` int(11) NOT NULL auto_increment,
`parent_qid` int(11) NOT NULL default '0',
@@ -198,9 +198,9 @@ CREATE TABLE `prefix_questions` (
) ENGINE=MYISAM AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table saved_control
---
+--
CREATE TABLE `prefix_saved_control` (
`scid` int(11) NOT NULL auto_increment,
`sid` int(11) NOT NULL default '0',
@@ -217,25 +217,20 @@ CREATE TABLE `prefix_saved_control` (
) ENGINE=MYISAM AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table templates_sessions
---
+--
CREATE TABLE `prefix_sessions`(
- sesskey varchar( 64 ) NOT NULL DEFAULT '',
- expiry DATETIME NOT NULL ,
- expireref varchar( 250 ) DEFAULT '',
- created DATETIME NOT NULL ,
- modified DATETIME NOT NULL ,
- sessdata LONGTEXT,
- PRIMARY KEY ( sesskey ) ,
- INDEX sess2_expiry( expiry ),
- INDEX sess2_expireref( expireref )
-);
-
-
---
+ `id` char(32) NOT NULL,
+ `expire` int(11) DEFAULT NULL,
+ `data` text,
+ PRIMARY KEY (`id`)
+) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
+
+
+--
-- Table structure for table settings_global
---
+--
CREATE TABLE `prefix_settings_global` (
`stg_name` varchar(50) NOT NULL default '',
`stg_value` varchar(255) NOT NULL default '',
@@ -243,9 +238,9 @@ CREATE TABLE `prefix_settings_global` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table surveys
---
+--
CREATE TABLE `prefix_surveys` (
`sid` int(11) NOT NULL,
`owner_id` int(11) NOT NULL,
@@ -271,26 +266,26 @@ CREATE TABLE `prefix_surveys` (
`printanswers` char(1) default 'N',
`ipaddr` char(1) default 'N',
`refurl` char(1) default 'N',
- `datecreated` date default NULL,
+ `datecreated` date default NULL,
`publicstatistics` char(1) default 'N',
`publicgraphs` char(1) default 'N',
`listpublic` char(1) default 'N',
`htmlemail` char(1) default 'N',
`sendconfirmation` char(1) default 'Y',
`tokenanswerspersistence` char(1) default 'N',
- `assessments` char(1) default 'N',
+ `assessments` char(1) default 'N',
`usecaptcha` char(1) default 'N',
`usetokens` char(1) default 'N',
`bounce_email` varchar(320) default NULL,
`attributedescriptions` text,
- `emailresponseto` text default NULL,
+ `emailresponseto` text default NULL,
`emailnotificationto` text default NULL,
`tokenlength` tinyint(2) default '15',
`showXquestions` char(1) default 'Y',
`showgroupinfo` char(1) default 'B',
`shownoanswer` char(1) default 'Y',
`showqnumcode` char(1) default 'X',
- `bouncetime` bigint(20),
+ `bouncetime` bigint(20),
`bounceprocessing` varchar(1) default 'N',
`bounceaccounttype` varchar(4),
`bounceaccounthost` varchar(200),
@@ -307,9 +302,9 @@ CREATE TABLE `prefix_surveys` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table surveys_languagesettings
---
+--
CREATE TABLE `prefix_surveys_languagesettings` (
`surveyls_survey_id` INT UNSIGNED NOT NULL DEFAULT 0,
`surveyls_language` varchar(45) NULL DEFAULT 'en',
@@ -328,19 +323,19 @@ CREATE TABLE `prefix_surveys_languagesettings` (
`surveyls_email_confirm_subj` varchar(255) NULL,
`surveyls_email_confirm` TEXT NULL,
`surveyls_dateformat` INT UNSIGNED NOT NULL DEFAULT 1,
- `email_admin_notification_subj` varchar(255) NULL,
- `email_admin_notification` TEXT NULL,
- `email_admin_responses_subj` varchar(255) NULL,
- `email_admin_responses` TEXT NULL,
+ `email_admin_notification_subj` varchar(255) NULL,
+ `email_admin_notification` TEXT NULL,
+ `email_admin_responses_subj` varchar(255) NULL,
+ `email_admin_responses` TEXT NULL,
`surveyls_numberformat` INT NOT NULL DEFAULT 0,
-
+
PRIMARY KEY (`surveyls_survey_id`, `surveyls_language`)
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table survey_permissions
---
+--
CREATE TABLE `prefix_survey_permissions` (
`sid` int(10) unsigned NOT NULL,
`uid` int(10) unsigned NOT NULL,
@@ -355,7 +350,7 @@ CREATE TABLE `prefix_survey_permissions` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table survey_url_parameters
--
CREATE TABLE `prefix_survey_url_parameters` (
@@ -367,9 +362,9 @@ CREATE TABLE `prefix_survey_url_parameters` (
PRIMARY KEY (`id`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table user_groups
---
+--
CREATE TABLE `prefix_user_groups` (
`ugid` int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
`name` varchar(20) NOT NULL UNIQUE,
@@ -378,19 +373,19 @@ CREATE TABLE `prefix_user_groups` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table user_in_groups
---
+--
CREATE TABLE `prefix_user_in_groups` (
`ugid` int(10) unsigned NOT NULL,
`uid` int(10) unsigned NOT NULL,
- PRIMARY KEY (`ugid`,`uid`)
+ PRIMARY KEY (`ugid`,`uid`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table users
---
+--
CREATE TABLE `prefix_users` (
`uid` int(11) NOT NULL auto_increment PRIMARY KEY,
`users_name` varchar(64) NOT NULL UNIQUE default '',
@@ -411,22 +406,22 @@ CREATE TABLE `prefix_users` (
`templateeditormode` varchar(7) default 'default',
`questionselectormode` varchar(7) default 'default',
`one_time_pw` BLOB,
- `dateformat` INT UNSIGNED NOT NULL DEFAULT 1
+ `dateformat` INT UNSIGNED NOT NULL DEFAULT 1
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table templates_rights
---
+--
CREATE TABLE `prefix_templates_rights` (
`uid` int(11) NOT NULL,
`folder` varchar(255) NOT NULL,
`use` int(1) NOT NULL,
PRIMARY KEY (`uid`,`folder`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table participants
---
+--
CREATE TABLE `prefix_participants` (
`participant_id` varchar(50) NOT NULL,
`firstname` varchar(40) NOT NULL,
@@ -437,45 +432,45 @@ CREATE TABLE `prefix_participants` (
`owner_uid` int(20) NOT NULL,
PRIMARY KEY (`participant_id`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table participant_attribute
---
+--
CREATE TABLE `prefix_participant_attribute` (
`participant_id` varchar(50) NOT NULL,
`attribute_id` int(11) NOT NULL,
`value` varchar(50) NOT NULL,
PRIMARY KEY (`participant_id`,`attribute_id`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table participant_attribute_names_lang
---
+--
CREATE TABLE `prefix_participant_attribute_names_lang` (
`attribute_id` int(11) NOT NULL,
`attribute_name` varchar(30) NOT NULL,
`lang` varchar(20) NOT NULL,
PRIMARY KEY (`attribute_id`,`lang`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table participant_attribute_names
---
+--
CREATE TABLE `prefix_participant_attribute_names` (
`attribute_id` int(11) NOT NULL AUTO_INCREMENT,
`attribute_type` varchar(4) NOT NULL,
`visible` char(5) NOT NULL,
PRIMARY KEY (`attribute_id`,`attribute_type`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table participant_attribute_names_values
---
+--
CREATE TABLE `prefix_participant_attribute_values` (
`value_id` int(11) NOT NULL AUTO_INCREMENT,
`attribute_id` int(11) NOT NULL,
`value` varchar(20) NOT NULL,
PRIMARY KEY ( `value_id`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table participant_shares
---
+--
CREATE TABLE `prefix_participant_shares` (
`participant_id` varchar(50) NOT NULL,
`share_uid` int(11) NOT NULL,
@@ -483,9 +478,9 @@ CREATE TABLE `prefix_participant_shares` (
`can_edit` varchar(5) NOT NULL,
PRIMARY KEY (`participant_id`,`share_uid`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table survey_links
---
+--
CREATE TABLE `prefix_survey_links` (
`participant_id` varchar(50) NOT NULL,
`token_id` int(11) NOT NULL,
@@ -493,9 +488,9 @@ CREATE TABLE `prefix_survey_links` (
`date_created` datetime NOT NULL,
PRIMARY KEY (`participant_id`,`token_id`,`survey_id`)
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
---
+--
-- Table structure for table templates
---
+--
CREATE TABLE `prefix_templates` (
`folder` varchar(255) NOT NULL,
`creator` int(11) NOT NULL,
@@ -516,7 +511,7 @@ CREATE TABLE `prefix_failed_login_attempts` (
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
--- Secondary indexes
+-- Secondary indexes
--
create index `answers_idx2` on `prefix_answers` (`sortorder`);
create index `assessments_idx2` on `prefix_assessments` (`sid`);
diff --git a/installer/sql/create-postgre.sql b/installer/sql/create-pgsql.sql
similarity index 89%
rename from installer/sql/create-postgre.sql
rename to installer/sql/create-pgsql.sql
index e421829a5b1..a60a710388e 100644
--- a/installer/sql/create-postgre.sql
+++ b/installer/sql/create-pgsql.sql
@@ -6,9 +6,9 @@ SET default_tablespace = '';
SET default_with_oids = false;
---
+--
-- Table structure for table answers
---
+--
CREATE TABLE prefix_answers (
qid integer DEFAULT 0 NOT NULL,
code character varying(5) DEFAULT ''::character varying NOT NULL,
@@ -17,13 +17,13 @@ CREATE TABLE prefix_answers (
assessment_value integer DEFAULT 0 NOT NULL,
"language" character varying(20) DEFAULT 'en'::character varying NOT NULL,
scale_id smallint DEFAULT 0 NOT NULL,
- CONSTRAINT prefix_answers_pkey PRIMARY KEY (qid, code, "language", scale_id)
+ CONSTRAINT prefix_answers_pkey PRIMARY KEY (qid, code, "language", scale_id)
);
-
---
+
+--
-- Table structure for table assessments
---
+--
CREATE TABLE prefix_assessments (
id serial,
sid integer DEFAULT 0 NOT NULL,
@@ -34,11 +34,11 @@ CREATE TABLE prefix_assessments (
maximum character varying(50) DEFAULT ''::character varying NOT NULL,
message text NOT NULL,
language character varying(20) DEFAULT 'en'::bpchar NOT NULL,
- CONSTRAINT prefix_assessments_pkey PRIMARY KEY (id,language)
+ CONSTRAINT prefix_assessments_pkey PRIMARY KEY (id,language)
);
---
+--
-- Table structure for table conditions
--
CREATE TABLE prefix_conditions (
@@ -49,11 +49,11 @@ CREATE TABLE prefix_conditions (
cfieldname character varying(50) DEFAULT ''::character varying NOT NULL,
method character(5) DEFAULT ''::bpchar NOT NULL,
value character varying(255) DEFAULT ''::character varying NOT NULL,
- CONSTRAINT prefix_conditions_pkey PRIMARY KEY (cid)
+ CONSTRAINT prefix_conditions_pkey PRIMARY KEY (cid)
);
---
+--
-- Table structure for table defaultvalues
--
CREATE TABLE prefix_defaultvalues (
@@ -63,7 +63,7 @@ CREATE TABLE prefix_defaultvalues (
language character varying(20) NOT NULL,
specialtype character varying(20) NOT NULL default '',
defaultvalue text,
- CONSTRAINT prefix_defaultvalues_pkey PRIMARY KEY (qid , scale_id, language, specialtype, sqid)
+ CONSTRAINT prefix_defaultvalues_pkey PRIMARY KEY (qid , scale_id, language, specialtype, sqid)
);
--
@@ -85,7 +85,7 @@ CREATE TABLE prefix_expression_errors (
);
---
+--
-- Table structure for table groups
--
CREATE TABLE prefix_groups (
@@ -96,11 +96,11 @@ CREATE TABLE prefix_groups (
description text,
"language" character varying(20) DEFAULT 'en'::character varying NOT NULL,
randomization_group varying(20) DEFAULT ''::character varying NOT NULL,
- CONSTRAINT prefix_groups_pkey PRIMARY KEY (gid, "language")
+ CONSTRAINT prefix_groups_pkey PRIMARY KEY (gid, "language")
);
---
+--
-- Table structure for table labels
--
CREATE TABLE prefix_labels (
@@ -110,23 +110,23 @@ CREATE TABLE prefix_labels (
sortorder integer NOT NULL,
assessment_value integer DEFAULT 0 NOT NULL,
"language" character varying(20) DEFAULT 'en'::character varying NOT NULL,
- CONSTRAINT prefix_labels_pkey PRIMARY KEY (lid, sortorder, "language")
+ CONSTRAINT prefix_labels_pkey PRIMARY KEY (lid, sortorder, "language")
);
CREATE INDEX prefix_labels_ixcode_idx ON prefix_labels USING btree (code);
---
+--
-- Table structure for table labelsets
--
CREATE TABLE prefix_labelsets (
lid serial NOT NULL,
label_name character varying(100) DEFAULT ''::character varying NOT NULL,
languages character varying(200) DEFAULT 'en'::character varying,
- CONSTRAINT prefix_labelsets_pkey PRIMARY KEY (lid)
+ CONSTRAINT prefix_labelsets_pkey PRIMARY KEY (lid)
);
---
+--
-- Table structure for table question_attributes
--
CREATE TABLE prefix_question_attributes (
@@ -135,13 +135,13 @@ CREATE TABLE prefix_question_attributes (
attribute character varying(50),
value text NULL,
"language" character varying(20),
- CONSTRAINT prefix_question_attributes_pkey PRIMARY KEY (qaid)
+ CONSTRAINT prefix_question_attributes_pkey PRIMARY KEY (qaid)
);
---
+--
-- Table structure for table quota
---
+--
CREATE TABLE prefix_quota (
id serial NOT NULL,
sid integer,
@@ -150,13 +150,13 @@ CREATE TABLE prefix_quota (
"action" integer,
"active" integer NOT NULL default '1',
autoload_url integer NOT NULL DEFAULT 0,
- CONSTRAINT prefix_quota_pkey PRIMARY KEY (id)
+ CONSTRAINT prefix_quota_pkey PRIMARY KEY (id)
);
-
---
+
+--
-- Table structure for table quota_languagesettings
---
+--
CREATE TABLE prefix_quota_languagesettings
(
quotals_id serial NOT NULL,
@@ -166,27 +166,27 @@ CREATE TABLE prefix_quota_languagesettings
quotals_message text NOT NULL,
quotals_url character varying(255),
quotals_urldescrip character varying(255),
- CONSTRAINT prefix_quota_languagesettings_pkey PRIMARY KEY (quotals_id)
+ CONSTRAINT prefix_quota_languagesettings_pkey PRIMARY KEY (quotals_id)
);
-
---
+
+--
-- Table structure for table quota_members
---
+--
CREATE TABLE prefix_quota_members (
id serial,
sid integer,
qid integer,
quota_id integer,
code character varying(11),
- CONSTRAINT prefix_quota_members_pkey PRIMARY KEY (id)
+ CONSTRAINT prefix_quota_members_pkey PRIMARY KEY (id)
);
CREATE INDEX prefix_quota_members_ixcode_idx ON prefix_quota_members USING btree (sid,qid,quota_id,code);
---
+--
-- Table structure for table questions
---
+--
CREATE TABLE prefix_questions (
qid serial NOT NULL,
parent_qid integer DEFAULT 0 NOT NULL,
@@ -204,11 +204,11 @@ CREATE TABLE prefix_questions (
scale_id smallint DEFAULT 0 NOT NULL,
same_default smallint DEFAULT 0 NOT NULL,
relevance text,
- CONSTRAINT prefix_questions_pkey PRIMARY KEY (qid, "language")
+ CONSTRAINT prefix_questions_pkey PRIMARY KEY (qid, "language")
);
-
---
+
+--
-- Table structure for table saved_control
--
CREATE TABLE prefix_saved_control (
@@ -223,37 +223,32 @@ CREATE TABLE prefix_saved_control (
status character(1) DEFAULT ''::bpchar NOT NULL,
saved_date timestamp without time zone NOT NULL,
refurl text,
- CONSTRAINT prefix_saved_control_pkey PRIMARY KEY (scid)
+ CONSTRAINT prefix_saved_control_pkey PRIMARY KEY (scid)
);
---
+--
-- Table structure for table sessions
--
CREATE TABLE prefix_sessions(
- sesskey VARCHAR( 64 ) NOT NULL DEFAULT '',
- expiry TIMESTAMP NOT NULL ,
- expireref VARCHAR( 250 ) DEFAULT '',
- created TIMESTAMP NOT NULL ,
- modified TIMESTAMP NOT NULL ,
- sessdata TEXT DEFAULT '',
- CONSTRAINT prefix_sessions_pkey PRIMARY KEY ( sesskey )
- );
-create INDEX sess_expiry on prefix_sessions( expiry );
-create INDEX sess_expireref on prefix_sessions ( expireref );
-
-
---
+ id character(32) NOT NULL,
+ expire integer DEFAULT NULL,
+ data text,
+ CONSTRAINT prefix_sessions_pkey PRIMARY KEY ( id )
+);
+
+
+--
-- Table structure for table settings_global
--
CREATE TABLE prefix_settings_global (
stg_name character varying(50) DEFAULT ''::character varying NOT NULL,
stg_value character varying(255) DEFAULT ''::character varying NOT NULL,
- CONSTRAINT prefix_settings_global_pkey PRIMARY KEY (stg_name)
+ CONSTRAINT prefix_settings_global_pkey PRIMARY KEY (stg_name)
);
---
+--
-- Table structure for table surveys
--
CREATE TABLE prefix_surveys (
@@ -313,11 +308,11 @@ CREATE TABLE prefix_surveys (
navigationdelay smallint DEFAULT '0',
nokeyboard character(1) DEFAULT 'N'::bpchar,
alloweditaftercompletion character(1) DEFAULT 'N'::bpchar,
- CONSTRAINT prefix_surveys_pkey PRIMARY KEY (sid)
+ CONSTRAINT prefix_surveys_pkey PRIMARY KEY (sid)
);
---
+--
-- Table structure for table surveys_languagesettings
--
CREATE TABLE prefix_surveys_languagesettings (
@@ -343,11 +338,11 @@ CREATE TABLE prefix_surveys_languagesettings (
email_admin_responses_subj character varying(255),
email_admin_responses text,
surveyls_numberformat integer NOT NULL DEFAULT 1,
- CONSTRAINT prefix_surveys_languagesettings_pkey PRIMARY KEY (surveyls_survey_id, surveyls_language)
+ CONSTRAINT prefix_surveys_languagesettings_pkey PRIMARY KEY (surveyls_survey_id, surveyls_language)
);
---
+--
-- Table structure for table survey_permissions
--
CREATE TABLE prefix_survey_permissions (
@@ -360,10 +355,10 @@ CREATE TABLE prefix_survey_permissions (
delete_p integer DEFAULT 0 NOT NULL,
import_p integer DEFAULT 0 NOT NULL,
export_p integer DEFAULT 0 NOT NULL,
- CONSTRAINT prefix_survey_permissions_pkey PRIMARY KEY (sid,uid,permission)
+ CONSTRAINT prefix_survey_permissions_pkey PRIMARY KEY (sid,uid,permission)
);
---
+--
-- Table structure for table survey_url_parameters
--
CREATE TABLE prefix_survey_url_parameters (
@@ -374,9 +369,9 @@ CREATE TABLE prefix_survey_url_parameters (
targetsqid integer NULL
);
---
+--
-- Table structure for table user_groups
---
+--
CREATE TABLE prefix_user_groups (
ugid serial NOT NULL,
name character varying(20) NOT NULL,
@@ -385,18 +380,18 @@ CREATE TABLE prefix_user_groups (
);
---
+--
-- Table structure for table user_in_groups
---
+--
CREATE TABLE prefix_user_in_groups (
ugid integer NOT NULL,
uid integer NOT NULL
);
---
+--
-- Table structure for table users
---
+--
CREATE TABLE prefix_users (
uid serial PRIMARY KEY NOT NULL,
users_name character varying(64) DEFAULT ''::character varying UNIQUE NOT NULL,
@@ -421,9 +416,9 @@ CREATE TABLE prefix_users (
);
---
+--
-- Table structure for table templates_rights
---
+--
CREATE TABLE prefix_templates_rights (
"uid" integer NOT NULL,
"folder" character varying(255) NOT NULL,
@@ -432,9 +427,9 @@ CREATE TABLE prefix_templates_rights (
);
---
+--
-- Table structure for table participants
---
+--
CREATE TABLE prefix_participants (
"participant_id" character varying( 50 ) PRIMARY KEY NOT NULL,
"firstname" character varying( 40 ) NOT NULL,
@@ -446,46 +441,46 @@ CREATE TABLE prefix_participants (
);
---
+--
-- Table structure for table participant_attribute
---
+--
CREATE TABLE prefix_participant_attribute (
"participant_id" character varying( 50 ) NOT NULL,
"attribute_id" integer NOT NULL,
"value" integer NOT NULL,
- CONSTRAINT prefix_participant_attribut_pkey PRIMARY KEY (participant_id,attribute_id)
+ CONSTRAINT prefix_participant_attribut_pkey PRIMARY KEY (participant_id,attribute_id)
);
---
+--
-- Table structure for table participant_attribute_names
---
+--
CREATE TABLE prefix_participant_attribute_names (
"attribute_id" serial NOT NULL,
"attribute_type" character varying( 30 ) NOT NULL,
"visible" character varying( 5 ) NOT NULL,
CONSTRAINT prefix_participant_attribute_names_pkey PRIMARY KEY (attribute_id, attribute_type)
);
---
+--
-- Table structure for table participant_attribute_lang
---
+--
CREATE TABLE prefix_participant_attribute_names_lang (
"id" serial PRIMARY KEY NOT NULL,
"attribute_id" integer NOT NULL,
"attribute_name" character varying( 30 ) NOT NULL,
"lang" character varying( 20 ) NOT NULL
);
---
+--
-- Table structure for table participant_attribute_values
---
+--
CREATE TABLE prefix_participant_attribute_values (
"value_id" serial PRIMARY KEY NOT NULL,
"attribute_id" integer NOT NULL,
"value" character varying( 20 ) NOT NULL
);
---
+--
-- Table structure for table participant_shares
---
+--
CREATE TABLE prefix_participant_shares (
"participant_id" character varying( 50 ) NOT NULL,
"shared_uid" integer NOT NULL,
@@ -495,9 +490,9 @@ CREATE TABLE prefix_participant_shares (
);
---
+--
-- Table structure for table participant_attribute_values
---
+--
CREATE TABLE prefix_survey_links (
"participant_id" character varying ( 50 ) NOT NULL,
"token_id" integer NOT NULL,
@@ -507,9 +502,9 @@ CREATE TABLE prefix_survey_links (
);
---
+--
-- Table structure for table templates
---
+--
CREATE TABLE prefix_templates (
"folder" character varying(255) NOT NULL,
"creator" integer NOT NULL,
@@ -529,7 +524,7 @@ CREATE TABLE prefix_failed_login_attempts (
--
--- Secondary indexes
+-- Secondary indexes
--
create index assessments_idx2 on prefix_assessments (sid);
create index assessments_idx3 on prefix_assessments (gid);
diff --git a/tmp/sample_installer_file.txt b/tmp/sample_installer_file.txt
new file mode 100644
index 00000000000..1677ac7d7d9
--- /dev/null
+++ b/tmp/sample_installer_file.txt
@@ -0,0 +1 @@
+This is a sample file used during installation. In case LimeSurvey can't delete this file due to directory permissions, you should delete this file manually after installation is successful.
\ No newline at end of file