"Fossies" - the Fresh Open Source Software Archive

Member "3.2.11/src/common.inc" (17 Jul 2005, 4274 Bytes) of package /linux/www/old/mnogosearch-php-3.2.11.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) fasm source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "common.inc" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 // -----------------------------------------------
    4 // exit_local()
    5 // -----------------------------------------------
    6 function exit_local($print_err = 1) {
    7     drop_temp_table($print_err);
    8     exit;
    9 }
   10 
   11 // -----------------------------------------------
   12 // print_error_local($str)
   13 // -----------------------------------------------
   14 function print_error_local($str){
   15     global $error;
   16     
   17     $error=$str;
   18 
   19     print_template('error');
   20     print_template('bottom');
   21     
   22     exit;
   23 }
   24 
   25 // -----------------------------------------------
   26 // get_doc_count()
   27 // -----------------------------------------------
   28 function get_doc_count() {
   29     global $udm_agent;
   30 
   31     if (Udm_Api_Version() >= 30111) {
   32     return(Udm_Get_Doc_Count($udm_agent));
   33     } else {
   34         return "Unknown";
   35     } 
   36 } 
   37 
   38 
   39 // -----------------------------------------------
   40 // format_lastmod($lastmod)
   41 // -----------------------------------------------
   42 function format_lastmod($lastmod) {
   43     $temp=$lastmod;
   44     if (!$temp) $temp = 'undefined';
   45     elseif (Udm_Api_Version() < 30204) $temp = strftime('%a, %d %b %Y %H:%M:%S %Z',$temp);
   46 
   47     return $temp;
   48 }
   49 
   50 // -----------------------------------------------
   51 // format_dp($dp)
   52 // -----------------------------------------------
   53 function format_dp($dp) {
   54     $result=0;
   55 
   56     while ($dp != '') {     
   57         if (preg_match('/^([\-\+]?\d+)([sMhdmy]?)/',$dp,$param)) {          
   58             switch ($param[2]) {
   59                 case 's':  $multiplier=1; break;
   60                                 case 'M':  $multiplier=60; break;
   61                                 case 'h':  $multiplier=3600; break;
   62                                 case 'd':  $multiplier=3600*24; break;
   63                                 case 'm':  $multiplier=3600*24*31; break;
   64                                 case 'y':  $multiplier=3600*24*365; break;
   65                 default: $multiplier=1;
   66             }
   67 
   68             $result += $param[1]*$multiplier;
   69                         $dp=preg_replace("/^[\-\+]?\d+$param[2]/",'',$dp);
   70         } else {
   71             return 0;
   72         }
   73     }
   74 
   75     return $result;
   76 }
   77 
   78 // -----------------------------------------------
   79 // format_userdate($date)
   80 // -----------------------------------------------
   81 function format_userdate($date) {
   82     $result=0;
   83 
   84     if (preg_match('/^(\d+)\/(\d+)\/(\d+)$/',$date,$param)) {
   85         $day=$param[1];
   86         $mon=$param[2];
   87         $year=$param[3];
   88 
   89         $result=mktime(0,0,0,$mon,$day,$year);
   90     }
   91 
   92     return $result;
   93 }
   94 
   95 // -----------------------------------------------
   96 // ParseDocText($text)
   97 // -----------------------------------------------
   98 function ParseDocText($text){
   99     global $all_words;
  100     global $hlbeg, $hlend;
  101        
  102     $str=$text;
  103 
  104     if (Udm_Api_Version() < 30200) {
  105         for ($i=0; $i<count($all_words); $i+=1) {
  106         $word=$all_words[$i];
  107         $str = preg_replace("/([\s\t\r\n\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\\\|\{\}\[\]\;\:\'\"\<\>\?\/\,\.]+)($word)/i","\\1$hlbeg\\2$hlend",$str);
  108         $str = preg_replace("/^($word)/i","$hlbeg\\1$hlend",$str);
  109         }
  110     } else {
  111         $str = str_replace("\2",$hlbeg,$str);
  112         $str = str_replace("\3",$hlend,$str);
  113     while (substr_count($str,$hlbeg) > substr_count($str,$hlend)) {
  114         $str.=$hlend;
  115     }
  116     }
  117 
  118     return $str;
  119 }
  120 
  121 // -------------------------------------
  122 // ParseQString
  123 // -------------------------------------
  124 function ParseQString() {
  125     global $QUERY_STRING;
  126     global $ul, $ul_arr;
  127     global $tag, $tag_arr;
  128     global $cat, $cat_arr;
  129     global $lang, $lang_arr;
  130     global $type, $type_arr;
  131     
  132     $pairs = explode("&", $QUERY_STRING);
  133     $ul_arr = array();
  134     $tag_arr = array();
  135     $cat_arr = array();
  136     $lang_arr = array();
  137     $type_arr = array();
  138     
  139     for($i=0; $i<count($pairs); $i+=1) {
  140     $pairs[$i]=str_replace('+',' ',$pairs[$i]);
  141     list($name, $value) = explode("=",$pairs[$i]);
  142     if ($name=='ul') {
  143         $ul_arr[]=urldecode($value);
  144         if (!count($ul_arr)) $ul=urldecode($value);
  145     } elseif ($name=='tag') {
  146         $tag_arr[]=urldecode($value);
  147         if (!count($tag_arr)) $tag=urldecode($value);
  148     } elseif ($name=='cat') {
  149         $cat_arr[]=urldecode($value);
  150         if (!count($cat_arr)) $cat=urldecode($value);
  151     } elseif ($name=='lang') {
  152         $lang_arr[]=urldecode($value);
  153         if (!count($lang_arr)) $lang=urldecode($value);
  154     } elseif ($name=='type') {
  155         $type_arr[]=urldecode($value);
  156         if (!count($type_arr)) $type=urldecode($value);
  157     } else continue;
  158     }
  159 }
  160 
  161 ?>