Anego CMS Setup

Tasks:

  1. Configure PHP / Server
    '; $warn = 'warning '; $bad = 'bad '; $configGood = true; $str='PHP Version 5 or higher'; if(intval(substr(phpversion(),0,1))>=5) { echo $good.$str; } else { echo $bad.$str.' - you have '.phpversion()." :("; $configGood=false; } echo '
    '; if(ini_get('short_open_tag')) echo $good; else { echo $bad; $configGood=false; } echo '(php.ini) short_open_tag on
    '; if(function_exists('mysqli_connect')) echo $good; else { echo $bad; $configGood=false; } echo '(php.ini) MySQL extension
    '; if(extension_loaded ('gd')) echo $good; else { echo $bad; $configGood=false; } echo '(php.ini) GD2 extension
    '; /*if(extension_loaded ('json')) echo $good; else { echo $bad; $configGood=false; } echo '(php.ini) JSON extension (included in php 5.2 and above)
    ';*/ if($cfg['fancyURLs']) { ?>
  2. Give write access to following folders/files:
    - no write access to some files in this folder!
    '; } else { echo $good.$f.'
    '; } } else { echo $bad.$f; echo '
    '; } $allWriteable = $allWriteable && $writeable; } ?>
  3. Configure conf.inc.php
    '; } else { if(file_exists('conf.inc.php')) $sql_link=@mysqli_connect(HOST,SQLUSER,SQLPASS); if (isset($_GET['a']) && $_GET['a'] == 'crdb') { if( @mysqli_query($sql_link, 'CREATE DATABASE IF NOT EXISTS '.$_POST['dbname'])) echo 'Database \''.$_POST['dbname'].'\' created. You have to add it to the conf.inc.php to be recognized by Setup.
    '; else echo 'Couldn\'t create database, please create it manually.Error was \''.mysqli_error($sql_link).'\'
    '; } $icon = $good; $err = ''; if (! $sql_link) { $icon = $bad; $err = ' - couldn\'t connect to database'; } else { if(!@mysqli_select_db($sql_link, SQLDB)) { $sql_link=0; $icon=$bad; $err=' - connected but couldn\'t select database (create a database with name:
    )
    '; } } echo $icon.'MySQL Info'.$err.'
    '; $err=''; if (file_exists('styles/'.STYLE.'/templates/index.tpl')) { echo $good.'Page design'; } else { echo $bad.'Page design - \'styles/'.STYLE.'/templates/index.tpl not found.\''; } echo '
    '; // Inform about domain if (!strlen($cfg['domain'])) { echo $warn; echo 'No domain supplied. Will be using ' . $cfg['default_domain'] . ''; echo '
    from server configuration. Please configure $cfg[\'domain\'] if this is incorrect. Wrong domain settings e.g. might prevent the TinyMCE from being loaded
    '; } else { if (substr($cfg['domain'], -1) != '/') { echo $warn; echo 'Domain is missing trailing slash (/), please add one to your $cfg[\'domain\']
    '; } else { echo $good.'Site Domain
    '; } } // Check if we are in the server root directory - if not, anego needs to know about this $path = dirname($_SERVER['REQUEST_URI']).'/'; if ($path == '//') $path = '/'; // dirname adds backslashes in windows O.o if(preg_match('/Windows/i', php_uname("s"))) $path = str_replace('\\','/',$path); if($path[0] != '/') { $path .= '/' . $path; } if($path == $cfg['path']) { echo $good; } else { echo $warn; $err = '
    Your Path settings might be incorrect. Try adding/adjusting the following line in conf.inc.php:
    $cfg[\'path\']=\''.$path.'\';
    '; } echo 'Anego path'.$err; echo '
    '; // Default salt if($cfg['hash_salt'] == 'Vw_0Q3Z,e;y_!xyGo+tI' || strlen($cfg['hash_salt']) < 15) { echo $warn; if(strlen($cfg['hash_salt']) < 15) { echo "Your hash salt is very short.
    "; echo '
    How about something longer like this: '. htmlspecialchars(genPwd(35)) . '
    '; } else { echo 'You are using the default hash salt. Please add following (or similar) line to your config:
    '; echo '
    $cfg[\'hash_salt\'] = \'' . htmlspecialchars(genPwd(35)) . '\';
    '; } } else { echo $good . 'Custom hash salt'; } } ?>
  4. Set up database
    Can\'t create tables, tables.sql file missing
    '; $installOK=false; } } $tablesOK=false; if($sql_link) { mysqli_query($sql_link, "show tables like '".$cfg['tablePrefix']."%'"); if(mysqli_affected_rows($sql_link)>=2) $tablesOK=true; } echo ($tablesOK?$good:$bad).' Database tables'; if($sql_link) echo ' (Create tables)'; if(!$tablesOK && $sql_link) echo ' - minimum required tables not set up'; ?>
  5. Set up a user
    refresh:
    '; echo '
    $user_accounts = Array(';
    						foreach($users as $name=>$pass) {
    							if($i++>0) echo ',';
    							echo "\n\t'".strtolower($name)."' => '".$pass."'";
    						}
    						$i=0;
    						echo "\n);\n\n";
    						echo '$user_roles = Array(';
    						foreach($userroles as $name=>$ro) {
    							if($i++>0) echo ',';
    							echo "\n\t'".strtolower($name)."' => Role::".$ro;
    						}
    						echo "\n);";
    						echo '

    ...or add another user if you need more (start over):

    '; } ?>
    '; ?> New user: , password: , role
    0) { echo $good . count($user_accounts); } else { echo $bad . '0'; } ?> Configured user(s)
  6. Delete setup.php and tables.sql
  7. All done. Enjoy setting up your freshly installed Anego CMS!
    Start by creating your first page in the menu'; } } } } ?>
[]{}|;:,.?"; while(strlen($pwd)<$len) { switch(mt_rand(0,3)) { case 0: $pwd.=chr(mt_rand(65,90)); break; case 1: $pwd.=chr(mt_rand(97,122)); break; case 2: $pwd.=chr(mt_rand(48,57)); break; case 3: $pwd.=$chars{mt_rand(0,strlen($chars)-1)}; break; } } return $pwd; } function CheckWriteableRec($f) { $dir=opendir($f); while($file=readdir($dir)) { if($file=='.' || $file=='..' || $file=='.htaccess' || $file=='.gitignore') continue; if(!is_writeable($f.'/'.$file)) return false; if(is_dir($f.'/'.$file)) if(!CheckWriteableRec($f.'/'.$file)) return false; } return true; } function createTables() { global $cfg, $sql_link; $sql = file('tables.sql'); $dir = opendir("modules"); $modulenames = array(); while ($modulename = readdir($dir)) { if ($modulename == '.' || $modulename == '..') continue; if (file_exists("modules/{$modulename}/tables.sql")) { $modulenames[] = $modulename; $sql = array_merge($sql, file("modules/{$modulename}/tables.sql")); } } $statement=''; foreach ($sql as $line) { if (preg_match("/^--/", $line)) continue; if ($cfg['tablePrefix'] != 'anego_' && preg_match('/CREATE/',$line)) { $line = str_replace('anego_',$cfg['tablePrefix'],$line); } if ($cfg['tablePrefix'] != 'anego_' && preg_match('/INSERT INTO/',$line)) { $line = str_replace('anego_',$cfg['tablePrefix'],$line); } $statement.=$line; if (preg_match("/;$/",$line)) { if (!@mysqli_query($sql_link, $statement)) { return array( "success" => false, "message" => 'Automatic creation of tables failed, please create them manually (use tables.sql file)
' . '(Error was \''.mysqli_error($sql_link).'\')
' ); break; } else $statement=''; } } return array( "success" => true, "message" => "Created tables for Anego and Modules (".implode(", ", $modulenames).")
" ); }