Пример #1
0
 function douploadimg()
 {
     $imgname = $_FILES['photofile']['name'];
     $extname = file::extname($imgname);
     $destfile = $_ENV['attachment']->makepath($extname);
     $arrupload = file::uploadfile($_FILES['photofile'], $destfile);
     if ($arrupload['result'] == true) {
         if (isset($this->setting['watermark'])) {
             $_ENV['watermark']->image($destfile, $destfile);
         }
         $uid = $this->user['uid'] ? $this->user['uid'] : 0;
         $did = $this->get['2'] ? $this->get['2'] : 0;
         $_ENV['attachment']->add_attachment($uid, $did, $imgname, $destfile, htmlspecialchars($this->post['picAlt']), $extname);
         $img_width_big = $this->setting['img_width_big'];
         $img_height_big = $this->setting['img_height_big'];
         $img_width_small = $this->setting['img_width_small'];
         $img_height_small = $this->setting['img_height_small'];
         $img_width_big = is_numeric($img_width_big) ? $img_width_big : 300;
         $img_height_big = is_numeric($img_height_big) ? $img_height_big : 300;
         $img_width_small = is_numeric($img_width_small) ? $img_width_small : 140;
         $img_height_small = is_numeric($img_height_small) ? $img_height_small : 140;
         $iamge300 = util::image_compress($destfile, '', $img_width_big, $img_height_big, '_s');
         $iamge140 = util::image_compress($destfile, '', $img_width_small, $img_height_small, '_140');
         $_ENV['user']->add_credit($uid, 'attachment-upload', $this->setting['credit_upload'], $this->setting['coin_upload']);
     } else {
         $_ENV['attachment']->showmsg($arrupload['msg']);
         exit;
     }
     $images = $this->post['picWidthHeight'] == 1 ? $iamge300['tempurl'] : $iamge140['tempurl'];
     if (empty($_FILES) === false) {
         $_ENV['attachment']->insert_image_js($images, $destfile);
     }
 }
Пример #2
0
 function uploadfile($attachment, $target, $maxsize = 1024, $is_image = 1)
 {
     $result = array('result' => false, 'msg' => 'upload mistake');
     if ($is_image) {
         $attach = $attachment;
         $filesize = $attach['size'] / 1024;
         if (0 == $filesize) {
             $result['msg'] = '上传错误';
             return $result;
         }
         if (substr($attach['type'], 0, 6) != 'image/' || !in_array(file::extname($attach['name']), array('jpg', 'jpeg', 'bmp', 'gif', 'png'))) {
             $result['msg'] = '格式错误';
             return $result;
         }
         if ($filesize > $maxsize) {
             $result['msg'] = '文件过大';
             return $result;
         }
     } else {
         $attach['tmp_name'] = $attachment;
     }
     $filedir = dirname($target);
     file::forcemkdir($filedir);
     if (@copy($attach['tmp_name'], $target) || @move_uploaded_file($attach['tmp_name'], $target)) {
         $result['result'] = true;
         $result['msg'] = '上传成功';
     }
     if (!$result['result'] && @is_readable($attach['tmp_name'])) {
         @($fp = fopen($attach['tmp_name'], 'rb'));
         @flock($fp, 2);
         @($attachedfile = fread($fp, $attach['size']));
         @fclose($fp);
         @($fp = fopen($target, 'wb'));
         @flock($fp, 2);
         if (@fwrite($fp, $attachedfile)) {
             @unlink($attach['tmp_name']);
             $result['result'] = true;
             $result['msg'] = '上传失败';
         }
         @fclose($fp);
     }
     return $result;
 }
Пример #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 setfocusimg($img)
 {
     if ('' == $img) {
         return '';
     }
     if (substr($img, 0, strlen(WIKI_URL)) == WIKI_URL) {
         $img = substr($img, strlen(WIKI_URL) + 1);
     }
     if ("http://" == substr($img, 0, 7) && substr($img, 0, strlen(WIKI_URL)) != WIKI_URL) {
         $tmpname = 'uploads/' . date("Ym") . "/" . util::random() . '.' . file::extname($img);
         if ($pic_content = @util::hfopen($img)) {
             file::forcemkdir(dirname($tmpname));
             if (file::writetofile($tmpname, $pic_content)) {
                 $img = $tmpname;
             }
         }
     }
     $compress = util::image_compress($img, 's_f_', 100, 75);
     if (!$compress['result']) {
         return '';
     }
     util::image_compress($img, 'f_', 152, 114);
     @unlink($tmpname);
     return $compress['tempurl'];
 }
Пример #5
0
 function dobaseedit()
 {
     if (!isset($this->post['imgupload'])) {
         $filedir = HDWIKI_ROOT . '/style/' . $this->get[2] . '/';
         file::forcemkdir($filedir);
         $handle = opendir($filedir);
         while ($filename = readdir($handle)) {
             if (!is_dir($filedir . $filename) && '.' != $filename && '..' != $filename && substr($filename, 0, 6) != 'admin_' && substr($filename, -4) == '.css' || substr($filename, -4) == '.xml') {
                 $style_key = str_replace('.', '', substr($filename, -4));
                 $stylelist[substr($filename, 0, -4)] = $style_key;
                 $stylelang[substr($filename, 0, -4)] = $this->view->lang['style' . substr($filename, 0, -4)];
             }
             if (is_file($filedir . 'screenshot.jpg')) {
                 $styleimg = 1;
             }
         }
         closedir($handle);
         $stylecss = $_ENV['theme']->add_check_style($this->get[2]);
         $style = unserialize($stylecss['css']);
         $this->view->assign('style_path', $this->get[2]);
         $this->view->assign('style', $style);
         $this->view->assign('styleimg', $styleimg);
         $this->view->display('admin_theme_baseedit');
     } else {
         $imgform = array('jpg', 'jpeg', 'png', 'gif');
         if ($_FILES['bg_file']['name'] != '') {
             $background_img = explode('.', $this->post['background_img']);
             $_FILES['bg_file']['rename'] = $background_img[0];
             $bg_extname = file::extname($_FILES['bg_file']['name']);
             if (!in_array($bg_extname, $imgform)) {
                 $this->message($this->view->lang['stylebgimgwrong'], BACK);
             }
             $uploadimg[] = $_FILES['bg_file'];
         }
         if ($_FILES['title_file']['name'] != '') {
             $titlebg_img = explode('.', $this->post['titlebg_img']);
             $_FILES['title_file']['rename'] = $titlebg_img[0];
             $title_extname = file::extname($_FILES['title_file']['name']);
             if (!in_array($title_extname, $imgform)) {
                 $this->message($this->view->lang['styledetitimgwrong'], BACK);
             }
             $uploadimg[] = $_FILES['title_file'];
         }
         if ($_FILES['screenshot_file']['name'] != '') {
             $_FILES['screenshot_file']['rename'] = 'screenshot';
             $screenshot_extname = file::extname($_FILES['screenshot_file']['name']);
             $imgform = array('jpg');
             if (!in_array($screenshot_extname, $imgform)) {
                 $this->message($this->view->lang['styledescreenwrong'], BACK);
             }
             $uploadimg[] = $_FILES['screenshot_file'];
         }
         $_ENV['theme']->upload_img($uploadimg, $this->get[2]);
         $stylelist = array('bg_color' => '#fff', 'titlebg_color' => '', 'nav_framcolor' => '#e1e1e1', 'input_bgcolor' => '#7f9db9', 'input_color' => '#666', 'link_color' => '#0268cd', 'link_hovercolor' => '#f30', 'link_difcolor' => '#ff3300');
         foreach ($stylelist as $key => $value) {
             $style[$key] = $this->post['style'][$key] ? $this->post['style'][$key] : $value;
         }
         $style['bg_imgname'] = $background_img[0] ? $background_img[0] . '.' . $bg_extname : '';
         $style['titbg_imgname'] = $titlebg_img[0] ? $titlebg_img[0] . '.' . $title_extname : 'col_h2_bg.gif';
         $style['path'] = $this->get[2];
         $_ENV['theme']->write_css($style);
         $stylecss = serialize($style);
         $_ENV['theme']->update_stylecss($stylecss, $style['path']);
         $this->cache->removecache('style');
         $this->message($this->view->lang['styleEditSuccess'], 'index.php?admin_theme-baseedit-' . $this->get[2]);
     }
 }
Пример #6
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;
 }