summaryrefslogtreecommitdiff
path: root/backend/php
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2012-02-08 23:08:46 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2012-02-08 23:08:46 (UTC)
commit17efce23d9f205f56f5ebbe8e4f4ca581ea47bcb (patch) (side-by-side diff)
tree4117988aa276fd20d624c60a37f3e05e2fa2c19b /backend/php
parent67455b069c4c9ec493f9cef76017e172a430a7d4 (diff)
parent96d01919d3ff42c3fdd7f6186a0500caccd3c140 (diff)
downloadclipperz-17efce23d9f205f56f5ebbe8e4f4ca581ea47bcb.zip
clipperz-17efce23d9f205f56f5ebbe8e4f4ca581ea47bcb.tar.gz
clipperz-17efce23d9f205f56f5ebbe8e4f4ca581ea47bcb.tar.bz2
Merge branch 'master' of github.com:gcsolaroli/password-manager into php+gamma
Diffstat (limited to 'backend/php') (more/less context) (show whitespace changes)
-rw-r--r--backend/php/src/setup/index.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/backend/php/src/setup/index.php b/backend/php/src/setup/index.php
index 4087961..93dea6f 100644
--- a/backend/php/src/setup/index.php
+++ b/backend/php/src/setup/index.php
@@ -1,359 +1,359 @@
<?php
/**
* @author Joel Wan & Mark Slemko. Designs by Jonathan Easton
* @link http://www.phpobjectgenerator.com
* @copyright Offered under the BSD license
*
* This setup file does the following:
* 1. Checks if configuration file is present
* 2. Checks if the data in the configuration file is correct
* 3. Checks if the database and table exist
* 4. Create table if not present
* 5. Tests 5 CRUD functions and determine if everything is OK for all objects within the current directory
* 6. When all tests pass, provides an interface to the database and a way to manage objects.
*/
if (!isset($_SESSION))
{
session_start();
}
if(file_exists("../configuration.php"))
{
include_once("../configuration.php");
}
include_once("setup_library/authentication.php");
include_once("setup_library/setup_misc.php");
include_once("data_initialization/read_dump_lib.php");
if(!isset($_SESSION['diagnosticsSuccessful']) || (isset($_GET['step']) && $_GET['step']=="diagnostics"))
{
$_SESSION['diagnosticsSuccessful'] = false;
}
?>
<?php include "setup_library/inc.header.php";?>
<?php
ini_set("max_execution_time", 0);
if(count($_POST) > 0 && $_SESSION['diagnosticsSuccessful']==false)
{
?>
<form action="./index.php" method="POST">
<div class="container">
<div class="left">
<div class="logo2"></div>
<div class="text"><div class="gold">POG setup diagnostics</div>
<br/>Setup performs unit tests on all your objects in the object directory and makes sure they're OK. <br/>This makes sure that your objects can talk to your database correctly. This can also be useful if you modify / customize the objects manually and want to make sure they still work once you're done.
<br/><br/>The diagnostics screen on the right shows the results of those tests. If all tests pass successfully, you can be assured that all objects are working correctly.
</div>
</div>
<div class="middle">
<div id="tabs">
<a href="./index.php?step=diagnostics"><img src="./setup_images/tab_setup.gif"/></a>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_diagnosticresults_on.gif"/>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_manageobjects.gif"/>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_manageplugins_off.gif"/>
</div><div class="subtabs">&nbsp;</div><a href="./index.php?step=diagnostics"><img src="./setup_images/setup_recheck.jpg" border="0"/></a><div class="middle2">
<?php
$errors = 0;
AddTrace('Initializing POG Setup....OK!');
if (isset($GLOBALS['configuration']['pdoDriver']))
{
$errors++;
AddError('POG setup for PHP4/5 objects cannot be run with a PDO configuration file. Regenerate configuration.php');
}
else
{
/**
* verify file structure status
*/
if(!file_exists("../objects/class.database.php"))
{
$errors++;
AddError('Database wrapper (class.database.php) is missing.');
}
else
{
include "../objects/class.database.php";
}
if(!file_exists("../objects/class.pog_base.php"))
{
$errors++;
AddError('POG Base class (class.pog_base.php) is missing.');
}
else
{
include "../objects/class.pog_base.php";
}
if (!file_exists("../configuration.php"))
{
$errors++;
AddError('Configuration file (configuration.php) is missing');
}
if ($GLOBALS['configuration']['plugins_path'] == '')
{
$errors++;
AddError('Path to plugin folder has not been specified in configuration.php');
}
else
{
if (!file_exists($GLOBALS['configuration']['plugins_path']."/plugin.base64.php"))
{
$errors++;
AddError('Base64 plugin file (plugins/plugin.base64.php) is missing');
}
else
{
include_once($GLOBALS['configuration']['plugins_path']."/plugin.base64.php");
}
}
//load object names to be ignored
$ignoreObjects = file("../objects/ignore_objects.txt");
foreach ($ignoreObjects as $key=>$ignoreObject){
$ignoreObjects[$key] = trim($ignoreObject);
}
$dir = opendir('../objects/');
$objects = array();
while(($file = readdir($dir)) !== false)
{
if(strlen($file) > 4 && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && $file != "class.database.php" && $file != "class.pog_base.php")
{
$objects[] = $file;
include_once("../objects/{$file}");
}
}
closedir($dir);
if (sizeof($objects) == 0)
{
$errors++;
AddError("[objects] folder does not contain any POG object.");
}
if ($errors == 0)
{
$dir = opendir($GLOBALS['configuration']['plugins_path']);
$plugins = array();
while(($file = readdir($dir)) !== false)
{
if(file_exists($GLOBALS['configuration']['plugins_path']."/IPlugin.php"))
{
include_once($GLOBALS['configuration']['plugins_path']."/IPlugin.php");
}
if(strlen($file) > 4 && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && strtolower(substr($file, 0, 6)) == 'plugin')
{
include_once($GLOBALS['configuration']['plugins_path']."/{$file}");
$pluginName = GetPluginName($file);
if ($pluginName != '')
{
$plugins[] = $file;
}
}
}
closedir($dir);
}
/**
* verify configuration info
*/
if ($errors == 0)
{
AddTrace('File Structure....OK!');
- if (!@mysql_connect ($GLOBALS['configuration']['host'].":".$GLOBALS['configuration']['port'], $GLOBALS['configuration']['user'], $GLOBALS['configuration']['pass']))
+ if (!mysql_connect ($GLOBALS['configuration']['host'].":".$GLOBALS['configuration']['port'], $GLOBALS['configuration']['user'], $GLOBALS['configuration']['pass']))
{
$errors++;
AddError('Cannot connect to the specified database server. Edit configuration.php');
}
if (isset($GLOBALS['configuration']['db_encoding']) && $GLOBALS['configuration']['db_encoding'] == 1 && !Base64::IsBase64FunctionInstalled())
{
$errors++;
AddError('$configuration[db_encoding] needs to be set to 0 until you install the base64 plugin. Set db_encoding to 0 by editing configuration.php, run setup again and go to the "Manage Plugins" tab. Install the base64 plugin. Then you can set db_encoding = 1');
}
if ($errors == 0)
{
if (!@mysql_select_db ($GLOBALS['configuration']['db']))
{
$errors++;
AddError('Cannot find the specified database "'.$GLOBALS['configuration']['db'].'". Edit configuration.php');
}
}
}
/**
* verify storage status
*/
if ($errors == 0)
{
AddTrace("Configuration Info....OK!\n");
AddTrace("Storage Status");
foreach($objects as $object)
{
$objectName = GetObjectName("../objects/".$object);
eval ('$instance = new '.$objectName.'();');
if (TestStorageExists($objectName, "mysql"))
{
if (isset($_POST['pog_table']) && ($_POST['pog_table'] == "recreate" || $_POST['pog_table'] == "recreate_import"))
{
if (!TestDeleteStorage($instance))
{
$errors++;
AddError("Dropping table '".strtolower($objectName)."' failed. Drop and recreate the table manually.");
}
else
{
if (!TestCreateStorage("../objects/".$object))
{
$errors++;
AddError("Creating table [".strtolower($objectName)."] failed. Create the table manually using the generated SQL query in the object header.");
}
else
{
AddTrace("\tDropping & Recreating table [".strtolower($objectName)."]....OK!");
}
}
}
else
{
if (!TestAlterStorage($instance))
{
$errors++;
AddError("Aligning [$objectName] with table '".strtolower($objectName)."' failed. Alter the table manually so that object attributes and table columns match.");
}
else
{
AddTrace("\tAligning [$objectName] with table '".strtolower($objectName)."'....OK!");
}
}
}
else
{
if (!TestCreateStorage("../objects/".$object))
{
$errors++;
AddError("Creating table [".strtolower($objectName)."] failed. Create the table manually using the generated SQL query in the object header.");
}
else
{
AddTrace("\tCreating table [".strtolower($objectName)."]....OK!");
}
}
}
}
$objectNameList = array();
/**
* Initialize test data?
*/
if (isset($_POST['pog_table']) && $_POST['pog_table'] == 'recreate_import')
{
$initialData = file_get_contents('data_initialization/data_initialization.sql');
PMA_splitSqlFile($statements, $initialData, 4);
if (sizeof($statements) > 0)
{
foreach ($statements as $statement)
{
if (!TestExecuteQuery($statement['query']))
{
$errors++;
AddError('Statement "'.$statement['query'].'" failed');
}
}
}
$structure_changes = file_get_contents('data_initialization/additional_table_structures.sql');
unset($statements);
PMA_splitSqlFile($statements, $structure_changes, 4);
if (sizeof($statements) > 0)
{
foreach ($statements as $statement)
{
if (!TestExecuteQuery($statement['query']))
{
$errors++;
AddError('Statement "'.$statement['query'].'" failed');
}
}
}
}
/**
* verify object status
*/
$objectNameList = array();
foreach($objects as $object)
{
$objectName = GetObjectName("../objects/".$object);
if (isset($objectName) && array_search($objectName, $ignoreObjects) ===false)
{
$objectNameList[] = $objectName;
}
}
if ($errors == 0)
{
$pluginNameList = array();
foreach($plugins as $plugin)
{
$pluginName = GetPluginName($plugin);
if ($pluginName != '')
{
$pluginNameList[] = $pluginName;
}
}
}
if ($errors == 0 && isset($_POST['pog_test']) && $_POST['pog_test'] == 'yes')
{
AddTrace("\nPOG Essentials");
$_SESSION['links'] = array();
$objectCount = 1;
foreach($objects as $object)
{
$objectName = GetObjectName("../objects/".$object);
if (isset($objectName) && array_search($objectName, $ignoreObjects) ===false)
{
eval('$instance = new '.$objectName.'();');
AddTrace("\t[".$objectName."]");
$link = GetAtLink("../objects/".$object);
$_SESSION['links'][$objectName] = $link;
if (!TestEssentials($instance))
{
$errors++;
AddError("Object $objectName failed essential tests");
}
if ($objectCount != sizeof($objects))
{
AddTrace("\t***");
}
}
$objectCount++;
}
}
if ($errors == 0 && isset($_POST['pog_test']) && $_POST['pog_test'] == 'yes')
{
AddTrace("\nPOG Relations PreRequisites");
$objectCount = 1;
foreach ($objects as $object)
{
$objectName = GetObjectName("../objects/".$object);
if (isset($objectName) && array_search($objectName, $ignoreObjects) ===false)
{
eval('$instance = new '.$objectName.'();');
AddTrace("\t[".$objectName."]");
if (!TestRelationsPreRequisites($instance, $objectNameList, $objectName, $ignoreObjects))