function note_action() { chkpw('template_note'); if (front::post('submit')) { unset(front::$post['submit']); help::$_var['template_note'] = front::$post; help::save(); } $dir = ROOT .'/template/'.config::get('template_dir'); $_dir = dir($dir); while ($file = $_dir->read()) { if (!preg_match('/^\./',$file) &&is_dir($dir .'/'.$file) &&!preg_match('/[#@]/',$file) &&!preg_match('/^_/',$file)) { $this->view->tps[$file] = '<b>'.$file .'</b>'; $__dir = dir($dir .'/'.$file); while ($_file = $__dir->read()) { if (!preg_match('/^\./',$_file) &&!preg_match('/[#@]/',$_file)) { if ($file=='skin'&&!preg_match('/\.(css|js)$/',$_file)) continue; $_file = str_replace('.','_',$_file); if (is_dir($dir .'/'.$file .'/'.$_file)) $this->view->tps[$file .'/'.$_file] = " └<b>".$_file .'</b>'; else $this->view->tps[$file .'/'.$_file] = " └".$_file; } } } elseif (!preg_match('/^\./',$file) &&is_file($dir .'/'.$file) &&!preg_match('/[#@]/',$file)) { $file = str_replace('.','_',$file); $tps[$file] = $file; } } //$this->view->tps = array_merge($tps,$this->view->tps); $tps_arr = array_merge($tps,$this->view->tps); //分页 $limit = 20; if(!front::get('page')) $page = 1; else $page = front::get('page'); $total = ceil(count($tps_arr)/$limit); if($page < 1) $page = 1; if($page > $total) $page = $total; $start = ($page-1) * $limit; $end = $start+$limit-1; $tmp = range($start,$end); $list_tps_arr = array(); $i = 0; foreach($tps_arr as $k => $v){ if(in_array($i++,$tmp)) $list_tps_arr[$k] = $v; } $this->view->tps = $list_tps_arr; $this->view->link_str = listPage($total,$limit,$page); }
function listimg_action() { if (!front::get('dir')) return; $image_dir = ROOT . '/upload/images/' . front::get('dir'); if (!is_dir($image_dir)) return; $handle = opendir($image_dir); //当前目录 $img_array = array(); while (false !== ($file = readdir($handle))) { //遍历该php文件所在目录 list($filesname, $kzm) = explode(".", $file); //获取扩展名 if ($kzm == "gif" or $kzm == "jpg" or $kzm == "png") { //文件过滤 if (!is_dir('./' . $file)) { //文件夹过滤 $img_arr[] = $file; //把符合条件的文件名存入数组 } } } $limit = 20; if (!front::get('page')) $page = 1; else $page = front::get('page'); $total = ceil(count($img_arr) / $limit = 20); if ($page < 1) $page = 1; if ($page > $total) $page = $total; $start = ($page - 1) * $limit; $end = $start + $limit - 1; $tmp = range($start, $end); $list_img_arr = array(); foreach ($img_arr as $k => $v) { if (in_array($k, $tmp)) $list_img_arr[] = $v; } $this->view->list_img_arr = $list_img_arr; $this->view->link_str = listPage($total, $limit, $page); return $img_arr; }
function listPage($host, $searchURL) { $html_content = scraperwiki::scrape($host . $searchURL); $html = str_get_html($html_content); $pageCount = 0; foreach ($html->find("div.photo ul.thumb a") as $el) { $propPage = str_replace("../", "/", $el->href); // echo "\nPAGE :" . $propPage; $property = listProperty($host, $propPage); //scraperwiki::save_sqlite(array('property'), array('property' => json_encode($property))); scraperwiki::save_sqlite(array('property'), $property); // scraperwiki::save_sqlite(array("a"),array("a"=>1, "bbb"=>"Hi there")); exit; } foreach ($html->find("a.pageResults") as $el) { if (trim($el->plaintext) == "Suivante") { $nextPage = $el->href; //echo "\nSEARCH : " . $nextPage; listPage($host, $nextPage); break; } } }
<?php $pageName = 'home'; $pageData = array(); $pageData['content_top'] = Render::content_top($pageName); $pageData['content_left'] = Render::content_left($pageName); $pageData['content_right'] = Render::content_right($pageName); $pageData['content_bottom'] = Render::content_bottom($pageName); Theme::model('search'); $headData = GlobalCMS::$setting; // $pageData['categories']=categories(); $keyword = ''; $pageData['newPost'] = searchResult(); $parseData = listPage(); $pageData['listPage'] = $parseData['pages']; $pageData['keywords'] = $parseData['keywords']; Theme::view('head', $headData); Theme::view('search', $pageData); Theme::view('footer');
<?php if (!($match = Uri::match('category-(\\d+)\\/?'))) { Redirect::to('404page'); // Alert::make('Page not found'); } $pageName = 'category'; $pageData = array(); $pageData['content_top'] = Render::content_top($pageName); $pageData['content_left'] = Render::content_left($pageName); $pageData['content_right'] = Render::content_right($pageName); $pageData['content_bottom'] = Render::content_bottom($pageName); Theme::model('category'); $headData = GlobalCMS::$setting; $pageData['newPost'] = searchResult($match[1]); $pageData['listPage'] = listPage(); Theme::view('head', $headData); Theme::view($pageName, $pageData); Theme::view('footer');
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); }