示例#1
0
/**
 * 返回插入语句
 * @param $key
 * @param $keys
 * @param $adKey
 * @return string
 */
function Insert($key, $keys, $adKey)
{
    $epath = GetEPath($key);
    //生成标题
    $arr_keys = explode(',', $key);
    shuffle($arr_keys);
    $arrKeys = array_slice($arr_keys, 0, 2);
    $title = $key . '_' . implode('_', $arrKeys);
    $sql = "('{$key}','{$title}','{$keys}','{$epath}', {$adKey}),";
    return $sql;
}
示例#2
0
    $memcached->addServer('127.0.0.1', '11211');
}
$templets = GetContent($indexCache->mainDomain . 'view.html', './templets/view.html', $memcached, 86400, $cfg->isMemcached);
//生成相关链接:
$arrKeys = explode(',', $indexCache->keys);
$keysLink = '';
foreach ($arrKeys as $v) {
    $keyEPath = GetEPath($v);
    $arr = explode('/', $keyEPath);
    $keysLink .= '<li><a href="http://' . $arr[0] . $indexCache->mainDomain . '/' . $arr[1] . '">' . $v . '</a></li>';
}
//生成taglink
$tagLink = '';
$arrTagKey = explode(',', $indexCache->tagKey);
foreach ($arrTagKey as $v) {
    $tagEPath = GetEPath($v);
    $arr = explode('/', $tagEPath);
    $tagLink .= '<li><a href="http://' . $arr[0] . $indexCache->mainDomain . '/' . $arr[1] . '">' . $v . '</li>';
}
//替换数组
$arrReplace = array();
$arrReplace['key'] = $indexCache->key;
$arrReplace['keys'] = $indexCache->keys;
$arrReplace['title'] = $randArticle->title;
$arrReplace['maintitle'] = $indexCache->title;
$arrReplace['adkey'] = $indexCache->adKey;
$arrReplace['keyslink'] = $keysLink;
$arrReplace['taglink'] = $tagLink;
$arrReplace['body'] = $randArticle->body . '<p>' . $additionLinks;
$arrReplace['baseurl'] = $indexCache->baseUrl;
$arrReplace['description'] = '';
示例#3
0
 /**
  * 输出正文
  * @param $isMemcached
  * @param $memcached
  */
 function Show($isMemcached, $memcached)
 {
     $templets = GetContent($this->mainDomain . 'index.html', './templets/index.html', $memcached, 86400, $isMemcached);
     //生成相关链接:
     $arrKeys = explode(',', $this->keys);
     $keysLink = '';
     foreach ($arrKeys as $v) {
         $keyEPath = GetEPath($v);
         $arr = explode('/', $keyEPath);
         $keysLink .= '<li><a href="http://' . $arr[0] . $this->mainDomain . '/' . $arr[1] . '">' . $v . '</a></li>';
     }
     //生成taglink
     $tagLink = '';
     $arrTagKey = explode(',', $this->tagKey);
     foreach ($arrTagKey as $v) {
         $tagEPath = GetEPath($v);
         $arr = explode('/', $tagEPath);
         $tagLink .= '<li><a href="http://' . $arr[0] . $this->mainDomain . '/' . $arr[1] . '">' . $v . '</li>';
     }
     //循环内容
     //百度
     $templetsBaidu = InStr('{baidu:}', '{/baidu}', $templets);
     $conBaidu = '';
     foreach ($this->viewBaidu as $k => $v) {
         if ($v['title'] == '') {
             continue;
         }
         $temp = str_replace('{url}', 'http://' . $this->baseUrl . 'view-' . $k . '.html', $templetsBaidu);
         $temp = str_replace('{title}', $v['title'], $temp);
         $temp = str_replace('{description}', $v['description'], $temp);
         $conBaidu .= $temp;
     }
     $templets = str_replace('{baidu:}' . $templetsBaidu . '{/baidu}', $conBaidu, $templets);
     $templetsBaidu = null;
     $conBaidu = null;
     $temp = null;
     unset($templetsBaidu, $conBaidu, $temp);
     //随机小说库生成文章
     $templetsRandArticle = InStr('{randarticle:}', '{/randarticle}', $templets);
     $conRandArticle = '';
     foreach ($this->viewRandArticle as $k => $v) {
         $temp = str_replace('{url}', 'http://' . $this->baseUrl . 'read-' . $k . '.html', $templetsRandArticle);
         $temp = str_replace('{title}', $v['title'], $temp);
         $temp = str_replace('{description}', $v['description'], $temp);
         $conRandArticle .= $temp;
     }
     $templets = str_replace('{randarticle:}' . $templetsRandArticle . '{/randarticle}', $conRandArticle, $templets);
     $templetsRandArticle = null;
     $conRandArticle = null;
     $temp = null;
     unset($templetsRandArticle, $conRandArticle, $temp);
     //替换数组
     $arrReplace = array();
     $arrReplace['key'] = $this->key;
     $arrReplace['keys'] = $this->keys;
     $arrReplace['title'] = $this->title;
     $arrReplace['adkey'] = $this->adKey;
     $arrReplace['keyslink'] = $keysLink;
     $arrReplace['taglink'] = $tagLink;
     foreach ($arrReplace as $k => $v) {
         $templets = str_replace('{' . $k . '}', $v, $templets);
     }
     echo $templets;
     $templets = null;
 }