public function add()
 {
     if (IS_POST) {
         $post = I('post.');
         $bridge = M('bridge');
         $post['name'] = trim($post['name']);
         $post['place'] = trim($post['place']);
         $post['user'] = $_SESSION['username'];
         $result = $bridge->query("select *from bridge where user='******' and name='%s'", $post['user'], $post['name']);
         if ($result[0]['bid'] != null) {
             echo "Cz";
         } else {
             $bridge->field('user,name,place')->create($post);
             $bridge->add();
             $result2 = $bridge->where("user='******' and name='%s'", $post['user'], $post['name'])->select();
             if ($result2[0]['bid'] == null) {
                 echo "Error";
                 exit;
             }
             $data['api'] = md5($result2[0]['user'] . $result2[0]['bid']);
             //创建桥图片资源文件夹    类库创建文件夹
             $url = "C:/wamp/www/Qiao/Application/Home/View/Public/img/" . $data['api'];
             import("Org.File.File");
             \File::mk_dir($url);
             $bridge->where("bid=%d", $result2[0]['bid'])->save($data);
         }
     } else {
         $this->error('非法操作');
     }
 }
Example #2
0
 public function session($dir = '')
 {
     if (!empty($dir)) {
         $this->sessSavePath = $dir;
     }
     File::mk_dir($this->sessSavePath);
     return $this;
 }
Example #3
0
 public function doimport()
 {
     $filename = $this->_post('filename');
     $checkdir = $this->_post('checkdir');
     if (strtolower(substr($filename, -4)) != '.zip') {
         $this->error('仅支持后缀为zip的压缩包');
     }
     $path = ltrim($filename, __ROOT__ . '/');
     $filename = substr(ltrim(strrchr($filename, '/'), '/'), 0, -4);
     $tplpath = './Public/Special/' . $filename;
     if (is_dir($tplpath) && $checkdir != 1) {
         $this->error('专题目录已存在!');
     }
     if (!is_file($path)) {
         $this->error('文件包不存在!');
     }
     File::mk_dir('./Public/Special');
     import('ORG.PclZip');
     $zip = new PclZip($path);
     $zip->extract(PCLZIP_OPT_PATH, $tplpath);
     //导入数据
     $xmlpath = './Public/Special/' . $filename . '/special.xml';
     if (is_file($xmlpath)) {
         $xml = simplexml_load_file($xmlpath);
         $data['title'] = (string) $xml->title;
         $data['seotitle'] = (string) $xml->seotitle;
         $data['keywords'] = (string) $xml->keywords;
         $data['description'] = (string) $xml->description;
         $data['content'] = (string) $xml->content;
         $data['tempindex'] = (string) $xml->tempindex;
         $data['waptempindex'] = (string) $xml->waptempindex;
         $data['pubdate'] = time();
         $model = M('special');
         $model->add($data);
     }
     $this->success('操作成功!', U('Special/index'));
 }
Example #4
0
 private function uptemp()
 {
     $upload = new UploadFile();
     $upload->maxSize = '1024000';
     $upload->savePath = './Public/Uploads/temp/' . date('Ymd') . '/';
     File::mk_dir("./Public/Uploads/temp");
     $upload->saveRule = uniqid;
     $upload->uploadReplace = true;
     $upload->allowExts = array('zip', 'xml', 'rar', 'txt', 'ppt', 'pptx', 'xls', 'xlsx', 'doc', 'docx', 'swf', 'jpg', 'png', 'gif', 'tar.gz', '.7z');
     //准许上传的文件后缀
     if ($upload->upload()) {
         $info = $upload->getUploadFileInfo();
         return $info;
     } else {
         $this->error($upload->getErrorMsg());
     }
 }
Example #5
0
 public function update()
 {
     $date = date('YmdHis');
     $logcontent = '歪酷CMS在线更新日志###';
     $logcontent .= '更新时间:' . date('Y-m-d H:i:s') . '###';
     $logcontent .= '系统原始版本:' . C('SOFT_VERSION') . '###';
     $backupall = isset($_GET['backupall']) ? $_GET['backupall'] : 0;
     $backupsql = isset($_GET['backupsql']) ? $_GET['backupsql'] : 0;
     $logcontent .= '正在执行系统版本检测...###';
     G('run1');
     $msg = fopen_url('http://cloud.waikucms.net/update.php?version=' . substr(C('SOFT_VERSION'), -8));
     $msg = $msg != 0 && $msg != 1 ? 2 : $msg;
     //$msg=1;
     if ($msg == 0) {
         $this->error('当前系统已经是最新版!');
     }
     $nowversion = fopen_url('http://cloud.waikucms.net/update.php?fullversion=1');
     if ($msg == 2) {
         $this->error('更新检测失败!');
     }
     $updateurl = fopen_url('http://cloud.waikucms.net/update.php?updateurl=1');
     $logcontent .= '系统更新版本:' . $nowversion . '###';
     $logcontent .= '系统版本检测完毕,区间耗时:' . G('run1', 'end1') . 's' . '###';
     //清理缓存
     $logcontent .= '清理系统缓存...###';
     G('run2');
     $this->clear();
     $logcontent .= '清理系统缓存完毕!,区间耗时:' . G('run2', 'end2') . 's' . ' ###';
     import('ORG.PclZip');
     File::mk_dir('./_update');
     File::mk_dir('./_update/' . $date);
     if ($backupall == 1) {
         //备份整站
         $logcontent .= '开始备份整站内容...###';
         G('run3');
         $backupallurl = './_update/' . $date . '/backupall.zip';
         $zip = new PclZip($backupallurl);
         $zip->create('Public/Config,Admin,User,Web,Core,index.php,admin.php,user.php');
         $logcontent .= '成功完成整站数据备份,备份文件路径:<a href=\'' . __ROOT__ . ltrim($backupallurl, '.') . '\'>' . $backupallurl . '</a>, 区间耗时:' . G('run3', 'end3') . 's' . ' ###';
     }
     if ($backupsql == 1) {
         //备份数据库
         $logcontent .= '准备执行数据库备份...###';
         G('run4');
         $backupsqlurl = $this->backupsql($date);
         $logcontent .= '成功完成系统数据库备份,备份文件路径:' . $backupsqlurl . ', 区间耗时:' . G('run4', 'end4') . 's' . ' ###';
     }
     //获取更新包
     $logcontent .= '开始获取远程更新包...###';
     G('run5');
     $updatedzipurl = './_update/' . $date . '/update.zip';
     File::write_file($updatedzipurl, fopen_url($updateurl));
     $logcontent .= '获取远程更新包成功,更新包路径:<a href=\'' . __ROOT__ . ltrim($updatedzipurl, '.') . '\'>' . $updatedzipurl . '</a>' . '区间耗时:' . G('run5', 'end5') . 's' . '###';
     //解压缩更新包
     $logcontent .= '更新包解压缩...###';
     G('run6');
     $zip = new PclZip($updatedzipurl);
     $zip->extract(PCLZIP_OPT_PATH, './');
     $logcontent .= '更新包解压缩成功...' . '区间耗时:' . G('run6', 'end6') . 's' . '###';
     //更新数据库
     $updatesqlurl = './update.sql';
     if (is_file($updatesqlurl)) {
         $logcontent .= '更新数据库开始...###';
         G('run7');
         if (file_exists($updatesqlurl)) {
             $rs = new Model();
             $sql = File::read_file($updatesqlurl);
             $sql = str_replace("\r\n", "\n", $sql);
             foreach (explode(";\n", trim($sql)) as $query) {
                 $rs->query(trim($query));
             }
         }
         unlink($updatesqlurl);
         $logcontent .= '更新数据库完毕...' . '区间耗时:' . G('run7', 'end7') . 's' . '###';
     }
     //系统版本号更新
     G('run8');
     $config = File::read_file('./Public/Config/config.ini.php');
     $config = str_replace(C('SOFT_VERSION'), $nowversion, $config);
     File::write_file('./Public/Config/config.ini.php', $config);
     $logcontent .= '更新系统版本号,记录更新日志,日志文件路径:<a href=\'' . __ROOT__ . '/_update/' . $date . '/log.txt\'>./_update/' . $date . '/log.txt</a>,';
     $logcontent .= '区间耗时:' . G('run8', 'end8') . 's';
     //beta 20130221 to 20120226 临时更新设置,下次更新则省略这段代码
     if (!strpos($config, 'SOFT_VERIFY')) {
         $config = str_replace("'DEFAULT_CHARSET'=>'utf8',", "'DEFAULT_CHARSET'=>'utf8','SOFT_VERIFY'=>0,", $config);
         File::write_file('./Public/Config/config.ini.php', $config);
     }
     //记录更新日志
     File::write_file('./_update/' . $date . '/log.txt', $logcontent);
     //清空cookie
     cookie('updatenotice', null);
     //跳转到更新展示页面
     $this->success('更新完毕!', U('Update/over?date=' . $date));
 }