分类 Php编程 下的文章

织梦CMS中嵌套查询语句,SetQuery和GetObject传入不同的参数就可以了。

if($keyword != '')
{
	$query2 = "SELECT id,title,typeid FROM `#@__archives` where arcrank>-1 AND ($keyword) ORDER BY id desc limit 0,5";
}
else
{
	$query2 = "SELECT id,title,typeid FROM `#@__archives` where arcrank>-1 ORDER BY id desc limit 0,5";
}
$dsql->SetQuery($query2);
$dsql->Execute(1);
while($row=$dsql->GetObject(1))
{
	$dsql->SetQuery("Select typedir From `#@__arctype` where id='$row->typeid'");
	$dsql->Execute(2);
	$ttrow=$dsql->GetObject(2);
	$tpdir=substr($ttrow->typedir,10);
	$likearticle .= "
  • ".cut_str(ConvertStr($row->title),16)."
  • "; }

    今天帮朋友迁移一个教育网站,在目标主机上面搭建好LNMP后,把网站打包上传,数据库备份上传,把数据库导入,网站文件和目录设置好,还有一些乱七八糟的设置设置。配置弄好后,启动程序,测试一下网站是否和原来的功能是否一致,页面是否都正常,需要和没迁移前保持一样。经过测试,其他的几个模块都没有问题,有一个BBS的模块,使用的dizcuz的程序,版本有些老了,打开首页直接显示模板内容了。看了对应的php是可以解析的,php解析没有问题,再看权限,设置的也合理。最后看了看解析的代码页没有问题,网站的文件都是打包过来的,文件一致性肯定能保证,肯定是环境哪里设置的问题。最好找了半天发现一个php的参数没有修改,原来是short_open_tag = Off,修改为On,重启一下php-fpm,(如果你是apache+php模块,就重启apache),再次访问就正常了。关于这个参数区别如下:

    php.ini
    ; This directive determines whether or not PHP will recognize code between
    ;  tags as PHP source which should be processed as such. It's been
    ; recommended for several years that you not use the short tag "short cut" and
    ; instead to use the full  tag combination. With the wide spread use
    ; of XML and use of these tags by other languages, the server can become easily
    ; confused and end up parsing the wrong code in the wrong context. But because
    ; this short cut has been a feature for such a long time, it's currently still
    ; supported for backwards compatibility, but we recommend you don't use them.
    ; Default Value: On
    ; Development Value: Off
    ; Production Value: Off
    ; http://php.net/short-open-tag
    short_open_tag = On
    

    这种情况也只有迁移的时候会遇到,如果重新安装,discuz检查php参数的时候肯定是报错不通过的。

    最近用dedecms搭建了一个简单的站,主要用于测试。发现在后台系统-系统基础参数。很多选项没有办法成功设置中文。
    实际上提交已成功,看数据库dede_sysconfig记录已成功插入,应该属于显示问题。看显示代码

    dede/templets/sys_info.htm:
    	echo "{$addstr}";
    

    用于转换html特殊字符,网上查询了一下,是PHP5.4以上版本会有这个问题,必须指定编号类型。需修改为

    	echo "{$addstr}";
    

    修改后,再修改系统基础参数就可以显示了。
    因为代码中太多类似的代码了,最好还是降低一下php的版本。

    应基友要求写一遍安装EasyXSS 1.0的文章,就在windows临时搭建了一下XSS环境,使用的是XAMPP搭建的,比较方便。
    XAMPP截图
    11-150x150
    1.apache 配置要点

    DocumentRoot “D:/xampp/htdocs”
    

    2.解压EASYXSS为xss到web目录下

    修改配置文件D:xampphtdocsxssAppConfconfig.php
     'User',
            'URL_MODEL'          => '1',
            'SESSION_AUTO_START' => true,
            'DB_DSN' => 'mysql://root:@127.0.0.1:3306/xss_tw',
            'DB_PREFIX' => 'xss_',
            'MAIL_ADDRESS'=>'info@xss.tw',
            'MAIL_SMTP'=>'smtp.gmail.com',
            'MAIL_LOGINNAME'=>'info@xss.tw',
            'MAIL_PASSWORD'=>'',
            'MAIL_SENDER'=>'info',
            'MAIL_PORT'=>'465',
            'TMPL_PARSE_STRING' =>array(
            	'__SITENAME__' =>'EasyXSS 1.0',
            	'__SITETITLE__'=>'EasyXSS',
            	),
        );
    ?>
    

    root为用户名,密码为空
    3.创建数据库

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | cdcol              |
    | mysql              |
    | performance_schema |
    | phpmyadmin         |
    | webauth            |
    +--------------------+
    6 rows in set (0.00 sec)
    mysql> create database xss_tw;
    Query OK, 1 row affected (0.00 sec)
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | cdcol              |
    | mysql              |
    | performance_schema |
    | phpmyadmin         |
    | webauth            |
    | xss_tw             |
    +--------------------+
    7 rows in set (0.00 sec)
    D:xamppmysqlbin>mysql.exe -uroot xss_tw -p < data.sql
    Enter password:
    D:xamppmysqlbin>mysql.exe -uroot -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 5
    Server version: 5.5.8 MySQL Community Server (GPL)
    Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    mysql> use xss_tw
    Database changed
    mysql> show tables;
    +------------------+
    | Tables_in_xss_tw |
    +------------------+
    | xss_ipdata       |
    | xss_key          |
    | xss_keyemail     |
    | xss_project      |
    | xss_user         |
    | xss_xssresult    |
    +------------------+
    6 rows in set (0.00 sec)
    mysql> select * from xss_key
        -> ;
    +-----+-------+------------+-------+------+
    | iid | ctime | key        | utime | user |
    +-----+-------+------------+-------+------+
    |   1 |     0 | 1234567890 |     0 |      |
    +-----+-------+------------+-------+------+
    1 row in set (0.02 sec)
    

    4.注册用户
    22-150x150
    5.登录
    33-150x150
    6.测试
    44-150x150

    帮gf把网站给迁移的时候,因为php版本比较高,导致登录的时候不能访问后台,只返回空页面,高版本不兼容,郁闷。wordpress做的挺好,主流兼容性比较好.
    百度之,搜了一下解决的方法,原来是一个函数的问题,下面是解决的方法。
    登陆dedemcs后台输入用户名和密码后没有提示显示为空白,主要原为是php5.4的版本废除了session_register函数
    可以采用如$_SESSION[$this->keepUserIDTag] = $this->userID; 这种方式处理完整代码如下
    首先打开 include/userlogin.class.php这个文件,在287行到308行原内容如下:

    @session_register($this->keepUserIDTag);
    $_SESSION[$this->keepUserIDTag] = $this->userID;
    @session_register($this->keepUserTypeTag);
    $_SESSION[$this->keepUserTypeTag] = $this->userType;
    @session_register($this->keepUserChannelTag);
    $_SESSION[$this->keepUserChannelTag] = $this->userChannel;
    @session_register($this->keepUserNameTag);
    $_SESSION[$this->keepUserNameTag] = $this->userName;
    @session_register($this->keepUserPurviewTag);
    $_SESSION[$this->keepUserPurviewTag] = $this->userPurview;
    @session_register($this->keepAdminStyleTag);
    $_SESSION[$this->keepAdminStyleTag] = $adminstyle;
    PutCookie(‘DedeUserID’, $this->userID, 3600 * 24, ‘/’);
    PutCookie(‘DedeLoginTime’, time(), 3600 * 24, ‘/’);
    

    替换成

    global $admincachefile,$adminstyle;
    if(empty($adminstyle)) $adminstyle = ‘dedecms’;
    //@session_register($this->keepUserIDTag);
    $_SESSION[$this->keepUserIDTag] = $this->keepUserIDTag;
    $_SESSION[$this->keepUserIDTag] = $this->userID;
    //@session_register($this->keepUserTypeTag);
    $_SESSION[$this->keepUserTypeTag] = $this->keepUserTypeTag;
    $_SESSION[$this->keepUserTypeTag] = $this->userType;
    // @session_register($this->keepUserChannelTag);
    $_SESSION[$this->keepUserChannelTag] = $this->keepUserChannelTag;
    $_SESSION[$this->keepUserChannelTag] = $this->userChannel;
    //@session_register($this->keepUserNameTag);
    $_SESSION[$this->keepUserNameTag] = $this->keepUserNameTag;
    $_SESSION[$this->keepUserNameTag] = $this->userName;
    //@session_register($this->keepUserPurviewTag);
    $_SESSION[$this->keepUserPurviewTag] = $this->keepUserPurviewTag;
    $_SESSION[$this->keepUserPurviewTag] = $this->userPurview;
    // @session_register($this->keepAdminStyleTag);
    $_SESSION[$this->keepAdminStyleTag] = $this->keepAdminStyleTag;
    $_SESSION[$this->keepAdminStyleTag] = $adminstyle;
    PutCookie(‘DedeUserID’, $this->userID, 3600 * 24, ‘/’);
    PutCookie(‘DedeLoginTime’, time(), 3600 * 24, ‘/’);