__FILE__, "line" => __LINE__, "query" => $option_id_q, "mysql_error" => mysql_error()))); $option_id_num = mysql_num_rows($option_id_do_q); if($option_id_num>0) { $option_id_array = mysql_fetch_assoc($option_id_do_q); $option_id = $option_id_array['optionID']; $option_value_q = "SELECT option_value FROM ".PRODUCT_OPTIONS_VALUES_TABLE." WHERE optionID='".$option_id."' AND productID='".$product_id."'"; $option_value_do_q = mysql_query($option_value_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $option_value_q, "mysql_error" => mysql_error()))); $option_value_num = mysql_num_rows($option_value_do_q); if($option_value_num>0) { $option_value_array = mysql_fetch_assoc($option_value_do_q); $option_value = stripslashes($option_value_array['option_value']); return $option_value; } else { return "0"; } } else { return "0"; } } function ConvertProductName($product_id) { $product_info = GetProductInfoById($product_id); $product_name = stripslashes($product_info['name']); $vendor_name = GetProductOptionFromProductIdAndOptionName("Производитель", $product_info['productID']); $return['product_name'] = ereg_replace("^$vendor_name? ", "", $product_name); $return['vendor_name'] = stripslashes($vendor_name); return $return; } function ManWoman($category_id) { $q = "SELECT meta_description FROM ".CATEGORIES_TABLE." WHERE categoryID='".addslashes($category_id)."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $num = mysql_num_rows($do_q); if($num > 0) { $do_q_array = mysql_fetch_assoc($do_q); $category_code = stripslashes($do_q_array['meta_description']); if(ereg("^man?", $category_code)) { $return = "man"; } elseif(ereg("^woman?", $category_code)) { $return = "woman"; } //print $return." => ".$category_code; return $return; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию ManWoman() по ID категории '".$category_id."' не было найдено ни одной записи в таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } function ConvertCategoryName($category_id) { $q = "SELECT name, parent FROM ".CATEGORIES_TABLE." WHERE categoryID='".addslashes($category_id)."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $num = mysql_num_rows($do_q); if($num > 0) { $do_q_array = mysql_fetch_assoc($do_q); $parent_name_q = "SELECT name FROM ".CATEGORIES_TABLE." WHERE categoryID='".addslashes($do_q_array['parent'])."'"; $parent_name_do_q = mysql_query($parent_name_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $parent_name_q, "mysql_error" => mysql_error()))); $parent_name_num = mysql_num_rows($parent_name_do_q); if($parent_name_num > 0) { $parent_name_array = mysql_fetch_assoc($parent_name_do_q); $category_name = stripslashes($do_q_array['name']); $parent_name = stripslashes($parent_name_array['name']); $return['category_name'] = ereg_replace("^$parent_name? ", "", $category_name); $return['vendor_name'] = $parent_name; return $return; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке узнать название родителськой категории по ее ID ".$do_q_array['parent']." при осуществлении функции ConvertCategoryName() не было найдено ни одной записи в таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию ConvertCategoryName() по ID категории '".$category_id."' не было найдено ни одной записи в таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } function GetProductInfoById($product_id) { $q = "SELECT * FROM ".PRODUCTS_TABLE." WHERE productID='".addslashes($product_id)."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $num = mysql_num_rows($do_q); if($num > 0) { $return = mysql_fetch_assoc($do_q); return $return; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetProductInfoById() по ID продукта '".$product_id."' не было найдено ни одной записив таблице продуктов", "file" => __FILE__, "line" => __LINE__))); } } function GetCategoryProductsByCategoryId($category_id) { $q = "SELECT productID, Price, list_price FROM ".PRODUCTS_TABLE." WHERE categoryID = '".addslashes($category_id)."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $num = mysql_num_rows($do_q); if($num > 0) { $i="0"; while($products = mysql_fetch_assoc($do_q)) { $return[$i]['product_id'] = $products['productID']; $return[$i]['product_price'] = $products['Price']; $return[$i]['product_price_with_unit'] = show_price($return[$i]['product_price']); if($products['list_price']=="0") { $return[$i]['product_old_price'] = "0"; } else { $return[$i]['product_old_price'] = show_price($products['list_price']); } $return[$i]['product_type'] = GetProductOptionFromProductIdAndOptionName("Тип товара", $products['productID']); $return[$i]['product_volume'] = GetProductOptionFromProductIdAndOptionName("Емкость", $products['productID']); $i++; } return $return; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetCategoryProductsByCategoryId() по ID категории '".$category_id."' не было найдено ни одной записив таблице продуктов", "file" => __FILE__, "line" => __LINE__))); } } function GetCategoryIdByProductId($productID) { $q = "SELECT categoryID FROM ".PRODUCTS_TABLE." WHERE productID='".addslashes($productID)."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $num = mysql_num_rows($do_q); if($num > 0) { $array = mysql_fetch_assoc($do_q); $category_id = stripslashes($array['categoryID']); return $category_id; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetCategoryIdByProductId() по ID продукта '".$productID."' не было найдено ни одной записив таблице продуктов", "file" => __FILE__, "line" => __LINE__))); } } function GetCategoryDescriptionsByCategoryId($category_id) { $q = "SELECT description FROM ".CATEGORIES_TABLE." WHERE categoryID='".addslashes($category_id)."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $num = mysql_num_rows($do_q); if($num > 0) { $array = mysql_fetch_assoc($do_q); $description = stripslashes($array['description']); $descriptions = explode(",", $description); $return['short'] = $descriptions[0]; $return['long'] = $descriptions[1]; return $return; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetCategoryDescriptionsByCategoryId() по ID категории '".$category_id."' не было найдено ни одной записив таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } function GetCategoryPicturesByCategoryId($category_id) { $q = "SELECT meta_keywords FROM ".CATEGORIES_TABLE." WHERE categoryID='".addslashes($category_id)."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $num = mysql_num_rows($do_q); if($num > 0) { $array = mysql_fetch_assoc($do_q); $pictures = stripslashes($array['meta_keywords']); $pictures = explode(",", $pictures); $return['s_picture'] = $pictures[0]; $return['m_picture'] = $pictures[1]; return $return; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetCategoryPicturesByCategoryId() по ID категории '".$category_id."' не было найдено ни одной записив таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } function GetCategoryIdByCategoryCode($category_code) { $category_id_q = "SELECT categoryID FROM ".CATEGORIES_TABLE." WHERE meta_description ='".addslashes($category_code)."'"; $category_id_do_q = mysql_query($category_id_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $category_id_q, "mysql_error" => mysql_error()))); $category_id_num = mysql_num_rows($category_id_do_q); if($category_id_num>0) { $category_id_array = mysql_fetch_assoc($category_id_do_q); $category_id = $category_id_array['categoryID']; return $category_id; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetCategoryIdByCategoryCode() по коду категории '".$category_code."' не было найдено ни одной записив таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } function GetProductIdByProductCode($product_code) { $product_id_q = "SELECT productID FROM ".PRODUCTS_TABLE." WHERE product_code='".addslashes($product_code)."'"; $product_id_do_q = mysql_query($product_id_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $product_id_q, "mysql_error" => mysql_error()))); $product_id_num = mysql_num_rows($product_id_do_q); if($product_id_num>0) { $product_id_array = mysql_fetch_assoc($product_id_do_q); $product_id = $product_id_array['productID']; return $product_id; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetProductIdByProductCode() по коду продукта '".$product_code."' не было найдено ни одной записив таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } function GetProductCodeByProductID($product_id) { $product_code_q = "SELECT product_code FROM ".PRODUCTS_TABLE." WHERE productID='".addslashes($product_id)."'"; $product_code_do_q = mysql_query($product_code_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $product_code_q, "mysql_error" => mysql_error()))); $product_code_num = mysql_num_rows($product_code_do_q); if($product_code_num>0) { $product_code_array = mysql_fetch_assoc($product_code_do_q); $product_code = $product_code_array['product_code']; return $product_code; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetProductCodeByProductID() по ID продукта '".$product_id."' не было найдено ни одной записив таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } function GetCategoryCodeByCategoryID($category_id) { $GetCategoryCodeByCategoryID_q = "SELECT meta_description FROM ".CATEGORIES_TABLE." WHERE categoryID='".addslashes($category_id)."'"; $GetCategoryCodeByCategoryID_do_q = mysql_query($GetCategoryCodeByCategoryID_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $GetCategoryCodeByCategoryID_q, "mysql_error" => mysql_error()))); $GetCategoryCodeByCategoryID_num = mysql_num_rows($GetCategoryCodeByCategoryID_do_q); if($GetCategoryCodeByCategoryID_num>0) { $GetCategoryCodeByCategoryID_array = mysql_fetch_assoc($GetCategoryCodeByCategoryID_do_q); $category_code = $GetCategoryCodeByCategoryID_array['meta_description']; return $category_code; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetCategoryCodeByCategoryID() по ID категории '".$category_id."' не было найдено ни одной записив таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } function RootCategory($categoryID) { $RootCategory_q = "SELECT parent FROM ".CATEGORIES_TABLE." WHERE categoryID='".addslashes($categoryID)."'"; $RootCategory_do_q = mysql_query($RootCategory_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $RootCategory_q, "mysql_error" => mysql_error()))); $RootCategory_num = mysql_num_rows($RootCategory_do_q); if($RootCategory_num > 0) { $RootCategoryArray = mysql_fetch_assoc($RootCategory_do_q); return $RootCategoryArray['parent']; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию RootCategory() по АйДи категории '".$categoryID."' не было найдено ни одной записив таблице категорий", "file" => __FILE__, "line" => __LINE__))); } } function NotEmptyCategory($categoryID) { $NotEmptyCategory_q = "SELECT count(*) FROM ".PRODUCTS_TABLE." WHERE categoryID='".addslashes($categoryID)."'"; $NotEmptyCategory_do_q = mysql_query($NotEmptyCategory_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $NotEmptyCategory_q, "mysql_error" => mysql_error()))); $NotEmptyCategory_num = mysql_fetch_row($NotEmptyCategory_do_q); if($NotEmptyCategory_num[0] > 0) { return "not_empty"; } else { return "empty"; } } function GetCategoryCodeByProductCode($product_code) { $GetCategoryIDByProductCode_q = "SELECT categoryID FROM ".PRODUCTS_TABLE." WHERE product_code='".addslashes($product_code)."'"; $GetCategoryIDByProductCode_do_q = mysql_query($GetCategoryIDByProductCode_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $GetCategoryIDByProductCode_q, "mysql_error" => mysql_error()))); $GetCategoryIDByProductCode_num = mysql_num_rows($GetCategoryIDByProductCode_do_q); if($GetCategoryIDByProductCode_num > 0) { $GetCategoryIDByProductCode_array = mysql_fetch_assoc($GetCategoryIDByProductCode_do_q); $category_id = $GetCategoryIDByProductCode_array['categoryID']; $category_code = GetCategoryCodeByCategoryID($category_id); return $category_code; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetCategoryCodeByProductCode() по коду продукта '".$product_code."' не было найдено ни одной записив таблице продуктов", "file" => __FILE__, "line" => __LINE__))); } } function GetCategoryNameByCategoryCode($category_code) { $GetCategoryNameByCategoryCode_q = "SELECT name FROM ".CATEGORIES_TABLE." WHERE meta_description='".addslashes($category_code)."'"; $GetCategoryNameByCategoryCode_do_q = mysql_query($GetCategoryNameByCategoryCode_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $GetCategoryNameByCategoryCode_q, "mysql_error" => mysql_error()))); $GetCategoryNameByCategoryCode_num = mysql_num_rows($GetCategoryNameByCategoryCode_do_q); if($GetCategoryNameByCategoryCode_num > 0) { $GetCategoryNameByCategoryCode_array = mysql_fetch_assoc($GetCategoryNameByCategoryCode_do_q); $category_name = $GetCategoryNameByCategoryCode_array['name']; return $category_name; } else { die(SendAdminNotification($notification_array = array("title" => "При попытке осуществить функцию GetCategoryNameByCategoryCode() по коду категории '".$category_code."' не было найдено ни одной записив таблице продуктов", "file" => __FILE__, "line" => __LINE__))); } } function CheckCategoryExist($category_code) { $check_category_exist_q = "SELECT count(*) FROM ".CATEGORIES_TABLE." WHERE meta_description='".addslashes($category_code)."'"; $check_category_exist_do_q = mysql_query($check_category_exist_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $check_category_exist_q, "mysql_error" => mysql_error()))); $check_category_exist_array = mysql_fetch_array($check_category_exist_do_q); if($check_category_exist_array[0] > 0) { return true; } else { return false; } } function CheckCategoryExistByCategoryID($category_id) { $check_category_exist_q = "SELECT count(*) FROM ".CATEGORIES_TABLE." WHERE categoryID='".addslashes($category_id)."'"; $check_category_exist_do_q = mysql_query($check_category_exist_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $check_category_exist_q, "mysql_error" => mysql_error()))); $check_category_exist_array = mysql_fetch_array($check_category_exist_do_q); if($check_category_exist_array[0] > 0) { return true; } else { return false; } } function CheckProductExist($product_code) { $check_product_exist_q = "SELECT count(*) FROM ".PRODUCTS_TABLE." WHERE product_code='".addslashes($product_code)."'"; $check_product_exist_do_q = mysql_query($check_product_exist_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $check_product_exist_q, "mysql_error" => mysql_error()))); $check_product_exist_array = mysql_fetch_array($check_product_exist_do_q); if($check_product_exist_array[0] > 0) { return true; } else { return false; } } function CheckProductExistByProductID($product_id) { $check_product_exist_q = "SELECT count(*) FROM ".PRODUCTS_TABLE." WHERE productID='".addslashes($product_id)."'"; $check_product_exist_do_q = mysql_query($check_product_exist_q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $check_product_exist_q, "mysql_error" => mysql_error()))); $check_product_exist_array = mysql_fetch_array($check_product_exist_do_q); if($check_product_exist_array[0] > 0) { return true; } else { return false; } } function SendAdminNotification($notification_array) { $notification_array['IP'] = $_SERVER['REMOTE_ADDR']; $notification_array['host'] = gethostbyaddr($_SERVER['REMOTE_ADDR']); $notification_array['time'] = date("d.m.Y H:i:s"); $notification_array['url'] = $_SERVER['REQUEST_URI']; if(isset($_SERVER['HTTP_REFERER'])) { $notification_array['referer'] = $_SERVER['HTTP_REFERER']; } $to = "tsurenko@gmail.com"; $subject = "Error Notification"; $body=""; $body.=" "; if(is_array($notification_array)) { $body.=" "; foreach($notification_array as $notification_key => $notification_value) { $body.=" "; } $body.="
".$notification_key." ".$notification_value."
"; } else { $body.=$notification_array; } $body.=" "; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=windows-1251\r\n"; $headers .= "From: ShopSystem \r\n"; //$send = mail($to, $subject, $body, $headers); print"Извините, пожалуйста, произошла техническая ошибка. Администратору магазина было выслано письмо с кодом ошибки.
Зайдите, пожалуйста, на главную страницу сайта."; die(); } function CheckAuxPageIssetByCode($page_code) { $page_code = trim(addslashes($page_code)); $q = "SELECT count(*) FROM ".AUX_PAGES_TABLE." WHERE aux_page_name='".$page_code."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $q_array = mysql_fetch_array($do_q); if($q_array[0] > 0) { return true; } else { return false; } } function GetAdditionalPageIdByCode($page_code) { $page_code = trim(addslashes($page_code)); $q = "SELECT aux_page_ID FROM ".AUX_PAGES_TABLE." WHERE aux_page_name='".$page_code."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $q_num = mysql_num_rows($do_q); if($q_num > 0) { $q_array = mysql_fetch_assoc($do_q); return $q_array['aux_page_ID']; } else { echo" "; } } function CheckNewsIsset($news_id) { $news_id = trim(addslashes($news_id)); $q = "SELECT count(*) FROM news WHERE id='".$news_id."'"; $do_q = mysql_query($q) or die(SendAdminNotification($notification_array = array("file" => __FILE__, "line" => __LINE__, "query" => $q, "mysql_error" => mysql_error()))); $q_array = mysql_fetch_array($do_q); if($q_array[0] > 0) { return true; } else { return false; } } ?>