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

📄 includes.php

📁 一个好用的php wap cms portal
💻 PHP
字号:
<?php
/********************************************************************************/ 
/*  Wap-2-Go Mobile Phone Nuke-Addon                                            */
/*          bringing the Advanced Content Management System to Mobile Format    */
/*  =========================================================================== */
/*                                              powered by Nuke SQL Database    */
/*                                                                              */
/* Copyright (c) 2007 by Philip Marsh   -   http://www.wap2go.co.uk             */
/*                                                                              */
/*  Main Functions File - commonly used functions sitewide                      */
/*                                                                              */
/********************************************************************************/ 
//function getuserinfo(username) {
//                               }
function doPageNavigation()
                        {
                        global $moduletitle,$start,$increment,$totalresults,$query,$lang;
                        if (file_exists("".NUKEDIR."/modules/Content/language/lang-".$lang.".php")) { include("".NUKEDIR."/modules/Content/language/lang-".$lang.".php"); }
                        if (!$start)     { $start = 0; }
                        if (!$limit)     { $limit = 5; }
                        if (!$increment) { $increment = 5; }
                        $prev       = $start-$increment; if ($prev<0) { $prev=0; }
                        $next       = $start+$increment;
                        if ($totalresults > $increment)
                           {
                           if ($totalresults) { $numpages  = $totalresults/$increment; if ($next>$totalresults) { $next = $totalresults; } }
                           $content = "\n      <p align=\"center\">\n        ";
                           if ($start>0)   {   $content    .= "<b>&lt; <a href=\"w2g_modules.php?name=".$moduletitle."";
                                               if ($query) { $content .= $query; }
                                               $content    .= "&amp;start=".$prev."\" title=\""._PREVIOUS."\">"._PREVIOUS."</a></b>";  }
                           if ($numpages>1)
                                  {
                                  for ($i=0;$i<$numpages;$i++)
                                      {   $pagestart = ($i)*$increment;
                                          $currentpage = ($start/$increment);
                                          $p = $i+1;
                                          $content .=  " | ";
                                          if ($i==$currentpage) { $content .= "<b>"; }
                                          $content    .= "<a href=\"w2g_modules.php?name=".$moduletitle."".$query."&amp;start=".$pagestart."\" title=\""._PAGE." ".$p."\">".$p."</a>";
                                          if ($i==$currentpage) { $content .= "</b>"; }  }
                                  }
                           if ($numpages>1) { $content .= " | "; }
                           if ($totalresults>$start+$increment)
                                         { $content .= "<b><a href=\"w2g_modules.php?name=".$moduletitle.$query."&amp;start=".$next."\" title=\""._NEXT."\">"._NEXT."</a> &gt;</b>";}
                           $content .= "\n      </p>";
                           }
                        $content = char_dec($content);
                        if ($htm==1) { $content = "\n  <div id=\"Navigation\">".char_dec($content)."\n  </div>"; }
                        echo $content;
                        }

function make_clickable($text) {
/* This function will check all links within a string and detect local nuke
links and reformat them accordingly for Wap-2-Go (Mobile Users) */
  global $nukeurl, $w2g_url;

  // pad it with a space so we can match things at the start of the 1st line.
  $ret = ' ' . $text;

  // Check for $nukeurl in URLs and replace with appropriate Wap-2-Go URL
  $nukeurl_friendly = str_replace("http://", "", $nukeurl);
  $w2g_url_friendly = dirname($_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]);
  $ret = preg_replace("#(^|[\n ])".$nukeurl_friendly."/modules.php#is", "\\1".$w2g_url_friendly."/w2g_modules.php", $ret);
  $ret = preg_replace("#(^|[\n ])http://".$nukeurl_friendly."/modules.php#is", "\\1http://".$w2g_url_friendly."/w2g_modules.php", $ret);
  $ret = preg_replace("#(^|[\n ])<a href=\"http://".$nukeurl_friendly."/modules.php(.*?)\">(.*?)</a>#is", "\\1<a href=\"http://".$w2g_url_friendly."/w2g_modules.php\\2\">\\3</a>", $ret);
  $ret = preg_replace("#(^|[\n ])<a href=\"http://".$nukeurl_friendly."\">(.*?)</a>#is", "\\1<a href=\"http://".$w2g_url_friendly."\">\\2</a>", $ret);

  // matches an "xxxx://yyyy" URL at the start of a line, or after a space.
  // xxxx can only be alpha characters.
  // yyyy is anything up to the first space, newline, comma, double quote or <
  $ret = preg_replace("#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\">\\2</a>", $ret);

  // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
  // Must contain at least 2 dots. xxxx contains either alphanum, or "-"
  // zzzz is optional.. will contain everything up to the first space, newline, 
  // comma, double quote or <.
  $ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#is", "\\1<a href=\"http://\\2\">\\2</a>", $ret);

  // matches an email@domain type address at the start of a line, or after a space.
  // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
  $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);

  // Remove our padding..
  $ret = substr($ret, 1);

  return($ret);
}

function doimage($url, $alt, $x = null) {
  global $w2g_url, $imgtype, $jpeg_img_qual, $usergfxpref, $htm, $w2g_image_cache, $w2gfurl, $domain;
  if ($x==null)       {   if ($usergfxpref>1) { $x = trim($usergfxpref); }
                          else { $x = 0; } }
  if ($url)
     {
     $url = trim($url);
     $img_loc_info = explode('/', $url);
     $c            = count($img_loc_info);
     $filedomain = $img_loc_info[2];
     $filename   = $img_loc_info[$c-1];

     if (!$x) { $x = $usergfxpref; }
     if (!$alt) { $alt = $filename; }
     $imgname = explode(".",$filename);
     $imgname = $imgname[0];

     if ($imgtype==1) { $filetype = ".gif"; }
     if ($imgtype==2) { $filetype = ".jpg"; }
     if ($imgtype==3) { $filetype = ".png"; }

     $image_info = @getimagesize($url);
     if ($x > $image_info[0]) { $x = $image_info[0]; }
     if ($image_info) { $img_height = ($image_info[1]/$image_info[0])*$x; }

     $x = round($x,0);
     $img_height = round($img_height,0);

     $imgcachefilename = trim($x);
     if ($imgtype==2) { $imgcachefilename .= "_".trim($jpeg_img_qual).""; }
     if ($c>=3) { for ($i=3; $i<$c-1; $i++) { $imgcachefilename .= "_".trim($img_loc_info[$i]).""; } }
     $imgcachefilename = trim($imgcachefilename."_".trim($imgname)."".trim($filetype)."");
     $imgcachedurl = trim($w2g_url."/includes/cache/".$imgcachefilename);

     $resizetags = "&amp;x=".trim($x)."&amp;t=".trim($imgtype)."";
     if ($imgtype==2) { $resizetags .= "&amp;q=".trim($jpeg_img_qual).""; }

     if ($x>0) {
                if ((!strpos($domain,$filedomain)) OR (!strpos($filedomain,$domain)))
                                           { $create_cache = 1;
                                             if (file_exists("includes/cache/".$imgcachefilename."")) { $cached = 1; }
                                           } // Calculate if image from own servers, if so set create_cache to ON (1)
                if ($cached)
                     { $image = "<img src=\"".$imgcachedurl."\"";
                       $image .= " alt=\"".$alt."\"";
                       if ($htm==1) { $image .= " height=\"".$img_height."\" width=\"".$x."\""; }
                       $image .= "></img>";
                } else if ($w2g_image_cache==1 AND $create_cache==1 AND (!$cached))
                     {
                       include("".$w2g_url."/includes/w2g_thumbs.php?src=".$url."&x=".$x."&t=".$imgtype."&q=".$jpeg_img_qual."&f=1&dest=".$imgcachefilename."");
                       if (file_exists("".$w2g_url."/includes/cache/".$imgcachefilename.""))
                            { $image = "<img src=\"".$imgcachedurl."\"";
                              $image .= " alt=\"".$alt."\"";
                              if ($htm==1) { $image .= " height=\"".$img_height."\" width=\"".$x."\""; }
                              $image .= "></img>";
                            } else {
                              $image = "<img src=\"".$w2g_url."/includes/w2g_thumbs.php?src=".$url.$resizetags."&amp;f=0\"";
                              $image .= " alt=\"".$alt."\"";
                              if ($htm==1) { $image .= " height=\"".$img_height."\" width=\"".$x."\""; }
                              $image .= "></img>";
                            }
                } else {
                       $image = "<img src=\"".$w2g_url."/includes/w2g_thumbs.php?src=".$url.$resizetags."&amp;f=0\"";
                       $image .= " alt=\"".$alt."\"";
                       if ($htm==1) { $image .= " height=\"".$img_height."\" width=\"".$x."\""; }
                       $image .= "></img>";
                }
     } else {
            $image = "".$alt."";
            }
     }
  return $image;
}
function doicon($url, $alt, $x = null) {
  global $iconwidth, $usergfxpref;
  if ($x==null) {   $x = $usergfxpref*$iconwidth; }
  $image = doimage($url, $alt, $x);
  return $image;
}
?>

⌨️ 快捷键说明

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