function ShowAddBannedIp() { global $banned, $error_list_banned_single_ip, $error_list_banned_range_ip, $ip_a, $ip_b, $ip_c, $ip_d, $ip_start_a, $ip_start_b, $ip_start_c, $ip_start_d, $ip_end_a, $ip_end_b, $ip_end_c, $ip_end_d; $process = $_REQUEST['process']; if ($process == "add_banned_single_ip") { $i = 0; $ip_a = $_REQUEST['ip_a']; $ip_b = $_REQUEST['ip_b']; $ip_c = $_REQUEST['ip_c']; $ip_d = $_REQUEST['ip_d']; if (!IsDigit($ip_a) || !IsDigit($ip_b) || !IsDigit($ip_c) || !IsDigit($ip_d)) { $error_list_banned_single_ip[$i] = "Ip must be digit"; $i++; } elseif ($ip_a >= 256 || $ip_b >= 256 || $ip_c >= 256 || $ip_d >= 256) { $error_list_banned_single_ip[$i] = "Ip is not valid"; $i++; } elseif ($banned->CheckBannedIp($ip_a . "." . $ip_b . "." . $ip_c . "." . $ip_d, $ip_a . "." . $ip_b . "." . $ip_c . "." . $ip_d)) { $error_list_banned_single_ip[$i] = "This Banned ip is already exist"; $i++; } if (!is_array($error_list_banned_single_ip)) { $ip_address_start = $ip_a . "." . $ip_b . "." . $ip_c . "." . $ip_d; $ip_address_end = $ip_a . "." . $ip_b . "." . $ip_c . "." . $ip_d; $ip_number_start = $banned->GetIpNumber($ip_address_start); $ip_number_end = $banned->GetIpNumber($ip_address_end); $banned->AddBannedIp($ip_address_start, $ip_address_end, $ip_number_start, $ip_number_end); header("Location: banned.php?pf=ip"); } } elseif ($process == "add_banned_range_ip") { $i = 0; $ip_start_a = $_REQUEST['ip_start_a']; $ip_start_b = $_REQUEST['ip_start_b']; $ip_start_c = $_REQUEST['ip_start_c']; $ip_start_d = $_REQUEST['ip_start_d']; $ip_end_a = $_REQUEST['ip_end_a']; $ip_end_b = $_REQUEST['ip_end_b']; $ip_end_c = $_REQUEST['ip_end_c']; $ip_end_d = $_REQUEST['ip_end_d']; if (!IsDigit($ip_start_a) || !IsDigit($ip_start_b) || !IsDigit($ip_start_c) || !IsDigit($ip_start_d) || !IsDigit($ip_end_a) || !IsDigit($ip_end_b) || !IsDigit($ip_end_c) || !IsDigit($ip_end_d)) { $error_list_banned_range_ip[$i] = "Ip must be digit"; $i++; } elseif ($ip_start_a >= 256 || $ip_start_b >= 256 || $ip_start_c >= 256 || $ip_start_d >= 256 || $ip_end_a >= 256 || $ip_end_b >= 256 || $ip_end_c >= 256 || $ip_end_d >= 256) { $error_list_banned_range_ip[$i] = "Ip is not valid"; $i++; } elseif ($banned->GetIpNumber($ip_start_a . "." . $ip_start_b . "." . $ip_start_c . "." . $ip_start_d) > $banned->GetIpNumber($ip_end_a . "." . $ip_end_b . "." . $ip_end_c . "." . $ip_end_d)) { $error_list_banned_range_ip[$i] = "Ip address start must be large than Ip address end"; $i++; } elseif ($banned->CheckBannedIp($ip_start_a . "." . $ip_start_b . "." . $ip_start_c . "." . $ip_start_d, $ip_end_a . "." . $ip_end_b . "." . $ip_end_c . "." . $ip_end_d)) { $error_list_banned_range_ip[$i] = "This Banned ip is already exist"; $i++; } if (!is_array($error_list_banned_range_ip)) { $ip_address_start = $ip_start_a . "." . $ip_start_b . "." . $ip_start_c . "." . $ip_start_d; $ip_address_end = $ip_end_a . "." . $ip_end_b . "." . $ip_end_c . "." . $ip_end_d; $ip_number_start = $banned->GetIpNumber($ip_address_start); $ip_number_end = $banned->GetIpNumber($ip_address_end); $banned->AddBannedIp($ip_address_start, $ip_address_end, $ip_number_start, $ip_number_end); header("Location: banned.php?pf=ip"); } } }
function ShowConfig() { global $tpl, $pf, $error_list, $site_name, $site_url, $site_mail, $protect_path, $protect_url, $notify_email, $notify_from, $notify_expire, $success; $pf = $_REQUEST['pf']; $process = $_REQUEST['process']; if ($process == 'edit') { $site_name = stripslashes($_REQUEST['site_name']); $site_mail = stripslashes($_REQUEST['site_mail']); $protect_path = stripslashes($_REQUEST['protect_path']); $protect_url = stripslashes($_REQUEST['protect_url']); $notify_email = stripslashes($_REQUEST['notify_email']); $notify_from = stripslashes($_REQUEST['notify_from']); $notify_expire = stripslashes($_REQUEST['notify_expire']); $i = 0; if ($site_name == "" || $site_mail == "" || $protect_path == "" || $protect_url == "" || $notify_email == "" || $notify_from == "") { if ($site_name == "") { $error_list[$i] = "Site name is required"; $i++; } if ($site_mail == "") { $error_list[$i] = "Site email is required"; $i++; } if ($protect_path == "") { $error_list[$i] = "Protected path is required"; $i++; } if ($protect_url == "") { $error_list[$i] = "Protected url is required"; $i++; } if ($notify_from == "") { $error_list[$i] = "Notify from is required"; $i++; } if ($notify_email == "") { $error_list[$i] = "Notify email is required"; $i++; } } elseif (!IsDigit($notify_expire)) { $error_list[$i] = "Notify expire must be digit"; $i++; } elseif (!IsEmailAddress($site_mail)) { $error_list[$i] = "Site email is not valid format"; $i++; } elseif (!IsEmailAddress($notify_email)) { $error_list[$i] = "Notify email is not valid format"; $i++; } if (!is_array($error_list)) { UpdateConfig($site_name, "site_name"); UpdateConfig($site_mail, "site_mail"); UpdateConfig($protect_path, "protect_path"); UpdateConfig($protect_url, "protect_url"); UpdateConfig($notify_email, "notify_email"); UpdateConfig($notify_from, "notify_from"); UpdateConfig($notify_expire, "notify_expire"); $success = true; } } else { $site_name = CFG_SITE_NAME; $site_mail = CFG_SITE_MAIL; $protect_path = CFG_PROTECT_PATH; $protect_url = CFG_PROTECT_URL; $notify_email = CFG_NOTIFY_EMAIL; $notify_from = CFG_NOTIFY_FROM; $notify_expire = CFG_NOTIFY_EXPIRE; } }
function ShowDetailProduct() { global $tpl, $product, $product_id, $name, $description, $price, $duration, $duration_unit, $path, $url, $success, $error_list; $product_id = $_REQUEST['product_id']; $process = $_REQUEST['process']; $product_data = $product->GetProduct($product_id); if ($process == 'edit') { $product_id = $_REQUEST['product_id']; $name = stripslashes($_REQUEST['name']); $description = stripslashes($_REQUEST['description']); $price = $_REQUEST['price']; $duration = $_REQUEST['duration']; $duration_unit = $_REQUEST['duration_unit']; $path = stripslashes($_REQUEST['path']); $url = stripslashes($_REQUEST['url']); $i = 0; if ($name == "" || $description == "" || $price == "" || $duration == "" || $path == "" || $url == "") { if ($name == "") { $error_list[$i] = "Name is required"; $i++; } if ($description == "") { $error_list[$i] = "Description is required"; $i++; } if ($price == "") { $error_list[$i] = "Price password is required"; $i++; } if ($duration == "") { $error_list[$i] = "Duration is required"; $i++; } if ($path == "") { $error_list[$i] = "Path is required"; $i++; } if ($url == "") { $error_list[$i] = "Url is required"; $i++; } } elseif (strtolower($name) != strtolower($product_data['name'])) { if ($product->CheckProductName($name)) { $error_list[$i] = "Product name is already exist"; $i++; } } elseif (!IsDigit($duration)) { $error_list[$i] = "Duration must be digit"; $i++; } if (!is_array($error_list)) { $path = strtolower($path); $url = strtolower($url); $product->Update($product_id, $name, $description, $price, $duration, $duration_unit, $path, $url); UpdateHtaccess($path, $product_data['path']); $success = true; } } else { $product_id = $product_data['product_id']; $name = $product_data['name']; $description = $product_data['description']; $price = $product_data['price']; $duration = $product_data['duration']; $duration_unit = $product_data['duration_unit']; $path = $product_data['path']; $url = $product_data['url']; } }
function EditCoupon() { global $coupon, $tpl, $coupon_id, $coupon_code, $coupon_value, $coupon_value_type, $percentage_coupon_value, $price_coupon_value, $month_start_date, $day_start_date, $year_start_date, $month_expire_date, $day_expire_date, $year_expire_date, $expire_usage, $error_list, $success; $coupon_id = $_REQUEST['id']; $coupon_detail_data = $coupon->GetCouponDetail($coupon_id); $process = $_REQUEST['process']; $i = 0; if ($process == "edit") { $coupon_code = $_REQUEST['coupon_code']; $coupon_value_type = $_REQUEST['coupon_value_type']; $percentage_coupon_value = $_REQUEST['percentage_coupon_value']; $price_coupon_value = $_REQUEST['price_coupon_value']; $month_start_date = $_REQUEST['month_start_date']; $year_start_date = $_REQUEST['year_start_date']; $day_start_date = $_REQUEST['day_start_date']; $month_expire_date = $_REQUEST['month_expire_date']; $day_expire_date = $_REQUEST['day_expire_date']; $year_expire_date = $_REQUEST['year_expire_date']; $expire_usage = $_REQUEST['expire_usage']; $start_date = mktime(23, 59, 59, $month_start_date, $day_start_date, $year_start_date); $expire_date = mktime(23, 59, 59, $month_expire_date, $day_expire_date, $year_expire_date); $i = 0; if ($coupon_code == "" || $coupon_value_type == "") { if ($coupon_code == "") { $error_list[$i] = "Coupon code required"; $i++; } if ($coupon_value_type == "") { $error_list[$i] = "Please checked coupon type option"; $i++; } } elseif ($coupon_value_type == "price") { $coupon_value = $price_coupon_value; if ($coupon_value == "") { $error_list[$i] = "Coupon value Price is required"; $i++; } elseif (!IsDigit($coupon_value)) { $error_list[$i] = "Coupon value Price must be digit value"; $i++; } } elseif ($coupon_value_type == "percentage") { $coupon_value = $percentage_coupon_value; if ($coupon_value == "") { $error_list[$i] = "Coupon value percentage is required"; $i++; } elseif ($coupon_value > 100) { $error_list[$i] = "Coupon value percentage max 100"; $i++; } elseif (!IsDigit($coupon_value)) { $error_list[$i] = "Coupon value percentage must be digit value"; $i++; } else { $coupon_value = $coupon_value . "%"; } } if ($start_date >= $expire_date) { $error_list[$i] = "Start Date must be less than expire date"; } if ($expire_usage != "" && !IsDigit($expire_usage)) { $error_list[$i] = "Expire usage must be digit"; $i++; } elseif ($expire_usage < $coupon_detail_data['usage_count'] && ($expire_usage != "" && $expire_usage != "0")) { $error_list[$i] = "Expire usage invalid<br> because this coupon was be used " . $coupon_detail_data['usage_count'] . " of"; $i++; } if ($coupon_code != $coupon_detail_data['coupon_code']) { if ($coupon->CheckCouponCode($coupon_code)) { $error_list[$i] = "Coupon code already exist"; $i++; } } if (!is_array($error_list)) { if ($coupon_detail_data['coupon_value'] != $coupon_value) { if (!$coupon->CouponValueIsValid($coupon_id, $coupon_value)) { $error_list[$i] = "Price value is outsize. <br> a product using this coupon has net price less than zero"; $i++; } } if (!is_array($error_list)) { if ($expire_usage == "") { $expire_usage_ = 0; } else { $expire_usage_ = $expire_usage; } $coupon->Edit($coupon_id, $coupon_code, $coupon_value, $start_date, $expire_date, $expire_usage_); $success = true; } } } else { $coupon_code = $coupon_detail_data['coupon_code']; $percentage = strrpos($coupon_detail_data['coupon_value'], "%"); if ($percentage) { $percent = str_replace("%", "", $coupon_detail_data['coupon_value']); $coupon_value_type = "percentage"; $percentage_coupon_value = $percent; } else { $coupon_value_type = "price"; $price_coupon_value = $coupon_detail_data['coupon_value']; } $month_start_date = date("n", $coupon_detail_data['start_date']); $day_start_date = date("j", $coupon_detail_data['start_date']); $year_start_date = date("Y", $coupon_detail_data['start_date']); $month_expire_date = date("n", $coupon_detail_data['expire_date']); $day_expire_date = date("j", $coupon_detail_data['expire_date']); $year_expire_date = date("Y", $coupon_detail_data['expire_date']); if ($coupon_detail_data['expire_usage'] == 0) { $expire_usage = ''; } else { $expire_usage = $coupon_detail_data['expire_usage']; } } }