Beispiel #1
0
 /**
  * @param ImageUpload $imageupload
  * @param string $s3Name
  */
 public function sendNotification(ImageUpload $imageupload, $s3Name)
 {
     $sns = $this->getSNS();
     $response = $sns->create_topic('asciigram-image-uploaded');
     $arn = (string) $response->body->CreateTopicResult->TopicArn;
     $this->initSNSSubscriptions($arn);
     $response = $sns->publish($arn, $imageupload->getMessage(), array('Subject' => $s3Name));
 }
Beispiel #2
0
 public function persistImageUpload(ImageUpload $imageupload)
 {
     $s3 = $this->getS3();
     // initialise bucket
     $bucket = 'asciigram-' . strtolower($s3->key);
     $this->initS3Bucket($bucket);
     // Upload the image
     $imageName = uniqid();
     $response = $s3->create_object($bucket, $imageName, array('fileUpload' => $imageupload->getImage()->getPathname(), 'acl' => \AmazonS3::ACL_PUBLIC));
     if ($response->isOk()) {
         return $imageName;
     }
 }
Beispiel #3
0
 public function imageDelete()
 {
     $imagePath = _get('imagePath');
     if (!$imagePath == NULL) {
         $imgUpload = new ImageUpload();
         $res = $imgUpload->deleteImage($imagePath);
         if ($res) {
             echo "1";
         } else {
             echo "-1";
         }
     }
 }
Beispiel #4
0
 public function save($model)
 {
     $model['openid'] = hash('sha256', $model['number'] . TORCH_SECRET);
     $model['support_service'] = implode(',', (array) $model['support_service']);
     $model['photo'] = ImageUpload::getImageUrl();
     parent::save($model);
     $time = time();
     header("location: ../user-success.php");
 }
Beispiel #5
0
$error = false;
$error_message = [];
$arr = ArticleRepo::load($link, $_GET['id']);
$title = $arr->getTitle();
$content = $arr->getContent();
if (!empty($_POST) && isset($_POST['titleNew']) && isset($_POST['contentNew'])) {
    $titleNew = trim($_POST['titleNew']);
    $contentNew = trim($_POST['contentNew']);
    if (isset($_FILES['image'])) {
        if ($_FILES['image']['name'] != '') {
            $arrtype = array('image/jpeg', 'image/gif', 'image/png');
            if (in_array($_FILES['image']['type'], $arrtype) && $_FILES['image']['size'] < 1000000) {
                if (!is_dir("img")) {
                    mkdir("img");
                }
                if (ImageUpload::upload($link, $_FILES['image'])) {
                    $name = $_FILES['image']['name'];
                    $name = " '{$name}' ";
                    $add = ImageRepo::add($link, $name, $_GET['id']);
                    $change = true;
                }
            } else {
                $error = true;
                $error_message[] = 'Файл должен быть формата .jpg, .png или .gif и размером меньше 1Mb';
            }
        }
    }
    if (!empty($titleNew) && !empty($contentNew)) {
        if (ArticleRepo::edit($link, $_GET['id'], $_POST['titleNew'], $_POST['contentNew'])) {
            $title = $titleNew;
            $content = $contentNew;
            break;
        case "png":
            if (!imagepng($image_p, $location)) {
                throw new RuntimeException('Failed to move uploaded file.');
            }
            break;
        default:
            throw new RuntimeException("Error Bad Extention");
            break;
    }
    imagedestroy($rImg);
    imagedestroy($image_p);
    /*
          if ( !move_uploaded_file( $_FILES["upfile"]["tmp_name"], $location) ) {
            throw new RuntimeException('Failed to move uploaded file.');
          }
    */
    $util = new Util();
    $fileName .= '.' . $ext;
    $imgupload = new ImageUpload();
    $imgupload->saveimage($_SESSION['user_id'], $fileName);
    $message = 'File is uploaded successfully.';
} catch (RuntimeException $e) {
    $message = $e->getMessage();
    $status = 500;
    $location = '';
}
header("HTTP/1.1 " . $status . " " . $status_codes[$status]);
$response = array("status" => $status, "status_message" => $status_codes[$status], "message" => $message, "location" => $location);
echo json_encode($response);
die;
<?php

require '../dao/AchieveDao.php';
require 'ImageUpload.php';
$imageUpload = new ImageUpload();
$userId = $_REQUEST['userId'];
$achieveType = $_REQUEST['achieveType'];
if (!empty($_REQUEST['achieveImage'])) {
    $achieveImage = $_REQUEST['achieveImage'];
} else {
    $achieveImage = $imageUpload->setAchieveImage();
}
$achieveTitle = $_REQUEST['achieveTitle'];
$achieveContent = $_REQUEST['achieveContent'];
$isGet = (int) $_REQUEST['isGet'];
//boolean
$achieveDao = new AchieveDao();
if ($achieveDao->setAchieve($userId, $achieveType, $achieveImage, $achieveTitle, $achieveContent, $isGet) > 0) {
    echo json_encode(array('mesg' => 'success', 'result' => true));
} else {
    echo json_encode(array('mesg' => 'fail', 'result' => false));
}
Beispiel #8
0
<?php

include 'image-upload-class.php';
//Prepare Image for upload
$ImgObj = new ImageUpload($_FILES);
//If image is valid do
if ($ImgObj->ValidateFileImg()) {
    //Upload Image to Gyldendal
    $ImgObj->UploadImage();
}
Beispiel #9
0
 public static function getImageUrl()
 {
     return ImageUpload::setImage('userImage');
 }
Beispiel #10
0
        if ($Upload->populate()) {
            print_r($Upload->Results);
        } else {
            print_r($Upload);
            die("Upload failed!");
        }
        break;
    case 2:
        $Upload = new ImageUpload(2);
        $Upload->auth("iSQGkh6VJjAtkMjcDQysTPXOUGxiHutVYBw71");
        $Upload->setSpecial($_FILES['fileselect']);
        if ($Upload->populate()) {
            print_r($Upload->Results);
        } else {
            print_r($Upload);
            die("Upload failed!");
        }
        break;
    case 3:
        $Upload = new ImageUpload(3);
        $Upload->auth("iSQGkh6VJjAtkMjcDQysTPXOUGxiHutVYBw71");
        $Urls = array("http://ptpimg.me/830y01.jpg", "http://ptpimg.me/lo73m5.jpg", "http://ptpimg.me/89fbx9.jpg");
        $Upload->setSpecial($Urls);
        if ($Upload->populate()) {
            print_r($Upload->Results);
        } else {
            print_r($Upload);
            die("Upload failed!");
        }
        break;
}
<?php

require '../dao/PostDao.php';
require '../dao/MessageDao.php';
require 'ImageUpload.php';
$imageUpload = new ImageUpload();
$postUser = $_REQUEST['postUser'];
$postImage = $imageUpload->getImageUrl();
$postTopic = $_REQUEST['postTopic'];
$postContent = $_REQUEST['postContent'];
$postTag = $_REQUEST['postTag'];
$isAnonymity = (int) $_REQUEST['isAnonymity'];
//boolean
$achieveId = 0;
if (!empty($_REQUEST['achieveId'])) {
    $achieveId = $_REQUEST['achieveId'];
}
$postDao = new PostDao();
$id = $postDao->postWrite($postUser, $postImage, $postTopic, $postContent, $postTag, $isAnonymity);
if ($id == null || $id == 0) {
    echo json_encode(array('mesg' => 'fail', 'result' => false));
} else {
    if ($achieveId != 0) {
        $messageDao = new MessageDao();
        $messageDao->setMessage($postUser, $achieveId, null, $isAnonymity, $id);
    }
    echo json_encode(array('mesg' => 'success', 'result' => true));
}
 private function uploadImage($file)
 {
     $img = new ImageUpload($file, 700, 526);
     $img->setDestinationFolder('voucher_img/');
     $img->saveImageReducedSize(2);
     return $img->finalImgName;
 }
Beispiel #13
0
<?php

$pu = new ImageUpload('profile', $_SESSION['logged_user']);
if (isset($_POST['datadir'])) {
    $uploadfile = $_POST['datadir'] . $_FILES['filetto']['name'];
    $temp = explode(".", $_FILES["filetto"]["name"]);
    $newfilename = md5(time());
    $newfilenameext = $newfilename . '.' . end($temp);
    move_uploaded_file($_FILES["filetto"]["tmp_name"], $_POST['datadir'] . $newfilenameext);
    $images = new Image($_POST['datadir'] . $newfilenameext);
    $images->resize(136, 136, 'crop');
    $images->save($newfilename, $_POST['datadir']);
    $pu->addImageToSQL($newfilenameext);
    $pu->changeProfileImage($newfilenameext);
}
echo $user->loadProfilePic($_GET['user']);
echo $user->printCard();
if ($_GET['user'] == $_SESSION['logged_user_email']) {
    $pu->lomake();
}
Beispiel #14
0
 public static function upload($link, $file)
 {
     if (copy($file['tmp_name'], 'img/' . $file['name'])) {
         ImageUpload::resize($file);
         return true;
     } else {
         return $error_message = 'Ошибка загрузки файла';
     }
 }
 public function saveImage(ImageUpload $image)
 {
     $path = Yii::getPathOfAlias('webroot') . '/' . $this->getImgPath();
     foreach ($this->imgParams as $params) {
         $width = (int) $params['width'];
         $height = (int) $params['height'];
         $quality = isset($params['quality']) ? (int) $params['quality'] : $this->defaultQuality;
         $imageName = $this->_getImageName();
         if ($image->processed) {
             $image->image_resize = TRUE;
             $image->file_new_name_body = $imageName;
             $image->image_x = $width;
             $image->image_y = $height;
             $image->image_ratio = TRUE;
             $image->jpeg_quality = $quality;
             $image->process($path);
             if ($image->processed) {
                 $this->owner->{$this->attributeName} = $image->file_dst_name;
                 if (isset($params['thumb'])) {
                     $width = (int) $params['thumb']['width'];
                     $height = (int) $params['thumb']['height'];
                     $quality = isset($params['thumb']['quality']) ? (int) $params['thumb']['quality'] : $this->defaultQuality;
                     $image->image_resize = TRUE;
                     $image->file_new_name_body = $imageName;
                     $image->file_name_body_add = '_thumb';
                     $image->image_x = $width;
                     $image->image_y = $height;
                     $image->jpeg_quality = $quality;
                     $image->image_ratio = TRUE;
                     $image->process($path);
                     if (!$image->processed) {
                         Yii::log($image->error, CLogger::LEVEL_ERROR, 'ImageUploadBehavior');
                     }
                 }
             } else {
                 Yii::log($image->error, CLogger::LEVEL_ERROR, 'ImageUploadBehavior');
             }
         } else {
             Yii::log($image->error, CLogger::LEVEL_ERROR, 'ImageUploadBehavior');
         }
     }
 }
Beispiel #16
0
<?php

session_start();
include 'initclasses.php';
if (isset($_POST['addroute'])) {
    $cragid = $_POST['crag'];
    $name = $_POST['routename'];
    $routegrade = $_POST['grade_number'] . $_POST['grade_letter'] . $_POST['grade_plus'];
    $description = $_POST['description'] ?: ' ';
    $route = new Route();
    $routeid = $route->addRouteToDB($cragid, $name, $routegrade, $description);
    $datapath = $_POST['datadir'] . $routeid . "/";
    $image = new ImageUpload('route', $routeid);
    $temp = explode(".", $_FILES["filetto"]["name"]);
    $newfilename = md5(time());
    $newfilenameext = $newfilename . '.' . end($temp);
    move_uploaded_file($_FILES["filetto"]["tmp_name"], $datapath . $newfilenameext);
    $images = new Image($datapath . $newfilenameext);
    $images->resize(175, 150, 'crop');
    $images->save($newfilename, $datapath);
    $image->addImageToSQL($newfilenameext);
    $image->linkImage('route', $routeid, $newfilenameext);
}
header('Location: markroute.php');
<?php

include '../class/image_class.php';
$image = new ImageUpload($_FILES);
$image->RemoveOldTemp();
$image->DoChecks();
//display errors
if (count($image->errors) > 0) {
    $string = '';
    foreach ($image->errors as $error) {
        $string .= $error . '|';
    }
    echo substr($string, 0, -1);
    exit;
}
$image->ReceiveImage();
echo $image->output;
<?php

require '../dao/UserDao.php';
require 'ImageUpload.php';
$imageUpload = new ImageUpload();
$userId = $_REQUEST['userId'];
$field = "userImage";
$value = $imageUpload->setUserImage();
$userDao = new UserDao();
if ($userDao->setUserInfo($userId, $field, $value) > 0) {
    echo json_encode(array('mesg' => 'success', 'result' => true, 'imgUrl' => $value));
} else {
    echo json_encode(array('mesg' => 'fail', 'result' => false));
}
Beispiel #19
0
<?php

session_start();
include 'initclasses.php';
if (isset($_POST['cragupload'])) {
    $name = $_POST['cragname'];
    $lat = $_POST['lat'];
    $long = $_POST['long'];
    $crag = new Crag();
    $cragid = $crag->addCragToDB($name, $lat, $long);
    $datapath = $_POST['datadir'] . $cragid . "/";
    $image = new ImageUpload('crag', $cragid);
    $uploadfile = $datapath . $_FILES['filetti']['name'];
    $temp = explode(".", $_FILES["filetti"]["name"]);
    $newfilename = md5(time());
    $newfilenameext = $newfilename . '.' . end($temp);
    move_uploaded_file($_FILES["filetti"]["tmp_name"], $datapath . $newfilenameext);
    $images = new Image($datapath . $newfilenameext);
    $images->resize(175, 150, 'crop');
    $images->save($newfilename, $datapath);
    $image->addImageToSQL($newfilenameext);
    $image->linkImage('crag', $cragid, $newfilenameext);
}
header('Location: markroute.php');
<?php

session_start();
include 'initclasses.php';
echo "MITITIAITAII";
$iu = new ImageUpload('profile', $_SESSION['logged_user']);
if (isset($_FILES['filetto'])) {
    $uploadfile = $iu->getDatadir() . $_FILES['filetto']['name'];
    $temp = explode(".", $_FILES["filetto"]["name"]);
    $newfilename = md5(time());
    $newfilenameext = $newfilename . '.' . end($temp);
    move_uploaded_file($_FILES["filetto"]["tmp_name"], $iu->getDatadir() . $newfilenameext);
    $images = new Image($iu->getDatadir() . $newfilenameext);
    $images->resize(256, 256, 'crop');
    $images->save($newfilename, $iu->getDatadir());
    $iu->addImageToSQL($newfilenameext);
    $iu->linkImage('user', null, $newfilenameext);
}
header('Location: profile.php?page=pictures');