示例#1
0
error_reporting($config->debug->error_reporting);
ini_set('display_startup_errors', $config->phpSettings->display_startup_errors);
ini_set('display_errors', $config->phpSettings->display_errors);
ini_set('log_errors', $config->phpSettings->log_errors);
ini_set('error_log', $config->phpSettings->error_log);

//after config is loaded - do auth
require_once($include_dir . 'sys/include/include_auth.php');

include_once("sys/include/class/db.php");
include_once("sys/include/class/index.php");
$db = db::getInstance();

include_once("sys/include/sql_queries.php");

$install_tables_exists = SimpleInvoices_Db::tableExists("biller");
if ($install_tables_exists == true)
{
	$install_data_exists = SimpleInvoices_Db::dataExists();
}

//TODO - add this as a function in sql_queries.php or a class file
//if ( ($install_tables_exists != false) AND ($install_data_exists != false) )
if ( $install_tables_exists != false )
{
	if (SimpleInvoices_Db_Table_SQLPatchManager::getNumberOfDoneSQLPatches() > "196")
	{
        $SI_EXTENSIONS = new SimpleInvoices_Db_Table_Extensions();
        // ToDo: Watch out! This get's translated while the original doesn't!!!
        $extensions = $SI_EXTENSIONS->fetchAll();
        $DB_extensions = array();
<?php
$menu = false;


if (SimpleInvoices_Db::tableExists("billers") == false)
{
//	echo "SCHEME";
	//SQL import
	$import = new import();
	$import->file = $include_dir . "/sys/databases/mysql/structure.sql";
	$import->pattern_find = array('si_','DOMAIN-ID','LOCALE','LANGUAGE');
	$import->pattern_replace = array(TB_PREFIX,'1','en_GB','en_GB');
	//dbQuery($import->collate());
	$db->query($import->collate());
}

<?php

$menu = false;

if ( (SimpleInvoices_Db::tableExists("customers") == true) AND ($install_data_exists == false) )
{
//	echo "ESSENTIAL";
	//JSON import
	$importjson = new importjson();
	$importjson->file = $include_dir ."/sys/databases/json/essential_data.json";
	//$importjson->debug = true;
	$importjson->pattern_find = array('si_','DOMAIN-ID','LOCALE','LANGUAGE');
	$importjson->pattern_replace = array(TB_PREFIX,'1','en_GB','en_GB');
	//dbQuery($importjson->collate());
	$db->query($importjson->collate());
}
		}
	$patch['128']['date'] = "200709";
	
	
	$patch['129']['name'] = "Fill user table with default values";
	$patch['129']['patch'] = "INSERT INTO `".TB_PREFIX."users` (`user_id`, `user_email`, `user_name`, `user_group`, `user_domain`, `user_password`) VALUES (NULL, '*****@*****.**', 'demo', '1', '1', MD5('demo'))";
	$patch['129']['date'] = "200709";
	
	$patch['130']['name'] = "Create auth_challenges table";
	
			if(SimpleInvoices_Db::tableExists('auth_challenges') == true)
			{
				//a do nothing patch cause the table already exists
			$patch['130']['patch'] = "select * from ".TB_PREFIX."auth_challenges";
			}
			if(SimpleInvoices_Db::tableExists('auth_challenges') == false)
			{
				$patch['130']['patch'] = "CREATE TABLE IF NOT EXISTS `".TB_PREFIX."auth_challenges` (
`challenges_key` int(11) NOT NULL,
`challenges_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP);
";
			}  
	$patch['130']['date'] = "200709";
	
	$patch['131']['name'] = "Make tax field 3 decimal places";
	$patch['131']['patch'] = "ALTER TABLE `".TB_PREFIX."tax` CHANGE `tax_percentage` `tax_percentage` DECIMAL (10,3)  NULL";
	$patch['131']['date'] = "200709";

//2008 09 26 - Beta release patches start