Beispiel #1
0
function Get_sp($format)
{
    global $db, $pre, $webdb, $TB_pre, $TB_url, $timestamp;
    //方便下面得到URL的真实列表地址
    $page = 1;
    $rsdb = $db->get_one("SELECT * FROM {$pre}special WHERE id='{$format['spid']}'");
    //纠正存在可能错误的字符串.比如',1,2'这种情形
    $array_a = explode(",", $rsdb[aids]);
    foreach ($array_a as $key => $value) {
        if (!$value) {
            unset($array_a[$key]);
        }
    }
    $rsdb[aids] = implode(",", $array_a);
    unset($array_a);
    $array_a = explode(",", $rsdb[tids]);
    foreach ($array_a as $key => $value) {
        if (!$value) {
            unset($array_a[$key]);
        }
    }
    $rsdb[tids] = implode(",", $array_a);
    $Rows = $format[rowspan] * $format[colspan];
    //有辅助模板时,要加多一条
    if ($format[tplpart_2code]) {
        $Rows++;
    }
    if ($rsdb[aids]) {
        //获取文章数据
        $format[start_num] || ($format[start_num] = 1);
        $start_num = intval($format[start_num] - 1);
        $detail = get_sp_article($format, $rsdb, $Rows + $start_num);
        $detail[0] && ($_listdb = $detail[0]);
        for ($i = 0; $i < $start_num; $i++) {
            unset($_listdb[$i]);
        }
        //$listdb的KEY要从0开始,方便后面的$listdb[0]
        $listdb = '';
        foreach ((array) $_listdb as $value) {
            $listdb[] = $value;
        }
        $rs2 = $detail[1];
    }
    //如果文章中获取的记录不够,则继续从论坛中获取
    if ($rsdb[tids]) {
        if ($format[tplpart_2code]) {
            if (count($listdb) < $Rows - 1) {
                $getbbs = 1;
            }
        } else {
            if (count($listdb) < $Rows) {
                $getbbs = 1;
            }
        }
    }
    if ($getbbs) {
        $Rows2 = $Rows - count($listdb);
        if (ereg("^pwbbs", $webdb[passport_type])) {
            $detail = get_sp_pwbbs($format, $rsdb, $Rows2, $rs2);
            $_listdb = $detail[0];
            $rs3 = $detail[1];
        } elseif (ereg("^dzbbs", $webdb[passport_type])) {
            $detail = get_sp_dzbbs($format, $rsdb, $Rows2, $rs2);
            $_listdb = $detail[0];
            $rs3 = $detail[1];
        }
        if ($format[order] == 'default') {
            $tidsdb = explode(",", $rsdb[tids]);
            foreach ($tidsdb as $key => $value) {
                if ($_listdb[$value]) {
                    $listdb[] = $_listdb[$value];
                }
            }
        } else {
            //数组会自动类加
            foreach ($_listdb as $key => $value) {
                $listdb[] = $value;
            }
        }
        //针对辅助模板
        if ($format[tplpart_2code]) {
            //针对如果记录没有足够指定的条数,则不必去掉一条记录,否则就要去掉最后一条
            if (count($listdb) > $Rows - 1) {
                array_pop($listdb);
            }
            //如果文章系统里不存在,则获取论坛的
            if ($rs3) {
                $rs2 = $rs3;
            }
        }
    }
    $listdb || ($listdb = array());
    //执行PHP逻辑
    if (strstr($listdb[0][tpl_1code], 'print <<<EOT')) {
        return run_label_php($listdb);
    }
    //幻灯片
    if ($format[stype] == 'rollpic' || $format[stype] == 'r') {
        foreach ($listdb as $key => $rs) {
            $iii++;
            $picurl[$iii] = $rs[picurl];
            unset($rs[picurl]);
            $picalt[$iii] = $rs[title];
            @extract($rs);
            eval("\$showurl=\"{$rs['showurl']}\";");
            $piclink[$iii] = $showurl;
        }
        $format[picurl] = $picurl;
        $format[picalt] = $picalt;
        $format[piclink] = $piclink;
        return rollPic_JS($format);
    }
    $listdb = array_chunk($listdb, $format[colspan]);
    $width = floor(1 / $format[colspan] * 100);
    foreach ($listdb as $key1 => $array1) {
        $show .= "<tr>";
        //有辅助模板时,第一个外循环,要特别处理一下,即内循环加多一个
        if ($format[tplpart_2code] && $key1 == 0) {
            $array1[-1] = $rs2;
            ksort($array1);
        }
        foreach ($array1 as $key2 => $rs) {
            $jjj++;
            @extract($rs);
            //有辅助模板时,第一个外循环,第一个内循环时,特别处理辅助模板
            if ($tpl_2code && $key1 == 0 && $jjj == 1) {
                $format[titlenum2] && ($title = get_word($full_title, $format[titlenum2]));
                $format[content_num2] && ($content = get_word($full_content, $format[content_num2]));
                $htmlcode = addslashes($tpl_2code);
                eval("\$htmlcode=\"{$htmlcode}\";");
                $htmlcode = $htmlcodeTOP = StripSlashes($htmlcode);
            } else {
                $i++;
                //方便模板用序号
                //$htmlcode=addslashes($format[tplpart_1code]);
                $htmlcode = addslashes($rs[tpl_1code]);
                eval("\$htmlcode=\"{$htmlcode}\";");
                $htmlcode = StripSlashes($htmlcode);
            }
            $show .= "<td width={$width}%>{$htmlcode}</td>";
            $DivTpl .= $htmlcode;
        }
        $show .= "</tr>";
    }
    if ($format[DivTpl]) {
        //DIV布局
        return $DivTpl;
    } else {
        //table布局
        return "{$htmlcodeTOP}<table width='100%' border='0' cellspacing='0' cellpadding='0'>{$show}</table>";
    }
}
Beispiel #2
0
 } elseif ($rs[type] == 'rollpic') {
     $detail = unserialize($rs[code]);
     foreach ($detail[picurl] as $key => $value) {
         $detail[picurl][$key] = En_TruePath($value, 0);
     }
     foreach ($detail[piclink] as $key => $value) {
         $detail[piclink][$key] = En_TruePath($value, 0);
     }
     if ($detail[rolltype] == 2) {
         //自定义样式
         unset($_listdb);
         foreach ($detail[picurl] as $key => $value) {
             $_listdb[] = array('picurl' => tempdir($value), 'link' => $detail[piclink][$key], 'url' => $detail[piclink][$key], 'title' => $detail[picalt][$key]);
         }
         $_listdb[0][tpl_1code] = En_TruePath($detail[tplpart_1code], 0);
         $value = run_label_php($_listdb);
     } elseif ($detail[picalt][1] == '') {
         //没有标题的情况
         $value = rollPic_no_title_js($detail);
     } else {
         if ($detail[rolltype] == 1) {
             $value = rollPic_flash($detail);
         } else {
             $value = rollpic_2js($detail);
         }
     }
 } else {
     $value = stripslashes($rs[code]);
     //真实地址还原
     $value = En_TruePath($value, 0);
 }