凉风有信,秋月无边
亏我思娇的情绪、好比度日如年

技术笔记 第5页

记录一些我自己使用过的东西,备忘用!

帝国cms调用自定义字段php代码

比较实用,可以调用数据库里的所有图片字段内容 <?php require('../e/class/connect.php'); //引入数据库配置文件和公共函数文件 require('../e/class/db_sql.php'); //引入数据库操作文件 require('../e/data/dbcache/class.php'); //引入栏目缓存文件 $link=db_connect(); //连接MYSQL $empire=new mysqlquery(); //声明数据库操作类 $editor=1; //声明目录层次 $sql=$empire->query("select * from {$dbtbpre}ecms_shop order by newstime limit 1000"); //查询新闻表最新10条记录 $totalquery="select count(*) as total from {$dbtbpre}ecms_shop"; $num=$empire->gettotal($totalquery); $i=1; ?> <?=$num?><br /> <?php while($r=$empire->fetch($sql)) //循环获取查询记录 { ?> <?=$r[titlepic]?>-----[id]<?=$r[id]?>---[classid]<?=$r[classid]?>---<?=$i++?><br/> <?php } ?> <?php db_close(); //关闭MYSQL链接 $empire=null; //注消操作类变量 ?>  

赞(0)villainvillain阅读(46)去评论

帝国cms模板中使用PHP实现随机字符的方法

做站的站长很多时候买个模板就直接用,对于模板的一些小优化这类知道的很少,下面来说说如何在模板中使用随机字符来提供模板的唯一性和原创程序。 方法1: 第一种方法是最容易理解的方法。它可以实现如下: 将所有可能的字母存储到字符串中,生成从0到字符串长度-1的随机索引,打印该索引处的字母,执行此步骤n次(其中n是所需字符串的长度)。 程序代码如下: <?php $n=10;function getName($n) {     $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';     $randomString = '';         for ($i = 0; $i < $n; $i++) {         $index = rand(0, strlen($characters) - 1);         $randomString .= $characters[$index];     }         return $randomString; }     echo getName($n);?> 说明这里面最开始的10是字符的长度,可以随意修改。 方法2: 使用uniqid()函数。PHP中的uniqid()函数是一个内置函数,用于根据当前时间(微秒)生成唯一ID。默认情况下,它返回一个13个字符长的唯一字符串。 一次生成13个不一样的字符,减少重复。根据时间来的。 程序: <?php $result = uniqid(); echo $result; ?> 一般模板中直接插入这两段代码就可以直接用了,非常的简便 。 以上就是在帝国cms模板中插入随机字符的方法和代码实例了。

赞(0)villainvillain阅读(35)去评论

帝国cms模板内容页用到的if判断语句

判断代码如下 <?php   if($navinfor[xb]==帅哥)   { ?><DIV class="xbox nan"> <? } else { echo "<DIV class=xbox>"; }   ?>     <?php if($navinfor['titlepic']) { ?> <a href='[!--titlepic--]' target='_blank'><img src='[!--titlepic--]' /></a> <? } else { ?>   <? } ?> 亲测有效!!

赞(0)villainvillain阅读(36)去评论
Navicat已经成功连接,忘记密码的解决方法-Villain博客

Navicat已经成功连接,忘记密码的解决方法

去到对应的注册表 查找Navicat的密码保存位置 去到对应的路径下面 计算机\HKEY_CURRENT_USER\Software\PremiumSoft 可以看到 打开对应的目录,寻找一下servers下要找的数据库,如我要找阿里云的密码 寻找pwd找出来,复制数据     去到 https://tool.lu/coderunner/ 复制黏贴一下php解密的代码 <?php namespace FatSmallTools; class NavicatPassword {     protected $version = 0;     protected $aesKey = 'libcckeylibcckey';     protected $aesIv = 'libcciv libcciv ';     protected $blowString = '3DC5CA39';     protected $blowKey = null;     protected $blowIv = null;     public function __construct($version = 12)     {         $this->version = $version;         $this->blowKey = sha1('3DC5CA39', true);         $this->blowIv = hex2bin('d9c7c3c8870d64bd');     }     public function encrypt($string)     {         $result = FALSE;         switch ($this->version) {             case 11:                 $result = $this->encryptEleven($string);                 break;             case 12:                 $result = $this->encryptTwelve($string);                 break;             default:                 break;         }         return $result;     }     protected function encryptEleven($string)     {         $round = intval(floor(strlen($string) / 8));         $leftLength = strlen($string) % 8;         $result = '';         $currentVector = $this->blowIv;         for ($i = 0; $i < $round; $i++) {             $temp = $this->encryptBlock($this->xorBytes(substr($string, 8 * $i, 8), $currentVector));             $currentVector = $this->xorBytes($currentVector, $temp);             $result .= $temp;         }         if ($leftLength) {             $currentVector = $this->encryptBlock($currentVector);             $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);         }         return strtoupper(bin2hex($result));     }     protected function encryptBlock($block)     {         return openssl_encrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);      }     protected function decryptBlock($block)     {         return openssl_decrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);      }     protected function xorBytes($str1, $str2)     {         $result = '';         for ($i = 0; $i < strlen($str1); $i++) {             $result .= chr(ord($str1[$i]) ^ ord($str2[$i]));         }         return $result;     }     protected function encryptTwelve($string)     {         $result = openssl_encrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);         return strtoupper(bin2hex($result));     }          public function decrypt($string)     {         $result = FALSE;         switch ($this->version) {             case 11:                 $result = $this->decryptEleven($string);                 break;             case 12:                 $result = $this->decryptTwelve($string);                 break;             default:                 break;         }         return $result;     }          protected function decryptEleven($upperString)     {         $string = hex2bin(strtolower($upperString));         $round = intval(floor(strlen($string) / 8));         $leftLength = strlen($string) % 8;         $result = '';         $currentVector = $this->blowIv;         for ($i = 0; $i < $round; $i++) {             $encryptedBlock = substr($string, 8 * $i, 8);             $temp = $this->xorBytes($this->decryptBlock($encryptedBlock), $currentVector);             $currentVector = $this->xorBytes($currentVector, $encryptedBlock);             $result .= $temp;         }         if ($leftLength) {             $currentVector = $this->encryptBlock($currentVector);             $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);         }         return $result;     }          protected function decryptTwelve($upperString)     {...

赞(0)villainvillain阅读(38)去评论

wordpress所有文章批量改为已发布状态

用wordpress建站的一个好处就是bd站长工具平台上有数据结构插件,可以认为bd默认支持wp发展,另外一种建站程序是discuz。我们在用wordpress发布文章时,特别是那种多用户投稿的文章一般都会设置发布状态为“等待审核”,如果你对他们之前的文章比较认可的话可以直接通过。一篇篇在后台通过审核会累趴的,那么如何将wordpress所有文章批量改为已发布状态呢?一个简单的sql语句就能搞定。 UPDATE `wp_posts`  SET `post_status` ='publish' WHERE (`post_status`='pending'); 我们提倡文章的原创,但如果你只是想多做点流量挂点广告,那采集是必不可少的,不过要进行加工噢!关于wordpress批量更新文章有很多种方法 UPDATE `wp_posts` SET `post_status` =’draft’ WHERE (`post_status`=’publish’);

赞(0)villainvillain阅读(38)去评论

帝国CMS自动定时审核发布插件+教程

我的站有大量采集信息,一次发布不利于长期SEO,所以从网上找了这个脚本稍作修改。分享给大家,其实也很简单,但比帝国自带的计划任务功能好的是,不用开启后台才运行,脚本放到服务器上后加入服务器的计划任务便可以每天定时审核发布信息。 <?php//使用密码控制if(empty($_GET['pwd']) || $_GET['pwd'] != '脚本运行密码,请自行修改'){        die('Fuck you! -www.lwtz.cn!');}define ( 'EmpireCMSAdmin', '1' );require ("../class/connect.php");require ("../class/db_sql.php");require ("../class/functions.php");require ("../class/t_functions.php");require ("../data/dbcache/class.php");require ("../data/dbcache/MemberLevel.php");$link = db_connect ();$empire = new mysqlquery ();$enews = $_POST ['enews'];if (empty ( $enews )) {        $enews = $_GET ['enews'];}//参数$news_table = "news";        //新闻表$news_num = 1;                        //每次审核条数/** *使用时间控制审核的栏目,下面的代码因为栏目太多,每天分三个时段更新 *实验证明这个效果是不好的,收录只有早上的那次 * $hours = date ( 'H' ); switch($hours){          //频道和列表          case '8': $where = "bclassid = 0 or classid between 33 and 86";          break;          case '13': $where = "bclassid = 0 or classid between 87 and 139";          break;          case '22': $where = "bclassid = 0 or classid between 140 and 192";          break;          default: $where = "classid='10000'"; } */$where = '1';  //审核新闻模型全部栏目$class_list = $empire->query ( "SELECT classid,islast from {$dbtbpre}enewsclass where $where" );$class = array ();$pclass = array ();while ( $r = $empire->fetch ( $class_list ) ) {        if ($r ['islast'] == '0') {                array_push ( $pclass, $r ['classid'] ); // 非终极栏目不可以发不信息,所以不参与信息审核        } else {                array_push ( $class, $r ['classid'] );        }}foreach ( $class as $key => $val ) {        ecmscheck ( $val, $news_table, $news_num ); // 审核}// 刷新非终极栏目foreach ( $pclass as $key => $value ) {        echo '上级栏目'.$value.'已经更新<hr/>';        ReListHtml ( $value, 1 );}ReIndex(); //刷新首页/** * * @param  $classid * @param  $table * @param  $num */function ecmscheck($classid, $table, $num) {        global $empire, $class_r, $dbtbpre;        $time = time ();        // 每周一审核的设置为推荐        $isgood = '0';        $day = strftime ( "%A" );                if ($day == 'Monday') {                $isgood = '1';        }                $res = $empire->query ( "select id from {$dbtbpre}ecms_" . $table . "_check where classid =" . $classid . " ORDER BY `truetime` ASC LIMIT {$num}" );        while ( $r = $empire->fetch ( $res ) ) {                $data [] = $r ['id'];        }                CheckNews_auto ( $classid, $data );}/** * 审核信息 * @param  $classid * @param  $id */function CheckNews_auto($classid, $id) {        global $empire, $class_r, $dbtbpre, $emod_r, $adddatar;        $classid = ( int ) $classid;        $count = count ( $id );        $time = time();                //每周一审核的设置为推荐        $isgood = strftime('%A') == 'Monday'?1:0;                for($i = 0; $i < $count; $i ++) {                $infoid = ( int ) $id [$i];                 $infor = $empire->fetch1 ( "select * from {$dbtbpre}ecms_" . $class_r [$classid] [tbname] . "_check where id='$infoid' limit 1" );                 //$picurl = empty($infor['titlepic'])?'/images/smallpic/'.rand(1,300).'.jpg':$infor['titlepic']; //为了网站能好看点设置一个1-300的随机图片                 $res = $empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check set truetime='$time',newstime='$time',lastdotime='$time',isgood='$isgood' where id='$infoid' limit 1");                 $sql = $empire->query ( "update {$dbtbpre}ecms_" . $class_r [$classid] [tbname] . "_index set checked=1,truetime='$time',newstime='$time',lastdotime='$time' where id='$infoid'" );                 // 未审核表转换                 MoveCheckInfoData ( $class_r [$classid] [tbname], 0, $infor ['stb'], "id='$infoid'" );                 // 更新栏目信息数                 AddClassInfos ( $infor ['classid'], '', '+1' );                 // 刷新信息                 GetHtml ( $infor ['classid'], $infor ['id'], $infor, 0 );                 echo '信息 '.$infor ['id'].' 内容页已经更新<hr/>';                 // 刷新列表                 ReListHtml ( $infor ['classid'], 1 );                 echo '终极栏目 '.$infor ['classid'].' 已经更新<hr/>';        }}//刷新首页function ReIndex(){        $indextemp=GetIndextemp();//取得模板        NewsBq($classid,$indextemp,1,0);        echo '首页已经刷新';} 因为我用的linux服务器,所以运行crontab就可以了,windows的请自行寻找计划任务方法,应该比linux简单

赞(0)villainvillain阅读(39)去评论

php版本蜘蛛统计代码

<?php//蜘蛛访问统计 $useragent = addslashes(strtolower($_SERVER['HTTP_USER_AGENT'])); if (strpos($useragent, 'googlebot')!== false){$bot = 'Google';} elseif (strpos($useragent,'mediapartners-google') !== false){$bot = 'Google Adsense';} elseif (strpos($useragent,'baiduspider') !== false){$bot = 'Baidu';} elseif (strpos($useragent,'sogou spider') !== false){$bot = 'Sogou';} elseif (strpos($useragent,'sogou web') !== false){$bot = 'Sogou web';} elseif (strpos($useragent,'sosospider') !== false){$bot = 'SOSO';} elseif (strpos($useragent,'360spider') !== false){$bot = '360Spider';} elseif (strpos($useragent,'yahoo') !== false){$bot = 'Yahoo';} elseif (strpos($useragent,'msn') !== false){$bot = 'MSN';} elseif (strpos($useragent,'msnbot') !== false){$bot = 'msnbot';} elseif (strpos($useragent,'sohu') !== false){$bot = 'Sohu';} elseif (strpos($useragent,'yodaoBot') !== false){$bot = 'Yodao';} elseif (strpos($useragent,'twiceler') !== false){$bot = 'Twiceler';} elseif (strpos($useragent,'ia_archiver') !== false){$bot = 'Alexa_';} elseif (strpos($useragent,'iaarchiver') !== false){$bot = 'Alexa';} elseif (strpos($useragent,'yisouspider') !== false){$bot = 'SMSpider';} elseif (strpos($useragent,'bingbot') !== false){$bot = 'bingbot';} $url = "http://".$_SERVER['HTTP_HOST']. $_SERVER['REQUEST_URI']; if(isset($bot)){ $fp = @fopen(date('Y-m-d').'.txt','a'); fwrite($fp,date('Y-m-d H:i:s')."\t".$_SERVER["REMOTE_ADDR"]."\t".$bot."\t".$url."\r\n");...

赞(0)villainvillain阅读(36)去评论

linux宝塔面板蜘蛛统计脚本(站群/多站版)脚本下载

说明: spider是蜘蛛标识,domain是要统计蜘蛛的站点域名,只统计当天的蜘蛛。 如果需要记录/分析每天的蜘蛛情况,可以将脚本添加定时任务(23:59)执行,并追加输出到txt文件。 例如:将脚本命名为spider.sh 保存,再使用crontab命令添加定时任务(注意:spider.sh文件需要700权限)。 59 23 * * * sh /www/spider.sh>>/www/spider.txt 代码粗陋,还望各位笑纳。高手可以各自完善。  提供liunx格式的脚本下载 防止windows跟liunx的编辑软件冲突导致代码出问题! #!/bin/bash m="$(date +%m)" case $m in "01") m='Jan';; "02") m='Feb';; "03") m='Mar';; "04") m='Apr';; "05") m='May';; "06") m='Jun';; "07") m='Jul';; "08") m='Aug';; "09") m='Sep';; "10") m='Oct';; "11") m='Nov';; "12") m='Dec';; esac d="$(date +%d)" spider=( Googlebot Baiduspider baiduboxapp Sogou YisouSpider 360Spider Bytespider ) domain=( www.1004619.com ) for j in ${domain[*]}; do echo $j for i in ${spider[*]}; do echo -e "$i " `cat /www/wwwlogs/$j.log |grep $d/$m|grep $i|wc -l` done echo "--------------------------------------------------------" done  

赞(0)villainvillain阅读(40)去评论