Exemple #1
0
    $save_path .= $ymd . "/";
    $save_url .= $ymd . "/";
    if (!file_exists($save_path)) {
        mkdir($save_path);
    }
    //新文件名
    $new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext;
    //移动文件
    $file_path = $save_path . $new_file_name;
    $file_path_s = $save_path . 's1_' . $new_file_name;
    //    $file_path_200 = $save_path.'s_200x200_'.$new_file_name;
    if (move_uploaded_file($tmp_name, $file_path) === false) {
        alert("上传文件失败!!");
    } else {
        //等比例生成缩略图
        move_uploaded_file(img2thumb($file_path, $file_path_s, '', '', 1, 0.4), $file_path);
        //        生成200x200缩略图
        //        move_uploaded_file(img2thumb($file_path,$file_path_200,'200','200',1,0), $file_path);
    }
    @chmod($file_path, 0644);
    //	$file_url = $save_url . $new_file_name;
    $file_url = $save_url . 's1_' . $new_file_name;
    header('Content-type: text/html; charset=UTF-8');
    $json = new Services_JSON();
    echo $json->encode(array('error' => 0, 'url' => $file_url));
    exit;
}
/**
 * 生成缩略图
 * @param string     源图绝对完整地址{带文件名及后缀名}
 * @param string     目标图绝对完整地址{带文件名及后缀名}
Exemple #2
0
                 cpmsg(lang('plugin/aljwsq', 'autoreply18'), 'action=plugins&operation=config&do=' . $_GET['do'] . '&identifier=aljwsq&pmod=autoreply', 'error');
             }
             $rand = rand(100, 999);
             $pics = date("YmdHis") . $rand . $type;
             $img_dir = 'source/plugin/aljwsq/images/logo/';
             if (!is_dir($img_dir)) {
                 mkdir($img_dir);
             }
             ${$pic} = $img_dir . $pics;
             if (@copy($_FILES[$pic]['tmp_name'], ${$pic}) || @move_uploaded_file($_FILES[$pic]['tmp_name'], ${$pic})) {
                 $imageinfo = getimagesize(${$pic});
                 $w360 = $imageinfo[0] < 360 ? $imageinfo[0] : 360;
                 $h200 = $imageinfo[1] < 200 ? $imageinfo[1] : 200;
                 $w200 = $imageinfo[0] < 640 ? $imageinfo[0] : 200;
                 img2thumb(${$pic}, ${$pic} . '.360x200.jpg', $w360, $h200);
                 img2thumb(${$pic}, ${$pic} . '.200x200.jpg', $w200, $h200);
                 @unlink($_FILES[$pic]['tmp_name']);
             }
         }
     }
     $updatearray = array('upid' => $_GET['upid'], 'msgtype' => $_GET['msgtype'], 'mykeyword' => $_GET['keyword'], 'bindkeyword' => $_GET['bindkeyword'], 'title' => $_GET['title'], 'url' => $_GET['url'], 'description' => $_GET['description'], 'tid' => $_GET['tid'], 'fid' => $_GET['fid'], 'threadnum' => $_GET['threadnum'], 'forumnum' => $_GET['forumnum'], 'updatetime' => TIMESTAMP, 'status' => $_GET['status'], 'displayorder' => $_GET['displayorder']);
     if (${$pic}) {
         $updatearray['picurl'] = ${$pic};
     }
     C::t('#aljwsq#aljwsq_autoreply')->update($_GET['aid'], $updatearray);
     cpmsg(lang('plugin/aljwsq', 'autoreply19'), 'action=plugins&operation=config&do=' . $_GET['do'] . '&identifier=aljwsq&pmod=autoreply', 'succeed');
 } else {
     //$menus = C::t('#aljwsq#aljwsq_menu')->fetch_all_by_upid(0);
     if ($reply['msgtype']) {
         $_GET['gettype'] = $reply['msgtype'];
     }
 public function doList()
 {
     global $_W, $_GPC;
     $op = $_GPC['op'];
     if (empty($op)) {
         $op = "display";
     }
     if ($op == 'display') {
         $classid = intval($_GPC['classid']);
         $pindex = max(1, intval($_GPC['page']));
         $psize = 24;
         $condition = '';
         $params = array();
         $condition .= " or weid = 0";
         if (!empty($classid)) {
             $condition .= " and classid = '{$classid}'";
         }
         $list = pdo_fetchall("SELECT * FROM " . tablename('sheka_list') . " WHERE weid = '{$_W['weid']}' {$condition} ORDER BY  id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize);
         $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('sheka_list') . " WHERE  weid = '{$_W['weid']}' {$condition}");
         $pager = pagination($total, $pindex, $psize);
     } elseif ($op == 'post') {
         $id = intval($_GPC['id']);
         $zid = intval($_GPC['zid']);
         if ($id) {
             if (empty($_W['isfounder'])) {
                 $item = pdo_fetch("SELECT * FROM " . tablename("sheka_list") . " WHERE  weid = 0 or weid=:weid and id = :id  ", array(':weid' => $_W['weid'], ':id' => $id));
             } else {
                 $item = pdo_fetch("SELECT * FROM " . tablename("sheka_list") . " WHERE  id = :id  ", array(':id' => $id));
             }
             if (empty($item)) {
                 message('用户不存在或是已经被删除!');
             }
             if ($item['weid'] == 0) {
                 if (empty($_W['isfounder'])) {
                     message('抱歉,你没有权限!', '', 'error');
                 }
             }
             $zhufu = pdo_fetch("SELECT * FROM " . tablename("sheka_zhufu") . " WHERE  cid = :cid  ", array(':cid' => $id));
         } else {
             $item['tempid'] = 0;
         }
         if (checksubmit('submit')) {
             if (empty($_GPC['title'])) {
                 message('标题不能为空,请输入标题!');
             }
             $insert = array('weid' => $_W['weid'], 'title' => $_GPC['title'], 'classid' => $_GPC['classid'], 'tempid' => $_GPC['tempid'], 'thumb' => $_GPC['thumb'], 'cardbg' => $_GPC['cardbg'], 'music' => $_GPC['music'], 'lang' => $_GPC['lang']);
             $zinsert = array('weid' => $_W['weid'], 'lang' => $_GPC['lang'], 'cardfrom' => $_GPC['cardfrom'], 'cardto' => $_GPC['cardto'], 'cardbody' => $_GPC['cardbody'], 'cardto_left' => $_GPC['cardto_left'], 'cardto_top' => $_GPC['cardto_top'], 'cardbody_width' => $_GPC['cardbody_width'], 'cardbody_left' => $_GPC['cardbody_left'], 'cardbody_top' => $_GPC['cardbody_top'], 'cardfrom_left' => $_GPC['cardfrom_left'], 'cardfrom_top' => $_GPC['cardfrom_top'], 'panel_top' => $_GPC['panel_top'], 'panel_left' => $_GPC['panel_left'], 'panel_width' => $_GPC['panel_width'], 'panel_height' => $_GPC['panel_height'], 'panel_color' => $_GPC['panel_color'], 'panel_bg' => $_GPC['panel_bg'], 'panel_alpha' => $_GPC['panel_alpha']);
             if (empty($id)) {
                 pdo_insert("sheka_list", $insert);
                 $insertid = pdo_insertid();
                 $zinsert['cid'] = $insertid;
                 pdo_insert("sheka_zhufu", $zinsert);
             } else {
                 pdo_update("sheka_list", $insert, array('id' => $id));
                 if ($zid) {
                     pdo_update("sheka_zhufu", $zinsert, array('id' => $zid));
                 } else {
                     $zinsert['cid'] = $id;
                     pdo_insert("sheka_zhufu", $zinsert);
                 }
             }
             $thumb = explode('/', $insert['thumb']);
             $asliname = IA_ROOT . '/resource/attachment/' . $insert['thumb'];
             //$newname=IA_ROOT . '/resource/attachment/'.$thumb[0].'/'.$thumb[1].'/'.$thumb[2].'/'.$thumb[3].'/s_'.$thumb[4];
             $newname = IA_ROOT . '/resource/attachment/' . $thumb[0] . '/' . $thumb[1] . '/' . $thumb[2] . '/' . $thumb[3];
             img2thumb($asliname, $newname, 75, 75, 1);
             message('修改成功!', $this->createWebUrl('list', array('op' => 'post', 'id' => $id)), 'success');
         }
     }
     include $this->template('list');
 }
Exemple #4
0
 //临时存放文件
 $error = $file['error'];
 if ($erro) {
     json('no', '上传出现错误' . $error, '');
 }
 if ($size > 1000000) {
     //大于1m
     json('no', '图片太大' . $size, '');
 }
 if ($type != 'image/jpeg') {
     json('no', '类型不符合标准' . $type, '');
 }
 $extension = '.jpg';
 $filename = date("Ymdhis") . '_' . rand(0, 100) . $extension;
 $thumbpic = "./temp/thumb_" . $filename;
 img2thumb($tmpfile, $thumbpic);
 //$myfile="./temp/".$filename;
 /*****上传至weed服务器*****/
 $fid = get_fid();
 if (empty($fid)) {
     //抽空吧这里改成存储到本服务器
     json('no', '上传失败-图片服务器不可用', '');
 }
 $post_data['file'] = '@' . $tmpfile;
 //原图
 $uppic = update_pic($post_data, 'http://127.0.0.1:8081/' . $fid . '_1');
 $post_thumb_data['file'] = '@' . $thumbpic;
 //缩略图
 $uppic_thumb = update_pic($post_thumb_data, 'http://127.0.0.1:8081/' . $fid);
 $uppicobj_thumb = json_decode($uppic_thumb);
 $uppicobj = json_decode($uppic);
Exemple #5
0
function uploadpic($picpath)
{
    set_time_limit(0);
    $action = I("act");
    if ($action == 'delimg') {
        $filename = I("imagename");
        if (!empty($filename)) {
            unlink($picpath . $filename);
            echo '1';
        } else {
            echo '删除失败.';
        }
    } else {
        $picname = $_FILES['mypic']['name'];
        $picsize = $_FILES['mypic']['size'];
        if ($picname != "") {
            if ($picsize > 8192000) {
                echo '图片大小不能超过8M';
                exit;
            }
            //$type = strstr($picname, '.');
            $picarr = explode(".", $picname);
            $type = $picarr[count($picarr) - 1];
            $type = trim(strtolower($type));
            if (!in_array($type, array('gif', 'jpg', 'jpeg', 'png', 'JPEG', 'JPG', 'GIF', 'PNG'))) {
                echo '图片格式不对!';
                exit;
            }
            $rand = rand(100, 999);
            $randname = date("YmdHis") . $rand;
            $pics = $randname . "." . $type;
            //上传路径
            $pic_path = $picpath . $pics;
            move_uploaded_file($_FILES['mypic']['tmp_name'], $pic_path);
        }
        //生成缩略图
        $dst_img = $randname . "_thumb." . $type;
        img2thumb($pic_path, $picpath . $dst_img, 120, 120);
        $size = round($picsize / 1024, 2);
        $arr = array('name' => $picname, 'pic' => $dst_img, 'size' => $size);
        echo json_encode($arr);
    }
}
Exemple #6
0
function savepic($url, $path, $thumbpath, $fname, $flag, &$msg)
{
    $res = false;
    $pathlink = '../' . $path;
    $thumblink = '../' . $thumbpath;
    if (!is_dir($pathlink)) {
        mkdirs($pathlink);
    }
    if (!is_dir($thumblink)) {
        mkdirs($thumblink);
    }
    $st = strrpos($url, "/");
    $tmpfpath = substring($url, $st, 0);
    $tmpfname = rawurlencode(substring($url, strlen($url) - $st, $st + 1));
    $url = $tmpfpath . "/" . $tmpfname;
    $errsize = 3;
    $byte = getPage($url, "utf-8");
    $bytelen = strlen($byte);
    $size = round($bytelen / 1024, 2);
    fwrite(fopen($pathlink . $fname, "wb"), $byte);
    $img_mime = array('image/gif', 'image/jpeg', 'image/png', 'image/bmp');
    $re = getimagesize($pathlink . $fname);
    if (!in_array($re['mime'], $img_mime)) {
        $msg = "(<font color=red>该文件可能是无效图片,跳过保存</font>)<a target=_blank href=" . $url . ">查看</a>";
        $status = false;
    } else {
        if ($flag == 'vod') {
            if ($GLOBALS['MAC']['upload']['watermark'] == 1) {
                imageWaterMark($pathlink . $fname, MAC_ROOT . '/inc/common/', $GLOBALS['MAC']['upload']['waterlocation'], $GLOBALS['MAC']['upload']['waterfont']);
            }
            if ($GLOBALS['MAC']['upload']['thumb'] == 1) {
                $thumbst = img2thumb($pathlink . $fname, $thumblink . $fname, $GLOBALS['MAC']['upload']['thumbw'], $GLOBALS['MAC']['upload']['thumbh']);
            }
            if ($GLOBALS['MAC']['upload']['ftp'] == 1) {
                uploadftp($path, $fname);
                if ($thumbst) {
                    uploadftp($thumbpath, $fname);
                }
            }
        }
        $msg = "PicView:<a href='" . $pathlink . $fname . "' target='_blank'>" . $pathlink . $fname . "</a> <font color=red>" . $size . "</font>Kb";
        $status = true;
    }
    unset($img_mime, $re);
    return $status;
}
Exemple #7
0
 $fname = date('Ymd') . time() . '.' . $ext;
 while (file_exists($updir . $fname)) {
     sleep(1);
     $fname = date('Ymd') . time() . '.' . $ext;
 }
 if (function_exists('move_uploaded_file')) {
     @move_uploaded_file($FILEa['tmp_name'], $updir . $fname);
 } else {
     @copy($FILEa['tmp_name'], $updir . $fname);
 }
 $thumbjs = '';
 if ($MAC['upload']['watermark'] == 1) {
     imageWaterMark($updir . $fname, getcwd(), $MAC['upload']['waterlocation'], $MAC['upload']['waterfont']);
 }
 if ($id == 'd_pic' && $MAC['upload']['thumb'] == 1) {
     $thumbst = img2thumb($updir . $fname, "../../" . $thumbdir . $fname, $MAC['upload']['thumbw'], $MAC['upload']['thumbh']);
     if ($thumbst) {
         $thumbjs = '<script>parent.document.getElementById("d_picthumb").value="' . $thumbdir . $fname . '"</script>';
     }
 }
 if ($path == 'vod' && $action != "xht" && $MAC['upload']['ftp'] == 1) {
     uploadftp($showdir, $fname);
     if ($thumbst) {
         uploadftp($thumbdir, $fname);
     }
 }
 if ($action == "xht") {
     echo '{"status":"true","err":"' . $errm . '","msg":"' . $MAC['site']['installdir'] . $showdir . $fname . '"}';
 } elseif ($action == 'uploadify') {
     echo '{"status":"true","msg":"ok","file":"' . $showdir . $fname . '"}';
 } else {
 public function queryThumbnail($bucket_name, $object_name)
 {
     $Connection = isset($this->ceph_conn) ? $this->ceph_conn : $this->connectionCeph();
     $msg = '';
     $status = $this->INVAILD_PARAMETER;
     if ($Connection->if_object_exists($bucket_name, $object_name)) {
         $res = $Connection->get_object($bucket_name, $object_name);
         if ($res->isOK()) {
             $boby = $res->body;
             $user_upload_path = session('user_upload_path');
             $filepath = $user_upload_path . DIRECTORY_SEPARATOR . $object_name;
             mkdirs($filepath);
             if (file_put_contents($filepath . DIRECTORY_SEPARATOR . $object_name, $boby)) {
                 $src_img = $filepath . DIRECTORY_SEPARATOR . $object_name;
                 $dst_img = $filepath . DIRECTORY_SEPARATOR . $object_name . ".png";
                 $stat = img2thumb($src_img, $dst_img, 64, 64, $cut = 0, $proportion = 0);
                 if ($stat) {
                     $status = $this->SUCCESS;
                 } else {
                     $status = $this->ERR_OCCURED;
                     $msg = "Generate img to thumb failed!";
                 }
             } else {
                 $status = $this->ERR_OCCURED;
                 $msg = 'get object use generate temporary files failed!';
             }
         } else {
             $status = $this->OUT_OF_SERVICE;
             $msg = 'get object body failed!';
         }
     } else {
         $msg = 'not found the [' . $object_name . '].';
     }
     return array('status' => $status, 'msg' => $msg);
 }
Exemple #9
0
        default:
            throw new RuntimeException('未知错误.');
    }
    if ($_FILES['upload_file']['size'] > 2097152000) {
        throw new RuntimeException('文件过大.');
    }
    $finfo = new finfo(FILEINFO_MIME_TYPE);
    if (false === ($ext = array_search($finfo->file($_FILES['upload_file']['tmp_name']), array('jpg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif'), true))) {
        throw new RuntimeException('上传出错,文件格式不正确,网站只允许上传jpg,png或gif文件.');
    }
    if (!move_uploaded_file($_FILES['upload_file']['tmp_name'], sprintf('upload/%s.%s', $title, $ext))) {
        throw new RuntimeException('上传出错,文件未能被正确保存.');
    }
    $filepath = 'upload/' . $title . "." . $ext;
    $thumb_path = 'thumbnail/' . $title . "." . $ext;
    img2thumb($filepath, $thumb_path);
    try {
        $dbh = new PDO('mysql:host=' . DB_HOST . ';port=' . DB_PORT . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD);
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $dbh->exec("set names 'utf8'");
        $title = $title . "." . $ext;
        $sth = $dbh->prepare("INSERT INTO `photos` (`id`, `title`, `time`, `description`, `album`) VALUES (NULL, ?, CURRENT_TIMESTAMP, ?,?);");
        $sth->execute(array($title, $desc, $album));
    } catch (PDOException $e) {
        $result['msg'] = $e->getMessage();
    }
    $result["filepath"] = $filepath;
    $result["success"] = true;
} catch (RuntimeException $e) {
    $result['msg'] = $e->getMessage();
}