⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 general.php

📁 全新且完善的强大网上商店系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:

function tep_generate_category_path($id, $from = 'category', $categories_array = '', $index = 0) {
    global $languages_id, $db, $table_categories, $table_categories_description, $table_categories, $table_categories_description, $table_products, $table_products_to_categories;
		global $languages_id;
    if (!is_array($categories_array)) $categories_array = array();
    if ($from == 'product') {
        $categories_query = $db->query("select categories_id from $table_products_to_categories where products_id = '" . (int)$id . "'");
        while ($categories = $db->fetch_array($categories_query)) {
            if ($categories['categories_id'] == '0') {
                 $categories_array[$index][] = array('id' => '0', 'text' => TEXT_TOP);
            } else {
                 $category_query = $db->query("select cd.categories_name, c.parent_id from $table_categories c, $table_categories_description cd where c.categories_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
                 $category = $db->fetch_array($category_query);
                 $categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);
                 if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
                 $categories_array[$index] = array_reverse($categories_array[$index]);
            }
            $index++;
        }
    } elseif ($from == 'category') {
        $category_query = $db->query("select cd.categories_name, c.parent_id from $table_categories c, $table_categories_description cd where c.categories_id = '" . (int)$id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
        $category = $db->fetch_array($category_query);
        $categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']);
        if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
    }
    return $categories_array;
}

function tep_output_generated_category_path($id, $from = 'category') {
    $calculated_category_path_string = '';
    $calculated_category_path = tep_generate_category_path($id, $from);
    for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {
      for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {
        $calculated_category_path_string .= $calculated_category_path[$i][$j]['text'] . '&nbsp;&gt;&nbsp;';
      }
      $calculated_category_path_string = substr($calculated_category_path_string, 0, -16) . '<br>';
    }
    $calculated_category_path_string = substr($calculated_category_path_string, 0, -4);

    if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP;

    return $calculated_category_path_string;
}

function tep_prepare_country_zones_pull_down($country_id = '') {
    $pre = '';
    if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {
         for ($i=0; $i<45; $i++) $pre .= '&nbsp;';
    }
    $zones = tep_get_country_zones($country_id);
    if (sizeof($zones) > 0) {
         $zones_select = array(array('id' => '', 'text' => PLEASE_SELECT));
         $zones = array_merge($zones_select, $zones);
    } else {
         $zones = array(array('id' => '', 'text' => TYPE_BELOW));
         if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {
              for ($i=0; $i<9; $i++) {
                  $zones[] = array('id' => '', 'text' => $pre);
              }
         }
    }
    return $zones;
}

function tep_set_time_limit($limit) {
    if (!get_cfg_var('safe_mode')) {
        set_time_limit($limit);
    }
}

function tep_cfg_pull_down_styles_list($style_id) {
   	global $db,$table_styles;
		$stylelist = "<select name=\"configuration_value\">\n";
	  $query = $db->query("SELECT styleid, name FROM $table_styles");
	  while($style = $db->fetch_array($query)) {
		   $selected = $style[styleid] == $style_id ? "selected=\"selected\"" : NULL;
		   $stylelist .= "<option value=\"$style[styleid]\" $selected>$style[name]</option>\n";
	  }
	  $stylelist .= "</select>";
	  return ($stylelist);
}

function tep_get_style_name($style_id) {
   	global $db,$table_styles;
	  $query = $db->query("SELECT name FROM $table_styles where styleid='$style_id'");
	  $style = $db->fetch_array($query);
	  return $style['name'];
}

function tep_options_name($options_id) {
    global $languages_id,$db,$table_products_options;
    $options = $db->query("select products_options_name from $table_products_options where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'");
    $options_values = $db->fetch_array($options);
    return $options_values['products_options_name'];
}

function tep_values_name($values_id) {
    global $languages_id, $table_products_options_values, $db, $table_categories;
    $values = $db->query("select products_options_values_name from $table_products_options_values where products_options_values_id = '" . (int)$values_id . "' and language_id = '" . (int)$languages_id . "'");
    $values_values = $db->fetch_array($values);
    return $values_values['products_options_values_name'];
}


function tep_remove_product($product_id) {
    global $db, $soobic, $table_products, $table_specials, $table_products_to_categories, $table_products_description, $table_customers_basket, $table_reviews,$table_reviews_description;
		$product_image_query = $db->query("select products_image from $table_products where products_id = '" . (int)$product_id . "'");
    $product_image = $db->fetch_array($product_image_query);

    $duplicate_image_query = $db->query("select count(*) as total from $table_products where products_image = '" . ($product_image['products_image']) . "'");
    $duplicate_image = $db->fetch_array($duplicate_image_query);

    if ($duplicate_image['total'] < 2) {
      if (file_exists($soobic.'./upload/images/products/'. $product_image['products_image'])) {
        @unlink($soobic.'./upload/images/products/'. $product_image['products_image']);
        if(!file_exists($soobic.'./upload/images/products/small_'. $product_image['products_image'])){
            $src=eregi_replace(strrchr($soobic.'./upload/images/products/small_'. $product_image['products_image'],'.'),'.jpg',$soobic.'./upload/images/products/small_'. $product_image['products_image']);
            @unlink($src);
        }
        @unlink($soobic.'./upload/images/products/small_'. $product_image['products_image']);
			}
    }

    $db->query("delete from $table_specials where products_id = '" . (int)$product_id . "'");
    $db->query("delete from $table_products where products_id = '" . (int)$product_id . "'");
    $db->query("delete from $table_products_to_categories where products_id = '" . (int)$product_id . "'");
    $db->query("delete from $table_products_description where products_id = '" . (int)$product_id . "'");
    $db->query("delete from $table_customers_basket where products_id = '" . (int)$product_id . "'");

    $product_reviews_query = $db->query("select reviews_id from $table_reviews where products_id = '" . (int)$product_id . "'");
    while ($product_reviews = $db->fetch_array($product_reviews_query)) {
      $db->query("delete from $table_reviews_description where reviews_id = '" . (int)$product_reviews['reviews_id'] . "'");
    }
    $db->query("delete from $table_reviews where products_id = '" . (int)$product_id . "'");
}

function tep_remove_category($category_id) {
    global $db, $soobic, $table_categories, $table_categories_description, $table_products_to_categories;
		$category_image_query = $db->query("select categories_image from $table_categories where categories_id = '" . (int)$category_id . "'");
    $category_image = $db->fetch_array($category_image_query);

    $duplicate_image_query = $db->query("select count(*) as total from $table_categories where categories_image = '" .($category_image['categories_image']) . "'");
    $duplicate_image = $db->fetch_array($duplicate_image_query);

    if ($duplicate_image['total'] < 2) {
       if (file_exists($soobic.'./upload/images/category/'. $category_image['categories_image'])) {
          @unlink($soobic.'./upload/images/category/'. $category_image['categories_image']);
       }
    }
    $db->query("delete from $table_categories where categories_id = '" . (int)$category_id . "'");
    $db->query("delete from $table_categories_description where categories_id = '" . (int)$category_id . "'");
    $db->query("delete from $table_products_to_categories where categories_id = '" . (int)$category_id . "'");
}

function tep_childs_in_category_count($categories_id) {
    global $db, $table_categories;
		$categories_count = 0;
    $categories_query = $db->query("select categories_id from $table_categories where parent_id = '" . (int)$categories_id . "'");
    while ($categories = $db->fetch_array($categories_query)) {
        $categories_count++;
        $categories_count += tep_childs_in_category_count($categories['categories_id']);
    }
    return $categories_count;
}
 
function tep_products_in_category_count($categories_id, $include_deactivated = false) {
    global $db, $table_products,$table_products_to_categories, $table_categories;
		$products_count = 0;
    if ($include_deactivated) {
        $products_query = $db->query("select count(*) as total from $table_products p, $table_products_to_categories p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$categories_id . "'");
    } else {
        $products_query = $db->query("select count(*) as total from $table_products p, $table_products_to_categories p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$categories_id . "'");
    }
    $products = $db->fetch_array($products_query);
    $products_count += $products['total'];
    $childs_query = $db->query("select categories_id from $table_categories where parent_id = '" . (int)$categories_id . "'");
    if ($db->num_rows($childs_query)) {
        while ($childs = $db->fetch_array($childs_query)) {
           $products_count += tep_products_in_category_count($childs['categories_id'], $include_deactivated);
        }
    }
    return $products_count;
} 

function tep_get_generated_category_path_ids($id, $from = 'category') {
    $calculated_category_path_string = '';
    $calculated_category_path = tep_generate_category_path($id, $from);
    for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {
      for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {
        $calculated_category_path_string .= $calculated_category_path[$i][$j]['id'] . '_';
      }
      $calculated_category_path_string = substr($calculated_category_path_string, 0, -1) . '<br>';
    }
    $calculated_category_path_string = substr($calculated_category_path_string, 0, -4);
    if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP;
    return $calculated_category_path_string;
}
function tep_cfg_textarea($text) {
    return tep_draw_textarea_field('configuration_value', false, 35, 5, $text);
} 

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -