Compare commits
1 Commits
master
...
github_luc
Author | SHA1 | Date | |
---|---|---|---|
674a9ca6b6 |
26
LICENSE
26
LICENSE
@ -1,26 +0,0 @@
|
||||
Copyright (c) <year> <owner> . All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
16
README
Normal file
16
README
Normal file
@ -0,0 +1,16 @@
|
||||
2010-04-20 Reiner Jung <reiner@kb-m.com>
|
||||
|
||||
- To provide a simpler installation, all files will go under the web
|
||||
dir, and there's no longer need to create a symlink. Have
|
||||
this in mind when upgrading, replacing the symlink you currently have
|
||||
with the files from this release.
|
||||
|
||||
- Some of the new features need new configuration directives. To
|
||||
upgrade, use the older config.php file, and only after a successful
|
||||
upgrade you can take a look at config.default.php and fill out the new
|
||||
directives into the config.php file
|
||||
|
||||
NEW REQUIREMENTS:
|
||||
|
||||
- Minimal supported PHP version is 5.2.4
|
||||
- For YubiKey support php-curl package is required
|
29
README.md
29
README.md
@ -2,32 +2,3 @@ CommunityID
|
||||
===========
|
||||
|
||||
PHP OpenID Server
|
||||
|
||||
|
||||
2010-04-20 Reiner Jung <reiner@kb-m.com>
|
||||
|
||||
- To provide a simpler installation, all files will go under the web
|
||||
dir, and there's no longer need to create a symlink. Have
|
||||
this in mind when upgrading, replacing the symlink you currently have
|
||||
with the files from this release.
|
||||
|
||||
- Some of the new features need new configuration directives. To
|
||||
upgrade, use the older config.php file, and only after a successful
|
||||
upgrade you can take a look at config.default.php and fill out the new
|
||||
directives into the config.php file
|
||||
|
||||
NEW REQUIREMENTS:
|
||||
|
||||
- Minimal supported PHP version is 5.2.4
|
||||
- For YubiKey support php-curl package is required
|
||||
|
||||
|
||||
# Description
|
||||
Community-ID is an OpenID implementation in PHP which is OpenID 2.0 compliant.
|
||||
* Community-ID is build to 100% on Open Source software and is release under the BSD license.
|
||||
* Users can keep track of their trusted sites and manage them.
|
||||
* For Community-ID administrators statistics are available to track registration of new users, authorized users per day or the number of trusted sites.
|
||||
* Administrators can set the site in maintenance mode or send emails to all registered users.
|
||||
* For user data and authentication, admin can choose the default db storage, or to connect to an LDAP server
|
||||
|
||||
source: "http://wiki.openid.net/w/page/12995226/Run%20your%20own%20identity%20server"
|
||||
|
@ -9,90 +9,80 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
{
|
||||
class Install_CredentialsController extends CommunityID_Controller_Action {
|
||||
|
||||
const PHP_MINIMAL_VERSION_REQUIRED = '5.2.4';
|
||||
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if ($errors = $this->_getErrors()) {
|
||||
return $this->_forward('index', 'permissions', null, array('errors' => $errors));
|
||||
}
|
||||
public function indexAction(){
|
||||
if( $errors = $this->_getErrors() )
|
||||
return $this->_forward( 'index' , 'permissions' , null , array( 'errors' => $errors ) );
|
||||
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->installForm)) {
|
||||
$appSession = Zend_Registry::get( 'appSession' );
|
||||
if( isset( $appSession->installForm ) ){
|
||||
$this->view->form = $appSession->installForm;
|
||||
unset($appSession->installForm);
|
||||
} else {
|
||||
unset( $appSession->installForm );
|
||||
}else{
|
||||
$this->view->form = new Install_Form_Install();
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
public function saveAction(){
|
||||
$form = new Install_Form_Install();
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
return $this->_forwardFormError($form);
|
||||
$form->populate( $formData );
|
||||
if( !$form->isValid( $formData ) )
|
||||
return $this->_forwardFormError( $form );
|
||||
|
||||
if( !$this->_connectToDbEngine( $form ) ){
|
||||
$this->_helper->FlashMessenger->addMessage( $this->view->translate( "We couldn't connect to the database using those credentials." ) );
|
||||
$this->_helper->FlashMessenger->addMessage( $this->view->translate( 'Please verify and try again.' ) );
|
||||
return $this->_forwardFormError( $form );
|
||||
}
|
||||
|
||||
if (!$this->_connectToDbEngine($form)) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('We couldn\'t connect to the database using those credentials.'));
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Please verify and try again.'));
|
||||
return $this->_forwardFormError($form);
|
||||
}
|
||||
|
||||
if (!$this->_createDbIfMissing($form)) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate(
|
||||
'The connection to the database engine worked, but the database %s doesn\'t exist or the provided user doesn\'t have access to it. An attempt was made to create it, but the provided user doesn\'t have permissions to do so either. Please create it yourself and try again.', $form->getValue('dbname')));
|
||||
return $this->_forwardFormError($form);
|
||||
if( !$this->_createDbIfMissing( $form ) ){
|
||||
$this->_helper->FlashMessenger->addMessage( $this->view->translate( "The connection to the database engine worked, but the database %s doesn\'t exist or the provided user doesn\'t have access to it. An attempt was made to create it, but the provided user doesn't have permissions to do so either. Please create it yourself and try again." , $form->getValue( 'dbname' ) ) );
|
||||
return $this->_forwardFormError( $form );
|
||||
}
|
||||
|
||||
$this->_importDb();
|
||||
$this->_createAdmin($form);
|
||||
$this->_createAdmin( $form );
|
||||
|
||||
if (!$this->_writeConfig($form)) {
|
||||
throw new Exception('Couldn\'t write to config file ' . APP_DIR . DIRECTORY_SEPARATOR . 'config.php');
|
||||
if( !$this->_writeConfig( $form ) )
|
||||
throw new Exception( 'Couldn\'t write to config file ' . APP_DIR . DIRECTORY_SEPARATOR . 'config.php' );
|
||||
|
||||
$this->_redirect( '/install/complete' );
|
||||
}
|
||||
|
||||
$this->_redirect('/install/complete');
|
||||
}
|
||||
private function _connectToDbEngine( Install_Form_Install $form ){
|
||||
$this->_config->database->params->host = $form->getValue( 'hostname' );
|
||||
$this->_config->database->params->username = $form->getValue( 'dbusername' );
|
||||
$this->_config->database->params->password = $form->getValue( 'dbpassword' );
|
||||
|
||||
private function _connectToDbEngine(Install_Form_Install $form)
|
||||
{
|
||||
$this->_config->database->params->host = $form->getValue('hostname');
|
||||
$this->_config->database->params->username = $form->getValue('dbusername');
|
||||
$this->_config->database->params->password = $form->getValue('dbpassword');
|
||||
|
||||
// setting dbname to null makes Zend_Db::getConnection() try to connect to the db engine
|
||||
// without attempting to connect to the dbname
|
||||
// setting dbname to null makes Zend_Db::getConnection() try to connect to the db engine without attempting to connect to the dbname
|
||||
$this->_config->database->params->dbname = null;
|
||||
|
||||
return Application::setDatabase();
|
||||
}
|
||||
|
||||
private function _createDbIfMissing(Install_Form_Install $form)
|
||||
{
|
||||
$this->_config->database->params->host = $form->getValue('hostname');
|
||||
$this->_config->database->params->username = $form->getValue('dbusername');
|
||||
$this->_config->database->params->password = $form->getValue('dbpassword');
|
||||
private function _createDbIfMissing( Install_Form_Install $form ){
|
||||
$this->_config->database->params->host = $form->getValue( 'hostname' );
|
||||
$this->_config->database->params->username = $form->getValue( 'dbusername' );
|
||||
$this->_config->database->params->password = $form->getValue( 'dbpassword' );
|
||||
$this->_config->database->params->dbname = $form->getValue( 'dbname' );
|
||||
|
||||
$this->_config->database->params->dbname = $form->getValue('dbname');
|
||||
|
||||
if (!Application::setDatabase()) {
|
||||
try {
|
||||
if( !Application::setDatabase() ){
|
||||
try{
|
||||
$this->_config->database->params->dbname = null;
|
||||
Application::setDatabase();
|
||||
|
||||
// binding doesn't work here for some reason
|
||||
Zend_Registry::get('db')->getConnection()->query("CREATE DATABASE `" . $form->getValue('dbname') . "`");
|
||||
$this->_config->database->params->dbname = $form->getValue('dbname');
|
||||
Zend_Registry::get( 'db' )->getConnection()->query( 'CREATE DATABASE `' . $form->getValue('dbname') . '`' );
|
||||
$this->_config->database->params->dbname = $form->getValue( 'dbname' );
|
||||
Application::setDatabase();
|
||||
} catch (PDOException $e) { // when using PDO, it throws this exception, not Zend's
|
||||
}catch( PDOException $e ){ // when using PDO, it throws this exception, not Zend's
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -100,170 +90,172 @@ class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _writeConfig(Install_Form_Install $form)
|
||||
{
|
||||
private function _writeConfig( Install_Form_Install $form ){
|
||||
$this->_config->environment->installed = true;
|
||||
$this->_config->email->supportemail = $form->getValue('supportemail');
|
||||
$this->_config->email->supportemail = $form->getValue( 'supportemail' );
|
||||
|
||||
$configTemplate = file_get_contents(APP_DIR . DIRECTORY_SEPARATOR . 'config.template.php');
|
||||
$replace = array(
|
||||
'{environment.installed}' => $this->_config->environment->installed? 'true' : 'false',
|
||||
'{environment.installed}' => ( $this->_config->environment->installed ? 'true' : 'false' ) ,
|
||||
'{environment.session_name}' => $this->_config->environment->session_name,
|
||||
'{environment.production}' => $this->_config->environment->production? 'true' : 'false',
|
||||
'{environment.YDN}' => $this->_config->environment->YDN? 'true' : 'false',
|
||||
'{environment.ajax_slowdown}' => $this->_config->environment->ajax_slowdown,
|
||||
'{environment.keep_history_days}' => $this->_config->environment->keep_history_days,
|
||||
'{environment.unconfirmed_accounts_days_expire}' => $this->_config->environment->unconfirmed_accounts_days_expire,
|
||||
'{environment.registrations_enabled}' => $this->_config->environment->registrations_enabled? 'true' : 'false',
|
||||
'{environment.locale}' => $this->_config->environment->locale,
|
||||
'{environment.template}' => $this->_config->environment->template,
|
||||
'{metadata.description}' => $this->_config->metadata->description,
|
||||
'{metadata.keywords}' => $this->_config->metadata->keywords,
|
||||
'{logging.location}' => $this->_config->logging->location,
|
||||
'{logging.level}' => $this->_config->logging->level,
|
||||
'{subdomain.enabled}' => $this->_config->subdomain->enabled? 'true' : 'false',
|
||||
'{subdomain.hostname}' => $this->_config->subdomain->hostname,
|
||||
'{subdomain.use_www}' => $this->_config->subdomain->use_www? 'true' : 'false',
|
||||
'{SSL.enable_mixed_mode}' => $this->_config->SSL->enable_mixed_mode? 'true' : 'false',
|
||||
'{database.adapter}' => $this->_config->database->adapter,
|
||||
'{database.params.host}' => $this->_config->database->params->host,
|
||||
'{database.params.dbname}' => $this->_config->database->params->dbname,
|
||||
'{database.params.username}' => $this->_config->database->params->username,
|
||||
'{database.params.password}' => $this->_config->database->params->password,
|
||||
'{environment.production}' => ( $this->_config->environment->production ? 'true' : 'false' ) ,
|
||||
'{environment.YDN}' => ( $this->_config->environment->YDN ? 'true' : 'false' ) ,
|
||||
'{environment.ajax_slowdown}' => $this->_config->environment->ajax_slowdown ,
|
||||
'{environment.keep_history_days}' => $this->_config->environment->keep_history_days ,
|
||||
'{environment.unconfirmed_accounts_days_expire}' => $this->_config->environment->unconfirmed_accounts_days_expire ,
|
||||
'{environment.registrations_enabled}' => ( $this->_config->environment->registrations_enabled ? 'true' : 'false' ) ,
|
||||
'{environment.locale}' => $this->_config->environment->locale ,
|
||||
'{environment.template}' => $this->_config->environment->template ,
|
||||
|
||||
'{metadata.description}' => $this->_config->metadata->description ,
|
||||
'{metadata.keywords}' => $this->_config->metadata->keywords ,
|
||||
|
||||
'{logging.location}' => $this->_config->logging->location ,
|
||||
'{logging.level}' => $this->_config->logging->level ,
|
||||
|
||||
'{subdomain.enabled}' => ( $this->_config->subdomain->enabled ? 'true' : 'false' ) ,
|
||||
'{subdomain.hostname}' => $this->_config->subdomain->hostname ,
|
||||
'{subdomain.use_www}' => ( $this->_config->subdomain->use_www ? 'true' : 'false' ) ,
|
||||
|
||||
'{SSL.enable_mixed_mode}' => ( $this->_config->SSL->enable_mixed_mode ? 'true' : 'false' ) ,
|
||||
|
||||
'{database.adapter}' => $this->_config->database->adapter ,
|
||||
'{database.params.host}' => $this->_config->database->params->host ,
|
||||
'{database.params.dbname}' => $this->_config->database->params->dbname ,
|
||||
'{database.params.username}' => $this->_config->database->params->username ,
|
||||
'{database.params.password}' => $this->_config->database->params->password ,
|
||||
|
||||
'{security.passwords.dictionary}' => $this->_config->security->passwords->dictionary,
|
||||
'{security.passwords.username_different}' => $this->_config->security->passwords->username_different? 'true' : 'false',
|
||||
'{security.passwords.username_different}' => ( $this->_config->security->passwords->username_different ? 'true' : 'false' ) ,
|
||||
'{security.passwords.minimum_length}' => $this->_config->security->passwords->minimum_length,
|
||||
'{security.passwords.include_numbers}'=> $this->_config->security->passwords->include_numbers? 'true' : 'false',
|
||||
'{security.passwords.include_symbols}'=> $this->_config->security->passwords->include_symbols? 'true' : 'false',
|
||||
'{security.passwords.lowercase_and_uppercase}' => $this->_config->security->passwords->lowercase_and_uppercase? 'true' : 'false',
|
||||
'{security.usernames.exclude}' => $this->_config->security->usernames->exclude->current(),
|
||||
'{ldap.enabled}' => $this->_config->ldap->enabled? 'true' : 'false',
|
||||
'{ldap.host}' => $this->_config->ldap->host,
|
||||
'{ldap.baseDn}' => $this->_config->ldap->baseDn,
|
||||
'{ldap.bindRequiresDn}' => $this->_config->ldap->bindRequiresDn? 'true' : 'false',
|
||||
'{ldap.username}' => $this->_config->ldap->username,
|
||||
'{ldap.password}' => $this->_config->ldap->password,
|
||||
'{ldap.admin}' => $this->_config->ldap->admin,
|
||||
'{ldap.keepRecordsSynced}' => $this->_config->ldap->keepRecordsSynced? 'true' : 'false',
|
||||
'{ldap.canChangePassword}' => $this->_config->ldap->canChangePassword? 'true' : 'false',
|
||||
'{ldap.passwordHashing}' => $this->_config->ldap->passwordHashing,
|
||||
'{ldap.fields.nickname}' => $this->_config->ldap->fields->nickname,
|
||||
'{ldap.fields.email}' => $this->_config->ldap->fields->email,
|
||||
'{ldap.fields.fullname}' => $this->_config->ldap->fields->fullname,
|
||||
'{ldap.fields.postcode}' => $this->_config->ldap->fields->postcode,
|
||||
'{yubikey.enabled}' => $this->_config->yubikey->enabled? 'true' : 'false',
|
||||
'{yubikey.force}' => $this->_config->yubikey->force? 'true' : 'false',
|
||||
'{yubikey.api_id}' => $this->_config->yubikey->api_id,
|
||||
'{yubikey.api_key}' => $this->_config->yubikey->api_key,
|
||||
'{email.supportemail}' => $this->_config->email->supportemail,
|
||||
'{email.adminemail}' => $this->_config->email->adminemail,
|
||||
'{email.transport}' => $this->_config->email->transport,
|
||||
'{email.host}' => $this->_config->email->host,
|
||||
'{email.auth}' => $this->_config->email->auth,
|
||||
'{email.username}' => $this->_config->email->username,
|
||||
'{email.password}' => $this->_config->email->password,
|
||||
'{security.passwords.include_numbers}' => ( $this->_config->security->passwords->include_numbers ? 'true' : 'false' ) ,
|
||||
'{security.passwords.include_symbols}' => ( $this->_config->security->passwords->include_symbols ? 'true' : 'false' ) ,
|
||||
'{security.passwords.lowercase_and_uppercase}' => ( $this->_config->security->passwords->lowercase_and_uppercase ? 'true' : 'false' ) ,
|
||||
'{security.usernames.exclude}' => $this->_config->security->usernames->exclude->current() ,
|
||||
|
||||
'{ldap.enabled}' => ( $this->_config->ldap->enabled ? 'true' : 'false' ) ,
|
||||
'{ldap.host}' => $this->_config->ldap->host ,
|
||||
'{ldap.baseDn}' => $this->_config->ldap->baseDn ,
|
||||
'{ldap.bindRequiresDn}' => ( $this->_config->ldap->bindRequiresDn ? 'true' : 'false' ) ,
|
||||
'{ldap.username}' => $this->_config->ldap->username ,
|
||||
'{ldap.password}' => $this->_config->ldap->password ,
|
||||
'{ldap.admin}' => $this->_config->ldap->admin ,
|
||||
'{ldap.keepRecordsSynced}' => ( $this->_config->ldap->keepRecordsSynced ? 'true' : 'false' ) ,
|
||||
'{ldap.canChangePassword}' => ( $this->_config->ldap->canChangePassword ? 'true' : 'false' ) ,
|
||||
'{ldap.passwordHashing}' => $this->_config->ldap->passwordHashing ,
|
||||
'{ldap.fields.nickname}' => $this->_config->ldap->fields->nickname ,
|
||||
'{ldap.fields.email}' => $this->_config->ldap->fields->email ,
|
||||
'{ldap.fields.fullname}' => $this->_config->ldap->fields->fullname ,
|
||||
'{ldap.fields.postcode}' => $this->_config->ldap->fields->postcode ,
|
||||
|
||||
'{yubikey.enabled}' => ( $this->_config->yubikey->enabled ? 'true' : 'false' ) ,
|
||||
'{yubikey.force}' => ( $this->_config->yubikey->force ? 'true' : 'false' ) ,
|
||||
'{yubikey.api_id}' => $this->_config->yubikey->api_id ,
|
||||
'{yubikey.api_key}' => $this->_config->yubikey->api_key ,
|
||||
|
||||
'{email.supportemail}' => $this->_config->email->supportemail ,
|
||||
'{email.adminemail}' => $this->_config->email->adminemail ,
|
||||
'{email.transport}' => $this->_config->email->transport ,
|
||||
'{email.host}' => $this->_config->email->host ,
|
||||
'{email.auth}' => $this->_config->email->auth ,
|
||||
'{email.username}' => $this->_config->email->username ,
|
||||
'{email.password}' => $this->_config->email->password ,
|
||||
);
|
||||
$configTemplate = str_replace(array_keys($replace), array_values($replace), $configTemplate);
|
||||
|
||||
return @file_put_contents(APP_DIR . DIRECTORY_SEPARATOR . 'config.php', $configTemplate);
|
||||
$configTemplate = file_get_contents( APP_DIR.DIRECTORY_SEPARATOR.'config.template.php' );
|
||||
|
||||
$configTemplate = str_replace( array_keys( $replace ) , array_values( $replace ), $configTemplate );
|
||||
|
||||
return @file_put_contents( APP_DIR.DIRECTORY_SEPARATOR.'config.php' , $configTemplate );
|
||||
}
|
||||
|
||||
private function _importDb()
|
||||
{
|
||||
$this->_runSqlFILE('final.sql');
|
||||
private function _importDb(){
|
||||
$this->_runSqlFILE( 'final.sql' );
|
||||
}
|
||||
|
||||
private function _createAdmin(Install_Form_Install $form)
|
||||
{
|
||||
private function _createAdmin( Install_Form_Install $form ){
|
||||
$users = new Users_Model_Users();
|
||||
$user = $users->createRow();
|
||||
$user->username = $form->getValue('username');
|
||||
$user->username = $form->getValue( 'username' );
|
||||
$user->accepted_eula = 1;
|
||||
$user->registration_date = date('Y-m-d');
|
||||
$user->registration_date = date( 'Y-m-d' );
|
||||
$user->openid = '';
|
||||
$user->setClearPassword($form->getValue('password1'));
|
||||
$user->setClearPassword( $form->getValue( 'password1' ) );
|
||||
$user->firstname = 'Admin';
|
||||
$user->lastname = 'User';
|
||||
$user->email = $form->getValue('supportemail');
|
||||
$user->email = $form->getValue( 'supportemail' );
|
||||
$user->role = Users_Model_User::ROLE_ADMIN;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
function _runSqlFile($fileName) {
|
||||
$fp = fopen(APP_DIR . DIRECTORY_SEPARATOR . "/setup/$fileName", 'r');
|
||||
function _runSqlFile( $fileName ){
|
||||
$fp = fopen( APP_DIR.DIRECTORY_SEPARATOR.'/setup/'.$fileName , 'r' );
|
||||
$query = '';
|
||||
$db = Zend_Registry::get('db');
|
||||
while (!feof($fp)) {
|
||||
$line = trim(fgets($fp));
|
||||
|
||||
$db = Zend_Registry::get( 'db' );
|
||||
while( !feof( $fp ) ){
|
||||
$line = trim( fgets( $fp ) );
|
||||
// skip SQL comments
|
||||
if (substr($line, 0, 2) == '--') {
|
||||
if (substr($line, 0, 2) == '--' )
|
||||
continue;
|
||||
}
|
||||
|
||||
$query .= $line;
|
||||
if ((substr($line, -1, 1) == ';' || feof($fp)) && $query != '') {
|
||||
// I had to resort to a direct call because regexes inside the Zend Framework are segfaulting with the long queries in sampleData.sql
|
||||
//$this->db->query($query);
|
||||
$db->getConnection()->query($query);
|
||||
|
||||
if( ( substr( $line , -1 , 1 )==';' || feof( $fp ) ) && $query!='' ){
|
||||
// I had to resort to a direct call because regexes inside the Zend Framework are segfaulting with the long queries in sampleData.sql $this->db->query($query);
|
||||
$db->getConnection()->query( $query );
|
||||
$query = '';
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
fclose( $fp );
|
||||
}
|
||||
|
||||
private function _forwardFormError(Install_Form_Install $form)
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
private function _forwardFormError( Install_Form_Install $form ){
|
||||
$appSession = Zend_Registry::get( 'appSession' );
|
||||
$appSession->installForm = $form;
|
||||
$this->_redirect('/install/credentials');
|
||||
$this->_redirect( '/install/credentials' );
|
||||
return;
|
||||
}
|
||||
|
||||
private function _getErrors()
|
||||
{
|
||||
private function _getErrors(){
|
||||
$errors = array();
|
||||
$webServerUser = $this->_getProcessUser();
|
||||
|
||||
if (version_compare(PHP_VERSION, self::PHP_MINIMAL_VERSION_REQUIRED, '<')) {
|
||||
$errors[] = $this->view->translate('PHP version %s or greater is required',
|
||||
self::PHP_MINIMAL_VERSION_REQUIRED);
|
||||
if( version_compare( PHP_VERSION , self::PHP_MINIMAL_VERSION_REQUIRED , '<' ) )
|
||||
$errors[] = $this->view->translate( 'PHP version %s or greater is required' , self::PHP_MINIMAL_VERSION_REQUIRED );
|
||||
|
||||
if( ( file_exists( APP_DIR.DIRECTORY_SEPARATOR.'config.php' ) && !is_writable( APP_DIR.DIRECTORY_SEPARATOR.'config.php' ) )
|
||||
|| !@touch( APP_DIR.DIRECTORY_SEPARATOR.'config.php' ) )
|
||||
$errors[] = $this->view->translate('The directory where Community-ID is installed must be writable by the web server user (%s). Another option is to create an EMPTY config.php file that is writable by that user.' , $webServerUser );
|
||||
if( !( is_dir( WEB_DIR.'/captchas' ) && is_writable( WEB_DIR.'/captchas' ) ) ){
|
||||
if( !is_dir( WEB_DIR.'/captchas' ) )
|
||||
mkdir( WEB_DIR.'/captchas' );
|
||||
if( !is_writable( WEB_DIR.'/captchas' ) ){
|
||||
chmod( WEB_DIR.'/captchas' , 0777 );
|
||||
chown( WEB_DIR.'/captchas' , $webServerUser );
|
||||
}
|
||||
if (!is_writable(APP_DIR) && !is_writable(APP_DIR . DIRECTORY_SEPARATOR . 'config.php')) {
|
||||
$errors[] = $this->view->translate('The directory where Community-ID is installed must be writable by the web server user (%s). Another option is to create an EMPTY config.php file that is writable by that user.', $webServerUser);
|
||||
}
|
||||
if (!is_writable(WEB_DIR . '/captchas')) {
|
||||
$errors[] = $this->view->translate('The directory "captchas" under the web directory for Community-ID must be writable by the web server user (%s)', $webServerUser);
|
||||
}
|
||||
if (!extension_loaded('mysqli')) {
|
||||
$errors[] = $this->view->translate('You need to have the %s extension installed', '<a href="http://www.php.net/manual/en/mysqli.installation.php">MySQLi</a>');
|
||||
}
|
||||
if (!extension_loaded('gd')) {
|
||||
$errors[] = $this->view->translate('You need to have the %s extension installed', '<a href="http://www.php.net/manual/en/image.installation.php">GD</a>');
|
||||
}
|
||||
if (!function_exists('imagepng')) {
|
||||
$errors[] = $this->view->translate('You need to have <a href="http://www.php.net/manual/en/image.installation.php">PNG support in your GD configuration</a>');
|
||||
}
|
||||
if (!function_exists('imageftbbox')) {
|
||||
$errors[] = $this->view->translate('You need to have <a href="http://www.php.net/manual/en/image.installation.php">Freetype support in your GD configuration</a>');
|
||||
}
|
||||
if (!function_exists('curl_init')) {
|
||||
$errors[] = $this->view->translate('You need to have the %s extension installed', '<a href="http://co.php.net/manual/en/curl.setup.php">cURL</a>');
|
||||
if( !( is_dir( WEB_DIR.'/captchas' ) && is_writable( WEB_DIR.'/captchas' ) ) )
|
||||
$errors[] = $this->view->translate('The directory "captchas" under the web directory for Community-ID must be writable by the web server user (%s)' , $webServerUser );
|
||||
}
|
||||
|
||||
if( !extension_loaded( 'mysqli' ) )
|
||||
$errors[] = $this->view->translate( 'You need to have the %s extension installed', '<a href="http://www.php.net/manual/en/mysqli.installation.php">MySQLi</a>' );
|
||||
if( !extension_loaded( 'gd' ) )
|
||||
$errors[] = $this->view->translate( 'You need to have the %s extension installed', '<a href="http://www.php.net/manual/en/image.installation.php">GD</a>' );
|
||||
if( !function_exists( 'imagepng' ) )
|
||||
$errors[] = $this->view->translate( 'You need to have <a href="http://www.php.net/manual/en/image.installation.php">PNG support in your GD configuration</a>' );
|
||||
if( !function_exists( 'imageftbbox' ) )
|
||||
$errors[] = $this->view->translate( 'You need to have <a href="http://www.php.net/manual/en/image.installation.php">Freetype support in your GD configuration</a>' );
|
||||
if( !function_exists( 'curl_init' ) )
|
||||
$errors[] = $this->view->translate('You need to have the %s extension installed', '<a href="http://co.php.net/manual/en/curl.setup.php">cURL</a>' );
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
private function _getProcessUser()
|
||||
{
|
||||
if (!function_exists('posix_getpwuid')) {
|
||||
// we're on windows
|
||||
return getenv('USERNAME');
|
||||
}
|
||||
private function _getProcessUser(){
|
||||
if( !function_exists( 'posix_getpwuid' ) ) // we're on windows
|
||||
return getenv( 'USERNAME' );
|
||||
|
||||
$processUser = posix_getpwuid(posix_geteuid());
|
||||
$processUser = posix_getpwuid( posix_geteuid() );
|
||||
|
||||
return $processUser['name'];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user