Exemplo n.º 1
0
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();
     }
 }
Exemplo n.º 4
0
 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) . "')");
     }
 }
Exemplo n.º 5
0
 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();
     }
 }
Exemplo n.º 6
0
 $cb_employees = isset($_POST['employees']) ? 1 : 0;
 $cb_users = isset($_POST['users']) ? 1 : 0;
 // error check company name and company full name
 if (!$company || !$company_name) {
     $messageStack->add(SETUP_CO_MGR_ERROR_EMPTY_FIELD, 'error');
     break;
 }
 if ($company == $_SESSION['company']) {
     $messageStack->add(SETUP_CO_MGR_DUP_DB_NAME, 'error');
     break;
 }
 // check for database already exists
 $db_old = new queryFactory();
 $db_old->connect($_SESSION['db_server'], $_SESSION['db_user'], $_SESSION['db_pw'], $_SESSION['company']);
 $db = new queryFactory();
 if (!$db->connect($db_server, $db_user, $db_pw, $company)) {
     $result = $db_old->Execute_return_error("create database " . $company);
     if ($db_old->error_number) {
         $messageStack->add('DB Error # ' . $db_old->error_number . ' ' . $db_old->error_text, 'error');
         $messageStack->add(SETUP_CO_MGR_NO_DB, 'error');
         break;
     } else {
         if (!$db->connect(DB_SERVER, $db_user, $db_pw, $company)) {
             $messageStack->add(SETUP_CO_MGR_CANNOT_CONNECT, 'error');
             break;
         }
     }
 }
 $result = db_executeSql(DIR_FS_MODULES . 'install/sql/current/tables.sql', $company, DB_PREFIX);
 if (count($result['errors']) > 0) {
     $messageStack->add(SETUP_CO_MGR_ERROR_1, 'error');
Exemplo n.º 7
0
 * @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 {
        exit;
    }
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
    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();
    $loaded_modules = array();
Exemplo n.º 10
0
        $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'));
$breadcrumb->add(NAVBAR_TITLE_2);
Exemplo n.º 11
0
<?php

if (!defined('IS_ADMIN_FLAG')) {
    die('Illegal Access');
}
if ($this_is_home_page && FORUM_SIDEBOX_ENABLED) {
    $forum_db = new queryFactory();
    if ($forum_db->connect(FORUM_DB_SERVER, FORUM_DB_SERVER_USERNAME, FORUM_DB_SERVER_PASSWORD, FORUM_DB_DATABASE, FORUM_USE_PCONNECT, false)) {
        $forum_article_sql = 'select topic_id,forum_id,topic_title
							  from   topics 
							  where topic_approved=1 
							  order by topic_views desc,topic_time desc limit 3';
        $forum_article_db = $forum_db->Execute($forum_article_sql);
        if ($forum_article_db->RecordCount() > 0) {
            $forum_articles = array();
            while (!$forum_article_db->EOF) {
                $tmp_topic_link = sprintf(FORUM_ARTICLE_LINK, $forum_article_db->fields['forum_id'], $forum_article_db->fields['topic_id']);
                $forum_articles[] = array('topic_title' => $forum_article_db->fields['topic_title'], 'topic_link' => $tmp_topic_link);
                $forum_article_db->MoveNext();
            }
            require $template->get_template_dir('tpl_forum_articles.php', DIR_WS_TEMPLATE, $current_page_base, 'sideboxes') . '/tpl_forum_articles.php';
        }
    }
    unset($forum_db);
    unset($forum_article_db);
}
Exemplo n.º 12
0
<?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';
Exemplo n.º 13
0
        $_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' ");
    define('PROJECT_DB_VERSION_MAJOR', $project_db_info->fields['project_version_major']);
Exemplo n.º 14
0
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MY_FILES . 'custom/general/backup/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
// set execution time limit to a large number to allow extra time
if (ini_get('max_execution_time') < 20000) {
    set_time_limit(20000);
}
// dump db
require DIR_FS_WORKING . 'functions/database.php';
// Load queryFactory db classes
require DIR_FS_WORKING . 'classes/db/mysql/query_factory.php';
require DIR_FS_MY_FILES . $company . '/config.php';
$db = new queryFactory();
$db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, $database);
$dest_dir = DIR_FS_MY_FILES . 'backups/';
$company_dir = DIR_FS_MY_FILES . $company . '/';
$compressed_dbname = 'db-' . $company . '-' . date('Ymd');
$compressed_dirname = 'bu-' . $company . '-' . date('Ymd');
$db_filename = $compressed_dbname . '.sql';
$db_temp_full_path = $company_dir . $db_filename;
$db_save_full_path = $dest_dir . $db_filename;
if (!is_dir($dest_dir)) {
    mkdir($dest_dir);
}
/***  PARA HACER EL DUMP, usamos directamente mysqldump**********/
$command = "mysqldump --opt -h " . DB_SERVER . " -u" . DB_SERVER_USERNAME . " -p" . DB_SERVER_PASSWORD . " " . $database . " > " . $dest_dir . $db_filename;
system($command);
/************/
// compress the company directory
Exemplo n.º 15
0
     }
     if (!install_build_co_config_file($db_name, 'DB_SERVER_USERNAME', $db_username)) {
         $error = true;
     }
     if (!install_build_co_config_file($db_name, 'DB_SERVER_PASSWORD', $db_password)) {
         $error = true;
     }
     if (!install_build_co_config_file($db_name, 'DB_SERVER_HOST', $db_host)) {
         $error = true;
     }
 }
 if (!$error) {
     // try to connect to db
     require '../includes/db/' . DB_TYPE . '/query_factory.php';
     $db = new queryFactory();
     if (!$db->connect($db_host, $db_username, $db_password, $db_name)) {
         $error = $messageStack->add(MSG_ERROR_CANNOT_CONNECT_DB . $db->show_error(), 'error');
     } else {
         // test for InnoDB support
         $result = $db->Execute("show engines");
         $innoDB_enabled = false;
         while (!$result->EOF) {
             if ($result->fields['Engine'] == 'InnoDB') {
                 $innoDB_enabled = true;
             }
             $result->MoveNext();
         }
         if (!$innoDB_enabled) {
             $error = $messageStack->add(MSG_ERROR_INNODB_NOT_ENABLED, 'error');
         }
     }
Exemplo n.º 16
0
error_reporting(E_ALL & ~E_NOTICE);
if (MODULE_PAYMENT_PAYPAL_IPN_DEBUG == 'Yes') {
    mail('*****@*****.**', 'IPN DEBUG MESSAGE', '0.0. in app top ' . $PHP_SELF);
}
@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/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) && file_exists('zc_install/index.php')) {
    header('location: zc_install/index.php');
    exit;
}
// Define the project version  (must come after DB class is loaded)
require DIR_WS_INCLUDES . 'version.php';
// 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';
Exemplo n.º 17
0
 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();
 }
Exemplo n.º 19
0
<?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">
Exemplo n.º 20
0
 // 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);
         }
     }
     $backup->delete_dir(DIR_FS_MY_FILES . $db_name);