tipask 修改,临时的(暂没进行很好的全面考虑,为上线用)

    技术2022-05-19  21

    此问吧程序基本上是通过index.php来传递操作信息;在control(起了设置参数=功能)中对应的名字的php调用model(用于实现功能)对应名字的php;再调用对应的html来显示;html是保存在view中;

    2011-2-21 by qidizi增加功能:分类中增加一个属性,用于控制是否在前台主页分类中显示此分类;1 ask_category表中增加一个字段:index_show boolean 默认是0;alter table ask_category add `index_show` boolean not null default 0;2 修改view目录中editcategory.html文件加上开关 在分类目录后插入以下代码

    <tr><th colspan="2">首页显示:</th></tr><tr><td><input name="index_show" type="checkbox"  {eval echo ($category['index_show']?"checked":''); }></td><td>在首页左边的分类中是否显示。</td></tr>3 修改control文件夹中admin_category.php加上传入参数代码

               在onedit()中             $index_show = $this->post['index_show'];            if (isset($index_show) && ($index_show == 'on'))$index_show=1;            else $index_show = 0;前插入上面代码,并为下面增加参数$index_show,            $_ENV['category']->update_by_id($id,$name,$categorydir,$cid,$index_show);4 model文件夹中category.class.php增加接收参数  function update_by_id($id,$name,$categorydir,$pid,$index_show) {    $this->db->query("UPDATE `".DB_TABLEPRE."category` SET  `index_show`=$index_show,`pid`=$pid ,`grade`=$grade , `name`='$name', `dir`='$categorydir' WHERE `id`=$id");//add by qidizi `index_show`=$index_show,增加一参数,$index_show;

    5 model中category.class.php修改/*用于在首页左侧显示*/    function list_by_grade($grade=1) {成判断是否属于首页显示的分类再加入首页调用的数组;$query=$this->db->query("select id,name,questions,grade,index_show from ".DB_TABLEPRE."category where grade=1 order by displayorder asc,id asc");加入查询index_show的字段;while($category1=$this->db->fetch_array($query)) {            if (!$category1['index_show']) continue;//不属于首页分类不加入数组;加入只有首页显示的分类才显示;修改完成;

     

     

    ----------------------------------------2011 2 22 屏闭掉回答问题的论证码检查功能model中base.class.php/*检查验证码*/    function checkcode() {    return true;//add by qidizi,no code;中中断为直接返回true;

    --------------------------------2011 2 22增加写入缓存权限判断,否则移动到新服务器时因为缓存文件不存在,写入失败而导致错误错误

    lib中tem...func.php

        $fp = @fopen($objfile, 'w') or die("Directory './data/view/' not found or have no access!");

        $template = preg_replace("//"(http)?[/w/.//:]+/?[^/"]+?&[^/"]+?/"/e", "transamp('//0')", $template);    $template = preg_replace("//<script[^/>]*?src=/"(.+?)/".*?/>/s*/<//script/>/ise", "stripscriptamp('//1')", $template);

        flock($fp, 2);    @fwrite($fp, $template) or die("Directory './data/view/'  no access for write!");    fclose($fp);}

    --------------去掉端口号,如何使用有端口登录时

    根目录下的index.php中,改写site_url定义

    define('SITE_URL','http://'.preg_replace('///:/d+/','',$_SERVER['HTTP_HOST']).substr($_SERVER['PHP_SELF'],0,-9) );//add by qidizi

    ----------------------缓存功能导致发贴不及时显示优化,暂不用,发现动态解释时,用到model=模式,会出错

    view文件夹中的tip.html文件

    修改成以下代码,主要是用js加上时间,让服务器及时更新

                            页面将在6秒后自动跳转到下一页,你也可以直接点 <a href="$redirect" >立即跳转</a>。                        <script type="text/javascript">                            function redirect(url, time) {                                if (!//?/.test(url)) url = url + "?time=" + new Date().getTime();                                else if (//?.+/.test(url)) url = url + "&time=" + new Date().getTime();                                else url = url + "time=" + new Date().getTime();                                setTimeout("window.location='" + url + "'", time * 1000);                            }                            redirect('$redirect', 6);                        </script>                                                --------------------------在view default下面的nosole.html list.html close.html sole.html== 包含有 赏金求答案 的都是用于对应页面:问题关闭,待解决,已解决,列表;可以使用动态地址方式看到实时修改模板效果;

    ----------解决js跨域问题:注意下面代码不能直接放到html中,因为tipask的模板解释script,导致页面出错;所以只能使用js调用方式js_reset_domain(js_path)qidizi.js

    function js_reset_domain(js_path){//解决跨域问题,替换成当前域  js_path = js_path.replace(/^ *http/:[^//]+/i,"http://" + location.hostname);  js_path = '<script type="text/javascript" ' + ' src="' + js_path;  js_path = js_path + '" ' + '></script' + '>';  document.writeln( js_path );}

    <script type="text/javascript" src="{SITE_URL}js/qidizi.js"></script><script type="text/javascript"> js_reset_domain("{SITE_URL}js/jquery.js"); js_reset_domain("{SITE_URL}js/dialog.js"); js_reset_domain("{SITE_URL}js/common.js");</script>

    -------------解决动态页面使用www有缓存地址问题

    首页index.php有声明SITE_URL下行修改

    define('SITE_URL_WWW','http://www.'.preg_replace('///:/d+/','',preg_replace('/^ *www//./','',$_SERVER['HTTP_HOST'])).substr($_SERVER['PHP_SELF'],0,-9) );//有www,去掉端口define('SITE_URL',preg_replace("/^ *http//:// *www//./i",'http://',SITE_URL_WWW));//无www,

    在libtemplate.func.php中加入一个func

    function no_www($url){//去掉www,只使用父域  return preg_replace("/^ *http//:// *www//./i",'http://',$url);}上面修改用于直接调用

    在libtemplate.func.php

        $template = preg_replace("//{url/s+(.+?)/}/ies", "url('//1')", $template);//这行插入下面二句    $template = preg_replace("//{url_www/s+(.+?)/}/ies", "url_www('//1')", $template);//无www

    并在global.func.php加入以下二个func

    /* 返回无缓存页面地址 */

    function url_www($var, $url='') {    global $setting;    $location = '?' . $var . $setting['seo_suffix'];    if ($setting['static_on'] && $url) {        return SITE_URL_WWW . $url; //主要是程序动态获取的,给question的model使用    }    if ($setting['seo_on']) {        $rewritearray = array('question/view/', 'category/view/', 'category/list/', 'category/recommend/', 'user/space/', 'user/scorelist/');        foreach ($rewritearray as $item) {            if (false !== strpos($var, $item)) {                $location = $var . $setting['seo_suffix'];            }        }    }    $location = urlmap($location, 2);    if ($url)        return SITE_UR_WWW . $location; //程序动态获取的,给question的model使用 else        return '<?=SITE_URL_WWW?>' . $location; //模板编译时候生成使用}

    在调用时对应调用即可;

    静态直接使用{$sss['url']},不要使用{url xxx}

    ---------修改cookie域数据库中setting表中cookie_domain修改;

    --------修改headter.html模板的site_url重设,解决跨域问题;

    js/qidizi.js中function reset_domain(js_path){//解决跨域问题,替换成当前域  js_path = js_path.replace(/^ *http/:[^//]+/i,"http://" + location.hostname);  return js_path;}

     

    js/qidizi.js中function reset_domain_no_www(js_path){//替换成无www.  js_path = js_path.replace(/^ *http/:www/./i,"http://");  return js_path;}

    ---------------------

    解决生成静态,也把用户生成了;

    在header.html中替换掉用户条那里.

    <div class="top">

     <iframe src="{SITE_URL_WWW}index.php?user/login_show.html" style="width:100%;height:23px;border:0px;" FRAMEBORDER=0></iframe>要替换成这个,在上面和下面之间

     <div class="top2">   保存login_show.html到viw default {eval global $starttime,$querynum;$mtime = explode(' ', microtime());$runtime=number_format($mtime[1] + $mtime[0] - $starttime,6); $setting=$this->setting;$user=$this->user;$headernavlist=$this->nav;$regular=$this->regular;}<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset={TIPASK_CHARSET}"/><title>{$navtitle} {$setting['site_name']} {$setting['seo_title']}</title><meta name="keywords" content="{$metakeywords}{$setting['seo_keywords']}" /><meta name="description" content="$metadescription {$setting['site_name']} {$setting['seo_description']}" /><meta name="generator" content="Tipask {TIPASK_VERSION} {TIPASK_RELEASE}" /><meta name="author" content="Tipask Team" /><meta name="copyright" content="2011 Tipask.com." /><meta name="robots" content="index, follow"><meta name="googlebot" content="index, follow"><link href="{SITE_URL}css/default/ask.css" rel="stylesheet" type="text/css">

    <script type="text/javascript" src="{SITE_URL}js/qidizi.js"></script><script type="text/javascript">g_site_url=reset_domain('{SITE_URL}');g_prefix='{$setting['seo_prefix']}';g_suffix='{$setting['seo_suffix']}';editor_items='{$setting['editor_items']}';</script><script type="text/javascript"> js_reset_domain("{SITE_URL}js/jquery.js"); js_reset_domain("{SITE_URL}js/dialog.js"); js_reset_domain("{SITE_URL}js/common.js");</script>

    {$setting['seo_headers']}

    </head><body>

    <div class="top1 blake">  <div class="top1right">            <a href="{SITE_URL}" target="_blank">问答首页</a><span>︱</span>              <a href="{url user/ask}" target="_blank">我的提问</a><span>︱</span>              <a href="javascript:void(0)" οnclick="SetHomepage()">设为首页</a><span>︱</span>              <a href="javascript:void(0)" οnclick="addfavorite()">收藏夹</a><span>︱</span>              <a href="{url index/help}" target="_blank">帮助</a>  </div>  <span class="rit padding-r">  <!--{if 0!=$user['uid']}-->   您好,<a href="{url_www user/default}" target="_blank"><strong>{$user['username']}</strong></a>   <!--{if $user['newmsg']>0}-->   | <a id="TopLink_MessageBox" href="{url_no_www message/new}" target="_blank">您有<span id="MessagesCount" style="color: rgb(255, 0, 0);">{$user['newmsg']}</span>条新信息</a>     <!--{/if}-->   | <a href="{url_no_www user/default}"  target="_blank">个人中心</a>    <!--{if $user['groupid']<=3}-->   | <a href="{SITE_URL_NO_WWW}index.php?admin_main"  target="_blank">系统设置</a>   <!--{/if}-->    | <a href="{url_no_www user/logout}" target="_top">退出</a>   <!--{else}-->      您好,欢迎来{$setting['site_name']}![<a  href="{url_no_www user/login}"  target="_top">请登录</a>]       [<a  href="{url_no_www user/register}" target="_top">免费注册</a>]  <!--{/if}-->  </span>  </div> </body></html>

     

    base.class.php

        /*权限检测*/    function checkable($url) {        $this->regular=$url;        if(1==$this->user['groupid']) return true;        $regulars = explode(',', 'user/login,user/logout,user/code,user/getpass,user/resetpass,index/help,js/view,user/login_show,'.$this->user['regulars']);//加上user/login_show,注意最后是,                        user.php        中加入                func               

        function onlogin_show() {        $this->load('setting');        $wordslist = unserialize($this->setting['hot_words']);        $linklist=$this->cache->load('link','id','displayorder');        include template('login_show');    }                -------------        解决静态化没登录跳到不正确的地址        user.php中改成    $this->message('用户名或密码错误!', 'index.php?user/login');        ------------------    原参数改成带www nowww就是无    index.php中改define('SITE_URL','http://www.'.preg_replace('///:/d+/','',preg_replace('/^ *www//./','',$_SERVER['HTTP_HOST'])).substr($_SERVER['PHP_SELF'],0,-9) );

    ------------------------使用了框架,需要改退出链接成 target="_self" 和user.php onloginut中messge这里加上'BACK';让在框架内运行

    ---------------

    在lib/global.func.php中加入一func

    function domain_www($url='') {//把绝对地址转成有www        if ( preg_match("/^/s*http/:/i",$url)  && (!preg_match("/^/s*http/:www/./i",$url)) )               $url= preg_replace("/^/s*http/:/i",'http://www.',$url);        return $url;}

    在模板中使用href="{= domain_www($nosolve['url']);}"

    ---------------lib/temp...func.php

        $template = preg_replace("//{///=/s*([a-zA-Z0-9_/[/]/'/"/$/./x7f-/xff]+)/}/s", "<? echo //1?>", $template);//{= domain_www($nosolve['url']);} 增加解释此格式标签            -------------------    lib/template.func .php    存在一个不存在的func    texit,已修改成exit;    是在缓存文件夹不可用时使用;        --------------    录入站把模板header.html中的框架中的地址改成http://47389.com/ask/.....    然后在base.class.php    中修改,加入复制中的内容         /*生成一个问题的静态页面*/    function write_question($question) {        global $setting,$db;        include_once TIPASK_ROOT.'/control/question.php';        $this->get[2]=$question['id'];        $control = new questioncontrol($this->get,$this->post);        ob_start();        $control->onview();        $html=ob_get_contents();        ob_end_clean();

            $staticurl=getstaticurl($question);        if($question['url'] && file_exists($question['url'])) {            unlink($question['url']);        }        $this->db->query("UPDATE `".DB_TABLEPRE."question`  SET url='$staticurl'  WHERE id =".$question['id']);        forcemkdir(dirname($staticurl));        writetofile($staticurl,$html);        //复制        $ask_html = preg_replace("/http:(www/.)?47389/.com//ask_admin/i", 'http://www.47389.com/ask', $html);        $ask_q_dir = '/var/www/html/ask/question/' . preg_replace('/^.*///','',$staticurl);        qidizi($ask_q_dir. chr(10).$ask_html);        writetofile($ask_q_dir,$ask_html);        //复制                return $staticurl;    }    就可以达到录入时把内容生成到www的站中.                                        ----------------    首页==网友在问这些,    因为在base中用到查询数据库中最新数据,在分类代码写法上可能有问题,导致最后分类不是所有最新,而是某一个类,    需要到base.clas中改 ''成null    因为判断中用到    (type ) && (sql .= '')这样的写,就是如果分类设置了就拼接上.        -----------        把首页的网友正在问,改成无分类区别,要求所有的分类                    case 'indexnosolvelist': //首页待解决问题,网友正在问,这个无分类限制,全部分类                $this->load('question');                $cachedata=$_ENV['question']->list_by_cfield_cvalue_status(null,0,1,0,$this->setting['list_indexnosolve']);                break;                                而需要在首页的模板中用到indexno...这个,而不是原来的.


    最新回复(0)