http url querystring to array in PHP
<?php
$urlQueryString = “param=1&pageNo=0&pageSize=10″;
parse_str($url,$args);//此方法是void的,没有返回值。第二个参数是返回值。
/**
parse_str($url);
echo $param;
echo $pageNo;
**/
print_r($args);
?>
http url querystring to array in PHP
<?php
$urlQueryString = “param=1&pageNo=0&pageSize=10″;
parse_str($url,$args);//此方法是void的,没有返回值。第二个参数是返回值。
/**
parse_str($url);
echo $param;
echo $pageNo;
**/
print_r($args);
?>
FLEA是一个兼容PHP4的phpmvc框架,tbs(小强)是一个轻量级的模板引擎,FLEA默认是不支持Tbs的,于是按照其结构写了下边的代码
\FLEA\View\Tbs.php
<?php
/////////////////////////////////////////////////////////////////////////////
// FleaPHP Framework
//
// Copyright (c) 2005 – 2008 QeeYuan China Inc. (http://www.qeeyuan.com)
//
// 许可协议,请查看源代码中附带的 LICENSE.txt 文件,
// 或者访问 http://www.fleaphp.org/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////
/**
* 定义 FLEA_View_Tbs 类
*
* @copyright Copyright (c) 2005 – 2008 QeeYuan China Inc. (http://www.qeeyuan.com)
* @author 起源科技 (www.qeeyuan.com)
* @package Core
* @version $Id: Smarty.php 1005 2007-11-03 07:43:55Z qeeyuan $
*/
// {{{ includes
do {
if (PHP5) {
if (class_exists(‘clsTinyButStrong’, false)) { break; }
} else {
if (class_exists(‘clsTinyButStrong’)) { break; }
}
$viewConfig = FLEA::getAppInf(‘viewConfig’);
if (!isset($viewConfig['tbsDir']) && !defined(‘TBS_DIR’)) {
FLEA::loadClass(‘FLEA_View_Exception_NotConfigurationTbs’);
return __THROW(new FLEA_View_Exception_NotConfigurationTbs());
}
if (PHP5) {
$filename = $viewConfig['tbsDir'] . ‘/tbs_class_php5.php’;
}else{
$filename = $viewConfig['tbsDir'] . ‘/tbs_class.php’;
}
if (!is_readable($filename)) {
FLEA::loadClass(‘FLEA_View_Exception_InitTbsFailed’);
return __THROW(new FLEA_View_Exception_InitTbsFailed($filename));
}
require($filename);
} while (false);
// }}}
class FLEA_View_Tbs extends clsTinyButStrong
{
/**
* 构造函数
*
* @return FLEA_View_Tbs
*/
function FLEA_View_Tbs() {
parent::clsTinyButStrong();
$viewConfig = FLEA::getAppInf(‘viewConfig’);
if (is_array($viewConfig)) {
foreach ($viewConfig as $key => $value) {
if (isset($this->{$key})) {
$this->{$key} = $value;
}
}
}
//FLEA::loadClass(‘FLEA_View_SmartyHelper’);
//new FLEA_View_SmartyHelper($this);
}
}
?>
FLEA\View\Exception\InitTbsFailed.php
<?php
/////////////////////////////////////////////////////////////////////////////
// FleaPHP Framework
//
// Copyright (c) 2005 – 2008 QeeYuan China Inc. (http://www.qeeyuan.com)
//
// 许可协议,请查看源代码中附带的 LICENSE.txt 文件,
// 或者访问 http://www.fleaphp.org/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////
/**
* 定义 FLEA_View_Exception_InitSmartyFailed 类
*
* @copyright Copyright (c) 2005 – 2008 QeeYuan China Inc. (http://www.qeeyuan.com)
* @author 起源科技 (www.qeeyuan.com)
* @package Exception
* @version $Id: InitSmartyFailed.php 972 2007-10-09 20:56:54Z qeeyuan $
*/
/**
* FLEA_View_Exception_InitSmartyFailed 指示 FLEA_View_Smarty 无法初始化 Smarty 模版引擎
*
* @package Exception
* @author 起源科技 (www.qeeyuan.com)
* @version 1.0
*/
class FLEA_View_Exception_InitTbsFailed extends FLEA_Exception
{
var $filename;
function FLEA_View_Exception_InitTbsFailed($filename)
{
$this->filename = $filename;
$code = 0×0905002;
parent::FLEA_Exception(sprintf(_ET($code), $filename), $code);
}
}
FLEA\View\Exception\NotConfigurationTbs.php
<?php
/////////////////////////////////////////////////////////////////////////////
// FleaPHP Framework
//
// Copyright (c) 2005 – 2008 QeeYuan China Inc. (http://www.qeeyuan.com)
//
// 许可协议,请查看源代码中附带的 LICENSE.txt 文件,
// 或者访问 http://www.fleaphp.org/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////
/**
* 定义 FLEA_View_Exception_NotConfigurationSmarty 类
*
* @copyright Copyright (c) 2005 – 2008 QeeYuan China Inc. (http://www.qeeyuan.com)
* @author 起源科技 (www.qeeyuan.com)
* @package Exception
* @version $Id: NotConfigurationSmarty.php 972 2007-10-09 20:56:54Z qeeyuan $
*/
/**
* FLEA_View_Exception_NotConfigurationSmartySmarty 表示开发者
* 没有为 FLEA_View_Smarty 提供初始化 Smarty 模版引擎需要的设置
*
* @package Exception
* @author 起源科技 (www.qeeyuan.com)
* @version 1.0
*/
class FLEA_View_Exception_NotConfigurationTbs extends FLEA_Exception
{
function FLEA_View_Exception_NotConfigurationTbs()
{
$code = 0×0905001;
parent::FLEA_Exception(_ET($code), $code);
}
}
修改FLEA\_Errors\chinese-utf8\ErrorMessage.php
增加
// FLEA_View_Exception_NotConfigurationTbs
0×0905001 => ‘FLEA_View_Tbs 需要应用程序设置 “viewConfig[\'tbsDir\']“.’,
// FLEA_View_Exception_InitTbsFailed
0×0905002 => ‘Tbs 模板引擎文件 “%s” 没有找到.’,
增加FLEA\Helper\Tbs.php
<?php
class FLEA_Helper_Tbs{
var $TBS;
function FLEA_Helper_Tbs($TBS = null){
$this->TBS = $TBS;
}
function prepareRender($tpl){
$TBS = $this->TBS;
$TBS->ObjectRef['helper'] = &$this;
$TBS->ObjectRef['controllerName']=$this->_controllerName;
$TBS->LoadTemplate($tpl) ;
$TBS->MergeField(‘get’,$_GET);
$TBS->MergeField(‘post’,$_POST);
$TBS->MergeField(‘session’,$_SESSION);
$TBS->MergeField(‘server’,$_SERVER);
$TBS->MergeField(‘request’,$_REQUEST);
$TBS->MergeField(‘cookies’,$_COOKIE);
$TBS->MergeField(‘env’,$_ENV);
}
function url($controllerName, $actionName=null, $argsUrl=null, $anchor=null, $options=null){
$argsUrl = str_replace(“‘”,”",$argsUrl);
parse_str($argsUrl,$args);
return url($controllerName, $actionName, $args, $anchor, $options);
}
}
使用例子
app/index.php
<?php
require(‘../config.php’);
$dir = dirname(__FILE__);
define(‘NO_LEGACY_FLEAPHP’, true);
define(‘APP_DIR’, $dir . ‘/APP’);
//’urlMode’=>’URL_STANDARD’,
//’urlMode’=>’URL_PATHINFO’,
$appInf = array(
‘dbDSN’=>$dsn,
‘autoSessionStart’ =>true,
‘autoResponseHeader’=>true,
‘controllerAccessor’=>’ctrl’,
‘actionAccessor’=>’act’,
‘urlAlwaysUseBootstrap’=>false,
‘urlMode’=>’URL_STANDARD’,
‘view’ => ‘FLEA_View_Tbs’,
‘viewConfig’ => array(
‘tbsDir’ => INCLUDES_PATH.’lib/tbs_us/’,
‘NoErr’ =>false,
)
);
FLEA::loadAppInf($appInf);
FLEA::import(APP_DIR);
FLEA::runMVC();
?>
app/Controller/Base.php
<?php
class Controller_Base extends FLEA_Controller_Action{
function Controller_Base($controllerName){
define(‘ADMIN_TPL_DIR’, dirname(__FILE__).’/');
parent::FLEA_Controller_Action($controllerName);
$this->_getDispatcher();
if($controllerName!=”Login” && $_SESSION['access'] != “true”){
$this->_forward(“Login”,”Index”);
}else{
$TBS =& $this->_getView();
FLEA::loadFile(‘FLEA_Helper_Tbs.php’,true);
$TBS_Helper = new FLEA_Helper_Tbs($TBS);
$TBS_Helper->prepareRender(ADMIN_TPL_DIR.$this->_controllerName.’.html’);
}
}
}
app/Controller/Default.php
<?php
FLEA::loadFile(dirname(__FILE__) .”/Base.php”);
class Controller_Default extends Controller_Base{
function actionIndex() {
$TBS =& $this->_getView();
$TBS->Show() ;
}
}
app/Controller/Default.html
[onload;file='__Header.html']
<a target=”_Right” href=”[var.~helper.url(PostEdit);htmlconv=no;]“>Test</a>
[onload;file='__Footer.html']
欢迎各位与我交流。
打开libraries/config.default.php/
默认的PHPmyadmin config是不用验证直接访问,http及cookie均要求先通过验证
$cfg['Servers'][$i]['controluser'] = ”;
$cfg['Servers'][$i]['controlpass'] = ”;
$cfg['Servers'][$i]['user'] = ”; // MySQL user
$cfg['Servers'][$i]['password'] = ”; // MySQL password (only needed
$cfg['Servers'][$i]['only_db'] = ”; // If set to a db-name, only
修改
$cfg['Servers'][$i]['auth_type'] = ‘cookie’; // Authentication method (config, http or cookie based)?$cfg['Servers'][$i]['auth_type'] =
改为cookie,并设置
$cfg['blowfish_secret'] = ”;//随便添加一个秘密值
保存上传就能实现PHPmyadmin web验证了