function getCategoryTree($pid, $level) { global $categories; if (count($categories[$pid]) > 0) { foreach ($categories[$pid] as $category) { return getCategoryTree($category['id'], $level++); } } return ""; }
function getCategoryTree($parent_id, $level, $sub_category = false) { global $category_dropdown; if ($sub_category) { $name_prefix = str_pad('', $level, '-'); } else { $name_prefix = ''; } $result = xtc_db_query("SELECT c.categories_id, cd.categories_name FROM categories c, categories_description cd WHERE c.parent_id = '" . $parent_id . "' AND c.categories_status = 1 AND cd.language_id = '" . (int) $_SESSION['languages_id'] . "' AND c.categories_id = cd.categories_id ORDER BY c.sort_order"); while ($category = xtc_db_fetch_array($result)) { if (!$sub_category) { $level = 0; } $category_dropdown[] = array('id' => (int) $category['categories_id'], 'text' => $name_prefix . $category['categories_name']); $check = xtc_db_query("SELECT c.categories_id FROM categories c WHERE c.parent_id = '" . $category['categories_id'] . "' AND c.categories_status = 1"); if (xtc_db_num_rows($check) > 0) { getCategoryTree($category['categories_id'], ++$level, true); } } }
<?php include "../common.php"; $html = new HTML(); checkUser(); $current_action = 'profile'; $category_id_list = getCategoryTree(); if (isset($_REQUEST['name'])) { if ($User->update($_SESSION['user_id'], $QUERY['password'], $QUERY['name'], $QUERY['email'], $QUERY['url'], $QUERY['anchor_text'], $QUERY['rss'], $QUERY['company'], $QUERY['description'], $QUERY['phone'], $QUERY['category_id'])) { $QUERY['success'] = "Profile Updated"; } } $PARAM = $User->find($_SESSION['user_id']); unset($PARAM['password']); render();
// // Set key for access to functionality this script // define('WEB_API_KEY', 'key1'); require_once './app/Mage.php'; Mage::app(); $key = Mage::app()->getRequest()->getParam('key'); if (!isset($key) || $key != WEB_API_KEY) { $json = array('success' => false, 'code' => 20, 'message' => 'Invalid secret key'); print_r(json_encode($json)); } elseif (Mage::app()->getRequest()->getParam('route') == "feed/web_api/categories") { # -- $_GET params ------------------------------ $parent = Mage::app()->getRequest()->getParam('parent', 0); $level = Mage::app()->getRequest()->getParam('level', 1); # -- End $_GET params -------------------------- print_r(json_encode(getCategoryTree($parent, $level))); } elseif (Mage::app()->getRequest()->getParam('route') == "feed/web_api/products") { # -- $_GET params ------------------------------ $category_id = Mage::app()->getRequest()->getParam('category', 0); # -- End $_GET params -------------------------- print_r(json_encode(products($category_id))); } elseif (Mage::app()->getRequest()->getParam('route') == "feed/web_api/product") { # -- $_GET params ------------------------------ $product_id = Mage::app()->getRequest()->getParam('id', 0); # -- End $_GET params -------------------------- print_r(json_encode(product($product_id))); } elseif (Mage::app()->getRequest()->getParam('route') == "feed/web_api/random") { # -- $_GET params ------------------------------ $limit = Mage::app()->getRequest()->getParam('limit', 4); # -- End $_GET params -------------------------- print_r(json_encode(random_products($limit)));