function _sess_write($key, $val) { global $db; if (!is_object($db)) { //PHP 5.2.0 bug workaround ... if (!class_exists('queryFactory')) { require 'includes/classes/db/' . DB_TYPE . '/query_factory.php'; } $db = new queryFactory(); $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false); } $val = base64_encode($val); global $SESS_LIFE; $expiry = time() + $SESS_LIFE; $qid = "select count(*) as total\r\n from " . TABLE_SESSIONS . "\r\n where sesskey = '" . zen_db_input($key) . "'"; $total = $db->Execute($qid); if ($total->fields['total'] > 0) { $sql = "update " . TABLE_SESSIONS . "\r\n set expiry = '" . zen_db_input($expiry) . "', value = '" . zen_db_input($val) . "'\r\n where sesskey = '" . zen_db_input($key) . "'"; $result = $db->Execute($sql); } else { $sql = "insert into " . TABLE_SESSIONS . "\r\n values ('" . zen_db_input($key) . "', '" . zen_db_input($expiry) . "', '" . zen_db_input($val) . "')"; $result = $db->Execute($sql); } return !empty($result) && !empty($result->resource); }
public function __construct($options = array()) { parent::__construct(); $this->useSelfDb = false; global $db; if (!is_object($db)) { //PHP 5.2.0 bug workaround。这是ZenCart原来的注释,Jianhui迁移Session的时候,迁移过来的。 $db = new queryFactory(); $db->connect($options['host'], $options['username'], $options['password'], $options['database'], $options['use_pconnect'], false); $this->useSelfDb = true; } $this->db = $db; }
public function ShowProductDetail($productID) { $db = new queryFactory(); $this->Products = array(); $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE); $products_all_query_raw = "SELECT\n p.products_type,\n p.products_id,\n pd.products_name,\n p.products_image,\n p.products_price,\n p.products_tax_class_id,\n p.products_date_added,\n m.manufacturers_name,\n p.products_model,\n p.products_quantity,\n p.products_weight,\n p.product_is_call,\n p.product_is_always_free_shipping,\n p.products_qty_box_status,\n p.master_categories_id,\n pd.products_description\n FROM " . TABLE_PRODUCTS . " p\n LEFT JOIN " . TABLE_MANUFACTURERS . " m\n ON (p.manufacturers_id = m.manufacturers_id),\n " . TABLE_PRODUCTS_DESCRIPTION . " pd\n WHERE p.products_status = 1\n AND p.products_id = pd.products_id\n AND pd.language_id = 1\n AND p.products_id = " . $productID . "\n Order By p.products_date_added desc\n LIMIT 10"; $products_all_results = $db->Execute($products_all_query_raw, '', false, 0); $track = 0; while (!$products_all_results->EOF) { $this->Products[$track] = array('id' => $products_all_results->fields['products_id'], 'name' => $products_all_results->fields['products_name'], 'price' => $products_all_results->fields['products_price'], 'image' => $products_all_results->fields['products_image'], 'dateadded' => $products_all_results->fields['products_date_added'], 'desctiption' => $products_all_results->fields['products_description'], 'model' => $products_all_results->fields['products_model']); $track++; $products_all_results->MoveNext(); } }
function _sess_write($key, $val) { global $SESS_LIFE, $db; if (!is_object($db)) { //PHP 5.2.0 bug workaround ... $db = new queryFactory(); $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false); } $expiry = time() + $SESS_LIFE; $value = $val; $total = $db->Execute("select count(*) as total\r\n from " . TABLE_SESSIONS . "\r\n where sesskey = '" . zen_db_input($key) . "'"); if ($total->fields['total'] > 0) { return $db->Execute("update " . TABLE_SESSIONS . "\r\n set expiry = '" . zen_db_input($expiry) . "',\r\n value = '" . zen_db_input($value) . "'\r\n where sesskey = '" . zen_db_input($key) . "'"); } else { return $db->Execute("insert into " . TABLE_SESSIONS . "\r\n values ('" . zen_db_input($key) . "', '" . zen_db_input($expiry) . "',\r\n '" . zen_db_input($value) . "')"); } }
function UI_Router($id) { //go to db and get UI name //return ui name global $db5; //, $cPath, $cPath_array; $this->returnContent = ""; //will either be a path or definition; $db5 = new queryFactory(); $db5->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE); $interface_qry = "select * from EZ_UserInterface where\n Interfaceid = {$id}"; $ui = $db5->Execute($interface_qry, '', false, 0); while (!$ui->EOF) { if ($ui->fields["InterfaceUseDef"] == 1) { $this->returnContent .= $ui->fields["InterfaceDefinition"]; } else { $this->returnContent .= $ui->fields["InterfacePath"]; } $ui->MoveNext(); } }
/** * @package admin * @copyright Copyright 2003-2013 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version GIT: $Id: Author: DrByte Mon Oct 28 23:52:35 2013 -0400 Modified in v1.5.2 $ */ if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } // include the cache class require DIR_FS_CATALOG . DIR_WS_CLASSES . 'cache.php'; $zc_cache = new cache(); // Load queryFactory db classes require DIR_FS_CATALOG . DIR_WS_CLASSES . 'db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE); // Do a quick sanity check that system tables exist if (defined('SQL_CACHE_METHOD') && SQL_CACHE_METHOD == 'database') { $sql = "SHOW TABLES LIKE '" . TABLE_DB_CACHE . "'"; } else { $sql = "SHOW TABLES LIKE '" . TABLE_PROJECT_VERSION . "'"; } $db->dieOnErrors = FALSE; $result = $db->Execute($sql, FALSE, FALSE); if ($result->RecordCount() == 0) { if (defined('ERROR_DATABASE_MAINTENANCE_NEEDED')) { die(ERROR_DATABASE_MAINTENANCE_NEEDED); } die('<a href="http://www.zen-cart.com/content.php?334-ERROR-0071-There-appears-to-be-a-problem-with-the-database-Maintenance-is-required" target="_blank">ERROR 0071: There appears to be a problem with the database. Maintenance is required.</a>'); }
function createDBObject() { global $db; if (!is_object($db)) { $db = new queryFactory(); $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false); } return $db; }
if ($is_upgrade && !$zc_install->fatal_error) { //if upgrading, move onto the upgrade page //update the cache folder setting: $db = new queryFactory(); $db->Connect($_POST['db_host'], $_POST['db_username'], $_POST['db_pass'], $_POST['db_name'], true); $sql = "update " . $_POST['db_prefix'] . "configuration set configuration_value='" . $_POST['sql_cache_dir'] . "' where configuration_key='SESSION_WRITE_DIRECTORY'"; $db->Execute($sql); //update the phpbb setting: $sql = "update " . $_POST['db_prefix'] . "configuration set configuration_value='" . $_GET['use_phpbb'] . "' where configuration_key='PHPBB_LINKS_ENABLED'"; $db->Execute($sql); header('location: index.php?main_page=database_upgrade&language=' . $language); exit; } elseif (!$zc_install->fatal_error) { // not upgrading - load the fresh database //OK, files written -- now let's connect to the database and load the tables: $db = new queryFactory(); $db->Connect($_POST['db_host'], $_POST['db_username'], $_POST['db_pass'], $_POST['db_name'], true); if ($zc_show_progress == 'yes') { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Zen Cart™ Installer</title> <link rel="stylesheet" type="text/css" href="includes/templates/template_default/css/stylesheet.css"> </head> <div id="wrap"> <div id="header"> <img src="includes/templates/template_default/images/zen_header_bg.jpg"> </div> <div class="progress" align="center">Installation In Progress...<br /><br />
// end while //check for errors $zc_install->test_store_configure(ERROR_TEXT_STORE_CONFIGURE, ERROR_CODE_STORE_CONFIGURE); if (!$zc_install->fatal_error && isset($_POST['adminid']) && isset($_POST['adminpwd'])) { $zc_install->fileExists('sql/' . DB_TYPE . $sniffer_file, DB_TYPE . $sniffer_file . ' ' . ERROR_TEXT_DB_SQL_NOTEXIST, ERROR_CODE_DB_SQL_NOTEXIST); $zc_install->functionExists(DB_TYPE, ERROR_TEXT_DB_NOTSUPPORTED, ERROR_CODE_DB_NOTSUPPORTED); $zc_install->dbConnect(DB_TYPE, DB_SERVER, DB_DATABASE, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, ERROR_TEXT_DB_CONNECTION_FAILED, ERROR_CODE_DB_CONNECTION_FAILED, ERROR_TEXT_DB_NOTEXIST, ERROR_CODE_DB_NOTEXIST); $zc_install->verifyAdminCredentials($_POST['adminid'], $_POST['adminpwd']); } //end if !fatal_error if (ZC_UPG_DEBUG2 == true) { echo 'Processing [' . $sniffer_file . ']...<br />'; } if ($zc_install->error == false && $nothing_to_process == false) { //open database connection to run queries against it $db = new queryFactory(); $db->Connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE) or die("Unable to connect to database"); // load the upgrade.sql file(s) relative to the required step(s) $query_results = executeSql('sql/' . DB_TYPE . $sniffer_file, DB_DATABASE, DB_PREFIX); if ($query_results['queries'] > 0 && $query_results['queries'] != $query_results['ignored']) { $messageStack->add('upgrade', $query_results['queries'] . '条指令成功执行。', 'success'); } else { $messageStack->add('upgrade', '失败: ' . $query_results['queries'], 'error'); } if (zen_not_null($query_results['errors'])) { foreach ($query_results['errors'] as $value) { $messageStack->add('upgrade-error-details', '忽略: ' . $value, 'error'); } } if ($query_results['ignored'] != 0) { $messageStack->add('upgrade', '说明: ' . $query_results['ignored'] . '条指令未执行。详情查看 "upgrade_exceptions" 数据表。', 'caution');
// include the list of extra database tables and filenames // include(DIR_WS_MODULES . 'extra_datafiles.php'); if ($za_dir = @dir(DIR_WS_INCLUDES . 'extra_datafiles')) { while ($zv_file = $za_dir->read()) { if (strstr($zv_file, '.php')) { require DIR_WS_INCLUDES . 'extra_datafiles/' . $zv_file; } } } // include the cache class require DIR_FS_CATALOG . DIR_WS_CLASSES . 'cache.php'; $zc_cache = new cache(); // Load db classes // Load queryFactory db classes require DIR_FS_CATALOG . DIR_WS_CLASSES . 'db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE); $zc_cache->sql_cache_flush_cache(); // Define the project version (must come after db class is loaded) require DIR_FS_CATALOG . DIR_WS_INCLUDES . 'version.php'; // Determine the DATABASE patch level $project_db_info = $db->Execute('select * from ' . TABLE_PROJECT_VERSION . ' WHERE project_version_key = "Zen-Cart Database" '); define('PROJECT_DB_VERSION_MAJOR', $project_db_info->fields['project_version_major']); define('PROJECT_DB_VERSION_MINOR', $project_db_info->fields['project_version_minor']); define('PROJECT_DB_VERSION_PATCH1', $project_db_info->fields['project_version_patch1']); define('PROJECT_DB_VERSION_PATCH2', $project_db_info->fields['project_version_patch2']); define('PROJECT_DB_VERSION_PATCH1_SOURCE', $project_db_info->fields['project_version_patch1_source']); define('PROJECT_DB_VERSION_PATCH2_SOURCE', $project_db_info->fields['project_version_patch2_source']); // set application wide parameters $configuration = $db->Execute('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
@ini_set("arg_separator.output", "&"); // Set the local configuration parameters - mainly for developers if (file_exists('includes/local/configure.php')) { include 'includes/local/configure.php'; } // include server parameters if (file_exists('includes/configure.php')) { include 'includes/configure.php'; } require 'includes/classes/class.base.php'; require 'includes/classes/class.notifier.php'; require 'includes/classes/class.phpmailer.php'; require 'includes/classes/class.smtp.php'; $zco_notifier = new notifier(); require 'includes/classes/db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); if (!$db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false)) { die('Cannot connect to database. Please notify webmaster.'); exit; } // set the type of request (secure or not) $request_type = strtolower($_SERVER['HTTPS']) == 'on' || $_SERVER['HTTPS'] == '1' || strstr(strtoupper($_SERVER['HTTP_X_FORWARDED_BY']), 'SSL') || strstr(strtoupper($_SERVER['HTTP_X_FORWARDED_HOST']), 'SSL') ? 'SSL' : 'NONSSL'; // set php_self in the local scope if (!isset($PHP_SELF)) { $PHP_SELF = $_SERVER['PHP_SELF']; } // include the list of project filenames require DIR_WS_INCLUDES . 'filenames.php'; // include the list of project database tables require DIR_WS_INCLUDES . 'database_tables.php'; // include the list of compatibility issues
define('DB_DATABASE', $db_name); require DIR_FS_MY_FILES . $db_name . '/config.php'; define('DB_SERVER_HOST', DB_SERVER); // for old PhreeBooks installs } else { die("No database name passed! Cannot determine which company to connect to!"); } // set the language $_SESSION['language'] = $_GET['lang'] ? $_GET['lang'] : 'en_us'; define('LANGUAGE', $_SESSION['language']); gen_pull_language('phreedom'); require_once DIR_FS_ADMIN . 'soap/language/' . LANGUAGE . '/language.php'; // include the database functions // Load queryFactory db classes require_once DIR_FS_ADMIN . 'includes/db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); if (!$db->connect(DB_SERVER_HOST, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE)) { die('cannot connec to db!'); } // set application wide parameters for phreebooks module $configuration = $db->Execute("select configuration_key, configuration_value from " . DB_PREFIX . "configuration"); while (!$configuration->EOF) { define($configuration->fields['configuration_key'], $configuration->fields['configuration_value']); $configuration->MoveNext(); } // load general language translation gen_pull_language('phreedom', 'menu'); require_once DIR_FS_MODULES . 'phreedom/config.php'; $dirs = scandir(DIR_FS_MODULES); foreach ($dirs as $dir) { // first pull all module language files, loaded or not
$db->Connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE) or die("Unable to connect to database"); $result = $db->Execute($sql); $db->Close(); if (!($admin_name == $result->fields['admin_name']) || $admin_name == 'demo') { $zc_install->setError(ERROR_TEXT_ADMIN_PWD_REQUIRED, ERROR_CODE_ADMIN_PWD_REQUIRED, true); } if (!zen_validate_password($admin_pass, $result->fields['admin_pass'])) { $zc_install->setError(ERROR_TEXT_ADMIN_PWD_REQUIRED, ERROR_CODE_ADMIN_PWD_REQUIRED, true); } } // end admin verification if (ZC_UPG_DEBUG2 == true) { echo 'Processing prefix updates...<br />'; } if ($zc_install->error == false && $nothing_to_process == false) { $db = new queryFactory(); $db->Connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE) or die("Unable to connect to database"); $tables = $db->Execute("SHOW TABLES"); // get a list of tables to compare against $tables_list = array(); while (!$tables->EOF) { $tables_list[] = $tables->fields['Tables_in_' . DB_DATABASE]; $tables->MoveNext(); } //end while //read the "database_tables.php" files, and loop through the table names foreach ($database_tablenames_array as $filename) { if (!file_exists($filename)) { continue; } $lines = file($filename);
function table_exists_phpbb($table_name) { global $db; // Check to see if the requested PHPBB table exists, regardless of which database it's set to use $sql = "SHOW TABLES like '" . $table_name . "'"; $db_phpbb = new queryFactory(); $db_phpbb->connect($this->phpBB['dbhost'], $this->phpBB['dbuser'], $this->phpBB['dbpasswd'], $this->phpBB['dbname'], USE_PCONNECT, false); $tables = $db_phpbb->Execute($sql); //echo 'tables_found = '. $tables->RecordCount() .'<br>'; if ($tables->RecordCount() > 0) { $found_table = true; } $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false); return $found_table; }
function zen_sd_menu_tree() { global $db, $cPath, $cPath_array; $db2 = new queryFactory(); $db2->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE); $new_path = ''; $this->tree = array(); $treeids = array(); $count = 0; /** $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = 0 and c.categories_id = cd.categories_id and cd.language_id='" . (int)$_SESSION['languages_id'] . "' and c.categories_status= 1 order by sort_order, cd.categories_name"; **/ $categories_query = "select \r\n \t\t\t\t\t\t\tc.categories_id, \r\n \t\t\t\t\t\t\tcd.categories_name, \r\n \t\t\t\t\t\t\tc.parent_id, \r\n \t\t\t\t\t\t\tc.categories_image\r\n from \r\n \t\t" . TABLE_CATEGORIES . " c, \r\n \t\t" . TABLE_CATEGORIES_DESCRIPTION . " cd\r\n where\r\n \r\n \t c.categories_id = cd.categories_id\r\n \t and cd.language_id='" . (int) $_SESSION['languages_id'] . "'\r\n \t and c.categories_status= 1\r\n \t order by sort_order, cd.categories_name"; $categories = $db->Execute($categories_query, '', false, 0); while (!$categories->EOF) { $treeids[$count] = $categories->fields['categories_id']; $count++; $last_sub_item; $this->tree[$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'parent' => $categories->fields['parent_id'], 'level' => 0, 'path' => $categories->fields['categories_id'], 'image' => $categories->fields['categories_image'], 'next_id' => false, 'mainID' => $categories->fields['categories_id']); //just assume it has no subcategories for now; $this->tree[$categories->fields['categories_id']]['has_sub_cat'] = false; if (isset($parent_id)) { // if(!$this->tree[$parent_id]['has_sub_cat']) // { $this->tree[$parent_id]['next_id'] = $categories->fields['categories_id']; // } // else // { //the next id for the parent has already been set // $this->tree[$sublast_id]['next_id'] = $categories->fields['categories_id']; //unset($subparent_id); // unset($sublast_id); //} //}else // $this->tree[$parent_id]['next_id'] = $categories->fields['categories_id']; } $parent_id = $categories->fields['categories_id']; if (!isset($first_element)) { $first_element = $categories->fields['categories_id']; } /** $current_id = $categories->fields['categories_id']; $subcategories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = " . $current_id . " and c.categories_id = cd.categories_id and cd.language_id=" . (int)$_SESSION['languages_id'] . " and c.categories_status= 1 order by c.parent_id, cd.categories_name"; $subcategories = $db2->Execute($subcategories_query, '', false, 0); if ($subcategories->RecordCount()>0) { $new_path .= $parent_id; //set this property to true so that the app works properly // $this->tree[$parent_id]['has_sub_cat'] = true; while(!$subcategories->EOF) { $this->tree[$subcategories->fields['categories_id']] = array('name' => $subcategories->fields['categories_name'] , 'parent' => $subcategories->fields['parent_id'], 'level' => 1, 'path' => $new_path . '_' . $subcategories->fields['categories_id'], 'image' => $subcategories->fields['categories_image'], 'next_id' => false, 'mainID' => $subcategories->fields['categories_id']); if (isset($subparent_id)) { $this->tree[$subparent_id]['next_id'] = $subcategories->fields['categories_id']; } $subparent_id = $subcategories->fields['categories_id']; if (!isset($subfirst_id)) { $subfirst_id = $subcategories->fields['categories_id']; } $sublast_id = $subcategories->fields['categories_id']; $subcategories->MoveNext(); } //unset($subparent_id); //$this->tree[$sublast_id]['next_id'] = $parent_id; $this->tree[$current_id]['next_id'] = $subfirst_id; unset($subfirst_id); $new_path .= '_'; } **/ $categories->MoveNext(); } /** for($x = 0; $x < sizeof($treeids); $x++) { $subcategories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = " . $treeids[$x] . " and c.categories_id = cd.categories_id and cd.language_id=" . (int)$_SESSION['languages_id'] . " and c.categories_status= 1 order by c.parent_id, cd.categories_name"; $subcategories = $db->Execute($subcategories_query, '', false, 15000); if ($subcategories->RecordCount()>0) { $new_path .= $treeids[$x]; $this->tree[$treeids[$x]]['has_sub_cat'] = true; while(!$subcategories->EOF) { $this->tree[$subcategories->fields['categories_id']] = array('name' => $subcategories->fields['categories_name'] , 'parent' => $subcategories->fields['parent_id'], 'level' => 1, 'path' => $new_path . '_' . $subcategories->fields['categories_id'], 'image' => $subcategories->fields['categories_image'], 'next_id' => false, 'mainID' => $treeids[$x]); if (isset($subparent_id) && $subparent_id != $subcategories->fields['categories_id']) { $this->tree[$subparent_id]['next_id'] = $subcategories->fields['categories_id']; } $subparent_id = $subcategories->fields['categories_id']; if (!isset($subfirst_id)) { $subfirst_id = $subcategories->fields['categories_id']; } $sublast_id = $subcategories->fields['categories_id']; $subcategories->MoveNext(); } $this->tree[$sublast_id]['next_id'] = $this->tree[$treeids[$x]]['next_id']; $this->tree[$treeids[$x]]['next_id'] = $subfirst_id; $new_path .= '_'; } } **/ return $this->zen_show_all_categories($first_element, 0); //return $this->zen_category_tree(); }
<?php require 'config.php'; require 'language/' . DEFAULT_LANGUAGE . '/language.php'; require 'includes/functions.php'; require 'includes/db/' . DB_TYPE . '/query_factory.php'; $context_ref = isset($_GET['idx']) ? $_GET['idx'] : ''; // Load db class $db = new queryFactory(); if (!$db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE)) { echo $db->show_error() . '<br />'; die(NO_CONNECT_DB); } $current = check_version(); // make sure db is current with latest information files $result = false; if ($context_ref) { $result = $db->Execute("select doc_url from " . DB_PREFIX . "zh_search where doc_pos = '" . $context_ref . "'"); } $start_page = !$result ? DOC_ROOT_URL . '/' . DOC_HOME_PAGE : $result->fields['doc_url']; //$start_page = DOC_ROOT_URL . '/' . DOC_HOME_PAGE; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title><?php echo HEADING_TITLE; ?> </title> <link rel="stylesheet" href="css/phreehelp.css">
} elseif ($password_new != $password_confirmation) { $error = true; $messageStack->add('account_password', ENTRY_PASSWORD_NEW_ERROR_NOT_MATCHING); } if ($error == false) { $check_customer_query = "select customers_password, customers_nick\r\n from " . TABLE_CUSTOMERS . "\r\n where customers_id = '" . (int) $_SESSION['customer_id'] . "'"; $check_customer = $db->Execute($check_customer_query); if (zen_validate_password($password_current, $check_customer->fields['customers_password'])) { $nickname = $check_customer->fields['customers_nick']; $db->Execute("update " . TABLE_CUSTOMERS . " set customers_password = '******' where customers_id = '" . (int) $_SESSION['customer_id'] . "'"); $sql = "update " . TABLE_CUSTOMERS_INFO . "\r\n set customers_info_date_account_last_modified = now()\r\n where customers_info_id = '" . (int) $_SESSION['customer_id'] . "'"; $db->Execute($sql); if ($sniffer->phpBB['installed'] == true) { if (zen_not_null($nickname) && $nickname != '') { // require($sniffer->phpBB['phpbb_path'] . 'config.php'); $db_phpbb = new queryFactory(); $db_phpbb->connect($sniffer->phpBB['dbhost'], $sniffer->phpBB['dbuser'], $sniffer->phpBB['dbpasswd'], $sniffer->phpBB['dbname'], USE_PCONNECT, false); $sql = "update " . $sniffer->phpBB['users_table'] . " set user_password='******'\r\n where username = '******'"; $phpbb_users = $db_phpbb->Execute($sql); $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false); } } $messageStack->add_session('account', SUCCESS_PASSWORD_UPDATED, 'success'); zen_redirect(zen_href_link(FILENAME_ACCOUNT, '', 'SSL')); } else { $error = true; $messageStack->add('account_password', ERROR_CURRENT_PASSWORD_NOT_MATCHING); } } } $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL'));
$admin_email = zen_db_prepare_input($_POST['admin_email']); $admin_pass = zen_db_prepare_input($_POST['admin_pass']); $admin_pass_confirm = zen_db_prepare_input($_POST['admin_pass_confirm']); if (isset($_POST['check_for_updates']) && $_POST['check_for_updates'] == '1') { $check_for_updates = 1; } else { $check_for_updates = 0; } $zc_install->isEmpty($admin_username, ERROR_TEXT_ADMIN_USERNAME_ISEMPTY, ERROR_CODE_ADMIN_USERNAME_ISEMPTY); $zc_install->isEmpty($admin_email, ERROR_TEXT_ADMIN_EMAIL_ISEMPTY, ERROR_CODE_ADMIN_EMAIL_ISEMPTY); $zc_install->isEmail($admin_email, ERROR_TEXT_ADMIN_EMAIL_NOTEMAIL, ERROR_CODE_ADMIN_EMAIL_NOTEMAIL); $zc_install->isEmpty($admin_pass, ERROR_TEXT_ADMIN_PASS_ISEMPTY, ERROR_CODE_ADMIN_PASS_ISEMPTY); $zc_install->isEqual($admin_pass, $admin_pass_confirm, ERROR_TEXT_ADMIN_PASS_NOTEQUAL, ERROR_CODE_ADMIN_PASS_NOTEQUAL); if (!$zc_install->error) { require '../includes/classes/db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $db->Connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE) or die("Unable to connect to database"); $sql = "update " . DB_PREFIX . "admin set admin_name = '" . $admin_username . "', admin_email = '" . $admin_email . "', admin_pass = '******' where admin_id = 1"; $db->Execute($sql) or die("Error in query: {$sql}" . $db->ErrorMsg()); // enable/disable automatic version-checking $sql = "update " . DB_PREFIX . "configuration set configuration_value = '" . ($check_for_updates ? 'true' : 'false') . "' where configuration_key = 'SHOW_VERSION_UPDATE_IN_HEADER'"; $db->Execute($sql) or die("Error in query: {$sql}" . $db->ErrorMsg()); $db->Close(); header('location: index.php?main_page=finished&language=' . $language); exit; } } if (!isset($_POST['admin_username'])) { $_POST['admin_username'] = ''; } if (!isset($_POST['admin_email'])) {
<?php /** * @package admin * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: init_database.php 3001 2006-02-09 21:45:06Z wilt $ */ if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } // include the cache class require DIR_FS_CATALOG . DIR_WS_CLASSES . 'cache.php'; $zc_cache = new cache(); // Load db classes // Load queryFactory db classes require DIR_FS_CATALOG . DIR_WS_CLASSES . 'db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE); $zc_cache->sql_cache_flush_cache();
if ($zc_install->error == false) { $phreebooks_database_connect_OK = true; } if ($zc_install->error == true) { $phreebooks_previous_version_installed = false; } //reset error-check class after connection attempt $zc_install->error = false; $zc_install->fatal_error = false; $zc_install->error_list = array(); } //endif check for db_type and db_name defined if ($phreebooks_database_connect_OK) { #1 //open database connection to run queries against it $db_test = new queryFactory(); $db_test->Connect($zdb_server, $zdb_user, $zdb_pwd, $zdb_name) or $phreebooks_database_connect_OK = false; if ($phreebooks_database_connect_OK) { //#2 This check is done again just in case connect fails on previous line //set database table prefix define('DB_PREFIX', $zdb_prefix); // Check to see if any PhreeBooks tables exist $sql = "SHOW TABLES like '" . DB_PREFIX . "configuration'"; $tables = $db_test->Execute($sql); if ($tables->RecordCount() > 0) { $zdb_configuration_table_found = true; } if ($zdb_configuration_table_found) { // now check for database version levels // Check to see if this is v1.0 ... ie, is it really PhreeBooks? $sql = "select * from " . DB_PREFIX . "configuration where configuration_key = 'COMPANY_COUNTRY'";
} else { define('DIR_WS_ICONS', 'themes/default/icons/'); } // use default $messageStack = new messageStack(); $toolbar = new toolbar(); // determine what company to connect to $db_company = isset($_SESSION['company']) ? $_SESSION['company'] : $_SESSION['companies'][$_POST['company']]; if ($db_company && file_exists(DIR_FS_MY_FILES . $db_company . '/config.php')) { define('DB_DATABASE', $db_company); require_once DIR_FS_MY_FILES . $db_company . '/config.php'; define('DB_SERVER_HOST', DB_SERVER); // for old PhreeBooks installs // Load queryFactory db classes require_once DIR_FS_INCLUDES . 'db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $db->connect(DB_SERVER_HOST, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE); // set application wide parameters for phreebooks module $result = $db->Execute_return_error("select configuration_key, configuration_value from " . DB_PREFIX . "configuration"); if ($db->error_number != '' || $result->RecordCount() == 0) { trigger_error(LOAD_CONFIG_ERROR, E_USER_ERROR); } while (!$result->EOF) { define($result->fields['configuration_key'], $result->fields['configuration_value']); $result->MoveNext(); } // search the list modules and load configuration files and language files gen_pull_language('phreedom', 'menu'); gen_pull_language('phreebooks', 'menu'); require_once DIR_FS_MODULES . 'phreedom/config.php'; $messageStack->debug_header();
if (defined('DEFAULT_LANGUAGE')) { $_SESSION['language'] = DEFAULT_LANGUAGE; } else { $_SESSION['language'] = 'en_us'; } } // include the list of project database tables require DIR_FS_INCLUDES . 'database_tables.php'; // include the list of project security tokens require DIR_FS_INCLUDES . 'security_tokens.php'; // include the database functions if ($use_db) { require DIR_FS_FUNCTIONS . 'database.php'; // Load queryFactory db classes require DIR_FS_CLASSES . 'db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_SERVER_NAME); // set application wide parameters for phreebooks module $configuration = $db->Execute_return_error("select configuration_key as cfgKey, configuration_value as cfgValue\r\n\t\t\t\t\t\t\t\t from " . TABLE_CONFIGURATION); if ($db->error_number) { // there was a problem, report and halt die('There was an error returned while retrieving the configuration data.<br />PhreeBooks was able to connect to the database but could not find the configuration table. Looks like the table is missing! Options include deleting /includes/configure.php and re-installing (for new installations) or restoring the database tables (database crash).'); } while (!$configuration->EOF) { define($configuration->fields['cfgKey'], $configuration->fields['cfgValue']); $configuration->MoveNext(); } // Define the project version (must come after db class is loaded) require DIR_FS_INCLUDES . 'version.php'; // Determine the DATABASE patch level $project_db_info = $db->Execute("select * from " . TABLE_PROJECT_VERSION . " WHERE project_version_key = 'PhreeBooks Database' ");
if (!isset($_POST['store_address'])) { $_POST['store_address'] = STORE_ADDRESS_DEFAULT_VALUE; } if (!isset($_POST['store_default_language'])) { $_POST['store_default_language'] = ''; } if (!isset($_POST['store_default_currency'])) { $_POST['store_default_currency'] = ''; } require '../includes/configure.php'; if (!defined('DB_TYPE') || DB_TYPE == '') { echo 'Database Type Invalid. Did your configure.php file get written correctly?'; $zc_install->error = true; } require '../includes/classes/db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $db->Connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE) or die("Unable to connect to database"); if (isset($_POST['submit'])) { // require('../includes/functions/functions_general.php'); // require('../includes/functions/validations.php'); $store_name = zen_db_prepare_input($_POST['store_name']); $store_owner = zen_db_prepare_input($_POST['store_owner']); $store_owner_email = zen_db_prepare_input($_POST['store_owner_email']); $store_country = zen_db_prepare_input($_POST['store_country']); $store_zone = zen_db_prepare_input($_POST['store_zone']); $store_address = zen_db_prepare_input($_POST['store_address']); $store_default_language = zen_db_prepare_input($_POST['store_default_language']); $store_default_currency = zen_db_prepare_input($_POST['store_default_currency']); $zc_install->isEmpty($store_name, ERROR_TEXT_STORE_NAME_ISEMPTY, ERROR_CODE_STORE_NAME_ISEMPTY); $zc_install->isEmpty($store_owner, ERROR_TEXT_STORE_OWNER_ISEMPTY, ERROR_CODE_STORE_OWNER_ISEMPTY); $zc_install->isEmpty($store_owner_email, ERROR_TEXT_STORE_OWNER_EMAIL_ISEMPTY, ERROR_CODE_STORE_OWNER_EMAIL_ISEMPTY);
<?php if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } if ($this_is_home_page && BLOG_SIDEBOX_ENABLED) { $blog_db = new queryFactory(); if ($blog_db->connect(BLOG_DB_SERVER, BLOG_DB_SERVER_USERNAME, BLOG_DB_SERVER_PASSWORD, BLOG_DB_DATABASE, BLOG_USE_PCONNECT, false)) { $blog_article_sql = 'select post_title,id,post_content,post_author,post_date from wp_posts where post_type="post" and post_parent=0 order by comment_count desc limit 2'; $blog_article_db = $blog_db->Execute($blog_article_sql); if ($blog_article_db->RecordCount() > 0) { $blog_articles = array(); while (!$blog_article_db->EOF) { $blog_postdate = $blog_article_db->fields['post_date']; $blog_postdate = explode(' ', $blog_postdate); $blog_postdate = $blog_postdate[0]; $blog_link = sprintf(BLOG_ARTICLE_LINK, $blog_article_db->fields['id']); $blog_articles[] = array('title' => $blog_article_db->fields['post_title'], 'blog_link' => $blog_link, 'content' => $blog_article_db->fields['post_content'], 'author' => $blog_article_db->fields['post_author'], 'date' => $blog_postdate); $blog_article_db->MoveNext(); } /*$blog_articles=array('title'=>$blog_article_db->fields['post_title'], 'id'=>$blog_article_db->fields['id'], 'content'=>$blog_article_db->fields['post_content'], //'author'=>$blog_article_db->fields['post_author'], 'date'=>$blog_article_db->fields['post_date'] );*/ require $template->get_template_dir('tpl_blog_articles.php', DIR_WS_TEMPLATE, $current_page_base, 'sideboxes') . '/tpl_blog_articles.php';
* see {@link http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem wikitutorials} for more details. * * @package initSystem * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: init_database.php 3008 2006-02-11 09:32:24Z drbyte $ */ if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } /** * require the query_factory clsss based on the DB_TYPE */ require 'includes/classes/db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $down_for_maint_source = 'nddbc.html'; if (!$db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false)) { if (file_exists('zc_install/index.php')) { header('location: zc_install/index.php'); exit; } elseif (file_exists($down_for_maint_source)) { if (defined('HTTP_SERVER') && defined('DIR_WS_CATALOG')) { header('location: ' . HTTP_SERVER . DIR_WS_CATALOG . $down_for_maint_source); } else { header('location: ' . $down_for_maint_source); // header('location: mystoreisdown.html'); } exit; } else { exit;
echo 'db-connection failed using the credentials supplied'; } if (ZC_UPG_DEBUG == true) { $zc_install->logDetails('db-connection failed using the credentials supplied'); } } //reset error-check class after connection attempt $zc_install->error = false; $zc_install->fatal_error = false; $zc_install->error_list = array(); } //endif check for db_type and db_name defined if ($zen_cart_database_connect_OK) { #1 //open database connection to run queries against it $db_test = new queryFactory(); $db_test->Connect($zdb_server, $zdb_user, $zdb_pwd, $zdb_name) or $zen_cart_database_connect_OK = false; if ($zen_cart_database_connect_OK) { //#2 This check is done again just in case connect fails on previous line //set database table prefix define('DB_PREFIX', $zdb_prefix); // Now check the database for what version it's at, if found require 'includes/classes/class.installer_version_manager.php'; $dbinfo = new versionManager(); // Check to see whether we should offer the option to upgrade "database only", rather than rebuild configure.php files too. // For v1.2.1, the only check we need is whether we're at v1.2.0 already or not. // Future versions may require more extensive checking if the core configure.php files change. // NOTE: This flag is also used to determine whether or not we prevent moving to next screen if the configure.php files are not writable if ($dbinfo->found_version >= '1.2.0') { $zen_cart_allow_database_upgrade = true; }
* see {@link http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem wikitutorials} for more details. * * @package initSystem * @copyright Copyright 2003-2013 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version GIT: $Id: Author: DrByte Sat Nov 2 00:02:54 2013 -0400 Modified in v1.5.2 $ */ if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } /** * require the query_factory clsss based on the DB_TYPE */ require 'includes/classes/db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $down_for_maint_source = 'nddbc.html'; if (!$db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false)) { session_write_close(); if (file_exists('zc_install/index.php')) { header('location: zc_install/index.php'); exit; } elseif (file_exists($down_for_maint_source)) { if (defined('HTTP_SERVER') && defined('DIR_WS_CATALOG')) { header('location: ' . HTTP_SERVER . DIR_WS_CATALOG . $down_for_maint_source); } else { header('location: ' . $down_for_maint_source); // header('location: mystoreisdown.html'); } exit; } else {
if ($zc_install->error == false) { $zen_cart_database_connect_OK = true; } if ($zc_install->error == true) { $zen_cart_previous_version_installed = false; } //reset error-check class after connection attempt $zc_install->error = false; $zc_install->fatal_error = false; $zc_install->error_list = array(); } //endif check for db_type and db_name defined if ($zen_cart_database_connect_OK) { #1 //open database connection to run queries against it $db_test = new queryFactory(); $db_test->Connect($zdb_server, $zdb_user, $zdb_pwd, $zdb_name) or $zen_cart_database_connect_OK = false; if ($zen_cart_database_connect_OK) { //#2 This check is done again just in case connect fails on previous line //set database table prefix define('DB_PREFIX', $zdb_prefix); // Check to see if any Zen Cart tables exist $sql = "SHOW TABLES like '" . DB_PREFIX . "configuration'"; $tables = $db_test->Execute($sql); if (ZC_UPG_DEBUG == true) { echo 'ZEN-Configuration (should be 1) = ' . $tables->RecordCount() . '<br>'; } if ($tables->RecordCount() > 0) { $zdb_configuration_table_found = true; } if ($zdb_configuration_table_found) {
if ($_POST['demo_install'] == 'true') { $zc_install->fileExists('demo/' . DB_TYPE . '_demo.sql', ERROR_TEXT_DEMO_SQL_NOTEXIST, ERROR_CODE_DEMO_SQL_NOTEXIST); } if ($zc_install->error == false) { if ($_POST['demo_install'] == 'true') { $zc_install->dbDemoDataInstall(); } $zc_install->dbStoreSetup(); // Close the database connection $zc_install->db->Close(); header('location: index.php?main_page=admin_setup' . zcInstallAddSID()); exit; } } require '../includes/classes/db/' . DB_TYPE . '/query_factory.php'; $db = new queryFactory(); $db->Connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE) or die("Unable to connect to database"); //if not submit, set some defaults $sql = "select countries_id, countries_name from " . DB_PREFIX . "countries order by countries_name"; $country = $db->Execute($sql); $country_string = ''; while (!$country->EOF) { $country_string .= '<option value="' . $country->fields['countries_id'] . '"' . setSelected($country->fields['countries_id'], $_POST['store_country']) . '>' . $country->fields['countries_name'] . '</option>'; $country->MoveNext(); } $sql = "select zone_id, zone_name from " . DB_PREFIX . "zones"; // order by zone_country_id, zone_name $zone = $db->Execute($sql); $zone_string = ''; $zone_string .= '<option value="-1"' . setSelected('-1', $_POST['store_zone']) . '>' . '-- Please Select --' . '</option>'; $zone_string .= '<option value="0"' . setSelected('0', $_POST['store_zone']) . '>' . '-None-' . '</option>';
if (!$error && $db_name != $_SESSION['company']) { // connect to other company, retrieve login info $config = file(DIR_FS_MY_FILES . $db_name . '/config.php'); foreach ($config as $line) { if (strpos($line, 'DB_SERVER_USERNAME')) { $db_user = substr($line, strpos($line, ",") + 1, strpos($line, ")") - strpos($line, ",") - 1); } elseif (strpos($line, 'DB_SERVER_PASSWORD')) { $db_pw = substr($line, strpos($line, ",") + 1, strpos($line, ")") - strpos($line, ",") - 1); } elseif (strpos($line, 'DB_SERVER_HOST')) { $db_server = substr($line, strpos($line, ",") + 1, strpos($line, ")") - strpos($line, ",") - 1); } } $db_user = str_replace("'", "", $db_user); $db_pw = str_replace("'", "", $db_pw); $db_server = str_replace("'", "", $db_server); $del_db = new queryFactory(); if (!$del_db->connect($db_server, $db_user, $db_pw, $db_name)) { $error = $messageStack->add(SETUP_CO_MGR_CANNOT_CONNECT, 'error'); } if (!$error) { $tables = array(); $table_list = $del_db->Execute("show tables"); while (!$table_list->EOF) { $tables[] = array_shift($table_list->fields); $table_list->MoveNext(); } if (is_array($tables)) { foreach ($tables as $table) { $del_db->Execute("drop table " . $table); } }