function edit_action() { $path=ROOT.'/lang/'.config::get('lang_type').'/system.php'; $tipspath=ROOT.'/lang/cn/system.php'; if (front::post('submit')) { $content=file_get_contents($path); $to_delete_items=front::$post['to_delete_items']; unset(front::$post['to_delete_items']); foreach (front::$post as $key=>$val) { preg_match_all("/'".$key."'=>'(.*?)',/",$content,$out); if (is_array($to_delete_items) && in_array($key,$to_delete_items)) $content=str_replace($out[0][0],'',$content); else $content=str_replace($out[1][0],$val,$content); } file_put_contents($path,$content); if ($_GET['site'] != 'default') { $ftp=new nobftp(); $ftpconfig=config::get('website'); $ftp->connect($ftpconfig['ftpip'],$ftpconfig['ftpuser'],$ftpconfig['ftppwd'],$ftpconfig['ftpport']); $ftperror=$ftp->returnerror(); if ($ftperror) { exit($ftperror); } else { $ftp->nobchdir($ftpconfig['ftppath']); $ftp->nobput($ftpconfig['ftppath'].'/lang/'.config::get('lang_type').'/system.php',$path); } } unset($content); event::log('修改语言包','成功'); echo '<script type="text/javascript">alert("操作完成!");window.location.href="'.url('language/edit',true).'";</script>'; } $content=include($path); $tips=include($tipspath); $this->view->tips=$tips; //分页 $limit = 30; if(!front::get('page')) $page = 1; else $page = front::get('page'); $total = ceil(count($content)/$limit); if($page < 1) $page = 1; if($page > $total) $page = $total; $start = ($page-1) * $limit; $end = $start+$limit-1; $tmp = range($start,$end); $list_content_arr = array(); $i = 0; foreach($content as $k => $v){ if(in_array($i++,$tmp)) $list_content_arr[$k] = $v; } $this->view->sys_lang=$list_content_arr; $this->view->link_str = listPage($total,$limit,$page); }
function run($attachment) { $this->max_size=config::get('upload_max_filesize') * 1024000; if (!isset($this->url_pre)) $this->url_pre='upload/'.$this->dir.'/'.date('Ym'); $this->path=ROOT.'/'.$this->url_pre; tool::mkdir($this->path); if (!$attachment['name']) { return false; } $new_name=$new_name_gbk=str_replace('.','',Time::getMicrotime()).'.'.end(explode('.',$attachment['name'])); $content=file_get_contents($attachment['tmp_name']); if (!front::checkstr($content)) { return false; } if (strlen($content) >$this->max_size) { return false; } if(!in_array(end(explode('.',$attachment['name'])), $this->type)){ return false; } move_uploaded_file($attachment['tmp_name'],$this->path.'/'.$new_name_gbk); $this->save_path=$this->path.'/'.$new_name_gbk; if ($_GET['site'] != 'default') { $ftp=new nobftp(); $ftpconfig=config::get('website'); $ftp->connect($ftpconfig['ftpip'],$ftpconfig['ftpuser'],$ftpconfig['ftppwd'],$ftpconfig['ftpport']); $ftperror=$ftp->returnerror(); if ($ftperror) { exit($ftperror); } else { $ftp->nobchdir($ftpconfig['ftppath']); $ftp->nobput($ftpconfig['ftppath'].'/'.$this->url_pre.'/'.$new_name,$this->save_path); } } return $this->url_pre.'/'.$new_name; }
$_keywordcount=trim(front::post('keywordcount')); session::set('keywordcount', $_keywordcount); } else { session::set('keywordcount', null); $_keywordcount=session::get('keywordcount'); } } if ($_GET['site'] != 'default') { $ftp=new nobftp(); $ftpconfig=config::get('website'); $ftp->connect($ftpconfig['ftpip'], $ftpconfig['ftpuser'], $ftpconfig['ftppwd'], $ftpconfig['ftpport']); $ftperror=$ftp->returnerror(); if ($ftperror) { exit($ftperror); } else { $ftp->nobchdir($ftpconfig['ftppath']); $hotkeywordlist=$ftp->nobnlist($ftpconfig['ftppath'].'/data/hotsearch'); } if (is_array($hotkeywordlist)) { foreach ($hotkeywordlist as $val) { $val=str_replace($ftpconfig['ftppath'], config::get('site_url'), $val); $keywordcount=@file_get_contents($val); $valtmp=str_replace(config::get('site_url'), '', $val); $valtmp=str_replace('/data/hotsearch', '', $valtmp); $valtmp=str_replace('/', '', $valtmp);
function save_action() { $id = front::post('sid'); $tpl = str_replace('_d_','/',$id); $tpl = str_replace('#','',$tpl); $tpl = str_replace('_html','.html',$tpl); $tpl = str_replace('_css','.css',$tpl); $tpl = str_replace('_js','.js',$tpl); $res = array(); $content = htmlspecialchars_decode(front::post('scontent')); $content = preg_replace('%</textarea%','</textarea',$content); if($_GET['site']!='default') { set_time_limit(0); $ftp = new nobftp(); $ftpconfig = config::get('website'); $ftp->connect($ftpconfig['ftpip'],$ftpconfig['ftpuser'],$ftpconfig['ftppwd'],$ftpconfig['ftpport']); $ftperror = $ftp->returnerror(); if($ftperror) { exit($ftperror); }else { $ftp->nobchdir($ftpconfig['ftppath']); file_put_contents(ROOT.'/data/tpl.tmp.php',$content); $ftp->nobput($ftpconfig['ftppath'].'/template/'.config::get('template_dir') .'/'.$tpl,ROOT.'/data/tpl.tmp.php'); $res['message'] = 'ok'; } }else { if ($content) { $content = stripslashes($content); file_put_contents(TEMPLATE .'/'.config::get('template_dir') .'/'.$tpl,$content); $res['message'] = 'ok'; } } echo $res['message']; exit; }
function config_action() { chkpw('union_config'); /*function str_replace_once($needle,$replace,$haystack) { $pos = @strpos($haystack,$needle); if ($pos === false) { return $haystack; } return substr_replace($haystack,$replace,$pos,strlen($needle)); }*/ if (front::post('submit') &&$this->manage->vaild()) { $this->manage->filter($this->Exc); $this->manage->add_before($this); $this->manage->save_before(); $path = ROOT.'/config/union.php'; $content = file_get_contents($path); foreach(front::$post['setting'] as $key=>$val) { $content = preg_replace("/'$key'=>'(.*?)',/is","'$key'=>'$val',", $content); //preg_match_all("/'".$key."'=>'(.*?)',/isu",$content,$out); //var_dump($out); //$content = str_replace_once($out[1][0],$val,$content); } //exit; file_put_contents(ROOT.'/config/union.tmp.php',$content); if($_GET['site']!='default') { set_time_limit(0); $ftp = new nobftp(); $ftpconfig = config::get('website'); $ftp->connect($ftpconfig['ftpip'],$ftpconfig['ftpuser'],$ftpconfig['ftppwd'],$ftpconfig['ftpport']); $ftperror = $ftp->returnerror(); if($ftperror) { exit($ftperror); }else { $ftp->nobchdir($ftpconfig['ftppath']); $ftp->nobput($ftpconfig['ftppath'].'/config/union.php',ROOT.'/config/union.tmp.php'); } }else { file_put_contents($path,$content); } unset($content); front::flash("{$this->tname}完成操作!"); front::redirect(url::modify('act/config/table/'.$this->table)); } $path = ROOT.'/config/union.php'; $config = include $path; $this->_view_table=$config; }
function checkftp_action() { set_time_limit(0); $ftp = new nobftp(); $ftp->connect($_GET['ftpip'],$_GET['ftpuser'],$_GET['ftppwd']); $ftperror = $ftp->returnerror(); if(!$ftperror) { echo '<font color="green">连接FTP服务器成功!</font>'; }else { echo '<font color="red">'.$ftperror.'</font>'; } exit; }