Esempio n. 1
0
function upload($uid, $uploadName = false, $FILE, $newWidth = 0, $newHeight = 0)
{
    global $OP;
    $dots = explode(".", $FILE['name']);
    $extension = strtolower($dots[count($dots) - 1]);
    $extensions = array("png", "jpg", "gif", "jpeg");
    if ($uploadName === false) {
        $uploadName = $OP->randStr(5) . "_" . $OP->randStr(5) . "_" . $OP->randStr(5);
    }
    /**
     * Check if User Id is numeric and $FILE array contain more than 0 items
     */
    if (is_numeric($uid) && is_array($FILE) && count($FILE) > 0) {
        /**
         * Check if File Extension is supported
         */
        if (array_search($extension, $extensions) !== false) {
            $path = $FILE['tmp_name'];
            $resize = new ResizeImage($path);
            $ratio = $resize->imgw() / $resize->imgh();
            $newWidth = ($newWidth == 0 ? $resize->imgw() : $newWidth) * $ratio;
            $newHeight = ($newHeight == 0 ? $resize->imgh() : $newHeight) * $ratio;
            /**
             * We resize to reduce the file size of image
             */
            $resize->resizeTo($newWidth, $newHeight, 'exact');
            $resize->saveImage($path, 50);
            /**
             * For Saving Database Space, we md5 the upload file name
             */
            $uploadMD5Name = md5($uploadName);
            $uploadContent = file_get_contents($path);
            /**
             * Only do data insertion if the data doesn't exist, else update the already existing value
             */
            $sql = $OP->dbh->prepare("SELECT 1 FROM `data` WHERE `uid`=? AND `name`=?");
            $sql->execute(array($uid, $uploadMD5Name));
            if ($sql->rowCount() == 0) {
                $sql = $OP->dbh->prepare("INSERT INTO `data` (`uid`, `name`, `txt`) VALUES (?, ?, ?)");
                $sql->execute(array($uid, $uploadMD5Name, $uploadContent));
            } else {
                $sql = $OP->dbh->prepare("UPDATE `data` SET `txt` = ? WHERE `uid`=? AND `name`=?");
                $sql->execute(array($uploadContent, $uid, $uploadMD5Name));
            }
            /* We, for fun add a .png extension to the file name */
            $uploadName .= ".png";
            /* and return the image URL */
            return Open::URL("/data/{$uid}/{$uploadName}");
        } else {
            return "extensionNotSupported";
        }
    } else {
        return false;
    }
}
Esempio n. 2
0
 public function __construct($id = NULL)
 {
     if (isset($id)) {
         $this->blog_id = $id;
         $this->check_blog_existance($id);
         if (isset($_POST['blog_title'])) {
             if ($this->blog_image == '') {
                 $rand = round(rand() * 10000, 4);
                 $this->blog_image = preg_replace('/[^a-zA-Z0-9\']/', '_', $_POST['blog_title']) . $rand;
             }
             if (isset($_FILES['blog_image_new']) && $_FILES['blog_image_new']['name'] != '' && $_FILES["blog_image_new"]["type"] == "image/jpeg") {
                 move_uploaded_file($_FILES["blog_image_new"]["tmp_name"], "images/blog/" . $this->blog_image . '.jpg');
                 $resize = new ResizeImage("images/blog/" . $this->blog_image . '.jpg');
                 $resize->resizeTo(400, 400, maxHeight);
                 $resize->saveImage("images/blog/" . $this->blog_image . '_300.jpg');
                 $document_root = $_SERVER['DOCUMENT_ROOT'];
                 copy("images/blog/" . $this->blog_image . '.jpg', $document_root . MAIN_SITE_FOLDER . "/images/blog/" . $this->blog_image . '.jpg');
                 copy("images/blog/" . $this->blog_image . '_300.jpg', $document_root . MAIN_SITE_FOLDER . "/images/blog/" . $this->blog_image . '_300.jpg');
             }
             $string = $_POST['blog_content_new'];
             $fp = fopen("blog/" . $this->blog_image . ".php", "w");
             fwrite($fp, $string);
             fclose($fp);
             $this->update_blog();
         }
     } else {
         if (isset($_POST['blog_title'])) {
             if ($this->blog_image == '') {
                 $rand = round(rand() * 10000, 4);
                 $this->blog_image = preg_replace('/[^a-zA-Z0-9\']/', '_', $_POST['blog_title']) . $rand;
             }
             if (isset($_FILES['blog_image_new']) && $_FILES['blog_image_new']['name'] != '' && $_FILES["blog_image_new"]["type"] == "image/jpeg") {
                 move_uploaded_file($_FILES["blog_image_new"]["tmp_name"], "images/blog/" . $this->blog_image . '.jpg');
                 $resize = new ResizeImage("images/blog/" . $this->blog_image . '.jpg');
                 $resize->resizeTo(400, 400, maxHeight);
                 $resize->saveImage("images/blog/" . $this->blog_image . '_300.jpg');
                 $document_root = $_SERVER['DOCUMENT_ROOT'];
                 copy("images/blog/" . $this->blog_image . '.jpg', $document_root . MAIN_SITE_FOLDER . "/images/blog/" . $this->blog_image . '.jpg');
                 copy("images/blog/" . $this->blog_image . '_300.jpg', $document_root . MAIN_SITE_FOLDER . "/images/blog/" . $this->blog_image . '_300.jpg');
             }
             $string = $_POST['blog_content_new'];
             $fp = fopen("blog/" . $this->blog_image . ".php", "w");
             fwrite($fp, $string);
             fclose($fp);
             $this->blog_id = $this->add_blog();
         }
     }
     $this->check_blog_existance($this->blog_id);
 }
Esempio n. 3
0
 public function __construct($id = NULL)
 {
     if (isset($id)) {
         $this->news_id = $id;
         $this->check_news_existance($id);
         if (isset($_POST['edit_news'])) {
             if (isset($_FILES['news_image']) && $_FILES['news_image']['name'] != '' && $_FILES["news_image"]["type"] == "image/jpeg") {
                 $rand = round(rand() * 10000, 4);
                 $this->news_image = preg_replace('/[^a-zA-Z0-9\']/', '_', $_POST['news_heading']) . $rand;
                 move_uploaded_file($_FILES["news_image"]["tmp_name"], "images/news/" . $this->news_image . '.jpg');
                 $resize = new ResizeImage("images/news/" . $this->news_image . '.jpg');
                 $resize->resizeTo(400, 300, 'exact');
                 $resize->saveImage("images/news/" . $this->news_image . '_300.jpg');
                 $resize = new ResizeImage("images/news/" . $this->news_image . '.jpg');
                 $resize->resizeTo(130, 100, 'exact');
                 $resize->saveImage("images/news/" . $this->news_image . '_100.jpg');
             }
         }
     } else {
         if (isset($_POST['add_news'])) {
             if ($this->news_image == '') {
                 $rand = round(rand() * 10000, 4);
                 $this->news_image = preg_replace('/[^a-zA-Z0-9\']/', '_', $_POST['news_heading']) . $rand;
             }
             if (isset($_FILES['news_image']) && $_FILES['news_image']['name'] != '' && $_FILES["news_image"]["type"] == "image/jpeg") {
                 move_uploaded_file($_FILES["news_image"]["tmp_name"], "images/news/" . $this->news_image . '.jpg');
                 $resize = new ResizeImage("images/news/" . $this->news_image . '.jpg');
                 $resize->resizeTo(400, 300, 'exact');
                 $resize->saveImage("images/news/" . $this->news_image . '_300.jpg');
                 $resize = new ResizeImage("images/news/" . $this->news_image . '.jpg');
                 $resize->resizeTo(130, 100, 'exact');
                 $resize->saveImage("images/news/" . $this->news_image . '_100.jpg');
             }
             $this->news_id = $this->add_news();
         }
     }
 }
 public function updateUser()
 {
     if (isset($_POST['submit'])) {
         //            var_dump($_POST['pass']) ;
         if ($_POST['nip'] == "" || $_POST['nama'] == "") {
             echo 'ada field yang masih belum diisi';
         } else {
             if ($_POST['pass'] !== $_POST['cpass']) {
                 echo 'data tidak bisa disimpan karena password berbeda dengan confirm passwordnya';
             }
             if ($_POST['pass'] == "no_change" || $_POST['cpass'] == "no_change") {
                 if ($_FILES['upload']['name'] == "") {
                     $user = new User($registry);
                     $user->set_id($_POST['id']);
                     $user->set_nip($_POST['nip']);
                     $user->set_nmUser($_POST['nama']);
                     $user->set_akses($_POST['akses']);
                     $user->updateUser_withoutpass($user);
                 } else {
                     $allowedExts = array("jpg", "jpeg", "png");
                     $ext = explode('.', $_FILES['upload']['name']);
                     $extension = $ext[count($ext) - 1];
                     if (in_array($extension, $allowedExts)) {
                         $img_small = new ResizeImage($_FILES["upload"]["tmp_name"]);
                         $img_small->resizeTo(64, $resizeOption = 'maxwidth');
                         $img_small->saveImage("files/foto/" . $_POST['nip'] . "_small." . $extension);
                         move_uploaded_file($_FILES["upload"]["tmp_name"], "files/foto/" . $_POST['nip'] . "." . $extension);
                     } else {
                     }
                     $user = new User($registry);
                     $user->set_id($_POST['id']);
                     $user->set_nip($_POST['nip']);
                     $user->set_nmUser($_POST['nama']);
                     $user->set_akses($_POST['akses']);
                     $user->set_foto($_POST['nip'] . "." . $extension);
                     $user->updateUser_withoutpass($user);
                 }
             }
             if ($_POST['pass'] !== "no_change" && $_POST['pass'] == $_POST['cpass']) {
                 if ($_FILES['upload']['name'] == "") {
                     $user = new User($registry);
                     $user->set_id($_POST['id']);
                     $user->set_nip($_POST['nip']);
                     $user->set_nmUser($_POST['nama']);
                     $user->set_pass($_POST['pass']);
                     $user->set_akses($_POST['akses']);
                     $user->updateUser($user);
                 } else {
                     $allowedExts = array("jpg", "jpeg", "png");
                     $ext = explode('.', $_FILES['upload']['name']);
                     $extension = $ext[count($ext) - 1];
                     if (in_array($extension, $allowedExts)) {
                         $img_small = new ResizeImage($_FILES["upload"]["tmp_name"]);
                         $img_small->resizeTo(64, $resizeOption = 'maxwidth');
                         $img_small->saveImage("files/foto/" . $_POST['nip'] . "_small." . $extension);
                         move_uploaded_file($_FILES["upload"]["tmp_name"], "files/foto/" . $_POST['nip'] . "." . $extension);
                     } else {
                     }
                     $user = new User($registry);
                     $user->set_id($_POST['id']);
                     $user->set_nip($_POST['nip']);
                     $user->set_nmUser($_POST['nama']);
                     $user->set_pass($_POST['pass']);
                     $user->set_akses($_POST['akses']);
                     $user->set_foto($_POST['nip'] . "." . $extension);
                     $user->updateUser($user);
                 }
             }
         }
     }
     header('location:' . URL . 'admin/listUser');
 }
 public function admin_edit($id = null)
 {
     if (!$this->Product->exists($id)) {
         throw new NotFoundException('Invalid product');
     }
     if ($this->request->is('post') || $this->request->is('put')) {
         // pr($this->request->data);die;
         App::import('Vendor', 'ResizeImage', array('file' => 'thumbnail' . DS . 'ThumbLib.inc.php'));
         $this->Img = $this->Components->load('Img');
         $targetdir = WWW_ROOT . 'images/original';
         if (!empty($this->request->data['Product']['image']['name'])) {
             list($width, $height) = getimagesize($this->request->data['Product']['image']['tmp_name']);
             if ($width != '740' && $height != '510') {
                 $this->Session->setFlash('Image  size  should be 740x510 ', 'default', array('class' => 'alert alert-danger'));
                 $this->redirect($this->referer());
             }
             $ext = $this->Img->ext($this->request->data['Product']['image']['name']);
             $origFile = 'meal' . time() . '.' . $ext;
             if (file_exists($targetdir . $this->request->data['Product']['image_name'])) {
                 @unlink($targetdir . $this->request->data['Product']['image_name']);
             }
             if (file_exists(WWW_ROOT . 'images/large/' . $this->request->data['Product']['image_name'])) {
                 @unlink(WWW_ROOT . 'images/large/' . $this->request->data['Product']['image_name']);
             }
             if (file_exists(WWW_ROOT . 'images/small/' . $this->request->data['Product']['image_name'])) {
                 @unlink(WWW_ROOT . 'images/small/' . $this->request->data['Product']['image_name']);
             }
             $upload = $this->Img->upload($this->request->data['Product']['image']['tmp_name'], $targetdir, $origFile);
             if ($upload == 'Success') {
                 //$this->Img->resampleGD($targetdir . DS . $origFile, WWW_ROOT . 'images/large/', $origFile, 368, 328, 1, 0);
                 // $this->Img->resampleGD($targetdir . DS . $origFile, WWW_ROOT . 'images/small/', $origFile, 295, 295, 1, 0);
                 $resize = new ResizeImage($targetdir . DS . $origFile);
                 $resize->resizeTo(304, 209, 'maxWidth');
                 $resize->saveImage(WWW_ROOT . 'images/small/' . $origFile);
                 $resize->resizeTo(368, 328, 'exact');
                 $resize->saveImage(WWW_ROOT . 'images/large/' . $origFile);
                 $this->request->data['Product']['image'] = $origFile;
             }
         } else {
             $this->request->data['Product']['image'] = $this->request->data['Product']['image_name'];
         }
         $this->request->data['Product']['pick_time_from'] = date("H:i", strtotime($this->request->data['Product']['pick_time_from']));
         $this->request->data['Product']['pick_time_to'] = date("H:i", strtotime($this->request->data['Product']['pick_time_to']));
         $this->request->data['Product']['order_time'] = date("H:i", strtotime($this->request->data['Product']['order_time']));
         if (!empty($this->request->data['Product']['avail_multiple_day'])) {
             $this->request->data['Product']['day'] = implode(",", $this->request->data['Product']['day']);
         }
         //pr($this->request->data);die;
         if ($this->Product->save($this->request->data)) {
             $this->Session->setFlash('The Recipe updated successfully.', 'default', array('class' => 'alert alert-success'));
             return $this->redirect(array('controller' => 'products', 'action' => 'index', 'admin' => true));
         } else {
             $this->Session->setFlash('The Product could not be saved. Please, try again.', 'default', array('class' => 'alert alert-danger'));
         }
     } else {
         $product = $this->Product->find('first', array('conditions' => array('Product.id' => $id)));
         //pr($product);
         if (!empty($product['Product']['avail_multiple_day'])) {
             $product['Product']['day'] = explode(',', $product['Product']['day']);
         }
         $this->request->data = $product;
     }
     $this->set(compact('product'));
     $brands = $this->Product->Brand->find('list');
     $this->set(compact('brands'));
     $categories = $this->Product->Category->generateTreeList(null, null, null, '--');
     $this->set(compact('categories'));
     /*$productmods = $this->Product->Productmod->find('all', array(
           'conditions' => array(
               'Productmod.product_id' => $product['Product']['id']
           )
       ));
       $this->set(compact('productmods'));*/
     $users = $this->Product->User->find('list', array('conditions' => array('User.role' => 'cook'), 'fields' => array('id', 'first_name')));
     //pr($users);
     $this->set(compact('users'));
 }
     $j = new Jobs($id);
     $job = $j->getJobFromToken($token);
     $data['is_featured'] = isset($data['is_featured']) ? 1 : 0;
     if ($data['trap'] != '') {
         $app->redirect(ADMIN_URL . "jobs/new");
     }
     if (isset($_FILES['logo']) && $_FILES['logo']['name'] != '') {
         $file = $_FILES['logo'];
         $path = IMAGE_PATH;
         $data['logo'] = time() . '_' . $file['name'];
         $data['logo_type'] = $file['type'];
         $data['logo_size'] = $file['size'];
         $ext = strtolower(pathinfo($data['logo'], PATHINFO_EXTENSION));
         if (move_uploaded_file($file['tmp_name'], "{$path}{$data['logo']}") && isValidImageExt($ext)) {
             $resize = new ResizeImage("{$path}{$data['logo']}");
             $resize->resizeTo(LOGO_H, LOGO_W);
             $resize->saveImage("{$path}thumb_{$data['logo']}");
         }
     } else {
         $data['logo'] = $job->logo;
     }
     $data['step'] = 3;
     $j->jobCreateUpdate($data, ACTIVE);
     $app->redirect(ADMIN_URL . "jobs/{$id}/publish/{$token}");
 });
 // get publish job details
 $app->get('/:id/publish/:token', 'validateUser', function ($id, $token) use($app) {
     $j = new Jobs($id);
     $job = $j->getJobFromToken($token);
     $title = $j->getSlugTitle();
     $city = $j->getJobCity($job->city);
Esempio n. 7
0
    $_SERVER["HTTP_IF_NONE_MATCH"] = isset($_SERVER["HTTP_IF_NONE_MATCH"]) && $_SERVER["HTTP_IF_NONE_MATCH"] != null ? $_SERVER["HTTP_IF_NONE_MATCH"] : 501;
    if ($_SERVER["HTTP_IF_NONE_MATCH"] == $etag) {
        /* "Yes, it's the old version and nothing has been changed" - We send this message to the browser */
        header("HTTP/1.1 304 Not Modified");
    }
    /* Serve the small image if it's the one that is requested */
    if (isset($resizeIMG)) {
        /* make a temporary file and replace it with the original image */
        $temp = tempnam("/tmp", "FOO");
        file_put_contents($temp, $fileData);
        $resize = new ResizeImage($temp);
        /**
         * Make the small image resize to small according to the original ratio
         */
        $ratio = $resize->imgw() / $resize->imgh();
        $newWidth = $ratio * $fileCrop;
        $newHeight = $ratio * $fileCrop;
        if ($newWidth > $resize->imgw() || $newHeight > $resize->imgh()) {
            $fileData = file_get_contents($temp);
        } else {
            /**
             * Resize & Save
             */
            $resize->resizeTo($newWidth, $newHeight, 'exact');
            $resize->saveImage($temp, 80);
            $fileData = file_get_contents($temp);
        }
    }
    /* Output the file data */
    echo $fileData;
}
Esempio n. 8
0
 /**
  * Ресайз и сохранение
  * @param type $saveNameFile -   изображение
  * @param type $width -          новая ширина 
  * @param type $height -         новая высота 
  * @param type $parameterImage - принцип ресайза
  */
 private function resizeImages($saveNameFile, $width, $height, $parameterImage)
 {
     // получаем размеры загруженного файла
     $this->getOriginalSize($saveNameFile);
     // если надо, ресайзим загруженное изображение
     if ($this->originalWidth !== $width || $this->originalHeight !== $height) {
         $resize = new ResizeImage($saveNameFile);
         $resize->resizeTo($width, $height, $parameterImage);
         $resize->saveImage($saveNameFile, 100);
     }
 }
Esempio n. 9
0
 $target_thumb = $globalpath . "images/uploads/finaoimages/thumbs/";
 $target_medium = $globalpath . "images/uploads/finaoimages/medium/";
 $upload_path = "/images/uploads/finaoimages";
 $caption = mysql_real_escape_string($_REQUEST['caption']);
 if ($_FILES['image']['name'] != "") {
     $upload_type = "34";
     $target_path = $target_path . $id . "-" . basename($_FILES['image']['name']);
     $target_thumb = $target_thumb . $id . "-" . basename($_FILES['image']['name']);
     $target_medium = $target_medium . $id . "-" . basename($_FILES['image']['name']);
     @move_uploaded_file($_FILES['image']['tmp_name'], $target_path);
     $uploadfile_name = $id . "-" . basename($_FILES['image']['name']);
     $resize = new ResizeImage($target_path);
     $resize->resizeTo(100, 100, 'default');
     $resize->saveImage($target_thumb);
     $resize_m = new ResizeImage($target_path);
     $resize_m->resizeTo(240, 240, 'default');
     $resize_m->saveImage($target_medium);
 }
 if ($_FILES['video']['name'] != "") {
     $upload_type = "35";
     $target_path = $target_path . $id . "-" . basename($_FILES['video']['name']);
     @move_uploaded_file($_FILES['video']['tmp_name'], $target_path);
     set_time_limit(0);
     include 'phpviddler.php';
     $v = new Viddler_V2('1mn4s66e3c44f11rx1xd');
     $auth = $v->viddler_users_auth(array('user' => 'nageshvenkata', 'password' => 'V1d30Pl@y3r'));
     $session_id = isset($auth['auth']['sessionid']) ? $auth['auth']['sessionid'] : NULL;
     $response = $v->viddler_videos_prepareUpload(array('sessionid' => $session_id));
     $endpoint = isset($response['upload']['endpoint']) ? $response['upload']['endpoint'] : NULL;
     $token = isset($response['upload']['token']) ? $response['upload']['token'] : NULL;
     $query = array('uploadtoken' => $token, 'title' => 'Video from iphone App', 'description' => 'Video from iphone App', 'tags' => 'testing,upload', 'file' => '@../../finaonation/images/uploads/finaoimages/' . $id . "-" . basename($_FILES['video']['name']));
 public function admin_edit($id = null)
 {
     if (!$this->Product->exists($id)) {
         throw new NotFoundException('Invalid product');
     }
     if ($this->request->is('post') || $this->request->is('put')) {
         App::import('Vendor', 'ResizeImage', array('file' => 'thumbnail' . DS . 'ThumbLib.inc.php'));
         $this->Img = $this->Components->load('Img');
         $targetdir = WWW_ROOT . 'images/original';
         if (!empty($this->request->data['Product']['image']['name'])) {
             $ext = $this->Img->ext($this->request->data['Product']['image']['name']);
             $origFile = 'meal' . time() . '.' . $ext;
             if (file_exists($targetdir . $this->request->data['Product']['image_name'])) {
                 @unlink($targetdir . $this->request->data['Product']['image_name']);
             }
             if (file_exists(WWW_ROOT . 'images/large/' . $this->request->data['Product']['image_name'])) {
                 @unlink(WWW_ROOT . 'images/large/' . $this->request->data['Product']['image_name']);
             }
             if (file_exists(WWW_ROOT . 'images/small/' . $this->request->data['Product']['image_name'])) {
                 @unlink(WWW_ROOT . 'images/small/' . $this->request->data['Product']['image_name']);
             }
             $upload = $this->Img->upload($this->request->data['Product']['image']['tmp_name'], $targetdir, $origFile);
             if ($upload == 'Success') {
                 //$this->Img->resampleGD($targetdir . DS . $origFile, WWW_ROOT . 'images/large/', $origFile, 368, 328, 1, 0);
                 // $this->Img->resampleGD($targetdir . DS . $origFile, WWW_ROOT . 'images/small/', $origFile, 295, 295, 1, 0);
                 $resize = new ResizeImage($targetdir . DS . $origFile);
                 $resize->resizeTo(295, 295, 'exact');
                 $resize->saveImage(WWW_ROOT . 'images/small/' . $origFile);
                 $resize->resizeTo(368, 328, 'exact');
                 $resize->saveImage(WWW_ROOT . 'images/large/' . $origFile);
                 $this->request->data['Product']['image'] = $origFile;
             }
         } else {
             $this->request->data['Product']['image'] = $this->request->data['Product']['image_name'];
         }
         if ($this->Product->save($this->request->data)) {
             $this->Session->setFlash($upload);
             return $this->redirect(array('controller' => 'products', 'action' => 'index', 'admin' => true));
         } else {
             $this->Session->setFlash('The Product could not be saved. Please, try again.');
         }
     } else {
         $product = $this->Product->find('first', array('conditions' => array('Product.id' => $id)));
         $this->request->data = $product;
     }
     $this->set(compact('product'));
     $brands = $this->Product->Brand->find('list');
     $this->set(compact('brands'));
     $categories = $this->Product->Category->generateTreeList(null, null, null, '--');
     $this->set(compact('categories'));
     /*$productmods = $this->Product->Productmod->find('all', array(
           'conditions' => array(
               'Productmod.product_id' => $product['Product']['id']
           )
       ));
       $this->set(compact('productmods'));*/
     $users = $this->Product->User->find('list', array('conditions' => array('User.role' => 'cook'), 'fields' => array('id', 'first_name')));
     //pr($users);
     $this->set(compact('users'));
 }
Esempio n. 11
0
            $fileName = $_FILES["photo"]["name"];
            list($fN, $format) = explode(".", $fileName);
            $fID = $MemberID;
            $nFN = $fID . "." . $format;
            //print $nFN ;
            $newName = $memberFile . $nFN;
            if (move_uploaded_file($_FILES["photo"]["tmp_name"], $newName)) {
                //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
                //update tb file path
                if ($picExist != "Y") {
                    $sql2 = "INSERT INTO {$TFilePath}(Modules,ItemID,PathUpload,Added) VALUES('member','{$fID}','{$nFN}','" . date("Y-m-d H:i:s") . "')";
                    $q2 = mysql_db_query($dbname, $sql2) or die($sql2);
                }
                //resize
                $resize = new ResizeImage($newName);
                $resize->resizeTo($cfg["photoProfileWidth"], $cfg["photoProfileHeight"], 'maxWidth');
                $resize->saveImage($newName);
            } else {
                //Upload failed.
                echo "Sorry, there was an error uploading your file.";
            }
        }
    }
    if ($con == "profile") {
        print "<meta http-equiv='refresh' content='1;url=" . $_SERVER["PHP_SELF"] . "'>";
    } else {
        print "<meta http-equiv='refresh' content='1;url=" . $_SERVER["PHP_SELF"] . "?module=viewmember&MemberID={$MemberID}'>";
    }
}
//get list edit
$sql3 = "SELECT * FROM {$TMember} WHERE MemberID ='{$MemberID}'";
Esempio n. 12
0
 /**
  * Run application
  * @return boolean
  */
 public function run()
 {
     // checks the final name if it is in shuffle mode
     if ($this->file_name !== true) {
         // preserve the file extension if there
         if (!pathinfo($this->file_name, PATHINFO_EXTENSION)) {
             $file = $this->file_name . '.' . $this->file_src_name_ext;
         } else {
             $file = $this->file_name;
         }
         $path = $this->upload_to . $file;
     } else {
         $hash = md5(uniqid(rand(), true));
         $file = $hash . '.' . $this->file_src_name_ext;
         $path = $this->upload_to . $file;
     }
     $get_mime = isset($this->mime_check) ? true : false;
     // checks MIME type which are allowed
     if ($get_mime && empty($this->file_src_mime)) {
         $this->was_uploaded = false;
         $this->error = "MIME type can't be detected!";
     } elseif ($get_mime && !empty($this->file_src_mime) && !in_array($this->file_src_mime, $this->MIME_allowed)) {
         $this->was_uploaded = false;
         $this->error = "Incorrect type of file";
     }
     // checks file maximum size
     if ($this->file_src_size > $this->get_file_max_size) {
         $this->error = 'File too big Original Size : ' . $this->file_src_size . ' File size limit : ' . $this->get_file_max_size;
         $this->was_uploaded = false;
         return false;
     }
     // checks if the destination directory exists, and attempt to create it
     if ($this->get_auto_create_path) {
         if (!$this->r_mkdir($this->upload_to)) {
             $this->was_uploaded = false;
             $this->error = "Destination directory can't be created. Can't carry on a process";
             return false;
         }
     } elseif (!is_dir($this->upload_to)) {
         $this->error = "Destination directory doesn't exist. Can't carry on a process";
         return false;
     }
     // checks file already exist or if are to replace it
     if (file_exists($path)) {
         if (!$this->get_auto_replace) {
             $this->was_uploaded = false;
             $this->error = $this->file_src_name . ' already exists. Please change the file name';
         }
         return false;
     }
     // checks more likely errors that can happen
     switch ($this->file_src_errors) {
         case 0:
             // all is OK
             break;
         case 1:
             $this->was_uploaded = false;
             $this->error = "File upload error (the uploaded file exceeds the upload_max_filesize directive in php.ini)";
             break;
         case 2:
             $this->was_uploaded = false;
             $this->error = "File upload error (the uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form)";
             break;
         case 3:
             $this->was_uploaded = false;
             $this->error = "File upload error (the uploaded file was only partially uploaded)";
             break;
         case 4:
             $this->was_uploaded = false;
             $this->error = "File upload error (no file was uploaded)";
             break;
         default:
             $this->was_uploaded = false;
             $this->error = "File upload error (unknown error code)";
     }
     // checks if not occurred an error to upload file
     if ($this->was_uploaded) {
         if (move_uploaded_file($this->file_src_temp, $path)) {
             $this->final_file_name = $file;
             // extracts image dimensions
             list($w, $h) = getimagesize($path);
             $this->file_width = $w;
             $this->file_height = $h;
             // the resize mode is available ?
             if (isset($this->resize)) {
                 $resize = new ResizeImage($path);
                 $resize->resizeTo($this->image_x, $this->image_y, $this->resize_option);
                 $resize->saveImage($path);
             }
             return true;
         } else {
             $this->was_uploaded = false;
             $this->error = 'was not possible to send the file.';
             return false;
         }
     }
 }
Esempio n. 13
0
 public function __construct($id = NULL)
 {
     if (isset($id)) {
         $this->profile_id = $this->check_existance($id);
         if (isset($_POST['leader_name'])) {
             if ($this->leader_picture == '') {
                 $rand = round(rand() * 10000, 4);
                 $this->leader_picture = str_replace(' ', '_', $_POST['leader_name']) . $rand;
             }
             if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']["name"] != '') {
                 move_uploaded_file($_FILES['profile_picture']["tmp_name"], "images/party/profile/" . $this->leader_picture . '.jpg');
                 $document_root = $_SERVER['DOCUMENT_ROOT'];
                 $resize = new ResizeImage("images/party/profile/" . $this->leader_picture . '.jpg');
                 $resize->resizeTo(200, 200, 'exact');
                 $resize->saveImage("images/party/profile/" . $this->leader_picture . '_200.jpg');
                 $resize->resizeTo(100, 100, 'exact');
                 $resize->saveImage("images/party/profile/" . $this->leader_picture . '_100.jpg');
                 $resize->resizeTo(50, 50, 'exact');
                 $resize->saveImage("images/party/profile/" . $this->leader_picture . '_50.jpg');
                 copy("images/party/profile/" . $this->leader_picture . '_200.jpg', $document_root . MAIN_SITE_FOLDER . "/images/party/profile/" . $this->leader_picture . '_200.jpg');
                 copy("images/party/profile/" . $this->leader_picture . '_100.jpg', $document_root . MAIN_SITE_FOLDER . "/images/party/profile/" . $this->leader_picture . '_100.jpg');
                 copy("images/party/profile/" . $this->leader_picture . '_50.jpg', $document_root . MAIN_SITE_FOLDER . "/images/party/profile/" . $this->leader_picture . '_50.jpg');
             }
             $this->update_profile();
         }
         $this->profile_id = $this->check_existance($id);
     } else {
         if (isset($_POST['leader_name'])) {
             if ($this->leader_picture == '') {
                 $rand = round(rand() * 10000, 4);
                 $this->leader_picture = str_replace(' ', '_', $_POST['leader_name']) . $rand;
             }
             if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']["name"] != '') {
                 move_uploaded_file($_FILES['profile_picture']["tmp_name"], "images/party/profile/" . $this->leader_picture . '.jpg');
                 $document_root = $_SERVER['DOCUMENT_ROOT'];
                 $resize = new ResizeImage("images/party/profile/" . $this->leader_picture . '.jpg');
                 $resize->resizeTo(200, 200, 'exact');
                 $resize->saveImage("images/party/profile/" . $this->leader_picture . '_200.jpg');
                 $resize->resizeTo(100, 100, 'exact');
                 $resize->saveImage("images/party/profile/" . $this->leader_picture . '_100.jpg');
                 $resize->resizeTo(50, 50, 'exact');
                 $resize->saveImage("images/party/profile/" . $this->leader_picture . '_50.jpg');
                 copy("images/party/profile/" . $this->leader_picture . '_200.jpg', $document_root . MAIN_SITE_FOLDER . "/images/party/profile/" . $this->leader_picture . '_200.jpg');
                 copy("images/party/profile/" . $this->leader_picture . '_100.jpg', $document_root . MAIN_SITE_FOLDER . "/images/party/profile/" . $this->leader_picture . '_100.jpg');
                 copy("images/party/profile/" . $this->leader_picture . '_50.jpg', $document_root . MAIN_SITE_FOLDER . "/images/party/profile/" . $this->leader_picture . '_50.jpg');
             }
             $this->profile_id = $this->add_profile();
         }
     }
 }
Esempio n. 14
0
function resize_image($path, $save_path, $width, $height)
{
    $image = new ResizeImage($path);
    $image->resizeTo($width, $height, 'exact');
    $image->saveImage($save_path);
}
Esempio n. 15
0
function uploaddata($type, $sourcetype, $finaoid, $userid, $uploadtext, $data, $captiondata)
{
    $target_path = $globalpath . "images/uploads/finaoimages/";
    $target_thumb = $globalpath . "images/uploads/finaoimages/thumb/";
    $target_medium = $globalpath . "images/uploads/finaoimages/medium/";
    $upload_path = "/images/uploads/finaoimages";
    $query = "insert into fn_uploaddetails (`uploadtype`,`upload_text`,`upload_sourcetype`, `upload_sourceid`, `uploadedby`, `uploadeddate`, `status`) values ('{$type}','{$uploadtext}','{$sourcetype}','{$finaoid}','{$userid}',now(),1)";
    mysql_query($query);
    $uploadid = mysql_insert_id();
    if (!empty($data)) {
        if ($data['image1']['name'] != '') {
            $sno = 0;
            foreach ($data as $key => $val) {
                $name = $val['name'];
                $uploadfile_name = $finaoid . "-" . $name;
                $tmpname = $val['tmp_name'];
                $target_main = $target_path . $uploadfile_name;
                $target_thumb = $target_thumb . $uploadfile_name;
                $target_medium = $target_medium . $uploadfile_name;
                @move_uploaded_file($tmpname, $target_main);
                $resize = new ResizeImage($target_main);
                $resize->resizeTo(100, 100, 'default');
                $resize->saveImage($target_thumb);
                $resize_m = new ResizeImage($target_main);
                $resize_m->resizeTo(240, 240, 'default');
                $resize_m->saveImage($target_medium);
                $query = "insert into fn_images (`upload_id`,`uploadfile_name`,`uploadfile_path`, `caption`, `uploadedby`, `uploadeddate`, `status`) values ('{$uploadid}','{$uploadfile_name}','{$upload_path}','{$captiondata[$sno]}','{$userid}',now(),1)";
                mysql_query($query);
                $sno++;
            }
        } else {
            $target_path = $target_path . $finaoid . "-" . basename($data['video']['name']);
            @move_uploaded_file($data['video']['tmp_name'], $target_path);
            set_time_limit(0);
            include 'phpviddler.php';
            $v = new Viddler_V2('145i86zgnzi1h1xln0ly');
            $auth = $v->viddler_users_auth(array('user' => ' finaonation', 'password' => 'Finao123'));
            $session_id = isset($auth['auth']['sessionid']) ? $auth['auth']['sessionid'] : NULL;
            $response = $v->viddler_videos_prepareUpload(array('sessionid' => $session_id));
            $endpoint = isset($response['upload']['endpoint']) ? $response['upload']['endpoint'] : NULL;
            $token = isset($response['upload']['token']) ? $response['upload']['token'] : NULL;
            $query = array('uploadtoken' => $token, 'title' => 'Video from iphone App', 'description' => 'Video from iphone App', 'tags' => 'testing,upload', 'file' => '@../../preprod/images/uploads/finaoimages/' . $finaoid . "-" . basename($data['video']['name']));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $endpoint);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
            curl_setopt($ch, CURLOPT_HEADER, TRUE);
            curl_setopt($ch, CURLOPT_NOBODY, FALSE);
            curl_setopt($ch, CURLOPT_TIMEOUT, 0);
            curl_setopt($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
            $response = curl_exec($ch);
            $info = curl_getinfo($ch);
            $header_size = $info['header_size'];
            $header = substr($response, 0, $header_size);
            $video = unserialize(substr($response, $header_size));
            curl_close($ch);
            @unlink('../../preprod/images/uploads/finaoimages/' . $finaoid . "-" . basename($data['video']['name']));
            $videoid = $video['video']['id'];
            $results = $v->viddler_videos_getDetails(array('sessionid' => $session_id, 'video_id' => $videoid));
            $videostatus = $results['video']['status'];
            $video_img = $results['video']['thumbnail_url'];
            $query = "insert into fn_videos (`upload_id`,`videoid`,`videostatus`, `video_img`, `caption`, `uploadedby`, `uploadeddate`, `status`) values ('{$uploadid}','{$videoid}','{$videostatus}','{$video_img}','{$captiondata['0']}','{$userid}',now(),1)";
            mysql_query($query);
        }
    }
    // updating the current date time in fn_user_finao
    $sqlUpdate = "update fn_user_finao set updateddate=NOW(),updatedby=" . $userid . " where user_finao_id=" . $finaoid;
    mysql_query($sqlUpdate);
    // end of fn_user_finao update
}