Advertisement
johnburn

Untitled

May 11th, 2011
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.93 KB | None | 0 0
  1. <?php
  2. function get_category_path($categoryID, &$array_to_fill, &$manipulator) {
  3.     $data_temp = $manipulator->select("Category", "*", array("CategoryID" => $categoryID));
  4.     array_push($array_to_fill, $data_temp[0]);
  5.     if (intval($data_temp[0]["HeadCategoryID"]) > 0) {
  6.         get_category_path(intval($data_temp[0]["HeadCategoryID"]), $array_to_fill, $manipulator);
  7.     }
  8. }
  9. function get_sub_categories($categoryID, &$manipulator) {
  10.     $array_to_return = array();
  11.     $data_temp = $manipulator->select("Category", "*", array("HeadCategoryID" => $categoryID));
  12.     if (!empty($data_temp)) {
  13.         foreach($data_temp as $dat) array_push($array_to_return, $dat);
  14.     }
  15.     return $array_to_return;
  16. }
  17. function get_app_header(&$mainCategory) {
  18.     include ("theme/default/inc.header.php");
  19. }
  20. function get_app_media() {
  21.     echo base_url . "theme/default/images/";
  22. }
  23. function get_cat_icon($categoryID) {
  24.     $temp_src = base_url . "media/cls_cat_" . $categoryID . "_5520.jpg";
  25.     echo $temp_src;
  26.     if (file_exists($temp_src)) return "<img src='" . $temp_src . "' style='vertical-align: middle; position: relative; left: -5px;' border='0' vspace='1' />";
  27.     return "<img src='' alt='No Image' style='vertical-align: middle; position: relative; left: -5px;' border='0' vspace='1' />";
  28. }
  29. function get_menu() {
  30.     include ("theme/default/inc.menu.php");
  31. }
  32. function get_base_url() {
  33.     return base_url;
  34. }
  35. function get_listing_url($categoryID, $regionID) {
  36.     if (intval($categoryID) < 1) return base_url . "browse.php";
  37.     if (intval($categoryID) < 1) return base_url . "browse.php?regid=" . $regionID;
  38.     return base_url . "browse.php?catid=" . $categoryID;
  39. }
  40. function get_post_url() {
  41.     return base_url . "selectcat.php";
  42. }
  43. function get_detail_link($clsID) {
  44.     return base_url . "detail.php?clsid=" . $clsID;
  45. }
  46. function get_query_string_vars($exception = "") {
  47.     $str = "";
  48.     if (!empty($_GET)) {
  49.         foreach($_GET as $key => $val) if ($key != $exception) $str.= "&$key=$val";
  50.     }
  51.     return $str;
  52. }
  53. function get_sef_search_listing_url($url_string, $exception = "", $new_val = "") {
  54.     $str = "";
  55.     $found = 0;
  56.     if ($url_string != "") {
  57.         $var_params = explode("|", $url_string);
  58.         if (!empty($var_params)) foreach($var_params as $val) {
  59.             if ($val != "") {
  60.                 $var_temp = explode(":", $val);
  61.                 if ($var_temp[0] != $exception) {
  62.                     $str.= $var_temp[0] . ":" . $var_temp[1] . "|";
  63.                 } else {
  64.                     $found = 1;
  65.                     if ($new_val != "") {
  66.                         $str.= $new_val . "|";
  67.                     }
  68.                 }
  69.             }
  70.         }
  71.         if ($found == 0) $str.= $new_val;
  72.     } else {
  73.         $str = $new_val;
  74.     }
  75.     return $str;
  76. }
  77. function getDistance($a1, $b1, $a2, $b2) {
  78.     $r = 3963.1;
  79.     $pi = 3.14159265358979323846;
  80.     $a1 = $a1 * ($pi / 180);
  81.     $a2 = $a2 * ($pi / 180);
  82.     $b1 = $b1 * ($pi / 180);
  83.     $b2 = $b2 * ($pi / 180);
  84.     $ret = (acos(cos($a1) * cos($b1) * cos($a2) * cos($b2) + cos($a1) * sin($b1) * cos($a2) * sin($b2) + sin($a1) * sin($a2)) * $r);
  85.     return $ret;
  86. }
  87. function get_sef_url($entity_id, $entity_type) {
  88.     if (!$data) {
  89.         require_once ("classes/manipulate.php");
  90.         $data = new DataManipulator;
  91.     }
  92.     $entity = $data->select("SEF_URL", "*", array("EntityType" => $entity_type, "EntityID" => $entity_id));
  93.     return $entity[0]["URL"];
  94. }
  95. function generate_sef_url($entity_title, $entity_id, $entity_type) {
  96.     $data = new DataManipulator;
  97.     $entity_title = trim($entity_title);
  98.     $entity_title = str_replace(" ", "-", $entity_title);
  99.     $entity_title = str_replace("&", "", $entity_title);
  100.     $entity_title = str_replace("?", "", $entity_title);
  101.     $entity_title = str_replace("=", "", $entity_title);
  102.     $entity_title = str_replace(">", "", $entity_title);
  103.     $entity_title = str_replace(",", "", $entity_title);
  104.     $entity_title = str_replace("'", "", $entity_title);
  105.     $entity_title = str_replace("/", "", $entity_title);
  106.     $entity_title = str_replace("\\", "", $entity_title);
  107.     $entity_title = str_replace("--", "-", $entity_title);
  108.     $entity_title = str_replace("--", "-", $entity_title);
  109.     $entity_title = str_replace(":", "", $entity_title);
  110.     $entity = $data->select("SEF_URL", "*", array("URL" => $entity_title));
  111.     if (!empty($entity)) {
  112.         return generate_sef_url($entity_title . "-" . $entity_id, $entity_id, $entity_type);
  113.     } else {
  114.         return $data->insert("SEF_URL", array("EntityType" => $entity_type, "EntityID" => $entity_id, "URL" => $entity_title));
  115.     }
  116. }
  117. function re_generate_sef_url($entity_title, $entity_id, $entity_type) {
  118.     $data = new DataManipulator;
  119.     $entity_title = trim($entity_title);
  120.     $entity_title = str_replace(" ", "-", $entity_title);
  121.     $entity_title = str_replace("&", "", $entity_title);
  122.     $entity_title = str_replace("?", "", $entity_title);
  123.     $entity_title = str_replace("=", "", $entity_title);
  124.     $entity_title = str_replace(">", "", $entity_title);
  125.     $entity_title = str_replace(",", "", $entity_title);
  126.     $entity_title = str_replace("'", "", $entity_title);
  127.     $entity_title = str_replace("/", "", $entity_title);
  128.     $entity_title = str_replace("\\", "", $entity_title);
  129.     $entity_title = str_replace(":", "", $entity_title);
  130.     $entity = $data->select("SEF_URL", "*", array("EntityType" => $entity_type, "EntityID" => $entity_id));
  131.     if (!empty($entity)) {
  132.         return $data->update("SEF_URL", array("URL" => $entity_title), array("EntityType" => $entity_type, "EntityID" => $entity_id));
  133.     } else {
  134.         return generate_sef_url($entity_title, $entity_id, $entity_type);
  135.     }
  136. }
  137. function PPHttpPost($methodName_, $nvpStr_, $paymentParam) {
  138.     global $environment;
  139.     $API_UserName = $paymentParam["PayPalUserName"];
  140.     $API_Password = $paymentParam["PayPalPassword"];
  141.     $API_Signature = $paymentParam["PayPalSignature"];
  142.     $API_Endpoint = "https://api-3t.paypal.com/nvp";
  143.     if ("sandbox" === $environment || "beta-sandbox" === $environment) {
  144.         $API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
  145.     }
  146.     $version = urlencode('51.0');
  147.     $ch = curl_init();
  148.     curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
  149.     curl_setopt($ch, CURLOPT_VERBOSE, 1);
  150.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  151.     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  152.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  153.     curl_setopt($ch, CURLOPT_POST, 1);
  154.     $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
  155.     curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
  156.     $httpResponse = curl_exec($ch);
  157.     if (!$httpResponse) {
  158.         exit('$methodName_ failed: ' . curl_error($ch) . '(' . curl_errno($ch) . ')');
  159.     }
  160.     $httpResponseAr = explode("&", $httpResponse);
  161.     $httpParsedResponseAr = array();
  162.     foreach($httpResponseAr as $i => $value) {
  163.         $tmpAr = explode("=", $value);
  164.         if (sizeof($tmpAr) > 1) {
  165.             $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
  166.         }
  167.     }
  168.     if ((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
  169.         exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
  170.     }
  171.     return $httpParsedResponseAr;
  172. }
  173. function get_status_license() {
  174.     $output = 1;
  175.     $ch = curl_init("http://www.couponscript.org/admin/status.php?nurl=" . base_url);
  176.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  177.     curl_setopt($ch, CURLOPT_HEADER, 0);
  178.     $output = curl_exec($ch);
  179.     curl_close($ch);
  180.     if (strlen($output) > 3) $output = 1;
  181.     elseif ($output == "") $output = 1;
  182.     if (intval($output) == 0) {
  183.         exit("You using invalid or expired license contact us at <a href='http://www.couponscript.org'>http://www.couponscript.org</a> . and get valid license , Your database and website is safe.");
  184.     }
  185. }
  186. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement