Exemplo n.º 1
0
 public function updateImage()
 {
     require_once 'helpers/upload.php';
     $code = '';
     if (isset($_POST['id']) && isset($_POST['path'])) {
         $id = intval($_POST['id']);
         $handle = new upload($_FILES['image_field']);
         if ($handle->uploaded) {
             $handle->file_new_name_body = $id;
             $handle->image_resize = true;
             $handle->image_x = 100;
             $handle->image_ratio_y = true;
             $handle->file_overwrite = true;
             $handle->process($_SERVER['DOCUMENT_ROOT'] . '/EduDB/imageUploads/');
             if ($handle->processed) {
                 $handle->clean();
             } else {
                 $_SESSION['ERROR'] = $handle->error;
                 // Failure
             }
         }
         Identity::updateImage($id, '/EduDB/imageUploads/' . $handle->file_dst_name);
     }
     header("Location: " . $_POST['path']);
 }
Exemplo n.º 2
0
 public function saveAction()
 {
     $cid = intval($_POST['wid']);
     $name = $_POST['name_cn'];
     $name_en = $_POST['name_en'];
     $type = $_POST['type'];
     $price = $_POST['price'];
     $desc = $_POST['desc'];
     $year = $_POST['years'];
     $active = isset($_POST['active']) && $_POST['active'] == 'on' ? 1 : 0;
     if ($cid) {
         $sql = "Update \n\t\t\t\t\t\t\t`product` \n\t\t\t\t\t\tset \n\t\t\t\t\t\t\t`name_cn`='" . ms($name) . "',\n\t\t\t\t\t\t\t`name_en`='" . ms($name_en) . "',\n\t\t\t\t\t\t\t`price`='" . intval($price) . "',\n\t\t\t\t\t\t\t`years`=" . intval($year) . ",\n\t\t\t\t\t\t\t`desc`='" . ms($desc) . "',\n\t\t\t\t\t\t\t`type`=" . intval($type) . ",\n\t\t\t\t\t\t\t`active`=" . intval($active) . ",\n\t\t\t\t\t\t\t`modify_time`=" . time() . " \n\t\t\t\t\t\twhere \n\t\t\t\t\t\t\t`id`=" . ms($cid);
     } else {
         $sql = "Insert into\n\t\t\t\t\t\t\t `product` (\n\t\t\t\t\t\t\t \t\t`name_cn`,\n\t\t\t\t\t\t\t \t\t`name_en`,\n\t\t\t\t\t\t\t \t\t`price`,\n\t\t\t\t\t\t\t \t\t`years`,\n\t\t\t\t\t\t\t \t\t`desc`,\n\t\t\t\t\t\t\t \t\t`type`,\n\t\t\t\t\t\t\t \t\t`active`,\n\t\t\t\t\t\t\t \t\t`modify_time`) \n\t\t\t\t\t\tValues(\n\t\t\t\t\t\t\t'" . ms($name) . "',\n\t\t\t\t\t\t\t'" . ms($name_en) . "',\n\t\t\t\t\t\t\t'" . ms($price) . "',\n\t\t\t\t\t\t\t'" . ms($year) . "',\n\t\t\t\t\t\t\t'" . ms($desc) . "',\n\t\t\t\t\t\t\t'" . ms($type) . "',\n\t\t\t\t\t\t\t'" . ms($active) . "',\n\t\t\t\t\t\t\t" . time() . "\n\t\t\t\t\t\t)";
     }
     if (DB::query($sql) && !$cid) {
         $b_id = DB::lastInsertID();
     } else {
         if (DB::query($sql) && $cid) {
             $b_id = $cid;
         }
     }
     if (!empty($_FILES)) {
         $order = 1;
         foreach ($_FILES as $i => $v) {
             if (!$v['error']) {
                 $handle1 = new upload($v);
                 if ($handle1->uploaded) {
                     $handle1->file_name_body_pre = '16du_';
                     $handle1->file_new_name_body = $b_id . '_' . $order;
                     //$handle1->file_new_name_ext  = 'png';
                     $handle1->file_overwrite = true;
                     $handle1->file_max_size = '40480000';
                     // $handle1->image_convert = 'png';
                     //$handle1->png_compression = 5;
                     $handle1->process(PRODUCT_SRC . $b_id . '/');
                     if ($handle1->processed) {
                         $sql = "Update `product` set `src" . $order . "` = '" . $handle1->file_dst_name . "' where `id`=" . $b_id;
                         DB::query($sql);
                         $handle1->clean();
                     } else {
                         //echo 'error : ' . $handle1->error;
                     }
                     $order++;
                 }
             }
         }
     }
     $res = new ResultObj(true, '', '保存成功');
     echo $res->toJson();
     exit;
 }
Exemplo n.º 3
0
 public function saveFile($file)
 {
     $rep_dest = "../var/uploads/";
     $upload = new upload($file);
     $upload->file_overwrite = true;
     //supprime le fichier si existe
     if ($upload->uploaded) {
         //file
         $upload->file_new_name_body = uniqid();
         $upload->Process($rep_dest);
         $upload->clean();
         return $rep_dest . $upload->file_dst_name;
     }
     return null;
 }
 public function editarAction()
 {
     $this->view->setFile('editar');
     $user_id = $this->auth->getUserId();
     $this->request->setCustomFilters(array('email' => FILTER_VALIDATE_EMAIL));
     $post = $this->request->post();
     if (!empty($post)) {
         $atualizarUsuario = User::atualizar($user_id, $post);
         if ($atualizarUsuario->status === false) {
             $this->load('Helpers\\Alert', array('danger', 'Ops! Não foi possível atualizar seu perfil. <br> Verifique os erros abaixo:', $atualizarUsuario->errors));
         } else {
             if (isset($_FILES['image']) && !empty($_FILES['image']['tmp_name'])) {
                 $uploadUserImage = new upload($_FILES['image']);
                 if ($uploadUserImage->uploaded) {
                     $image_name = md5(uniqid());
                     $uploadUserImage->file_new_name_body = $image_name;
                     $uploadUserImage->file_new_name_ext = 'png';
                     $uploadUserImage->resize = true;
                     $uploadUserImage->image_x = 500;
                     $uploadUserImage->image_ratio_y = true;
                     $dir_path = ROOT_PATH . DS . 'public' . DS . 'uploads' . DS . 'users' . DS . $atualizarUsuario->user->id . DS;
                     $uploadUserImage->process($dir_path);
                     if ($uploadUserImage->processed) {
                         $uploadUserImage->clean();
                         $this->load('Helpers\\Alert', array('success', 'Uhuul! Perfil atualizado com sucesso!'));
                         if (!is_null($atualizarUsuario->user->image)) {
                             unlink($dir_path . $atualizarUsuario->user->image);
                         }
                         $atualizarUsuario->user->image = $image_name . '.png';
                         $atualizarUsuario->user->save(false);
                     } else {
                         $this->load('Helpers\\Alert', array('error', 'Oops! Não foi possível atualizar a sua imagem de perfil', $uploadUserImage->error));
                     }
                 }
             } else {
                 $this->load('Helpers\\Alert', array('success', 'Uhuul! Perfil atualizado com sucesso!'));
             }
             $this->view->setVar('user', $atualizarUsuario->user);
         }
     }
 }
Exemplo n.º 5
0
 public function newContact()
 {
     $identity = array('fName' => $_POST['firstName'], 'mName' => $_POST['middleName'], 'lName' => $_POST['lastName'], 'gender' => $_POST['gender'], 'email' => $_POST['email'], 'type' => 2);
     $contactIdentityId = Identity::newIdentity($identity);
     if (!$contactIdentityId) {
         $_SESSION['Error'] = "Unable to create a Contact Identity!";
         header("Location: " . $_POST['path']);
         // TODO: This should go to an error page.
         return false;
     }
     require_once 'helpers/upload.php';
     $code = '';
     if ($contactIdentityId) {
         $id = intval($contactIdentityId);
         $handle = new upload($_FILES['image_field']);
         if ($handle->uploaded) {
             $handle->file_new_name_body = $id;
             $handle->image_resize = true;
             $handle->image_x = 100;
             $handle->image_ratio_y = true;
             $handle->file_overwrite = true;
             $handle->process($_SERVER['DOCUMENT_ROOT'] . '/EduDB/imageUploads/');
             if ($handle->processed) {
                 $handle->clean();
             } else {
                 $_SESSION['ERROR'] = $handle->error;
                 // Failure
             }
         }
         Identity::updateImage($id, '/EduDB/imageUploads/' . $handle->file_dst_name);
     }
     // If we get here then we have made an identity but have not linked it
     // to the target contact yet. We will need to set the relationship.
     if (!session_id()) {
         session_start();
     }
     $_SESSION['contact']['studentId'] = $_POST['studentId'];
     $_SESSION['contact']['studentIdentityId'] = $_POST['identityId'];
     $_SESSION['contact']['contactIdentityId'] = $contactIdentityId;
     header("Location: ?controller=contact&action=setRelationship");
 }
Exemplo n.º 6
0
 public function elem($post, $get, $FILES)
 {
     require_once sys . '/plugin/class.upload/class.upload.php';
     $post = array_merge(array('chpu' => '', 'marker' => '', 'active_path' => ''), $post);
     $file = isset($FILES['form']) ? $FILES['form'] : array();
     $form = isset($post['form']) ? $post['form'] : array();
     $activePath = isset($post['active_path']) && $post['active_path'] != '' ? 1 : 0;
     $updateId = isset($post['id']) && $post['id'] != '' ? (int) $post['id'] : false;
     if ($updateId !== false) {
         Fx::db()->update(Fx::service_context()->namespace['construct_db'], array('chpu' => $post['chpu'], 'active_path' => $activePath, 'marker' => $post['marker'], 'date' => time()), array('id' => $updateId));
         $ref = Fx::db()->find(Fx::service_context()->namespace['construct_db'], array('ref' => $updateId));
         foreach ($ref as $v) {
             Fx::db()->update(Fx::service_context()->namespace['construct_db'], array('chpu' => $post['chpu'], 'active_path' => $post['active_path'], 'marker' => $post['marker'], 'date' => time()), array('id' => $v['id']));
         }
         $lastId = $updateId;
     } else {
         $num = count(Fx::db()->find(Fx::service_context()->namespace['construct_db'], array('parent' => (int) $post['parent'])));
         Fx::db()->insert(Fx::service_context()->namespace['construct_db'], array('parent' => (int) $post['parent'], 'ref' => '', 'object' => $post['object'], 'chpu' => $post['chpu'], 'num' => $num, 'active_path' => $activePath, 'marker' => $post['marker'], 'date' => time()));
         $form['id'] = $lastId = Fx::db()->lastID();
     }
     $table = Fx::db()->find(Fx::service_context()->namespace['struct_db'], array('code' => $post['object']));
     $table = $table[0];
     $row = Fx::db()->find(Fx::service_context()->namespace['struct_td'], array('parent' => $table['id']));
     $rows = array();
     foreach ($row as $v) {
         $rows[$v['code']] = array('id' => $v['id'], 'size' => $v['size'], 'type' => $v['type'], 'param' => json_decode($v['param'], true));
     }
     foreach ($form as $k => $v) {
         if (is_string($v)) {
             $form[$k] = Fx::db()->esc($v);
         }
     }
     foreach ($rows as $k => $v) {
         if (!isset($form[$k])) {
             $form[$k] = '';
         }
     }
     $path = root . '/' . Fx::service_context()->config['folder']['files'] . '/' . $lastId . '/';
     if (isset($file['tmp_name'])) {
         foreach ($file['tmp_name'] as $k => $v) {
             $savePath = '/' . Fx::service_context()->config['folder']['files'] . '/' . $lastId . '/';
             $fileName = isset($form[$k]['name']) && $form[$k]['name'] != '' ? trim($form[$k]['name']) : $k;
             $gist = $rows[$k];
             $fn = isset($form[$k]['url']) && $form[$k]['url'] != '' ? $form[$k]['url'] : $v['file'];
             $mime = Fx::io()->mime($file['name'][$k]['file'] != '' ? $file['name'][$k]['file'] : $form[$k]['url']);
             if (isset($form[$k]['url']) && $form[$k]['url'] !== '') {
                 Fx::io()->create_file(root . '/' . 'temporary.tmp');
                 Fx::io()->in_file(root . '/' . 'temporary.tmp', file_get_contents($fn));
                 $fn = root . '/' . 'temporary.tmp';
             }
             if ($fn != '') {
                 if (empty($fn)) {
                     continue;
                 }
                 $IMG = new upload($fn);
                 if ($IMG->uploaded) {
                     $IMG->file_new_name_body = $fileName;
                     $IMG->file_new_name_ext = $mime;
                     $gistParam = $gist['param'];
                     $width = isset($gistParam['width']) && $gistParam['width'] != '' ? $gistParam['width'] : 1000;
                     $height = isset($gistParam['height']) && $gistParam['height'] != '' ? $gistParam['height'] : 1000;
                     // Param
                     if (isset($gist['param']['method'])) {
                         switch ($gist['param']['method']) {
                             case 'scale':
                                 // Подгоняем по размеру и пропорциям, без полей
                                 $IMG->image_resize = true;
                                 $IMG->image_ratio = true;
                                 $IMG->image_y = $height;
                                 $IMG->image_x = $width;
                                 break;
                             case 'crop':
                                 // Точно по размеру игнорируя пропорции
                                 $IMG->image_resize = true;
                                 $IMG->image_ratio_crop = true;
                                 $IMG->image_y = $height;
                                 $IMG->image_x = $width;
                                 break;
                             case 'width':
                                 // ресайзим по ширине
                                 $IMG->image_resize = true;
                                 $IMG->image_ratio_x = true;
                                 $IMG->image_y = $height;
                                 break;
                             case 'height':
                                 // ресайзим по высоте
                                 $IMG->image_resize = true;
                                 $IMG->image_ratio_y = true;
                                 $IMG->image_x = $width;
                                 break;
                         }
                     }
                     if (is_file($path . $fileName . '.' . $mime)) {
                         unlink($path . $fileName . '.' . $mime);
                     }
                     $IMG->Process($path);
                     if (!$IMG->processed) {
                         setSystemMessage('error', $IMG->error);
                     }
                     $IMG->clean();
                     if (isset($gist['param']['zip']) && $gist['param']['zip'] == 1) {
                         $zip = new ZipArchive();
                         if ($zip->open($path . $fileName . '.zip', ZIPARCHIVE::CREATE) === TRUE) {
                             $zip->addFile($path . $fileName . '.' . $mime, $fileName . '.' . $mime);
                         }
                         $zip->close();
                         if (file_exists($path . $fileName . '.' . $mime)) {
                             unlink($path . $fileName . '.' . $mime);
                         }
                         $savePath = $savePath . $fileName . '.zip';
                     } else {
                         $savePath = $savePath . $fileName . '.' . $mime;
                     }
                 } else {
                     setSystemMessage('error', $IMG->error);
                 }
                 $form[$k] = file_exists(root . $savePath) ? $savePath : '';
             }
             if (is_array($form[$k])) {
                 if (isset($form[$k]['remove']) && $form[$k]['remove'] == 1) {
                     if (file_exists(root . $form[$k]['src'])) {
                         unlink(root . $form[$k]['src']);
                     }
                     $form[$k] = '';
                 } else {
                     if (isset($form[$k]['src']) && isset($form[$k]['name'])) {
                         $imagePath = explode('/', $form[$k]['src']);
                         $imageName = array_pop($imagePath);
                         $imageName = explode('.', $imageName);
                         $imageMime = array_pop($imageName);
                         $imageName = implode('.', $imageName);
                         if ($imageName !== $form[$k]['name']) {
                             $newImageName = implode('/', $imagePath) . '/' . $form[$k]['name'] . '.' . $imageMime;
                             if (is_file(root . $newImageName)) {
                                 unlink(root . $newImageName);
                             }
                             rename(root . $form[$k]['src'], root . $newImageName);
                             $form[$k] = $newImageName;
                         } else {
                             $form[$k] = $form[$k]['src'];
                         }
                     } else {
                         $form[$k] = '';
                     }
                 }
             }
         }
     }
     foreach ($form as $k => $v) {
         if (is_array($v)) {
             $form[$k] = serialize($v);
         }
     }
     if ($updateId !== false) {
         Fx::db()->update($post['object'], $form, array('id' => $updateId));
     } else {
         Fx::db()->insert($post['object'], $form);
     }
     load_url();
 }
Exemplo n.º 7
0
 function install()
 {
     $rep = $this->getResponse('json');
     $this->msg = "installation échouée";
     if (isset($_FILES["archive"])) {
         $rep_dest = "var/uploads/";
         $upload = new upload($_FILES["archive"]);
         $upload->file_overwrite = true;
         //supprime le file si existe
         $upload->allowed = array('application/zip');
         if ($upload->uploaded) {
             // It could be something like $upload->Process('www/my_uploads/');
             $upload->Process($rep_dest);
             //extraction de larchive
             $zip = new ZipArchive();
             $zip->open($upload->file_dst_pathname);
             //
             if (!$zip->getFromName('module.xml')) {
                 //if module file doesnt exists
                 $this->msg = "installation échouée: fichier d'installation absent";
             } else {
                 $moduleXml = simplexml_load_string($zip->getFromName('module.xml'));
                 //verifiying the compatibility with jelix core version
                 if ($this->compatibility($moduleXml->dependencies->jelix)) {
                     $zip->extractTo('modules/' . $moduleXml->info['name'] . '/');
                     //we extract to module directory
                     $this->setConfig($moduleXml->info['name']);
                     //set module config
                     $this->installScript($moduleXml->info['name']);
                     //$this->showOnMenu($moduleXml->info['name']);
                     $this->msg = "module installé";
                     $this->success = true;
                 } else {
                     $this->success = false;
                     $this->msg = "module non installé : versions non compatibles";
                 }
             }
             $zip->close();
             //close archive
             $upload->clean();
             //clean server temp
             unlink($upload->file_dst_pathname);
             //clean second app temp
         }
     }
     $rep->data = array('success' => $this->success, 'msg' => $this->msg);
     return $rep;
 }
 function upload_excel_file()
 {
     $excel_file = $_FILES['excel_file'];
     $this->directory = PATH . "Excel_File/";
     if ($excel_file['name'] != "") {
         if ($excel_file["type"] == "application/vnd.ms-excel") {
             $excel_file_upload = new upload($excel_file);
             $excel_file_upload->file_overwrite = true;
             $excel_file_upload->file_new_name_body = "student_current_enroll";
             $excel_file_upload->process($this->directory);
             //if ($image_upload->processed) {
             //$this->registered();
             $this->template->setAlert("File was Successfully Uploaded!..", Template::ALERT_SUCCESS);
             $excel_file_upload->clean();
             $filename = "../Excel_File/student_current_enroll.xls";
             if (file_exists($filename)) {
                 $this->template->assign('excel_file', 'true');
             }
             /* inserting into database table */
             $excel_data = new Spreadsheet_Excel_Reader('../Excel_File/student_current_enroll.xls');
             for ($y = 2; $y <= $excel_data->rowCount(); $y++) {
                 $student_id = $excel_data->val($y, A);
                 $lastname = $excel_data->val($y, B);
                 $firstname = $excel_data->val($y, C);
                 $middle_initial = $excel_data->val($y, D);
                 if ($this->registered_student_model->isValid($student_id, $lastname, $firstname) && $this->administrator_model->isValid($student_id, $lastname, $firstname)) {
                     $this->registered_student_model->insert($student_id, $lastname, $firstname, $middle_initial);
                 }
             }
             /* ------------------------------- */
         } else {
             $this->template->setAlert("You can Upload a XLS file only!..", Template::ALERT_ERROR);
         }
     }
 }
Exemplo n.º 9
0
 public function process($parameters)
 {
     $articleManager = new ArticleManager();
     $userManager = new UserManager();
     $validation = new Validation();
     $this->checkUser();
     $loggedUser = $userManager->returnUser();
     //editor je pristupny iba pre admina a redaktorov
     if ($loggedUser['admin'] == 1 || $loggedUser['admin'] == 2) {
         $article = array('article_id' => '', 'title' => '', 'thumbnail_img' => '', 'content' => '', 'url' => '', 'category' => '', 'description' => '', 'key_words' => '', 'author' => '');
         //ak je odoslany formular
         if ($_POST) {
             //ziskanie clanku z $_POST
             $keys = array('article_id', 'title', 'thumbnail_img', 'content', 'url', 'category', 'description', 'key_words', 'author', 'public');
             $article = array_intersect_key($_POST, array_flip($keys));
             //upload a spracovanie suboru
             $imageUpload = new upload($_FILES['image_field'], 'sk_SK');
             //nastavenie ID noveho clanku
             if (empty($article['article_id'])) {
                 $article['article_id'] = $articleManager->returnLastArticleId() + 1;
             }
             $targetDirectory = 'img/articles/' . $article['article_id'] . '/';
             $filePath = $targetDirectory . 'thumbnail.png';
             try {
                 //vytvori novy adresar podla ID noveho clanku
                 if (!file_exists($targetDirectory)) {
                     mkdir($targetDirectory, '0777', true);
                 }
                 //ak bol obrazok nahraty
                 if ($imageUpload->uploaded) {
                     $imageUpload->allowed = array('image/*');
                     //povolene formaty
                     $imageUpload->mime_check = true;
                     //kontrola formatu zapnuta
                     $imageUpload->file_new_name_body = 'thumbnail';
                     //novy nazov suboru
                     $imageUpload->image_resize = true;
                     //zmensenie
                     $imageUpload->image_convert = 'png';
                     //konvertovanie na png
                     $imageUpload->image_x = 120;
                     //vysledna sirka 120px
                     $imageUpload->image_ratio_y = true;
                     //vyska: auto
                     //zmazanie existujuceho nahladoveho obrazka
                     if (file_exists($filePath)) {
                         unlink($filePath);
                     }
                     $imageUpload->process($targetDirectory);
                     //uloz vysledny obrazok
                     //ak bol obrazok ulozeny
                     if ($imageUpload->processed) {
                         //uloz cestu k obrazku do '$article'
                         $article['thumbnail_img'] = $filePath;
                         $imageUpload->clean();
                     } else {
                         throw new UserError($imageUpload->error);
                     }
                 }
             } catch (UserError $error) {
                 $this->createMessage($error->getMessage(), 'warning');
             }
             //ulozenie clanku do databazy
             try {
                 //vytvorenie URL adresy z pola title
                 $article['url'] = $validation->checkUrl($article['title']);
                 //ulozenie clanku do databazy
                 $articleManager->saveArticle($_POST['article_id'], $article);
                 $this->createMessage('Článok bol úspešne uložený', 'success');
                 //presmeruj na clanok
                 $this->redirect('clanky/' . $article['url']);
             } catch (UserError $error) {
                 $this->createMessage($error->getMessage(), 'warning');
                 $this->redirect('editor');
             }
         }
         //ak je zadana URL adresa clanku na jeho editaciu
         if (!empty($parameters[0])) {
             $loadedArticle = $articleManager->returnArticle($parameters[0]);
             if ($loadedArticle) {
                 $article = $loadedArticle;
             } else {
                 $this->createMessage('Článok sa nenašiel', 'warning');
                 $this->redirect('chyba');
             }
             $this->data['article'] = $article;
             //hlavicka stranky
             $this->head = array('title' => 'Editor - ' . $article['title'], 'key_words' => 'coding.wz.sk - editor', 'description' => 'Editor článkov');
             $this->view = 'editor';
         } else {
             $article['author'] = $userManager->returnUser()['name'];
             $this->data['article'] = $article;
             //hlavicka stranky
             $this->head = array('title' => 'Editor - Nový článok', 'key_words' => 'coding.wz.sk - editor', 'description' => 'Editor článkov');
             $this->view = 'editor';
         }
     }
 }
Exemplo n.º 10
0
        $klasor = "formlar/a5";
        /* CLASS.UPLOAD.PHP ��ER�S�NDEK� Y�KLEME FONKS�YONLARIMIZI KULLANMAYA BA�LIYORUZ. */
        /* SINIFIMIZI BA�LATIYORUZ */
        $yukle = new upload(@$resim);
        /* E�ER Y�KLEME ��LEM�M�Z GER�EKLE�T� �SE */
        if ($yukle->uploaded) {
            $yukle->process($klasor);
            /* RESM�M�Z�N TA�INACA�I KLAS�R */
            /* OPS�YONEL SE�ENEKLER VEROT.NET DEN DAHA FAZLA �ZELL��E ULA�AB�L�RS�N�Z. */
            $yukle->image_resize = true;
            /* RES�M BOYUTLANDIRMAYI AKT�FLE�T�R�YORUZ */
            $yukle->image_x = 250;
            /* GEN��L�K DE�ER� */
            $yukle->image_y = 200;
            /* Y�KSEKL�K DE�ER� */
            /* OPS�YONEL ��LEMLER BA�ARILI OLDU �SE */
            if ($yukle->processed) {
                /* Y�KLENEN DOSYA �SM�N� ALIP $yuklenen_resim DE���KEN�NE ATIYORUZ */
                $yuklenen_resim = $yukle->file_dst_name;
                /* Y�KLENEN RESM�M�Z� EKRANA BASIYORUZ (BU KISIMDA VER�TABANINA DA YAZDIRAB�L�RS�N�Z AMACINIZA UYGUN KULLANAB�L�RS�N�Z.)*/
                //print '<img src="resimler/'.$yuklenen_resim.'" />';
                /* EN SON $yukle DE���KEN�M�Z� TEM�ZL�YORUZ */
                $yukle->clean();
            }
            /* 3. �F B�T�� */
        }
        /* 2.�F B�T�� */
    }
    /* FOR B�T�� */
}
/* 1.�F B�T�� */
Exemplo n.º 11
0
    // Count how many photos have already been uploaded for this ticket
    $i = 0;
    if ($handle = opendir($directory)) {
        while (($file = readdir($handle)) !== false) {
            if (!in_array($file, array('.', '..')) && !is_dir($directory . $file)) {
                $i++;
            }
        }
    }
    // Create new file name from directory count
    $filename = $i + 1;
    // Create new upload object with posted photo
    $photo = new upload($_FILES['photo']);
    // Configure photo processing options
    if ($photo->uploaded) {
        $photo->file_new_name_body = rand(0, 9999);
        $photo->image_convert = 'jpg';
        $photo->jpeg_quality = 70;
        $photo->png_compression = 7;
        $photo->image_resize = true;
        $photo->image_x = 1000;
        $photo->image_ratio_y = true;
        $photo->process($directory);
        if ($photo->processed) {
            // success!
            $photo->clean();
        } else {
            // echo 'error : ' . $photo->error;
        }
    }
}
Exemplo n.º 12
0
function UlozObrazek($cesta, $nazev, $typmenu)
{
    $tmp_name = $_FILES["userfile"]["tmp_name"];
    if ($tmp_name) {
        $handle = new upload($_FILES['userfile']);
        $x = $handle->image_src_x;
        $y = $handle->image_src_y;
        $mratiox = 0;
        // Only proceed if the file has been uploaded
        if ($handle->uploaded) {
            // Set the new filename of the uploaded image
            $handle->file_new_name_body = "nahled-" . $nazev;
            // Make sure the image is resized
            switch ($typmenu) {
                case "V":
                    $maxx = X_VISUAL_NAHLED;
                    $maxy = Y_VISUAL_NAHLED;
                    break;
                case "P":
                    $maxx = X_PUDORYS_NAHLED;
                    $maxy = Y_PUDORYS_NAHLED;
                    break;
                case "M":
                    $maxx = X_DUM_NAHLED;
                    $maxy = Y_DUM_NAHLED;
                    break;
                default:
                    $maxx = X_DUM_NAHLED;
                    $maxy = Y_DUM_NAHLED;
            }
            if ($x != $maxx || $y != $maxy) {
                // Set the width of the image
                if ($mratiox) {
                    $handle->image_resize = true;
                    $handle->image_x = $maxx;
                    $handle->image_ratio_y = true;
                    echo "OBRAZEK ZMENEN NA {$maxx},{$maxy} : a ratiox:" . $mratiox;
                } else {
                    $handle->image_resize = true;
                    $handle->image_x = $maxx;
                    $handle->image_y = $maxy;
                }
                $handle->jpeg_quality = 100;
                $handle->process($cesta);
            } else {
                $handle->image_resize = false;
                $handle->process($cesta);
            }
            switch ($typmenu) {
                case "V":
                    $ratiox = X_VISUAL_VELKE;
                    break;
                case "P":
                    $ratiox = X_PUDORYS_VELKE;
                    break;
                case "M":
                    $ratiox = 0;
                default:
                    $ratiox = 0;
            }
            if ($ratiox) {
                if ($x > $ratiox) {
                    $handle->image_resize = true;
                    $handle->image_ratio_y = true;
                    $handle->image_x = $ratiox;
                } else {
                    $handle->image_resize = false;
                    $handle->image_x = $x;
                    $handle->image_y = $y;
                }
                $handle->file_new_name_body = "obr-" . $nazev;
                $handle->process($cesta);
            }
            if ($handle->processed) {
                $nazevobr = $handle->file_dst_name;
                $handle->clean();
            } else {
                echo 'error : ' . $handle->error;
                return 0;
            }
            return $nazevobr;
        }
    }
}
Exemplo n.º 13
0
    if ($upload_image->uploaded) {
        // ย่อขนาดภาพให้เล็กลงหน่อย  โดยยึดขนาดภาพตามความกว้าง  ความสูงให้คำณวนอัตโนมัติ
        // ถ้าหากไม่ต้องการย่อขนาดภาพ ก็ลบ 3 บรรทัดด้านล่างทิ้งไปได้เลย
        $upload_image->image_resize = true;
        // อนุญาติให้ย่อภาพได้
        $upload_image->image_x = 1024;
        // กำหนดความกว้างภาพเท่ากับ 400 pixel
        $upload_image->image_ratio_y = true;
        // ให้คำณวนความสูงอัตโนมัติ
        $upload_image->process("upload_images");
        // เก็บภาพไว้ในโฟลเดอร์ที่ต้องการ  *** โฟลเดอร์ต้องมี permission 0777
        // ถ้าหากว่าการจัดเก็บรูปภาพไม่มีปัญหา  เก็บชื่อภาพไว้ในตัวแปร เพื่อเอาไปเก็บในฐานข้อมูลต่อไป
        if ($upload_image->processed) {
            $image_name = $upload_image->file_dst_name;
            // ชื่อไฟล์หลังกระบวนการเก็บ จะอยู่ที่ file_dst_name
            $upload_image->clean();
            // คืนค่าหน่วยความจำ
            $image_path = "upload_images/" . $image_name;
            // กำหนด sql ใหม่ เพื่อให้เก็บชื่อภาพลงฐานข้อมูลด้วย
            $sql = "UPDATE  `siitticket`.`machine` SET  `name` =  '{$mname}' , `owner` = '{$owner}',`place` = '{$place}',`image` = '{$image_path}',`os` = '{$os}' , `tuid` = '{$tuid}' , `detail` = '{$detail}' WHERE  `machine`.`mid` ='{$mid}'";
            //echo $insertSQL ;
            //mysql_select_db($database_connection, $connection);
            //$Result1 = mysql_query($insertSQL, $connection) or die(mysql_error());
        }
        // END if ( $upload_image->processed )
    }
    //END if ( $upload_image->uploaded )
    //$sql = "insert into image (id, image) values ('', '$image') ";  //เพิ่มข้อมูลลงดาต้าเบส โดยเก็บชื่อรูปไว้
    // $dbquery = mysql_db_query($dbname, $sql);
}
include "connectdb.php";
Exemplo n.º 14
0
        $handle2->image_x = 100;
        $handle2->image_ratio_y = true;
        $handle2->allowed = array('image/*');
        $handle2->image_convert = 'jpg';
        $handle2->file_overwrite = true;
        $handle2->process('..uploads/talent/talent_profiles/');
        if ($handle2->processed) {
            // save uploaded file name and path in database table field logo_url
            $last_modified_by = $_SESSION['user_id'];
            $last_modified_on = getDateTime(NULL, "mySQL");
            /* if client id is not empty update the database */
            if ($talent_id != "") {
                $update = DB::update('tams_talent', array('photo2_url' => '/talent/uploads/talent/talent_profiles/' . $talent_id . '_photo1.jpg', 'last_modified_by' => $last_modified_by, 'last_modified_on' => $last_modified_on), "talent_id=%s", $talent_id);
            }
            echo 'Photo is uploaded and path select saved in database';
            $handle2->clean();
        } else {
            echo 'error : ' . $handle2->error;
        }
        // close handle processed
    }
    // close handle uploaded
    //if update is successful redirect the page to view client list
    if ($update) {
        echo '<script>alert("Edited Details Successfully");</script>';
        echo '<script>window.location.replace("' . $_SERVER['PHP_SELF'] . '?route=modules/talent/view_talents");</script>';
    }
}
if (isset($_GET['talent_id'])) {
    $talent_id = $_GET['talent_id'];
    $sql = "SELECT\n\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\ttams_talent\n\t\t\t\tWHERE talent_id = {$talent_id} ;";
Exemplo n.º 15
0
 public static function resize($src_imagepath, $src_imagefilename, $ndest_loc, $nwidth, $nheight, $nfilename)
 {
     try {
         if (!JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_jvrelatives' . DS . 'helpers' . DS . 'class.resize_image.php')) {
             throw new Exception("Verot does not exist. JV-LD component may not be installed");
         }
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_jvrelatives' . DS . 'helpers' . DS . 'class.resize_image.php';
         JvrelInit::debug('resize: Uploaded file: ' . $src_imagepath . DS . $src_imagefilename);
         // copy file to /tmp/subdir
         $t = time() . rand(0, 99999);
         if (!JFolder::exists(_JVREL_ABS_JTMP . DS . $t)) {
             JFolder::create(_JVREL_ABS_JTMP . DS . $t);
         }
         JFile::copy($src_imagepath . DS . $src_imagefilename, _JVREL_ABS_JTMP . DS . $t . DS . $src_imagefilename);
         $handle = new upload(_JVREL_ABS_JTMP . DS . $t . DS . $src_imagefilename);
         $handle->image_resize = true;
         $handle->file_overwrite = false;
         $handle->image_convert = 'jpg';
         $handle->image_x = $nwidth;
         if ($nheight) {
             $handle->image_y = $nheight;
         } else {
             $handle->image_ratio_y = true;
         }
         $handle->file_new_name_body = substr($nfilename, 0, -4);
         $handle->process($ndest_loc);
         $handle->clean();
         @JFolder::delete(_JVREL_ABS_JTMP . DS . $t);
         return $nfilename;
     } catch (Exception $ex) {
         JvrelInit::debug($ex->getMessage());
         return "";
     }
 }
Exemplo n.º 16
0
             $size_y = $matches[2];
             $img->file_overwrite = true;
             $img->image_resize = true;
             $img->image_default_color = '#e1e1e1';
             if ($matches[3] == 'x1') {
                 $img->image_ratio_fill = true;
             } else {
                 $img->image_ratio_crop = true;
             }
             $img->dir_auto_create = true;
             $img->image_x = $size_x;
             $img->image_y = $size_y;
             $img->process($cache_dir . $size . '/');
             // Вывод ошибок и очистка
             if ($img->processed) {
                 $img->clean();
             } else {
                 echo 'error : ' . $img->error;
             }
             $image_name = Text::strtolow(str_replace(' ', '_', $image_name));
             $image_name = str_replace('(', '', $image_name);
             $image_name = str_replace(')', '', $image_name);
             // Получаем изображение из кэша
             $img = new upload($cache_dir . $size . '/' . $image_name);
             // Вывод изображения
             header('Content-type: ' . $img->file_src_mime);
             echo $img->Process();
             exit;
         }
     }
 } else {
Exemplo n.º 17
0
}
/**
 * Simplify using filters for STRINGS
 * @param $x
 * @return mixed
 */
function FStr($x)
{
    return filter_var($x, FILTER_SANITIZE_SPECIAL_CHARS);
}
/**
 * UPLOADING IMAGES
 * NEEDS THIS CLASS : https://github.com/verot/class.upload.php
 */
$Upload = new upload($_FILES["bannerupload"]);
if ($Upload->uploaded) {
    $Upload->Process("../IMG/bannersystem/");
    if ($Upload->processed) {
        /**
         * PUT MORE CODE HERE - HERE IS WHEN ALL GOES WELL
         */
        $FileName = $Upload->file_dst_name;
        $Upload->clean();
    } else {
        echo 'error : ' . $Upload->error;
    }
} else {
    echo 'error : ' . $Upload->error;
    echo "<br><br>";
    echo "LOG: " . $Upload->log;
}
Exemplo n.º 18
0
function UlozSoubor($cesta)
{
    $tmp_name = $_FILES["userfile"]["tmp_name"];
    if ($tmp_name) {
        $handle = new upload($_FILES['userfile']);
        if ($handle->uploaded) {
            $handle->process($cesta);
            if ($handle->processed) {
                $nazevs = $handle->file_dst_name;
                $handle->clean();
            } else {
                echo 'error : ' . $handle->error;
                return 0;
            }
            return $nazevs;
        }
    }
}
Exemplo n.º 19
0
 function __convertImages()
 {
     $images = $this->TeamsObject->Team->PersonalImage->find('all', array('fields' => array('filename'), 'conditions' => array('model' => 'Team', 'prop' => 'Personal')));
     App::import('Vendor', 'example', array('file' => 'class.upload.php'));
     $this->settings['baseDir'] = WWW_ROOT . 'img' . DS . 'Team' . DS;
     $this->settings['thumbsDir'] = WWW_ROOT . 'img' . DS . 'Team' . DS . 'thumbs' . DS;
     if ($handle1 = opendir($this->settings['baseDir'])) {
         while (false !== ($file = readdir($handle1))) {
             $handle = new upload($this->settings['baseDir'] . $file);
             if ($handle->uploaded) {
                 // $image['PersonalImage']['filename'] = str_replace('.jpg','',$image['PersonalImage']['filename']);
                 //$image['PersonalImage']['filename'] = str_replace('.gif','',$image['PersonalImage']['filename']);
                 //$image['PersonalImage']['filename'] = str_replace('.png','',$image['PersonalImage']['filename']);
                 //$handle->file_new_name_body   = $image['PersonalImage']['filename'];
                 $handle->image_resize = true;
                 //$handle->image_ratio_crop = true;
                 $handle->image_resize = true;
                 $handle->image_x = 120;
                 $handle->image_ratio_y = true;
                 //$handle->image_x                        = 120;
                 //$handle->image_y                        = 120;
                 //$handle->image_ratio_fill      = 'C';
                 $handle->process($this->settings['thumbsDir']);
                 if ($handle->processed) {
                     echo 'image resized<br>';
                     $handle->clean();
                 } else {
                     echo 'error : ' . $handle->error . '<br>';
                 }
             } else {
                 echo $this->settings['baseDir'] . $file . " is not uploaded<br>";
             }
         }
         closedir($handle1);
     }
     exit;
 }
Exemplo n.º 20
0
 public function addStudent()
 {
     $identity = array('fName' => $_POST['firstName'], 'mName' => $_POST['middleName'], 'lName' => $_POST['lastName'], 'gender' => $_POST['gender'], 'email' => $_POST['email'], 'type' => 1);
     $studentIdentityId = Identity::newIdentity($identity);
     if (!$studentIdentityId) {
         $_SESSION['Error'] = "Unable to create Student Identity!";
         header("Location: " . $_POST['path']);
         // TODO: This should go to an error page.
         return false;
     }
     require_once 'helpers/upload.php';
     $code = '';
     if ($studentIdentityId) {
         $id = intval($studentIdentityId);
         $handle = new upload($_FILES['image_field']);
         if ($handle->uploaded) {
             $handle->file_new_name_body = $id;
             $handle->image_resize = true;
             $handle->image_x = 100;
             $handle->image_ratio_y = true;
             $handle->file_overwrite = true;
             $handle->process($_SERVER['DOCUMENT_ROOT'] . '/EduDB/imageUploads/');
             if ($handle->processed) {
                 $handle->clean();
             } else {
                 $_SESSION['ERROR'] = $handle->error;
                 // Failure
             }
         }
         Identity::updateImage($id, '/EduDB/imageUploads/' . $handle->file_dst_name);
     }
     $student = array('gradeId' => $_POST['grade'], 'identityId' => $studentIdentityId, 'schoolId' => $_POST['school']);
     $sId = Student::newStudent($student);
     if (!$sId) {
         $_SESSION['Error'] = "Unable to update Student!";
     }
     header("Location: ?controller=student&action=viewStudent&id={$sId}");
 }
Exemplo n.º 21
0
             $handle->image_x = 100;
             $handle->image_ratio_y = true;
             $handle->allowed = array('image/*');
             $handle->image_convert = 'jpg';
             $handle->file_overwrite = true;
             $handle->process('../uploads/clients/');
             if ($handle->processed) {
                 // save uploaded file name and path in database table field logo_url
                 $last_modified_by = $_SESSION['user_id'];
                 $last_modified_on = getDateTime(NULL, "mySQL");
                 /* if client id is not empty update the database */
                 if ($client_id != "") {
                     $update = DB::update('tams_clients', array('logo_url' => '/talent/uploads/clients/' . $client_id . '_logo.jpg', 'last_modified_by' => $last_modified_by, 'last_modified_on' => $last_modified_on), "client_id=%s", $client_id);
                 }
                 echo 'Logo file uploaded and path select saved in database';
                 $handle->clean();
             } else {
                 echo 'error : ' . $handle->error;
             }
             // close handle processed
         }
         // close handle uploaded
     }
     // close file exist
     //if update is successful redirect the page to view client list
     if ($update) {
         echo '<script>alert("Edited Details Successfully");</script>';
         echo '<script>window.location.replace("' . $_SERVER['PHP_SELF'] . '?route=modules/clients/view_clients");</script>';
     }
 }
 echo '<h2> $_FILES variable</h2>';
Exemplo n.º 22
0
 public function process($parameters)
 {
     $userManager = new UserManager();
     $validation = new Validation();
     $user = $userManager->returnUser();
     //ak bol odoslany formular pre ulozenie udajov uzivatela
     //udaje z formularu sa ukladaju do premennej $data, z ktorej sa nakoniec vyberu a zapisu do DB vsetky udaje
     //v celom bloku try sa odchytavaju vsetky vynimky
     if (isset($_POST['submit'])) {
         try {
             $this->checkUser();
             //polia pre zmenu hesla
             //ak bolo vyplnene aspon jedno z poli
             if (!empty($_POST['old']) || !empty($_POST['password'] != '') || !empty($_POST['password2'] != '')) {
                 $userManager->checkPassword($user['name'], $_POST['old']);
                 //over stare heslo
                 if (!empty($_POST['password']) && !empty($_POST['password2'])) {
                     if ($_POST['password'] == $_POST['password2']) {
                         $validation->checkPasswordLength($_POST['password']);
                         //overi minimalnu dlzku hesla
                         $data['password'] = $userManager->returnHash($_POST['password']);
                         //pripravi pole a zasifruje heslo
                         $this->createMessage('Heslo bolo úspešne zmenené.', 'success');
                     } else {
                         throw new UserError('Heslá sa nezhodujú.');
                     }
                 } else {
                     throw new UserError('Nevyplnené pole.');
                 }
             }
             //radio button pohlavie
             if ($_POST['sex'] == 'male') {
                 $data['sex'] = 'muž';
             } else {
                 $data['sex'] = 'žena';
             }
             $userManager->updateUserData($user['name'], $data);
             //zapis udajov uzivatela do DB
             $this->createMessage('Nastavenia boli úspešne uložené.', 'success');
         } catch (UserError $error) {
             $this->createMessage($error->getMessage(), 'warning');
         }
     }
     //ak bol odoslany formular pre upload profiloveho obrazka
     if (isset($_POST['uploadImage'])) {
         $imageUpload = new upload($_FILES['image_field']);
         $targetDirectory = 'img/users/' . $user['name'] . '/';
         $filePath = $targetDirectory . 'user_avatar.gif';
         try {
             //ak neexistuje uzivatelov adresar, vytvor ho
             if (!file_exists($targetDirectory)) {
                 mkdir($targetDirectory, '0777', true);
             }
             //ak bol obrazok nahraty
             if ($imageUpload->uploaded) {
                 $imageUpload->allowed = array('image/*');
                 //povolene formaty
                 $imageUpload->mime_check = true;
                 //kontrola formatu zapnuta
                 $imageUpload->file_new_name_body = 'user_avatar';
                 //novy nazov suboru
                 $imageUpload->image_resize = true;
                 //zmensenie
                 $imageUpload->image_convert = 'gif';
                 //konvertovanie na gif
                 $imageUpload->image_x = 100;
                 //vysledna sirka 100px
                 $imageUpload->image_ratio_y = true;
                 //vyska: auto
                 //zmazanie existujuceho avataru
                 if (file_exists($filePath)) {
                     unlink($filePath);
                 }
                 $imageUpload->process($targetDirectory);
                 //uloz vysledny obrazok
                 //ak bol obrazok ulozeny
                 if ($imageUpload->processed) {
                     //uloz avatar do databazy
                     $userManager->updateUserData($user['name'], array('avatar' => $filePath));
                     $imageUpload->clean();
                 } else {
                     throw new UserError($imageUpload->error);
                 }
                 $this->createMessage('Váš obrázok bol úspešne uložený.', 'success');
             } else {
                 throw new UserError('Obrázok sa nenahral');
             }
         } catch (UserError $error) {
             $this->createMessage($error->getMessage(), 'warning');
         }
     }
     //ak je zadana URL pre odstranenie uzivatela
     if (!empty($parameters[1]) && $parameters[1] == 'odstranit') {
         $this->checkUser(true);
         $userManager->deleteUser($parameters[0]);
         $this->createMessage('Užívateľ<strong> ' . $parameters[0] . ' </strong>bol odstránený', 'success');
         $this->redirect('uzivatelia');
     }
     //ak je zadana URL pre zmenu opravnenia uzivatela
     if (!empty($parameters[1]) && $parameters[1] == 'zmenit-opravnenie') {
         $this->checkUser(true);
         $requiredUser = $userManager->returnUserInfo($parameters[0]);
         //ak ma uzivatel hodnost 'Clen', zmen ho na 'Redaktor'
         if ($requiredUser['admin'] == 0) {
             $value = array('admin' => 2);
             $userManager->updateUserData($parameters[0], $value);
             $this->createMessage('Užívateľovi ' . $parameters[0] . ' bola priradená hodnosť Redaktor', 'success');
             $this->redirect('uzivatelia');
         }
         //ak ma uzivatel hodnost 'Redaktor', zmen ho na 'Clen'
         if ($requiredUser['admin'] == 2) {
             $value = array('admin' => 0);
             $userManager->updateUserData($parameters[0], $value);
             $this->createMessage('Užívateľovi ' . $parameters[0] . ' bola priradená hodnosť Člen', 'success');
             $this->redirect('uzivatelia');
         }
     }
     //ak je zadane URL profilu uzivatela
     if (!empty($parameters[0])) {
         $user = $userManager->returnUserInfo($parameters[0]);
         //ak pouzivatel nebol najdeny, presmeruj na chybove hlasenie
         if (!$user) {
             $this->redirect('chyba');
         }
         //premenne pre sablonu
         $this->head['title'] = 'Užívateľský profil - ' . $user['name'];
         $this->data['userRank'] = $validation->returnUserRank($user['admin']);
         $this->data['user'] = $user['name'];
         $this->data['avatar'] = $user['avatar'];
         $this->data['registrationDate'] = $user['registration_date'];
         $this->data['lastVisit'] = $user['last_visit'];
         $this->data['comments'] = $user['comments'];
         $this->data['articles'] = $user['articles'];
         $this->data['sex'] = $user['sex'];
         $this->data['email'] = $user['email'];
         $this->data['loggedUser'] = $userManager->returnUser();
         //sablona
         $this->view = 'profile';
     } else {
         $this->checkUser(true);
         //premenne pre sablonu
         $this->head['title'] = 'Správa užívateľov';
         $this->data['admin'] = $user && $user['admin'];
         $this->data['users'] = $userManager->returnUsers();
         $this->data['loggedUser'] = $userManager->returnUser();
         $index = 0;
         foreach ($this->data['users'] as $userData) {
             $this->data['users'][$index]['rank'] = $validation->returnUserRank($userData['admin']);
             $index += 1;
         }
         //sablona
         $this->view = 'users';
     }
 }