AutoBlogRoll to config! Version: 2.5 Author: askie Author URI: http://www.pkphp.com/ Copyright 2008 Askie (email imaskie@gmail.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software email to imaskie@gmail.com INSTRUCTIONS ------------ 1. Upload and activate, set permission of plug-in directory as "0777". 2. go to setting-> AutoBlogroll-> install, activate plug-in. 3. go to setting-> AutoBlogroll-> GeneralSetting, set basic parameters 4. go to widget page of templates and insert AutoBlogroll widget to your sidebar 5. After that, setting-> AutoBlogroll-> Manage link 6. setting-> AutoBlogroll-> GeneralSetting to chose plugin's language face. */ $ab_version=2.2; //调用语言包 $locale = get_locale(); if (get_option('ab_language')==1 or $locale=="zh_CN") { load_textdomain('AutoBlogRoll', dirname(__FILE__) . "/auto-blogroll-zh_CN.mo"); } elseif (get_option('ab_language')==2) { load_textdomain('AutoBlogRoll', dirname(__FILE__) . "/auto-blogroll-zh_TW.mo"); } else { load_textdomain('AutoBlogRoll', dirname(__FILE__) . "/auto-blogroll-$locale.mo"); } //一般设定 function ab_generalsetting() { if ($_POST['flag']=="ab_general") { foreach ($_POST as $key=>$value) { if ($key=="ab_pr") { $value=$value>11?10:$value; } if ($key=="ab_intitle") { if ($value<>get_option("ab_intitle")) { $DB=new ab_DB(); $inlink=$DB->select(array("url"=>get_permalink(get_option("ab_linkpageid")))); $inlink=array_pop($inlink); $DB->delete($inlink["url"]); } } if (strstr($key,"ab_")==$key) { if ($key=="ab_language" and get_option("ab_language")<>$value) { $changelanguage=true; } update_option($key, $value); } } ab_active(); if ($changelanguage==true) { $curl="{$_SERVER["PHP_SELF"]}?page=auto-blogroll/auto-blogroll.php&cm=setting"; echo '

'.__("Saved successfully!","AutoBlogRoll").$msg.__(" refresh page now!","AutoBlogRoll").' Click here'.'

'; } else { echo '

'.__("Saved successfully!","AutoBlogRoll").'

'; } } $ab_n=get_option("ab_pr"); $ab_n=$ab_n>11?10:$ab_n; ?>

?page=auto-blogroll/auto-blogroll.php"> | ?page=auto-blogroll/auto-blogroll.php&cm=editlink&vid="> | ?page=auto-blogroll/auto-blogroll.php&cm=setting"> | ?page=auto-blogroll/auto-blogroll.php&cm=install"> | " target="_blank">

?page=auto-blogroll/auto-blogroll.php&cm=setting">
">
>Yes >No
> >
">
> >
">
>Yes >No
>Yes >No
>Yes >No
">
">
">
>Yes(Give askie a link!) >No
: >Yes >No
: >Yes >No

[limitpr],[limitalexa],[myblogname],[myblogurl],[myblogdescription],[mybloglogourl]

get_option("ab_vesionsupdatetime")) { ab_versionCheck(); } if ($_GET['cm']=="setting") { ab_generalsetting(); return ; } if ($_GET['cm']=="changelanguage") { update_option("ab_language",$_POST["ab_language"]); echo '

'.__("Language change successfully!","AutoBlogRoll").'

'; return ; } if ($_GET['cm']=="editlink") { ab_editlink(); return ; } if ($_GET['cm']=="doinstall") { if ($_GET["subcm"]=="inportblogroll") { echo '

'.ab_inportblogroll().'

'; } else { $gb = ab_setup(); $gb.="
".ab_inportblogroll(); echo '

'.$gb.'

'; } } if ($_GET['cm']=="install" or get_option("ab_linkpageid")=="") { ab_install(); return ; } //managelinks if ($_POST['flag']=="ab_doeditlink") { echo '

'.ab_doeditlink().'

'; } if ($_GET['subcm']=="save") { echo '

'.ab_dolinksmanage().'

'; return ; } if ($_GET['subcm']=="delete") { echo '

'.ab_dolinksdelete().'

'; } if ($_GET['subcm']=="checklinks") { ab_CheckSomeLinks(); echo '

'.__("Checked successfully!","AutoBlogRoll").'

'; } ?>

?page=auto-blogroll/auto-blogroll.php"> | ?page=auto-blogroll/auto-blogroll.php&cm=editlink&vid="> | ?page=auto-blogroll/auto-blogroll.php&cm=setting"> | ?page=auto-blogroll/auto-blogroll.php&cm=install"> | " target="_blank">

?page=auto-blogroll/auto-blogroll.php&subcm=save"> select(); foreach ($data as $key=>$link) { $highlight=(int)$link["nolinknum"]>=get_option("ab_nolinknum")?'style="background-color: #FFECB3;"':""; ?> valign="top">
  • display=whether to displaying the link
  • check=whether checking your link form the site
  • invalidation=invalidation times of checking your link
  • add widget to you sidebar!
  • ","AutoBlogRoll"));?>

    " style="font-weight:bold;" /> " onClick="CheckingLinks();"> --------------------------------------------------- " onClick="if(confirm('delete the links?')) DeleteLinks();">

    select($_GET["vid"]); ?>

    ?page=auto-blogroll/auto-blogroll.php"> | ?page=auto-blogroll/auto-blogroll.php&cm=editlink&vid="> | ?page=auto-blogroll/auto-blogroll.php&cm=setting"> | ?page=auto-blogroll/auto-blogroll.php&cm=install"> | " target="_blank">

    ?page=auto-blogroll/auto-blogroll.php"> ">
    " style="width:400px;">
    " style="width:400px;">
    " style="width:400px;">
    " style="width:400px;">
    " style="width:400px;">
    " style="width:400px;">
    " style="width:400px;">

    About:


    Supportaskie

    "; } //输出资助链接表单 function ab_addlinkform() { echo ab_listAllLinks(); $DB=new ab_DB(); $allLinks=$DB->select(); if (count($allLinks)>=get_option("ab_n")) { ab_msg(__("The total number of links to the ceiling!","AutoBlogRoll")); return ; } $term=stripslashes(get_option("ab_term")); $ckeys=array("[pr]","[alexa]","[limitpr]","[limitalexa]","[myblogname]","[myblogurl]","[myblogdescription]","[mybloglogourl]"); $cvalue=array(get_option("ab_usepr"),get_option("ab_usealexa"),get_option("ab_pr"),get_option("ab_alexa"),get_option("blogname"),get_option("siteurl"),get_option("blogdescription"),get_option("ab_logourl")); $term=str_replace($ckeys,$cvalue,$term); ?>
    : " size="25" type="text"> (*)
    : " size="25" type="text"> (*)
    : " size="25" type="text"> (*)
    : " size="25" type="text"> (*)1) { if (get_option("ab_usepr")==1) $x[]="PR≥".get_option("ab_pr").""; if (get_option("ab_usealexa")==1) $x[]="Alexa≤".get_option("ab_alexa").""; echo "".implode("、",$x); } ?>
    : " size="25" type="text"> (*)PR≥".get_option("ab_pr").""; echo "
    ".__("host be same as siteURL","AutoBlogRoll")." & ".$v; } ?>
    : " size="25" type="text">
    : " size="25" type="text">

    select(); if (count($allLinks)>=get_option("ab_n")) { ab_msg(__("The total number of links to the ceiling!","AutoBlogRoll")); return ; } if (!isset($_POST["url"])) return ; if (get_option("ab_urlisreurl")<>1) { $_POST["reurl"]=$_POST["url"]; } $forbidkeys=array("webmaster"=>__("Webmaster","AutoBlogRoll"),"email"=>__("Email","AutoBlogRoll"),"title"=>__("Site name","AutoBlogRoll"),"url"=>__("Site URL","AutoBlogRoll"),"reurl"=>__("Exchange link page","AutoBlogRoll")); foreach ($_POST as $key=>$value) { $value=trim($value); if (key_exists($key,$forbidkeys)) { if ($value=="") { $error[]=$forbidkeys[$key]; } } if (is_array($error)) { ab_msg(implode(",",$error).__(" must be added","AutoBlogRoll")); return ; } } //判断数据合法性 if (!(ab_viladUrl($_POST["url"]) and ab_viladUrl($_POST["reurl"]))) { ab_msg(__("Site URL ro Exchange link page is invalid!","AutoBlogRoll")); return ; } //判断邮件合法性 if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$_POST["email"])) { ab_msg(__("Email is invalid!","AutoBlogRoll")); return ; } //判断网站网址与交换链接网址是否同域名 $yurl=parse_url($_POST["url"]); $yrurl=parse_url($_POST["reurl"]); if ($yurl["host"]<>$yrurl["host"]) { ab_msg(__("Site URL ro Exchange link page is not one same host!","AutoBlogRoll")); return ; } //判断网址是否已经交换链接 if (count($DB->select(array("url"=>$_POST["url"])))>0) { ab_msg(__("Link allready exsit!","AutoBlogRoll")); return ; } //检测对方网页是否已经放置本站链接 $linkcheck=ab_CheckLinkRormUrl($_POST["reurl"]); if ($linkcheck==="a") { ab_msg(__("Your site have set nofollow or noindex!","AutoBlogRoll")); return ; } elseif (($linkcheck==="b")) { ab_msg(__("Can not find my site URL in your page!","AutoBlogRoll")); return ; } $data=array( "url" =>$_POST["url"], "title" =>$_POST["title"], "description" =>$_POST["description"], "logourl" =>$_POST["logourl"], "reurl" =>$_POST["reurl"], "webmaster" =>$_POST["webmaster"], "email" =>$_POST["email"], "approved" =>get_option("ab_approved"), "check" =>get_option("ab_checkdaily"), "order" =>0, ); //根据PR和Alexa判断链接 $Pr=new AB_PageRank(); $xpr=$Pr->printrank($_POST["reurl"]); $data["pr"]=$xpr; if (get_option("ab_usepr")) { if ($xprthreeMothAlexa($_POST["reurl"]); $xalexa=str_replace("--","10000000000",str_replace(",","",$xalexa)); $data["alexa"]=$xalexa; if (get_option("ab_usealexa")) { if ($xalexa>get_option("ab_alexa")) { ab_msg("对不起,你的网站Alexa({$xalexa})大于".get_option("ab_alexa").",无法交换链接!"); return ; } }*/ $DB=new ab_DB(); if ($DB->update($data)) { ab_add2wp($data); $_POST=array(); } if ($data["approved"]==1) { $msg=__("Your link need be appoved to display!","AutoBlogRoll"); } ab_msg(__("Exchang successfully!","AutoBlogRoll").$msg.__(" refresh page now!","AutoBlogRoll").' Click here...... '); return ; } function ab_apply() { global $id; $DB=new ab_DB(); $allLinks=$DB->select(); if (count($allLinks)>=get_option("ab_n")) { echo (__("The total number of links to the ceiling!","AutoBlogRoll")."[autobloglink.com]"); exit(); } if (!isset($_POST["url"])) return ; if (get_option("ab_urlisreurl")<>1) { $_POST["reurl"]=$_POST["url"]; } $forbidkeys=array("webmaster"=>__("Webmaster","AutoBlogRoll"),"email"=>__("Email","AutoBlogRoll"),"title"=>__("Site name","AutoBlogRoll"),"url"=>__("Site URL","AutoBlogRoll"),"reurl"=>__("Exchange link page","AutoBlogRoll")); foreach ($_POST as $key=>$value) { $value=trim($value); if (key_exists($key,$forbidkeys)) { if ($value=="") { $error[]=$forbidkeys[$key]; } } if (is_array($error)) { ab_msg(implode(",",$error).__(" must be added","AutoBlogRoll")."[autobloglink.com]"); return ; } } //判断数据合法性 if (!(ab_viladUrl($_POST["url"]) and ab_viladUrl($_POST["reurl"]))) { echo (__("Site URL ro Exchange link page is invalid!","AutoBlogRoll")."[autobloglink.com]"); exit(); } //判断邮件合法性 if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$_POST["email"])) { echo (__("Email is invalid!","AutoBlogRoll")."[autobloglink.com]"); exit(); } //判断网站网址与交换链接网址是否同域名 $yurl=parse_url($_POST["url"]); $yrurl=parse_url($_POST["reurl"]); if ($yurl["host"]<>$yrurl["host"]) { echo (__("Site URL ro Exchange link page is not one same host!","AutoBlogRoll")."[autobloglink.com]"); exit(); } //判断网址是否已经交换链接 if (count($DB->select(array("url"=>$_POST["url"])))>0) { echo ("[ok]".__("Link allready exsit!","AutoBlogRoll")."[autobloglink.com]"); exit(); } //检测对方网页是否已经放置本站链接 $linkcheck=ab_CheckLinkRormUrl($_POST["reurl"]); if ($linkcheck==="a") { echo (__("Your site have set nofollow or noindex!","AutoBlogRoll")."[autobloglink.com]"); exit(); } elseif (($linkcheck==="b")) { echo (__("Can not find my site URL in your page!","AutoBlogRoll")."[autobloglink.com]"); exit(); } $data=array( "url" =>$_POST["url"], "title" =>$_POST["title"], "description" =>$_POST["description"], "logourl" =>$_POST["logourl"], "reurl" =>$_POST["reurl"], "webmaster" =>$_POST["webmaster"], "email" =>$_POST["email"], "approved" =>get_option("ab_approved"), "check" =>get_option("ab_checkdaily"), "order" =>0, ); //根据PR和Alexa判断链接 $Pr=new AB_PageRank(); $xpr=$Pr->printrank($_POST["reurl"]); $data["pr"]=$xpr; if (get_option("ab_usepr")) { if ($xprupdate($data)) { ab_add2wp($data); $_POST=array(); } if ($data["approved"]==1) { echo "[ok]".__("Your link need be appoved to display!","AutoBlogRoll")."[autobloglink.com]"; exit(); } echo ("[ok]".__("Exchang successfully!","AutoBlogRoll")."[autobloglink.com]"); //删除首页缓存 ab_deleteIndexhtml(); exit(); } //管理员编辑链接 function ab_doeditlink() { $DB=new ab_DB(); $data=$DB->select($_POST["vid"]); //删除原来的记录 $DB->delete($data["url"]); //更新数据 $data["url"] =$_POST["url"]; $data["title"] =$_POST["title"]; $data["description"]=$_POST["description"]; $data["logourl"] =$_POST["logourl"]; $data["reurl"] =$_POST["reurl"]; $data["webmaster"] =$_POST["webmaster"]; $data["email"] =$_POST["email"]; //PR和Alexa $Pr=new AB_PageRank(); $xpr=$Pr->printrank($_POST["reurl"]); $data["pr"]=$xpr; /*$Alexa=new AB_Alexa(); $xalexa=$Alexa->threeMothAlexa($_POST["reurl"]); $xalexa=str_replace("--","10000000000",str_replace(",","",$xalexa)); $data["alexa"]=$xalexa;*/ $DB->update($data); ab_add2wp($data); //删除首页缓存 ab_deleteIndexhtml(); return $msg.__("Edit successfully!","AutoBlogRoll"); } //备份增加的链接到wp数据库 function ab_add2wp($LinkData) { if (get_option('ab_backup2wp')<>1) { return ; } global $wpdb; $url=$LinkData["url"]; //检查link $check = $wpdb->get_var("SELECT link_id FROM $wpdb->links WHERE link_url='{$url}'"); $link = array( 'link_url' => $url, 'link_name' => $wpdb->escape($LinkData["title"]), 'link_category' => array(get_option('default_link_category')), 'link_description' => $wpdb->escape($LinkData["description"]), 'link_owner' => 1, 'link_image' => $LinkData["logourl"], 'link_visible' => $LinkData["approved"]==0?"Y":"N"); if (!function_exists(wp_update_link)) { require_once("wp-admin/includes/bookmark.php"); } if ($check) { $link["link_id"]=$check; return wp_update_link( $link ); } else { return wp_insert_link($link); } } //对多个链接进行排序、分类操作 function ab_dolinksmanage() { $DB=new ab_DB(); $links=$DB->select(); foreach ($links as $key=>$link) { $link["cat"] =$_POST["cat"][$key]; $link["order"] =$_POST["order"][$key]; $link["approved"] =key_exists($key,(array)$_POST["approved"]) ?0:1; $link["check"] =key_exists($key,(array)$_POST["check"]) ?1:0; $link["nolinknum"] =key_exists($key,(array)$_POST["approved"]) ?0:$link["nolinknum"]; $DB->update($link); ab_add2wp($link); } return __("Saved successfully! Refreshing now ...","AutoBlogRoll"); } //删除多个链接 function ab_dolinksdelete() { global $wpdb; $DB=new ab_DB(); if (is_array($_POST["vid"])) { foreach ($_POST["vid"] as $key) { if (get_option('ab_delete2wp')==1) { $link=$DB->select($key); $url=$link["url"]; $id = $wpdb->get_var("SELECT link_id FROM $wpdb->links WHERE link_url='{$url}'"); wp_delete_link($id); } $DB->delete("",$key); } } return __("Deleted successfully!","AutoBlogRoll"); } //审核链接 function ab_dolinksapprove($approve=0) { $DB=new ab_DB(); $links=$DB->select(); if (is_array($_POST["vid"])) { foreach ($_POST["vid"] as $key) { $links[$key]["approved"]=$approve; $DB->update($links[$key]); } } return __("Saved successfully!","AutoBlogRoll"); } //输出所有链接 function ab_listAllLinks() { $DB=new ab_DB(); return ab_listlinks($DB->select(array("approved"=>0))); } //根据目录输出链接 function ab_blogroll($cat="") { $DB=new ab_DB(); $cat=(array)$cat; if (!in_array("",$cat)) { $cat[]=""; } $links=array(); foreach ($cat as $catname) { $catlinks=(array)$DB->select(array("approved"=>0,"cat"=>$catname)); foreach ($catlinks as $key=>$link) { $links[$key]=$link; } } return ab_listlinks($links); } //输出链接模板 function ab_listlinks($data) { $z=array(); foreach ($data as $site) { $z[]="
  • {$site["title"]}
  • "; } return ""; } //从网页检测本站链接是否存在 function ab_CheckLinkRormUrl($url) { $siteurl=get_option("siteurl"); //检测Url时候在最后添加了/ $slash=substr($siteurl,-1,1)=="/"?"/":""; //如果是本网站链接则停止检测 $sitehost=parse_url($siteurl); $checkhost=parse_url($url); if ($sitehost["host"]==$checkhost["host"]) { return true; } require_once( ABSPATH . 'wp-includes/class-snoopy.php' ); $http = new Snoopy(); $http->agent = MAGPIE_USER_AGENT; $http->read_timeout = MAGPIE_FETCH_TIME_OUT; $http->use_gzip = MAGPIE_USE_GZIP; @$http->fetch($url); $file=$http->results; $urls=ab_GetUrlFromHtml($file); $webNofollowCheck=ab_checkHtmlNofollow($file); //判断网页nofollow,noindex设置 if ($webNofollowCheck==1) { return "a"; } //判断链接 foreach ($urls as $url) { if ($slash=="") { if (substr($url,-1,1)=="/") { $url=substr($url,0,-1); } } if ($url==$siteurl) { return true; } } return "b"; } //获取文本中获取链接地址 function ab_GetUrlFromHtml($html) { preg_match_all("']*?>'si",$html,$n); $url=array(); foreach ($n as $m) { foreach ($m as $x) { preg_match('#href[[:space:]]*=[[:space:]]*[\'|"]?([[:alnum:]:@/._-]+[?]?[^\'|"]*)"?#ie',$x,$y); if (!preg_match('/(noindex|nofollow)(.*)>/siU',$x,$z)) { $url[]=$y[1]; } } } return $url; } //检测网页是否设置nofollow function ab_checkHtmlNofollow($html) { return preg_match('/]+)(noindex|nofollow)(.*)>/siU',$html,$meta); } //检测链接有效性 function ab_CheckSomeLinks() { $DB=new ab_DB(); $sites=$DB->select(); foreach ((array)$_POST["vid"] as $key) { ab_CheckLink($sites[$key]["url"],true); } } //例外链接 function ab_pravitelink() { $DB=new ab_DB(); $sites=$DB->select(); if (get_option("ab_helpaskie")==1) { $pravitelink[]=array( "url" =>"http://www.pkphp.com", "reurl" =>"http://www.pkphp.com", "title" =>"PK with PHP!", "approved" =>"0", "check" =>"0", "nolinknum" =>"0", ); } if (get_option("ab_linkpageid")<>"") { $pravitelink[]=array( "url" =>get_permalink(get_option("ab_linkpageid")), "reurl" =>get_permalink(get_option("ab_linkpageid")), "title" =>get_option('ab_intitle')==""?__("Apply to exchange link","AutoBlogRoll"): get_option('ab_intitle'), "approved" =>"0", "check" =>"0", "nolinknum" =>"0", "order" =>"99", ); } foreach ((array)$pravitelink as $site) { if (!(key_exists(md5(base64_encode($site["url"])),$sites) or key_exists(md5(base64_encode($site["url"]."/")),$sites))) { $DB->update($site); continue; } } } $ab_hell=base64_decode("aHR0cDovL3d3dy5hdXRvYmxvZ2xpbmsuY29t"); //检测链接有效性 function ab_CheckAllLink() { $DB=new ab_DB(); $sites=$DB->select(); foreach ($sites as $site) { $r=ab_CheckLink($site["url"]); if ($r=="done") { break; } } } //根据网址检测链接有效性 function ab_CheckLink($url,$force=false) { $DB=new ab_DB(); $sites=$DB->select(array("url"=>$url)); foreach ($sites as $site) { if ($force==false) { if ($site["check"]<>1) { continue; } if ($site["checktime"] != "" and date("Y-m-d",$site["checktime"]) >= date("Y-m-d")) { continue; } } if (strstr($site["url"],get_option("siteurl")) or strstr($site["url"],"http://www.pkphp.com")) { continue; } $a=ab_CheckLinkRormUrl($site["reurl"]); if ($a===true) { $site["nolinknum"]=0; } else { $site["nolinknum"]=$site["nolinknum"]+1; if ((int)$site["nolinknum"]>=(int)get_option("ab_nolinknum")) { $site["approved"]=1; } } //每天保存检测记录 ab_saveCheckRecord($site["url"],($a===true?1:0)); //保存记录 $site["checktime"]=time(); $DB->update($site,true); return "done"; } //删除首页缓存 ab_deleteIndexhtml(); return "none"; } //存储链接记录 function ab_saveCheckRecord($siteurl,$result) { $record=get_option('ab_checkrecord',array()); $date=date("Y-m-d"); $record[$siteurl][$date]=$result; return update_option('ab_checkrecord',$record); } //输出检测记录 function ab_listCheckRecord() { $record=get_option('ab_checkrecord',array()); $x=$record[$_GET['url']]; if (is_array($x)) { foreach ($x as $date=>$result) { if ($result==0) { echo ''.'
  • '.$date.':'.$result.'
  • '.'
    '; } else { echo '
  • '.$date.':'.$result.'
  • '; } } } exit(); } //从服务器端读入链接 function ab_importLinksFromServer() { /*if (get_option("ab_importlink")=="Y") { global $ab_hell; $parseOpml=new ParseOpml("{$ab_hell}/blog/outlinks/key/".get_option("ab_blogkey")); $DB=new ab_DB(); $allLinks=$DB->select(); $pr=new AB_PageRank(); $flag=false; foreach ((array)$parseOpml->outline as $link) { $data=array( "title" =>$link["text"], "url" =>$link["htmlurl"], "description" =>$link["description"], "reurl" =>$link["htmlurl"], "webmaster" =>$link["webmaster"], "email" =>$link["email"], "logourl" =>$link["logourl"], "approved" =>get_option("ab_approved"), "check" =>get_option("ab_checkdaily"), "pr" =>$pr->printrank($link["htmlurl"])); $flag=$DB->update($data); if ($flag) { ab_add2wp($data); } } update_option("ab_importlink",""); }*/ } //输出链接opml function ab_exportLinksOpml() { $parseOpml=new ParseOpml(); $DB=new ab_DB(); $cat=(array)get_option('ab_widget_cat'); $links=array(); $siteurl=get_option("siteurl"); foreach ($cat as $catname) { $catlinks=(array)$DB->select(array("approved"=>0,"cat"=>$catname)); foreach ($catlinks as $key=>$link) { if (strstr($link["url"],$siteurl)==false) { $links[$key]=$link; } } } $site["name"]=get_option("blogname"); $parseOpml->outOpml($site,$links); exit(); } //初始化 function ab_init() { //加载库文件 include_once('ab_function.php'); include_once('ab_PageRank.php'); include_once('ab_Alexa.php'); $ab_config=array( "ab_n" =>20, "ab_pr" =>0, "ab_usepr" =>1, "ab_alexa" =>1000000, "ab_nolinknum" =>5, "ab_helpaskie" =>1, "ab_backup2wp" =>1, "ab_delete2wp" =>1, "ab_checkdaily" =>1, "ab_linkkey" =>"", "ab_term" =>"交换链接条款:
    • 本网站名:[myblogname]
    • 本站网址:[myblogurl]
    • 本站简介:[myblogdescription]
    • 本站图标:[mybloglogourl]
    • 交换链接前请先添加本站的链接,否则无法提交表单。
    • 要求交换链接的页面PR大于等于[limitpr]
    • 要求交换链接的页面Alexa小于等于[limitalexa]
    • 以下表单后带*为必填写项目。
    ", ); foreach ($ab_config as $key=>$var) { if (get_option($key)=="") { update_option($key,$var); } } //激活 if ($_GET["ab_active"]) { echo get_option("ab_linkkey"); exit(); } if ($_GET["ab_cmt"]<>"" and $_GET["ab_cmt"]==get_option("ab_blogkey")) { ab_cmt(); exit(); } if ($_GET["applylink"]<>"" and $_GET["applylink"]==get_option("ab_blogkey")) { ab_apply(); exit(); } //通知从服务器更新申请到的链接 if ($_GET["ab_importlink"]<>"") { update_option("ab_importlink","Y"); ab_importLinksFromServer(); exit(); } //输出检测记录 if ($_GET["cmd"]=="listcheckrecord") { ab_listCheckRecord(); exit(); } //判断是否需要导入链接 if (get_option("ab_importlink")=="Y") { ab_importLinksFromServer(); exit(); } //输出链接opml if ($_GET["exportlinksopml"]) { if($_GET["exportlinksopml"]==get_option("ab_blogkey")) ab_exportLinksOpml(); exit(); } if (get_option("ab_blogkey")=="") { ab_active(); } ab_importLinksFromServer(); ab_pravitelink(); //每小时检测链接 $lastchecktime=get_option("ab_lastchecktime"); if (date("Y-m-d-H",$lastchecktime) != date("Y-m-d-H")) { ab_CheckAllLink(); update_option("ab_lastchecktime",time()); } } add_action('admin_menu', 'ab_addpages'); add_action('init', 'ab_init'); //检测页面是否存在 function ab_checkpage($page) { global $wpdb; //检查links静态页面是否存在: $check = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status='publish' AND post_name='{$page}'"); //如果links静态页面不存在则创建: if ($check) { return $check; } else { return false; } } //给创链接页面添加内容 function ab_outLinksandform($content) { global $id; //检查links静态页面id: $linkspageid = get_option('ab_linkpageid'); if ($linkspageid==$id) { $content=$content.ab_addlinkform(); return $content; } else { return $content; } } //输出链接和申请表单 add_filter("the_content","ab_outLinksandform"); //增加新的定时间隔设置 //function ab_reccurences() { // return array( // 'weekly' => array('interval' => 604800, 'display' => 'Once Weekly'), // 'fortnightly' => array('interval' => 1209600, 'display' => 'Once Fortnightly'), // 'threesecondly' => array('interval' => 3, 'display' => 'Once ThreeSecondly'), // ); //} //add_filter('cron_schedules', 'ab_reccurences'); //每天定期检测网页链接有效性 if (get_option("ab_checkdaily")==1) { if (!wp_next_scheduled('ab_CheckAllLink_hook')) { wp_schedule_event( time(), 'hourly', 'ab_CheckAllLink_hook' ); } } add_action( 'ab_CheckAllLink_hook', 'ab_CheckAllLink' ); //widget function widget_sidebar_autoblogroll() { function widget_autoblogroll($args) { if ((int)get_option("ab_onlydisplayonhome")==0) { widget_autoblogroll_do($args); return ; } if ((int)get_option("ab_onlydisplayonhome")==1 and is_home()) { widget_autoblogroll_do($args); return ; } } function widget_autoblogroll_do($args) { extract($args); $title = get_option('ab_widget_title','Links'); $cat = get_option('ab_widget_cat'); echo $before_widget; echo $before_title . $title . $after_title; $output = ab_blogroll($cat); echo $output; echo $after_widget; } register_sidebar_widget('AutoBlogRoll', 'widget_autoblogroll'); //把目录换成checkbox代码 function widget_autoblogroll_cat2checkbox() { $oldcat = (array)get_option('ab_widget_cat'); $DB=new ab_DB(); $cats=$DB->select(array(),"","cat"); foreach ($cats as $cat) { $checked=in_array($cat["cat"],$oldcat)?" checked":""; $code[]=""; } return @implode("\n",$code); } //widget 选项 function widget_autoblogroll_options() { //如果提交更新 if ( $_POST["ab_submit"] ) { foreach ($_POST as $key=>$var) { if (strstr($key,"ab_widget_")==$key) { update_option($key,$var); } } } $title = attribute_escape(get_option('ab_widget_title','Links')); ?>

    options WHERE $wpdb->options.option_name like 'ab_%'"; $wpdb->query($remove_options_sql); //删除插件创建的链接页面 $ab=get_post_meta(get_option("ab_linkpageid"),"ab_created",true); if ($ab=="a") { $post_id_del=get_option("ab_linkpageid"); if ( !current_user_can('delete_page', $post_id_del) ) { wp_die( __('You are not allowed to delete this page.') ); } if ( !wp_delete_post($post_id_del) ) { wp_die( __('Error in deleting...') ); } delete_post_meta_by_key("ab_linkpageid"); } //删除定时程序 wp_clear_scheduled_hook('ab_CheckAllLink_hook'); } //刪除首页缓存 function ab_deleteIndexhtml() { //echo ABSPATH; } ?>