예제 #1
0
function getstaticurl($question)
{
    global $setting, $category;
    $staticurl = $setting['static_url'];
    $repacearray = array('typedir' => getcategorypath($question['cid']), 'timestamp' => $question['time'], 'Y' => date('Y', $question['time']), 'M' => date('m', $question['time']), 'D' => date('d', $question['time']), 'qid' => $question['id'], 'pinyin' => getpinyin($question['title']) . '_' . $question['id'], 'py' => getpinyin($question['title'], 1) . '_' . $question['id'], 'cc' => date('md', $question['time']) . '_' . md5($question['id']));
    foreach ($repacearray as $search => $replace) {
        $staticurl = str_replace($search, $replace, $staticurl);
    }
    return $staticurl;
}
 function search_question()
 {
     if (!strtolower($this->get['q'])) {
         return;
     }
     $keywords = '%' . getpinyin($this->get['q']) . '%';
     $result = M('question')->where(array('pinyin' => array('like', $keywords)))->select();
     foreach ($result as $k => $v) {
         echo '<a href="' . U('question/view?qid=' . $v['id']) . '">' . getsubstr($v['title'], 0, 25) . '</a>';
         echo "\n";
     }
 }