?? psn.php
字號(hào):
<?
class CPage extends Page
{
var $username;
var $userid;
function CPage(& $app)
{
$this->Page($app);
$this->userid=userid;
$this->username=username;
$this->userlevel=userlevel;
}
function page_load()
{
if (empty($this->in['act'])) $this->onMain();
}
function onInsert(){
if ($this->in['_POST']['do']) {
if (trim($this->in['_POST']['Name']) != '') {
if($this->in['_POST']['psnType']=='local'){
if(empty($this->in['_POST']['localPath'])){
$this->err->catchErr($this->app->getSysMsg('isempty', "localPath"));
}
$localPath='Local::'.$this->in['_POST']['localPath'];
if(!is_dir($this->in['_POST']['localPath'])){
mkdir($this->in['_POST']['localPath'],0777);
chmod($this->in['_POST']['localPath'],0777);
}
}else{
if(empty($this->in['_POST']['ftp_host'])){
$this->err->catchErr($this->app->getSysMsg('isempty', "ftp_host"));
} $localPath='Ftp::'.$this->in['_POST']['ftp_user'].':'.$this->in['_POST']['ftp_pass'].'@'.$this->in['_POST']['ftp_host'].':'.$this->in['_POST']['ftp_port'].$this->in['_POST']['ftp_path'];
}
if(empty($this->in['_POST']['URL'])){
$this->err->catchErr($this->app->getSysMsg('isempty', "URL"));
}
$data=array(Name=>$this->in['_POST']['Name'],
PSN=>$localPath,
URL=>$this->in['_POST']['URL'],
Description=>$this->in['_POST']['Description']);
$PsnID== $this->objDataSet->insert($data, $this->psn);
$this->cachepsn();
header("location:".preg_replace("/totalnum=[^&]*&?/","",$this->fromUrl));
}
else{
$this->err->catchErr($this->app->getSysMsg('isempty', "Name"));
$this->page_err();
}
}
$this->tpl->assign("title", $this->app->getSysMsg('add_psn'));
$this->tpl->assign("act","insert");
$this->tpl->display('admin/psn_add.html');
}
function onUpdate()
{
if ($this->in['_POST']['do']) {
if (trim($this->in['_POST']['Name']) != '') {
if($this->in['_POST']['psnType']=='local'){
if(empty($this->in['_POST']['localPath'])){
$this->err->catchErr($this->app->getSysMsg('isempty', "localPath"));
}
$localPath='Local::'.$this->in['localPath'];
if(!is_dir($this->in['_POST']['localPath'])){
mkdir($this->in['_POST']['localPath'],0777);
chmod($this->in['_POST']['localPath'],0777);
}
}else{
if(empty($this->in['_POST']['ftp_host'])){
$this->err->catchErr($this->app->getSysMsg('isempty', "ftp_host"));
} $localPath='Ftp::'.$this->in['_POST']['ftp_user'].':'.$this->in['_POST']['ftp_pass'].'@'.$this->in['_POST']['ftp_host'].':'.$this->in['_POST']['ftp_port'].$this->in['_POST']['ftp_path'];
}
if(empty($this->in['_POST']['URL'])){
$this->err->catchErr($this->app->getSysMsg('isempty', "URL"));
}
$data=array(Name=>$this->in['_POST']['Name'],
PSN=>$localPath,
URL=>$this->in['_POST']['URL'],
Description=>$this->in['_POST']['Description']);
$this->objDataSet->update($data,"PSNID = '" . $this->in['_POST']['PSNID'] . "'", $this->psn);
}else{
$this->err->catchErr($this->app->getSysMsg('isempty', "Name"));
$this->page_err();
}
$this->cachepsn();
header("location:".preg_replace("/totalnum=[^&]*&?/","",$this->fromUrl));
}
$uData = $this->objDataSet->getDataById($this->in['_GET']['PSNID'], "PSNID", $this->psn);
$updateData['Name']=$uData['Name'];
if(ereg('Local::',$uData['PSN'])){
$updateData['localPath']=str_replace('Local::','',$uData['PSN']);
}else
{
$updateData['select']=='1';
}
$updateData['URL']=$uData['URL'];
$updateData['Description']=$uData['Description'];
$updateData['PSNID']=$this->in['_GET']['PSNID'];
$this->tpl->assign("title", $this->app->getSysMsg('edit_psn'));
$this->tpl->assign("act","update");
$this->tpl->assign('updateData', $updateData);
$this->tpl->display("admin/psn_add.html");
}
function onList()
{
$in = &$this->in;
$tpl = &$this->tpl;
$objDataSet = &$this->objDataSet;
$objServer = &$this->objServer;
$orderfield = $in['orderfield'] ? $in['orderfield'] : "PSNID";
$ordermode = $in['ordermode'] ? $in['ordermode'] : "desc";
$loop_data = $objDataSet->getList("select * from " . $this->psn . " order by $orderfield $ordermode", 20);
$tpl->assign("total", $loop_data->total());
$tpl->assign("fromto", $loop_data->fromto());
$loop_data->navchar = array($this->app->getSysMsg('firstpage'), '[<]', '[>]', $this->app->getSysMsg('endpage'));
$tpl->assign("navbar", $loop_data->navbar(10));
$tpl->assign("fieldsdata", $loop_data->field);
$tpl->assign($in['_GET']);
$column_id = $this->getColumnStr($this->app->getSysMsg('id'), "PSNID", (!$in['ordermode'] ? "↓" : "")) ;
$psn_name = $this->getColumnStr($this->app->getSysMsg('psn_name'), "Name") ;
$tpl->assign(array('column_id' => $column_id,
'psn_name' => $psn_name)) ;
$tpl->assign("title", $this->app->getSysMsg('list_psn'));
$tpl->display("admin/list_psn.htm");
}
function onDelete()
{
$in = & $this->in;
$dataset = & $this->objDataset;
if (isset($in['row_select']))
{
$ids = "'".implode("','",$in['row_select'])."'";
}
else $ids = "'".$in['PSNID']."'";
$dataset->delete("PSNID in ($ids)",$this->psn);
$this->cachepsn();
$this->page_err();
header("location:".preg_replace("/totalnum=[^&]*&?/","",$this->fromUrl));
}
function onChoose()
{
$sql = "SELECT * FROM " . $this->psn . " ORDER BY PSNID ASC";
$this->db->query($sql);
$psnlist = array();
while ($row = $this->db->fetch_array()) {
$psnlist[] = $row;
}
//print_r($psnlist);
$this->tpl->assign('psnlist',$psnlist);
$this->tpl->assign('topic',$this->app->getSysMsg('Choose_ResourcePSN'));
$this->tpl->display('admin/select_psn.html');
}
function onpsn_list_file()
{
include_once(DIR_CACHE.'cache_PSN.inc.php');
$path=str_replace('Local::','',$PSN_cache[$this->in[PSNID]][PSN]).$this->in['_GET']['PATH'];
if($this->in['_GET'][extra]=='updir'){
$path.='/../';
}
$this->app->includeClass("FileManager");
$FileManager=new FileManager;
$dirlist=$FileManager->fileList($path,$listChildDirs=false,$onlyDir=ture,$showPre=ture,$order="name");
$this->tpl->assign('PATH',$this->in['_GET']['PATH']);
$this->tpl->assign('PSNID',$this->in[PSNID]);
$this->tpl->assign('dirlist',$dirlist);
$this->tpl->display('admin/select_psn_fileList.html');
}
function onpsn_picker()
{
$sql = "SELECT * FROM " . $this->psn . " ORDER BY PSNID ASC";
$this->db->query($sql);
$psnlist = array();
while ($row = $this->db->fetch_array()) {
$psnlist[] = $row;
}
//print_r($psnlist);
$this->tpl->assign('psnlist',$psnlist);
$this->tpl->assign('topic',$this->app->getSysMsg('Choose_ResourcePSN'));
$this->tpl->display('admin/select_psn_picker.html');
}
function onpsn_picker_list_file()
{
include_once(DIR_CACHE.'cache_PSN.inc.php');
$path=str_replace('Local::','',$PSN_cache[$this->in[PSNID]][PSN]).$this->in['_GET']['PATH'];
if($this->in['_GET'][extra]=='updir'){
$path.='/../';
}
$this->app->includeClass("FileManager");
$FileManager=new FileManager;
$dirlist=$FileManager->fileList($path,$listChildDirs=false,$onlyDir=ture,$showPre=ture,$order="name");
$this->tpl->assign('PATH',$this->in['_GET']['PATH']);
$this->tpl->assign('PSNID',$this->in[PSNID]);
$this->tpl->assign('dirlist',$dirlist);
$this->tpl->display('admin/select_psn_picker_fileList.html');
}
function onpsn_mkdir()
{
include_once(DIR_CACHE.'cache_PSN.inc.php');
$path=str_replace('Local::','',$PSN_cache[$this->in[PSNID]][PSN]).$this->in['_GET']['PATH'];
mkdir($path.'/'.$this->in['dirname'],0777);
chmod($path.'/'.$this->in['dirname'],0777);
echo"<script language=javascript>alert('".$this->app->getSysMsg('makedir_ok')."');"; echo"setTimeout('window.location.href=\"index.php?module=psn&act=psn_list_file&PSNID=".$this->in[PSNID]."\"',0);</script>";
}
function cachepsn()
{
$sql = "select * from ".$this->psn." order by PSNID";
$this->db->query($sql);
$psnarray = array();
while ($row = $this->db->fetch_array())
{
$psnarray[$row[PSNID]] = $row;
}
$cache = var_export($psnarray,TRUE).';'.PHP_NEXTLINE.PHP_NEXTLINE;
if(@$fp = fopen(DIR_CACHE.'cache_PSN.inc.php', 'w'))
{
@fwrite($fp, "<?php".PHP_NEXTLINE."//SSMS cache file, DO NOT modify me!".
PHP_NEXTLINE."//Created on ".date("M j, Y,G:i").PHP_NEXTLINE.PHP_NEXTLINE."\$PSN_cache=".$cache.PHP_CLOSE_TAG);
@fclose($fp);
}else{
exit('Can not write to cache file, please check cache directory.');
}
}
}
?>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -