예제 #1
0
 function doupload()
 {
     @header('Content-type: text/html; charset=' . WIKI_CHARSET);
     $did = $this->post['did'] ? $this->post['did'] : 0;
     if (!$this->setting['attachment_open']) {
         exit;
     }
     $okfile = '';
     $this->setting['coin_download'] = isset($this->setting['coin_download']) ? $this->setting['coin_download'] : 10;
     $count = count($_FILES['attachment']['name']);
     for ($i = 0; $i < $count; $i++) {
         if (!(bool) $_FILES['attachment']['name'][$i]) {
             continue;
         }
         $size = $_FILES['attachment']['size'][$i] / 1024;
         $name = $_FILES['attachment']['name'][$i];
         $attachment_type = $_ENV['attachment']->get_attachment_type();
         $filetype = strtolower(substr($name, strrpos($name, ".") + 1));
         if ($attachment_type[0] != '*' && !in_array($filetype, $attachment_type)) {
             echo '<script>parent.Attachment.error("' . $name . ': ' . $this->view->lang['attachTypeError'] . '");</script>';
             continue;
         }
         if ($size > $this->setting['attachment_size'] || empty($size)) {
             echo '<script>parent.Attachment.error("' . $name . ': ' . $this->view->lang['attachSizeError2'] . '");</script>';
             continue;
         }
         $destfile = 'data/attachment/' . date('y-m') . '/' . date('Y-m-d') . '_' . util::random(10) . '.attach';
         file::createaccessfile('data/attachment/' . date('y-m') . '/');
         $result = file::uploadfile($_FILES['attachment']['tmp_name'][$i], $destfile, $this->setting['attachment_size'], 0);
         if ($result) {
             $okfile .= $name . '|';
             $coindown = $this->post['coin_download'][$i];
             if (empty($coindown) || !is_numeric($coindown)) {
                 $coindown = 0;
             } else {
                 if (0 > $coindown) {
                     $coindown = 0;
                 } else {
                     if ($this->setting['coin_download'] < $coindown) {
                         $coindown = $this->setting['coin_download'];
                     }
                 }
             }
             $_ENV['attachment']->add_attachment($this->user['uid'], $did, $name, $destfile, $this->post['attachmentdesc'][$i], $filetype, 0, $coindown);
         }
     }
     echo '<script>';
     if ($okfile) {
         echo 'parent.Attachment.addok("' . $okfile . '");';
     }
     echo '</script>';
 }
예제 #2
0
 function upload_attachment($did)
 {
     if (!$this->base->setting['attachment_open']) {
         return false;
     }
     $count = count($_FILES['attachment']['name']);
     for ($i = 0; $i < $count; $i++) {
         if (!(bool) $_FILES['attachment']['name'][$i]) {
             continue;
         }
         $attachment_type = $this->get_attachment_type();
         $filetype = strtolower(substr($_FILES['attachment']['name'][$i], strrpos($_FILES['attachment']['name'][$i], ".") + 1));
         if (!in_array($filetype, $attachment_type)) {
             $message .= $_FILES['attachment']['name'][$i] . $this->base->view->lang['attachTypeError'] . "<br />";
             continue;
         }
         if ($this->base->setting['attachment_size'] < $_FILES['attachment']['size'][$i] / 1024) {
             $message .= $_FILES['attachment']['name'][$i] . $this->base->view->lang['attachSizeError'] . "<br />";
             continue;
         }
         $destfile = 'data/attachment/' . date('y-m') . '/' . date('Y-m-d') . '_' . util::random(10) . '.attach';
         file::createaccessfile('data/attachment/' . date('y-m') . '/');
         $result = file::uploadfile($_FILES['attachment']['tmp_name'][$i], $destfile, $this->base->setting['attachment_size'], 0);
         if ($result) {
             $_ENV['attachment']->add_attachment($this->base->user['uid'], $did, $_FILES['attachment']['name'][$i], $destfile, $this->base->post['attachmentdesc'][$i], $filetype, 0);
         }
     }
     return $message;
 }
예제 #3
0
 function doedit()
 {
     if (!isset($this->post['submit'])) {
         $id = $this->get[2];
         $gift = $_ENV['gift']->get($id);
         $this->view->assign("gift", $gift);
         $this->view->display('admin_editgift');
     } else {
         $id = trim($this->post['id']);
         $gift = $_ENV['gift']->get($id);
         $title = htmlspecialchars(trim($this->post['title']));
         $credit = trim($this->post['credit']);
         $description = htmlspecialchars(trim($this->post['description']));
         $imgname = $_FILES['giftfile']['name'];
         /*
         if($gift['image']){
         	$destfile=str_replace('_s.', '.', $gift['image']);
         }else{
         	$extname=file::extname($imgname);
         	$destfile = 'uploads/gift/'.util::random(8).'.'.$extname;
         }
         */
         if ('' != $imgname) {
             $extname = file::extname($imgname);
             $destfile = 'uploads/gift/' . util::random(8) . '.' . $extname;
             file::uploadfile($_FILES['giftfile'], $destfile);
             util::image_compress($destfile, '', 500, 500, '');
             $iamge = util::image_compress($destfile, '', 106, 106, '_s');
             $destfile = $iamge['tempurl'];
         }
         $_ENV['gift']->edit($id, $title, $credit, $description, $destfile);
         $this->message($this->view->lang['usermanageOptSuccess'], 'index.php?admin_gift-search');
     }
 }
예제 #4
0
 function fileip($alluploadips, $regular, $attachment_size)
 {
     $filetype = strtolower(substr($_FILES['file_path']['name'], strrpos($_FILES['file_path']['name'], ".") + 1));
     $destfile = 'data/tmp/' . time() . '.' . $filetype;
     $result = file::uploadfile($_FILES['file_path']['tmp_name'], $destfile, $attachment_size, 0);
     if ($result) {
         if (file_exists($destfile)) {
             $data = file::readfromfile($destfile);
         }
         $alluploadips = $this->textip($alluploadips, $regular, $data);
         @unlink($destfile);
     }
     return $alluploadips;
 }
예제 #5
0
 function filewords($alluploadwords, $attachment_size)
 {
     $filetype = strtolower(substr($_FILES['file_path']['name'], strrpos($_FILES['file_path']['name'], ".") + 1));
     $destfile = 'data/tmp/' . time() . '.' . $filetype;
     $result = file::uploadfile($_FILES['file_path']['tmp_name'], $destfile, $attachment_size, 0);
     if ($result) {
         if (file_exists($destfile)) {
             if (WIKI_CHARSET == 'UTF-8') {
                 $data = string::hiconv(file::readfromfile($destfile), 'utf-8');
             } else {
                 $data = string::hiconv(file::readfromfile($destfile), 'gbk');
             }
         }
         $filewords = array_filter(explode(',', str_replace(',', ',', addslashes($data))), array($this, "trimwords"));
         $alluploadwords = array_merge($alluploadwords, $filewords);
         @unlink($destfile);
     }
     return $alluploadwords;
 }
예제 #6
0
 function doshare()
 {
     $pluginid = $this->get[2];
     if (!isset($this->post['submit'])) {
         $plugin = $this->db->fetch_by_field('plugin', 'pluginid', $pluginid);
         if (file_exists(HDWIKI_ROOT . '/plugins/' . $plugin['identifier'] . '/share.lock')) {
             $this->message($this->view->lang['pluginRepeatShareFail'], 'index.php?admin_plugin');
         }
         $plugin['authorurl'] = empty($plugin['authorurl']) ? 'http://' : $plugin['authorurl'];
         $plugin['weburl'] = empty($plugin['weburl']) ? 'http://' : $plugin['weburl'];
         $this->view->assign('plugin', $plugin);
         $this->view->display('admin_pluginshare');
     } else {
         $plugin['author'] = $this->post['author'];
         $plugin['authorurl'] = $this->post['authorurl'];
         $plugin['name'] = $this->post['name'];
         $plugin['tag'] = $this->post['tag'];
         $plugin['weburl'] = $this->post['weburl'];
         $plugin['version'] = $this->post['version'];
         $plugin['hdversion'] = HDWIKI_VERSION;
         $plugin['copyright'] = $this->post['copyright'];
         $plugin['description'] = $this->post['description'];
         $plugin['identifier'] = $this->post['identifier'];
         file::uploadfile($_FILES['pluginimg'], HDWIKI_ROOT . '/plugins/' . $plugin['identifier'] . '/screenshot.jpg');
         $share = $_ENV['plugin']->share_plugin($plugin);
         if ($share) {
             @touch(HDWIKI_ROOT . '/plugins/' . $plugin['identifier'] . '/share.lock');
             $this->message($this->view->lang['pluginShareSuccess'], 'index.php?admin_plugin');
         } else {
             $this->message($this->view->lang['pluginShareFail'], 'index.php?admin_plugin');
         }
     }
 }
예제 #7
0
 function dologo()
 {
     if (!isset($this->post['logsubmit'])) {
         $this->view->assign('logowidth', $this->setting['logowidth']);
         $this->view->display("admin_uploadlogo");
     } else {
         $settings['logowidth'] = $this->post['logowidth'] ? $this->post['logowidth'] : '220px';
         $setting = $_ENV['setting']->update_setting($settings);
         $this->cache->removecache('setting');
         if ($_FILES['logo']['name']) {
             $imgname = $_FILES['logo']['name'];
             $filetype = array('image/jpeg', 'image/gif', 'image/x-png', 'image/png', 'image/pjpeg');
             if (in_array($_FILES['logo']['type'], $filetype)) {
                 $destfile = 'style/default/logo.gif';
                 $arrupload = file::uploadfile($_FILES['logo'], $destfile, 1024);
                 if (isset($arrupload) && $arrupload['result'] == true) {
                     $this->message($arrupload['msg'], 'index.php?admin_setting-logo');
                 } else {
                     $this->message($this->view->lang['uploadFail'], 'BACK');
                 }
             } else {
                 $this->message($this->view->lang['uploadFormatWrong'], 'BACK');
             }
         }
         $this->message('宽度修改成功!', 'index.php?admin_setting-logo');
     }
 }
예제 #8
0
 function doeditxml()
 {
     if (!isset($this->post['stylesave']) && !isset($this->post['styleshare'])) {
         $xmlcon = $_ENV['theme']->read_xml($this->get[2]);
         $this->view->assign('stylename', $this->get[2]);
         $this->view->assign('style', $xmlcon);
         $this->view->assign('share', $this->get[3]);
         $this->view->display('admin_themexml_edit');
     } else {
         if ($_FILES['styleimg']['name'] != '') {
             $image = $_FILES['styleimg'];
             $extname = file::extname($image['name']);
             if ($extname == 'jpg') {
                 $destfile = 'style/' . $this->get[2] . '/screenshot.' . $extname;
                 $result = file::uploadfile($image, $destfile);
                 if ($result['result']) {
                     util::image_compress($destfile, NULL, 158, 118);
                 } else {
                     $this->message($result['msg'], 'BACK');
                 }
             } else {
                 $this->message($this->view->lang['uploadFormatWrong'], 'BACK');
             }
         }
         //insert into db
         $style = $this->post['style'];
         $style['hdversion'] = HDWIKI_VERSION;
         $style['path'] = trim($this->get[2]);
         $style['charset'] = $_ENV['theme']->style_charset($style[path]);
         $stylecon = $_ENV['theme']->add_check_style($style['path']);
         if ($stylecon == null) {
             $_ENV['theme']->add_style($style);
         } else {
             $_ENV['theme']->update_style($style);
         }
         //得到需要插入的blocks的sql。
         $style['sql'] = '';
         $blocks = $_ENV['theme']->get_blocks_by_theme($this->get[2]);
         if ($blocks) {
             $insertsql = "INSERT INTO wiki_block (theme,file,area,areaorder,block,fun,tpl,params) VALUES ";
             foreach ($blocks as $val) {
                 $insertsql .= "( '{$val['theme']}','{$val['file']}','{$val['area']}','{$val['areaorder']}','{$val['block']}','{$val['fun']}','{$val['tpl']}','{$val['params']}' ),";
             }
             $style['sql'] = substr($insertsql, 0, -1);
         }
         //write to xml
         $_ENV['theme']->write_xml($style);
         if (isset($this->post['stylesubmit'])) {
             $this->message($this->view->lang['docEditSuccess'], 'index.php?admin_theme');
         } else {
             if (isset($this->post['stylesave'])) {
                 $this->message($this->view->lang['docEditSuccess'], 'index.php?admin_theme-editxml-' . $style[path] . '-share');
             } else {
                 if (isset($this->post['styleshare'])) {
                     //check
                     $filename = 'style/' . $style['path'] . '/share.lock';
                     if (is_file($filename)) {
                         $this->message($this->view->lang['style_share_lock'] . $filename, 'BACK');
                     } else {
                         file::writetofile($filename, $a = '');
                     }
                     //zip
                     require HDWIKI_ROOT . "/lib/zip.class.php";
                     $zip = new Zip();
                     $filedir = array('style/' . $style['path'], 'view/' . $style['path'], 'block/' . $style['path']);
                     $zipdir = array('hdwiki/style/' . $style['path'], 'hdwiki/view/' . $style['path'], 'hdwiki/block/' . $style['path']);
                     file::forcemkdir(HDWIKI_ROOT . '/data/tmp/');
                     $tmpname = HDWIKI_ROOT . '/data/tmp/' . util::random(6) . '.zip';
                     @$zip->zip_dir($filedir, $tmpname, $zipdir);
                     //share
                     if (is_file($tmpname)) {
                         $zip_content = file::readfromfile($tmpname);
                         $upload_url = $this->setting['app_url'] . "/hdapp.php?action=upload&type=template";
                         $data = 'data=' . base64_encode($zip_content);
                         unlink($tmpname);
                         if ('1' == @util::hfopen($upload_url, 0, $data)) {
                             $this->message($this->view->lang['styleShareSuccess'], 'index.php?admin_theme');
                         } else {
                             $this->message($this->view->lang['styleShareFaile'], 'index.php?admin_theme');
                         }
                     } else {
                         $this->message($this->view->lang['styleFileZipFail'], 'index.php?admin_theme');
                     }
                 }
             }
         }
     }
 }
예제 #9
0
 function upload_img($uploadimg, $filename)
 {
     $counts = count($uploadimg);
     if ($counts != 0) {
         for ($i = 0; $i < $counts; $i++) {
             $imgname = $uploadimg[$i]['name'];
             $extname = file::extname($imgname);
             $destfile = HDWIKI_ROOT . '/style/' . $filename . '/' . $uploadimg[$i]['rename'] . "." . $extname;
             $result = file::uploadfile($uploadimg[$i], $destfile);
             if ($result['result'] && $uploadimg[$i]['rename'] == 'screenshot') {
                 util::image_compress($destfile, NULL, 158, 118);
             }
             $success++;
         }
     }
     return $success;
 }