/**
  * 在商品更新之前,更新图片信息。
  * @param  [type] &$data    更新的数据
  * @param  [type] $options  
  * @return [type]          
  */
 public function _before_update(&$data, $options)
 {
     /*****************同时更新图片路径*****************/
     //调用函数库中的图片上传函数
     $result = uploadImg($data, $options);
     //判断图片是否处理成功
     if (!$result[0]) {
         //如果返回false,则上传图片失败
         $this->error = $result[1];
     }
     /************判断分类是否更改,再进行分类数量的相应删除与增加************/
     if (!empty($data['cat_id'])) {
         //根据options获取更新的id
         $id = $options['where']['id'];
         //判断商品分类cat_id是否改变
         $oldGoods = M('goods')->field('cat_id')->find($id);
         //旧分类id
         $newCat_id = $data['cat_id'];
         //新分类id
         //比较新旧
         if ($oldGoods['cat_id'] != $newCat_id) {
             //删除原分类的商品数量
             $old = M('category')->query("update my_category set goods_num = goods_num - 1 where id = " . $oldGoods['cat_id']);
             //增加新分类的商品数量
             $new = M('category')->query("update my_category set goods_num = goods_num + 1 where id = " . $newCat_id);
         }
     }
 }
 public function _before_update()
 {
     //调用函数库中的图片上传函数
     $result = uploadImg($data, $options, false);
     //判断图片是否处理成功
     if (!$result[0]) {
         //如果返回false,则上传图片失败
         $this->error = $result[1];
     }
 }
 public function upload_image_post()
 {
     $this->check_token();
     $array = uploadImg();
     if (!empty($array)) {
         $result = array();
         $result['sha1'] = $array[0]['sha1'];
         $result['path'] = $array[0]['path'];
         $result['status'] = $array[0]['status'];
         $this->success($result);
     }
     $this->error(1417);
 }
 public function adicionartimeAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $dados = $this->_request->getPost();
     $dados['time']['img'] = uploadImg();
     /*    	$adapter = new Zend_File_Transfer_Adapter_Http();
         	$adapter->setDestination('/var/www/trunk/bolao/public/imagens/emblems');
         	
         	if (!$adapter->receive())
         	{
         		$messages = $adapter->getMessages();
         		echo implode("\n", $messages);
         	}
         	$upload = new Zend_File_Transfer();
         	
         	$files = $upload->getFileInfo();
         	foreach ($files as $file => $info)
         	{
         		if ($upload->isUploaded($file)){
         			echo 'campo de imagem vazio';
         			continue;
         		}
         	}
         	
         	if (!$upload->isValid($file))
         	{
         		dump("erro...");
         	}
         	
     	    	dump($files,1);
         	
         	dump($dados,1); */
     if ($this->_request->isPost()) {
         $mTime = new Application_Model_Time();
         $mTime->insert($dados['time']);
     }
     $this->_forward('times');
 }
示例#5
0
文件: rfiles.php 项目: rhempen/cms
     $action = $param[0];
     $cfile = $param[1];
     // current filename
     $nfile = $param[2];
     // new filename
     if (!($nfile = renameImg($clib, $cfile, $nfile))) {
         echo $l->m('er_001') . ': ' . $l->m('er_041');
     }
 } else {
     if ($param[0] == 'upload') {
         // action: upload image
         $action = $param[0];
         $chkT = isset($_REQUEST['chkThumbSize']) ? $_REQUEST['chkThumbSize'] : array();
         // thumb-sizes in Array
         if (isset($_FILES['nfile']['name'][0])) {
             if (!($nfile = uploadImg($clib, $chkT))) {
                 echo $l->m('er_001') . ': ' . $l->m('er_028');
             }
         }
     } else {
         if ($param[0] == 'create') {
             // action: create directory
             $action = $param[0];
             $nfile = $param[1];
             // new filename
             if (!createDir($clib, $nfile)) {
                 echo $l->m('er_001') . ': ' . $l->m('er_042');
             }
         } else {
             if ($param[0] == 'update') {
                 // action: update image list and select current image
示例#6
0
<?php

header("Access-Control-Origin: *");
//echo "imagepanel";
$function_code = $_REQUEST["code"];
require_once "./condb.php";
global $con;
if (isset($function_code)) {
    switch ($function_code) {
        case 'download':
            getImg();
            break;
        case 'upload':
            if (isset($_REQUEST['id']) && isset($_REQUEST['name']) && isset($_FILES)) {
                uploadImg();
            }
            break;
        default:
            //echo "string";
            break;
    }
}
//Recuperar imagenes a editar de DB..
function getImg()
{
    global $con;
    try {
        $sql = $con->prepare("SELECT img_id, img_name FROM imagenes WHERE visible='no'");
        $sql->execute();
        $imagenes = array();
        while ($img = $sql->fetch(PDO::FETCH_ASSOC)) {
 public function index()
 {
     uploadImg();
     phpinfo();
 }
示例#8
0
}
if (isset($_FILES['button_3_pic_hover'])) {
    $was_upload = uploadImg($_FILES['button_3_pic_hover'], 'button_3_pic_hover');
    if ($was_upload) {
        ?>
        <img id='uploaded_image_pc' class='box' src='admin_images/<?php 
        echo $was_upload;
        ?>
'/>
        <?php 
    }
}
if (isset($_FILES['uploaded_file'])) {
    //פה אני בודק האם צריך להחליף רקע לאחד העמודים לא משנה לאיזה עמוד אני עושה אותו הדבר ובודק בסוויטצ
    //echo($_POST['page_name']);
    $was_upload = uploadImg($_FILES['uploaded_file'], $_POST['page_name']);
    if ($was_upload) {
        ?>
        <img id='uploaded_image_pc' class='box' src='admin_images/<?php 
        echo $was_upload;
        ?>
'/>
        <?php 
    }
}
if (isset($_POST['movie_site_url'])) {
    $main_screen->movie_site_url = $_POST['movie_site_url'];
}
$main_screen->Update();
//מעדכן את כל מה שצריך עדכון בבת אחת
function uploadImg($file, $choose_page)
 function doUpload()
 {
     $db = new db();
     $name = $_POST['bookname'];
     if ($_POST['author'] != '') {
         $author = $_POST['author'];
     } else {
         $author = '未知';
     }
     if ($_POST['desc'] != '') {
         $desc = $_POST['desc'];
     } else {
         $desc = '无';
     }
     if ($_POST['authordesc'] != '') {
         $authorDesc = $_POST['authordesc'];
     } else {
         $authorDesc = '无';
     }
     if ($_POST['tag'] != '') {
         $tag = $_POST['tag'];
     } else {
         $tag = '其他';
     }
     if ($_POST['isbn'] != '') {
         $isbn = $_POST['isbn'];
     } else {
         $isbn = 0;
     }
     if (isset($_SESSION['email']) && $_SESSION['email'] != '') {
         $uploader = $_SESSION['email'];
     } else {
         $uploader = '匿名';
     }
     $id = $db->addBook($name, $author, $tag, $isbn, $desc, $authorDesc, $uploader);
     move_uploaded_file($_FILES["file"]["tmp_name"], './jae/' . $id . '.mobi');
     uploadEbook('./jae/' . $id . '.mobi');
     if ($_POST['pic-id'] != '') {
         rename('./jae/' . $_POST['pic-id'], './jae/' . $id . '.jpg');
     } else {
         createCover($name, $author, $id);
     }
     uploadImg('./jae/' . $id . '.jpg');
     unlink('./jae/' . $id . '.mobi');
     return $id;
 }
示例#10
0
        array_walk($value, 'is_array_value', $_imglib);
    }
    if ($value == $_imglib) {
        $value_found = true;
    }
}
array_walk($spaw_imglibs, 'is_array_value', $imglib);
if (!$value_found || empty($imglib)) {
    $imglib = $spaw_imglibs[0]['value'];
}
$lib_options = liboptions($spaw_imglibs, '', $imglib);
$img = isset($HTTP_POST_VARS['imglist']) ? $HTTP_POST_VARS['imglist'] : '';
$preview = '';
$errors = array();
if (isset($HTTP_POST_FILES['img_file']['size']) && $HTTP_POST_FILES['img_file']['size'] > 0) {
    if ($img = uploadImg('img_file')) {
        $preview = $spaw_base_url . $imglib . $img;
    }
}
// delete
if ($spaw_img_delete_allowed && isset($HTTP_POST_VARS['lib_action']) && $HTTP_POST_VARS['lib_action'] == 'delete' && !empty($img)) {
    deleteImg();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
  <title><?php 
echo $l->m('title');
?>
示例#11
0
    }
    $data = array('id' => $id, 'author' => $_POST['author'], 'title' => $_POST['title'], 'brief' => $_POST['brief'], 'showpic' => $showPic, 'description' => $_POST['description'], 'fromurl' => $_POST['fromurl']);
    if (isset($picPath) && !empty($picPath)) {
        $data['picPath'] = $picPath;
    }
    $msgNews->updateById($data);
} else {
    //添加
    //msgBase
    $msgBase = new MsgBase();
    $baseData = array('msgType' => 'news', 'inputCode' => $_POST['inputCode'], 'createTime' => date('Y-m-d'));
    $baseId = $msgBase->insert($baseData);
    //msgNews
    //上传图片
    $picPath = '';
    $uprst = uploadImg("imgFile");
    if ($uprst['flag']) {
        $picPath = $uprst['imgUrl'];
    }
    $msgNews = new MsgNews();
    $showPic = 0;
    if (!empty($_POST['showPic'])) {
        $showPic = 1;
    }
    $data = array('base_id' => $baseId, 'author' => $_POST['author'], 'title' => $_POST['title'], 'brief' => $_POST['brief'], 'showpic' => $showPic, 'description' => $_POST['description'], 'fromurl' => $_POST['fromurl'], 'picPath' => $picPath);
    $newsId = $msgNews->insert($data);
    $url = 'http://' . $_SERVER['HTTP_HOST'] . $CONTEXT_PATH . '/wxapi/newsread.php?id' . $newsId;
    $updata = array('id' => $newsId, 'url' => $url);
    $msgNews->updateById($updata);
}
header("Location:" . $CONTEXT_PATH . "/wxcms/msgnewsList.php");
 public function test_uploadVkImg()
 {
     $this->assertNotFalse(uploadImg('[object Object]/||/http://41.media.tumblr.com/589273c45f9cdc7f768869793341c609/tumblr_nrkfd5ePWL1tmeibwo1_1280.jpg/||/http://33.media.tumblr.com/122c50e38e08a2d7f42c0fb4420ce3b9/tumblr_nu1mnxmQwN1r4p08ko1_540.gif/||/http://38.media.tumblr.com/486044aceccdc183918cea97f28fee4a/tumblr_n70uykf1S71qfoa77o1_500.gif/||/http://41.media.tumblr.com/83d9b40e8748d48d1416efd6a74761bb/tumblr_nsb2lgg0hB1r4p08ko1_1280.jpg'));
 }
示例#13
0
<?php

require_once '../inc/common.php';
$user = getUser('mid');
$time = time();
$imgs = '';
$gid = isset($_REQUEST['gid']) ? (int) $_REQUEST['gid'] : 0;
if (!$gid) {
    header("Location: goods.php");
    die;
}
if ($_POST) {
    $res = array('msg' => '');
    if ($_FILES) {
        $res = uploadImg($_FILES);
        if ($res['msg']) {
            die(json_encode($res));
        }
        if (isset($res['imgs'])) {
            $imgs = implode('|', $res['imgs']);
        }
    }
    $content = htmlspecialchars($_POST['content']);
    $sql = "INSERT INTO m_comment SET pid=:gid, mid='{$user['mid']}',ctime='{$time}',imgs='{$imgs}',content=:content";
    $sth = $db->prepare($sql);
    $sth->bindParam(':gid', $gid);
    $sth->bindParam(':content', $content);
    $sth->execute();
    if (!$db->lastInsertId()) {
        $res['msg'] = '评论失败!';
    }
示例#14
0
}
if (isset($_FILES['img_upload'])) {
    if ($_POST['port_folder'] == 'no') {
        $folder = $_POST['folder'];
        if (strlen($_POST['newfolder']) > 2) {
            $folder = $_POST['newfolder'];
        }
    }
    if ($_POST['port_folder'] == 'yes') {
        $folder = $_POST['port_folder_selection'];
        if (strlen($_POST['new_port_folder']) > 2) {
            $folder = $_POST['new_port_folder'];
            $folder = "Portfolio/" . $folder;
        }
    }
    uploadImg($_FILES['img_upload'], $folder);
    getPhotosBlog();
    folder();
    portFolder();
    getPhotos();
}
if (isset($_POST['editabout']) && isset($_POST['mission'])) {
    $name = $_POST['editabout'];
    $ins = $_POST['mission'];
    $ins = escape($ins);
    if (strlen($ins) > 5) {
        doQuery("UPDATE info SET text = '{$ins}' WHERE (subsection ='name_content' OR subsection ='a_statement') AND title='{$name}'");
    }
    if (strlen($_POST['team_img']) > 3) {
        $img = $_POST['team_img'];
        doQuery("UPDATE info SET img = '{$img}' WHERE (subsection ='name_content' OR subsection ='a_statement') AND title='{$name}'");
示例#15
0
        $imgs[] = "{$image}";
    }
    $directory = "pictures/*/";
    $images = glob("" . $directory . "*.jpg");
    foreach ($images as $image) {
        $imgs[] = "{$image}";
    }
    $directory = "pictures/*/*/";
    $images = glob("" . $directory . "*.jpg");
    foreach ($images as $image) {
        $imgs[] = "{$image}";
    }
    $directory = "pictures/*/*/*/";
    $images = glob("" . $directory . "*.jpg");
    foreach ($images as $image) {
        $imgs[] = "{$image}";
    }
    $directory = "pictures/*/*/*/*/";
    $images = glob("" . $directory . "*.jpg");
    foreach ($images as $image) {
        $imgs[] = "{$image}";
    }
    shuffle($imgs);
    $response = json_decode(uploadImg("@" . $imgs[5]));
    postImg($response->payload->url);
}
preg_match('/(snape,?|!) ?list(\\s*)(save ?plates)?/i', $text, $matches);
if ($matches != null) {
    listNames();
    exit;
}
示例#16
0
        curl_setopt($ch, CURLOPT_URL, $link);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        @curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams);
        $response = curl_exec($ch);
        $photoParams = json_decode($response);
        $photo = $photoParams->photo;
        $server = $photoParams->server;
        $url = 'https://api.vk.com/method/photos.saveWallPhoto?group_id=' . $group_id . '&v=5.5&photo=' . $photo . '&server=' . $server . '&hash=' . $photoParams->hash . '&access_token=' . $token;
        $an = get_curl($url);
        $save = json_decode($an)->response;
        $attachments = "";
        for ($i = 0; $i < count($save); $i++) {
            $attachments = $attachments . "photo" . $user_uid . "_" . $save[$i]->id . ',';
        }
        $url = 'https://api.vk.com/method/wall.post?owner_id=-' . $group_id . '&from_group=1&attachments=' . $attachments . '&access_token=' . $token;
        $an = get_curl($url);
        if (!isset(\GuzzleHttp\json_decode($an)->response)) {
            echo "Unknown error";
            return false;
        } else {
            echo "Images is successfully uploaded";
            return true;
        }
    } else {
        echo "ERROR! You upload more than 6 images OR all your pics are GIFs !";
        return false;
    }
}
uploadImg($_POST['images']);
        break;
    }
}
if (!$value_found || empty($lib)) {
    $cur_imglib = $spaw_imglibs[0];
    $lib = $spaw_imglibs[0]['catID'];
}
$lib_options = liboptions($spaw_imglibs, '', $lib);
if (isset($_POST['imglist'])) {
    $img_params = explode(SPAW_VSEP, $_POST['imglist']);
    $img = basename($img_params[1]);
}
$preview = '';
$errors = array();
if (isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) {
    $img = uploadImg('img_file', $cur_imglib);
}
// delete confirm
if ($cur_imglib['delete_allowed'] && isset($_POST['lib_action']) && $_POST['lib_action'] == 'delete' && !empty($img)) {
    deleteConfirm($cur_imglib);
}
// delete
if ($cur_imglib['delete_allowed'] && isset($_POST['lib_action']) && $_POST['lib_action'] == 'dodelete' && !empty($img)) {
    deleteImg($cur_imglib, $img);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Content-Type" content="text/html; charset=<?php 
示例#18
0
<?php

define("DS", DIRECTORY_SEPARATOR);
define("ROOT", dirname(dirname(__FILE__)));
include_once ROOT . DS . "Model" . DS . "DataAccess.php";
$areaId = $_GET['area'];
$conn = new DataAccess("hciForum");
if ($_POST['sub']) {
    $areaId = $_POST['areaId'];
    $areaIcon = uploadImg("file");
    if ($areaIcon == "") {
        echo "failed";
    } else {
        $sql = "UPDATE `area` SET icon_url='{$areaIcon}' WHERE id='{$areaId}'";
        if (mysql_query($sql)) {
            echo "<script language=javascript>alert('添加成功');location='/HCI-forum/View/moderatorIndex.php?area={$areaId}';</script>";
        }
    }
} else {
}
$sql = "SELECT icon_url FROM `area` WHERE id='{$areaId}'";
$query = mysql_query($sql);
while ($area_rows = mysql_fetch_array($query)) {
    $iconUrl = $area_rows[0];
}
function uploadImg($file)
{
    if (($_FILES[$file]["type"] == "image/gif" || $_FILES[$file]["type"] == "image/jpeg" || $_FILES[$file]["type"] == "image/pjpeg" || $_FILES[$file]["type"] == "image/png") && $_FILES[$file]["size"] < 2000000) {
        if ($_FILES[$file]["error"] > 0) {
            return "";
        } else {
 public function upload()
 {
     require $_SERVER['DOCUMENT_ROOT'] . "/Application/Lib/upload.php";
     $result = uploadImg();
     if ($result['result'] === false) {
         $this->error($result['err']);
     } else {
         $this->insertReply($result['picDir'], date('Y-m-d H:i:s'));
     }
     $this->refreshDetail();
 }
示例#20
0
文件: upload.php 项目: Add-One/Design
{
    date_default_timezone_set("PRC");
    $imgData = $req['img_data'];
    $type = $req['type'];
    $savefile = 'uploadImg/';
    $time = date('YmdHis', time());
    $filename = $savefile . $time;
    $imgArr = array("image/jpg", "image/jpeg", "image/png", "image/gif");
    if (in_array($type, $imgArr)) {
        $img = base64_decode(str_replace('data:' . $type . ';base64,', '', $imgData));
        switch ($type) {
            case "image/jpeg":
            case "image/jpg":
                $filename = $filename . ".jpg";
                break;
            case "image/gif":
                $filename = $filename . ".gif";
                break;
            case "image/png":
                $filename = $filename . ".png";
                break;
        }
        file_put_contents($filename, $img);
        return $filename;
    } else {
        return false;
    }
}
$req = $_REQUEST;
$src = uploadImg($req);
echo $src;
示例#21
0
     // current filename
     $nfile = $param[2];
     // new filename
     if (!($nfile = renameImg($clib, $cfile, $nfile))) {
         echo $l->m('er_001') . ': ' . $l->m('er_033');
     }
 } else {
     if ($param[0] == 'upload') {
         // ACTION: upload image
         $action = $param[0];
         $chkT = isset($_REQUEST['chkThumbSize']) ? $_REQUEST['chkThumbSize'] : array();
         // thumb-sizes in Array
         $selR = isset($_REQUEST['selRotate']) ? $_REQUEST['selRotate'] : '';
         // auto rotate
         if (isset($_FILES['nfile']['name'][0])) {
             if (!($nfile = uploadImg($clib, $chkT, $selR))) {
                 echo $l->m('er_001') . ': ' . $l->m('er_028');
             }
         }
     } else {
         if ($param[0] == 'create') {
             // ACTION: create directory
             $action = $param[0];
             $nfile = $param[1];
             // new filename
             if (!createDir($clib, $nfile)) {
                 echo $l->m('er_001') . ': ' . $l->m('er_034');
             }
         } else {
             if ($param[0] == 'update') {
                 // ACTION: update image list and select current image
示例#22
0
        $rst['resize'] = ImageCopyResized($rst['dst'], $rst['src'], 0, 0, 0, 0, $tnW, $tnH, $w, $h);
        $rst['imgMod'] = imagejpeg($rst['dst'], $origPath, 100);
    } else {
        $rst['note'] = 'Error with file type!';
        return false;
    }
    return $rst;
}
if (!empty($_FILES)) {
    $name = explode('.', $_FILES['name']);
    $filename = $name[0] . substr(md5($_SERVER['REMOTE_ADDR'] . date('Y-m-d H:i:s')), 0, 8);
    /*if($_POST['adType']){
    switch ($_POST['adType']) {
        case 'bkgd':
            $mxW = 1200;
            $mxH = 800;
            break;
    }
    }elseif($_POST['maxW'] && $_POST['maxH']){
        $mxW = $_POST['maxW'];
        $mxH = $_POST['maxH'];
    }else{
        $mxW = 800;
        $mxH = 600;
    }*/
    $file = uploadImg($_FILES['Filedata'], $filename, 1800, 1200, $_POST['category']);
    echo "<pre>";
    print_r($_FILES);
    //print_r($file);
    echo "</pre>";
}