Exemplo n.º 1
0
function insertArticleIntoDB()
{
    // Create DB connection
    require_once __ROOT__ . '/admin/include/DBclass.php';
    $sqlConn = new DBclass("nazmarket");
    // Extract received informations.
    // Do checks for SQL injection, data times and other limitations.
    $articlename = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'articlename', FILTER_DEFAULT));
    $idcategory = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'idcategory', FILTER_DEFAULT));
    $idcompany = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'idcompany', FILTER_DEFAULT));
    $idunit = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'idunit', FILTER_DEFAULT));
    $articlecomment = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'articlecomment', FILTER_DEFAULT));
    $price = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'price', FILTER_DEFAULT));
    $available = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'available', FILTER_DEFAULT));
    // Corresponds to the name in HTML.
    $articleimage = uploadFile("articleimage");
    if ($articleimage == -1) {
        $articleimage = "";
    }
    // $articleName =
    //[articlename] => [idcategory] => 1 [idcompany] => 1 [articlecomment] => e.g. 500 [idunit] => 1 [price]
    // Insert:
    $query = "INSERT INTO article (articlename, idcategory, idcompany, idunit,\r\n            price, articlecomment, articleimage, available) \r\n            VALUES ('" . $articlename . "','" . $idcategory . "','" . $idcompany . "'," . $idunit . "," . $price . ",'" . $articlecomment . "','" . $articleimage . "'," . $available . ")";
    echo "<br/>" . $query . "<br/>";
    $sqlConn->exeQuery($query);
    // Remove DB connection
    unset($sqlConn);
}
Exemplo n.º 2
0
function uploadFile($copy_src_filename, $originalfilename, $testnewfilename)
{
    global $i;
    $dir_upload = '../upload/';
    if (!is_writable($dir_upload)) {
        @chmod($dir_upload, 0755);
    }
    if (file_exists($dir_upload . $testnewfilename)) {
        $fileinfo = pathinfo($originalfilename);
        $filename_noext = basename($originalfilename, '.' . $fileinfo['extension']);
        $i++;
        $suffix = str_pad($i, 3, '0', STR_PAD_LEFT);
        $newfilename = $filename_noext . ' - ' . $suffix . '.' . $fileinfo['extension'];
        uploadFile($copy_src_filename, $originalfilename, $newfilename);
    } else {
        $_SESSION['uploaded_files'][] = $testnewfilename;
        copy($copy_src_filename, $dir_upload . $testnewfilename);
        // image file name needed to append the image with its new name in uploadSuccess (handlers.js)
        ?>
		{"filename":"<?php 
        echo $testnewfilename;
        ?>
"}
	<?php 
    }
}
Exemplo n.º 3
0
/**
* @param string The class name for the installer
* @param string The URL option
* @param string The element name
*/
function uploadPackage($installerClass, $option, $element, $client)
{
    global $mainframe, $adminLanguage;
    $installer = new $installerClass();
    // Check if file uploads are enabled
    if (!(bool) ini_get('file_uploads')) {
        HTML_installer::showInstallMessage($adminLanguage->A_INSTALL_ENABLE_MSG, $adminLanguage->A_INSTALL_ERROR_MSG_TITLE, $installer->returnTo($option, $element, $client));
        exit;
    }
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        HTML_installer::showInstallMessage($adminLanguage->A_INSTALL_ZLIB_MSG, $adminLanguage->A_INSTALL_ERROR_MSG_TITLE, $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile = mosGetParam($_FILES, 'userfile', null);
    if (!$userfile) {
        HTML_installer::showInstallMessage($adminLanguage->A_INSTALL_NOFILE_MSG, $adminLanguage->A_INSTALL_NEWMODULE_ERROR_MSG_TITLE, $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile_name = $userfile['name'];
    $msg = '';
    $resultdir = uploadFile($userfile['tmp_name'], $userfile['name'], $msg);
    if ($resultdir !== false) {
        if (!$installer->upload($userfile['name'])) {
            HTML_installer::showInstallMessage($installer->getError(), $adminLanguage->A_INSTALL_UPLOAD_PRE . $element . $adminLanguage->A_INSTALL_UPLOAD_POST, $installer->returnTo($option, $element, $client));
        }
        $ret = $installer->install();
        HTML_installer::showInstallMessage($installer->getError(), $adminLanguage->A_INSTALL_UPLOAD_PRE . $element . ' - ' . ($ret ? $adminLanguage->A_INSTALL_SUCCESS : $adminLanguage->A_INSTALL_FAILED), $installer->returnTo($option, $element, $client));
        cleanupInstall($userfile['name'], $installer->unpackDir());
    } else {
        HTML_installer::showInstallMessage($msg, $adminLanguage->A_INSTALL_UPLOAD_PRE . $element . $adminLanguage->A_INSTALL_UPLOAD_POST2, $installer->returnTo($option, $element, $client));
    }
}
 function updateCategory()
 {
     global $CONFIG;
     $id = _p('category_id');
     $parent = _p('parent');
     $name = _p('name');
     $description = _p('description');
     $meta_description = _p('meta_description');
     $meta_keywords = _p('meta_keywords');
     $top = _p('top');
     $column = _p('column');
     $sort_order = _p('sort_order');
     $status = _p('status');
     $pathUpload = "";
     $date_modified = date('Y-m-d H:i:s');
     if ($_FILES['gambar']['name'] == "") {
         $query = "UPDATE ck_category SET parent_id={$parent}, top={$top}, `column`={$column}, sort_order={$sort_order}, status={$status}, date_modified = '{$date_modified}' WHERE category_id = {$id}";
     } else {
         $image = uploadFile('gambar', $pathUpload, 'image');
         $query = "UPDATE ck_category SET image='{$image}', parent_id={$parent}, top={$top}, `column`={$column}, sort_order={$sort_order}, status={$status}, date_modified='{$date_modified}' WHERE category_id = {$id}";
     }
     $query_desc = "UPDATE ck_category_description SET name = '{$name}', description = '{$description}', meta_description = '{$meta_description}', meta_keyword = '{$meta_keywords}' WHERE category_id = {$id}";
     $result_query = $this->query($query);
     $result_desc = $this->query($query_desc);
     // pr ($_FILES['gambar']);
     // echo ("<br/>");
     // pr ($image);
     // echo ("<br/>");
     // echo "<br />".$query;
     // exit();
     return $result_desc && $result_query;
 }
 function addProduct()
 {
     $category = _p('category');
     $name = _p('name');
     $description = _p('description');
     $meta_desc = _p('meta_descriptoion');
     $meta_key = _p('meta_keywords');
     $model = _p('model');
     $sku = _p('sku');
     $upc = _p('upc');
     $ean = _p('ean');
     $jan = _p('jan');
     $isbn = _p('isbn');
     $mpn = _p('mpn');
     $weight = _p('weight');
     $weight_class = _p('weight_class');
     $length = _p('length');
     $width = _p('width');
     $height = _p('height');
     $length_class = _p('length_class');
     $location = _p('location');
     $price = _p('price');
     $quantity = _p('quantity');
     $minimum = _p('minimum');
     $substract = _p('substract');
     $shipping = _p('shipping');
     $status = _p('status');
     $date_added = date('Y-m-d H:i:s');
     $pathUpload = "";
     $image = uploadFile('gambar', $pathUpload, 'image');
     $query_product = "INSERT INTO ck_product (`model`, `sku`, `upc`, `ean`, `jan`, `isbn`, `mpn`, `location`, `quantity`, `image`, `shipping`, `price`, `weight`, `weight_class_id`, `length`, `width`, `height`, `length_class_id`, `subtract`, `minimum`, `sort_order`, `status`, `date_added`) VALUES ('{$model}', '{$sku}', '{$upc}', '{$ean}', '{$jan}', '{$isbn}', '{$mpn}', '{$location}', {$quantity}, '{$image}', '{$shipping}', {$price}, {$weight}, '{$weight_class}', {$length}, {$width}, {$height}, '{$length_class}', '{$substract}', {$minimum}, '', {$status}, '{$date_added}' )";
     echo "<br />" . $query_product;
     echo "<br />";
     pr($image);
 }
 public function __construct()
 {
     $title = getInput("title");
     $description = getInput("description");
     // Create filestore object to store file information
     $file = new File();
     $file->title = $title;
     $file->description = $description;
     $file->owner_guid = getLoggedInUserGuid();
     $file->access_id = "public";
     $file->container_guid = getInput("container_guid");
     $guid = $file->save();
     uploadFile("file", $guid, getLoggedInUserGuid());
     $file = getEntity($guid);
     Image::createThumbnail($file->guid, TINY);
     Image::createThumbnail($file->guid, SMALL);
     Image::createThumbnail($file->guid, MEDIUM);
     Image::createThumbnail($file->guid, LARGE);
     Image::createThumbnail($file->guid, EXTRALARGE);
     Image::createThumbnail($file->guid, HUGE);
     new Activity(getLoggedInUserGuid(), "action:upload:file", $guid);
     runHook("upload_file:redirect");
     new SystemMessage("Your file has been uploaded.");
     forward();
 }
Exemplo n.º 7
0
/**
* @param string The class name for the installer
* @param string The URL option
* @param string The element name
*/
function uploadPackage($installerClass, $option, $element, $client)
{
    josSpoofCheck();
    $installer = new $installerClass();
    // Check if file uploads are enabled
    if (!(bool) ini_get('file_uploads')) {
        HTML_installer::showInstallMessage("O instalador não pode continuar antes que o envio dos arquivos esteja concluido. Por favor, use a instalação a partir do diretório.", 'Installer - Error', $installer->returnTo($option, $element, $client));
        exit;
    }
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        HTML_installer::showInstallMessage("O instalador não pode continuar antes que o zlib esteja habilitado", 'Installer - Error', $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile = mosGetParam($_FILES, 'userfile', null);
    if (!$userfile) {
        HTML_installer::showInstallMessage('Nenhum arquivo selecionado', 'envio novo módulo - erro', $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile_name = $userfile['name'];
    $msg = '';
    $resultdir = uploadFile($userfile['tmp_name'], $userfile['name'], $msg);
    if ($resultdir !== false) {
        if (!$installer->upload($userfile['name'])) {
            HTML_installer::showInstallMessage($installer->getError(), 'Envio ' . $element . ' - Envio Falhou', $installer->returnTo($option, $element, $client));
        }
        $ret = $installer->install();
        HTML_installer::showInstallMessage($installer->getError(), 'Envio ' . $element . ' - ' . ($ret ? 'Sucesso' : 'Falhou'), $installer->returnTo($option, $element, $client));
        cleanupInstall($userfile['name'], $installer->unpackDir());
    } else {
        HTML_installer::showInstallMessage($msg, 'Envio ' . $element . ' -  Envio Falhou', $installer->returnTo($option, $element, $client));
    }
}
Exemplo n.º 8
0
/**
* @param string The class name for the installer
* @param string The URL option
* @param string The element name
*/
function uploadPackage($installerClass, $option, $element, $client)
{
    josSpoofCheck();
    $installer = new $installerClass();
    // Check if file uploads are enabled
    if (!(bool) ini_get('file_uploads')) {
        HTML_installer::showInstallMessage("The installer can't continue before file uploads are enabled. Please use the install from directory method.", 'Installer - Error', $installer->returnTo($option, $element, $client));
        exit;
    }
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        HTML_installer::showInstallMessage("The installer can't continue before zlib is installed", 'Installer - Error', $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile = mosGetParam($_FILES, 'userfile', null);
    if (!$userfile) {
        HTML_installer::showInstallMessage('No file selected', 'Upload new module - error', $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile_name = $userfile['name'];
    $msg = '';
    $resultdir = uploadFile($userfile['tmp_name'], $userfile['name'], $msg);
    if ($resultdir !== false) {
        if (!$installer->upload($userfile['name'])) {
            HTML_installer::showInstallMessage($installer->getError(), 'Upload ' . $element . ' - Upload Failed', $installer->returnTo($option, $element, $client));
        }
        $ret = $installer->install();
        HTML_installer::showInstallMessage($installer->getError(), 'Upload ' . $element . ' - ' . ($ret ? 'Success' : 'Failed'), $installer->returnTo($option, $element, $client));
        cleanupInstall($userfile['name'], $installer->unpackDir());
    } else {
        HTML_installer::showInstallMessage($msg, 'Upload ' . $element . ' -  Upload Error', $installer->returnTo($option, $element, $client));
    }
}
Exemplo n.º 9
0
/**
 *编辑商品
 * @param int $id
 * @return string
 */
function editUser($id)
{
    $arr = $_POST;
    $path = "../uploads";
    $uploadFiles = uploadFile($path);
    $where = "id={$id}";
    $totalCap = getCityCapById(getcIdById($id)) - getCapById($id) + $arr['capacity'];
    //减去旧的,加上新的
    $sql = "update biogas_city set totalCap=" . $totalCap . " where id=" . getcIdById($id);
    mysql_query($sql);
    //更新城市的总池容
    $res = update("biogas_user", $arr, $where);
    $uid = $id;
    if ($res && $uid) {
        if ($uploadFiles && is_array($uploadFiles)) {
            foreach ($uploadFiles as $uploadFile) {
                $arr1['uid'] = $uid;
                $arr1['albumPath'] = $uploadFile['name'];
                addAlbum($arr1);
            }
        }
        $mes = "<p>编辑成功!</p><a href='listUser.php' target='mainFrame'>查看用户列表</a>";
    } else {
        $mes = "<p>编辑失败!</p><a href='listUser.php' target='mainFrame'>重新编辑</a>";
    }
    return $mes;
}
 function __construct()
 {
     adminGateKeeper();
     $guid = getInput("guid");
     $title = getInput("title");
     $description = getInput('description');
     $price = getInput("price");
     $hidden = getInput("hidden") == 0 ? false : true;
     $product = getEntity($guid);
     $product->title = $title;
     $product->description = $description;
     $product->price = $price;
     $product->hidden = $hidden;
     $product->save();
     $product->createAvatar();
     if (isset($_FILES["download"]) && $_FILES["download"]["name"]) {
         $file = new File();
         $file->access_id = "product";
         $file->container_guid = $product->guid;
         $guid = $file->save();
         uploadFile("download", $guid, array("zip"));
         $product->download = $guid;
     }
     new SystemMessage("Your product has been updated.");
     forward("store");
 }
Exemplo n.º 11
0
 /**
  * @noAuth
  * @url POST /?submissions
  * @url PUT /?submissions/$id
  */
 function insertSubmission($id = null, $data)
 {
     if ($data == null) {
         $data = $_POST;
     } else {
         $data = get_object_vars($data);
     }
     //var_dump($data);
     //check if file submitted
     $file = false;
     if (isset($_FILES['file']) && !empty($_FILES['file']['name']) && $_FILES['file']['size'] > 0) {
         $file = $_FILES['file'];
         $data['image_result'] = $file['name'];
     }
     //validate
     $validationRules = array();
     if (isset($data['text_question']) && !empty($data['text_question'])) {
         $validationRules['text_result'] = VALIDATE_RULE_NON_EMPTY_STRING | VALIDATE_RULE_REQUIRED;
     }
     if (isset($data['image_question']) && !empty($data['image_question'])) {
         $validationRules['image_result'] = VALIDATE_RULE_NON_EMPTY_STRING | VALIDATE_RULE_REQUIRED;
     }
     $validator = new Validator($data);
     $errors = $validator->validate($validationRules);
     if (!empty($errors)) {
         throw new RestException(400, implode(" ", $errors));
     }
     //add new entry
     if ($id == null) {
         //insert into database
         $db = new SubmissionDatabase();
         $db->insertSubmission($data);
         $id = $db->lastInsertRowid();
         //upload file
         if ($file) {
             $upload_dir = DIR_SUBMISSION_FILES . '/' . $id;
             try {
                 checkFileType($file['name'], array("jpg", "jpeg", "gif", "png"));
                 uploadFile($file['tmp_name'], $upload_dir, $file['name']);
             } catch (Exception $e) {
                 // delete entry if upload failed
                 $db->deleteSubmission($id);
                 throw new RestException(400, $e->getMessage());
             }
         }
         return $db->getSubmission($id);
         // modify entry
     } else {
         //insert Model and return it
         $db = new SubmissionDatabase();
         $db->insertSubmission($data);
         return $db->getSubmission($id);
     }
 }
Exemplo n.º 12
0
 function add($data)
 {
     unset($data['section']);
     $data['createdby'] = USER_ID;
     // upload image logo
     $image = uploadFile("image", BASEPATH . "../public/images/upload/");
     if (!empty($image['file_name'])) {
         $data['image'] = $image['file_name'];
     }
     return $this->db->insert($this->_table, $data);
 }
Exemplo n.º 13
0
 function add($data)
 {
     unset($data['section']);
     unset($data['old_image']);
     $data['createdby'] = USER_ID;
     // upload image logo
     $image = uploadFile("product_image", BASEPATH . "../public/images/products/");
     if (!empty($image['file_name'])) {
         $data['product_image'] = $image['file_name'];
     }
     return $this->db->insert("products", $data);
 }
Exemplo n.º 14
0
 function add($data)
 {
     $array = array();
     $array['brand_en'] = $data['brand_en'];
     $array['brand_vi'] = $data['brand_vi'];
     // upload image logo
     $image_logo = uploadFile("logo", BASEPATH . "../public/images/customers/");
     if (!empty($image_logo['file_name'])) {
         $array['logo'] = $image_logo['file_name'];
     }
     $array['createdby'] = USER_ID;
     return $this->db->insert("customers", $array);
 }
Exemplo n.º 15
0
 function edit($data, $code)
 {
     $array = array();
     $array['content_en'] = $data['content_en'];
     $array['content_vi'] = $data['content_vi'];
     // upload image logo
     $image_logo = uploadFile("image", BASEPATH . "../public/images/statics/");
     if (!empty($image_logo['file_name'])) {
         $array['image'] = $image_logo['file_name'];
         removeFile(BASEPATH . "../public/images/statics/" . $_POST['old_image']);
     }
     return $this->db->update('static_contents', $array, array('code' => $code));
 }
Exemplo n.º 16
0
/**
 *�༭��Ʒ
 * @param int $id
 * @return string
 */
function editHouse($id)
{
    $arr = $_POST;
    $arr['update_time'] = date("Y-m-d H:i:s");
    $sql = "select house_id from tg_host_house where id={$id}";
    $row = fetchOne($sql);
    //��house_id������album_id
    $album_id = $row['house_id'];
    $path = "../uploads/House_Album/user_id_" . $album_id;
    //����û�жϾ��ϴ�ͼƬ���ļ��У�ͼƬ��ݲ�һ���ɹ�������ݿ�
    $uploadFiles = uploadFile($path);
    if (is_array($uploadFiles) && $uploadFiles) {
        foreach ($uploadFiles as $key => $uploadFile) {
            thumb($path . "/" . $uploadFile['name'], "../image_50/user_id_" . $album_id . "/" . $uploadFile['name'], 50, 50);
        }
    }
    //����host_house�����
    $where = "house_id={$id}";
    $res = update("tg_host_house", $arr, $where);
    //ע�⣺����ֻ�ܸ�����ݱ������е��ֶΣ����post�����ݸ�table����ֶβ�ƥ�䣬����ʧ�ܣ�����
    $house_id = $row['house_id'];
    //����ȡ�� house_id ����Ӧ album_id
    $sql_img = "select i.album_id from tg_house_img as i left join tg_host_house h on h.house_id=i.album_id where i.album_id={$house_id}";
    $row_img = fetchOne($sql_img);
    //��img_path ��ӵ� tg_house_img��
    if ($res && $house_id) {
        if ($uploadFiles && is_array($uploadFiles)) {
            foreach ($uploadFiles as $uploadFile) {
                $arr1['album_id'] = $house_id;
                $arr1['img_path'] = $uploadFile['name'];
                //print_r($arr1['img_path']);exit;
                addAlbum($arr1);
            }
        }
        $mes = "<p>Edit success!</p><a href='listHouse.php' target='mainFrame'>View house list</a>";
    } else {
        if (is_array($uploadFiles) && $uploadFiles) {
            foreach ($uploadFiles as $uploadFile) {
                if (file_exists("../image_50/user_id_" . $_SESSION['user_id'] . "/" . $uploadFile['name'])) {
                    unlink("../image_50/user_id_" . $_SESSION['user_id'] . "/" . $uploadFile['name']);
                }
                if (file_exists("../uploads/House_Album/user_id_" . $_SESSION['user_id'] . "/" . $uploadFile['name'])) {
                    unlink("../uploads/House_Album/user_id_" . $_SESSION['user_id'] . "/" . $uploadFile['name']);
                }
            }
        }
        $mes = "<p>Failed!</p><a href='listHouse.php' target='mainFrame'>Edit again</a>";
    }
    return $mes;
}
Exemplo n.º 17
0
 public function ins_project()
 {
     global $basedomain;
     $_POST['description'] = htmlentities(htmlspecialchars($_POST['description'], ENT_QUOTES));
     $_POST['n_status'] = 1;
     $_POST['idRequired'] = implode(",", $_POST['idRequired']);
     if ($_FILES['gambar']['error'] == 0) {
         $files = uploadFile('gambar');
         $_POST['image'] = $files['full_name'];
     }
     $this->mproject->insertData($_POST, 'hr_project');
     echo "<script>alert('Data successfully inserted');window.location.href='" . $basedomain . "project'</script>";
     exit;
 }
Exemplo n.º 18
0
 /**
  * Function to upload images into WYSIWYG
  *
  * @return array Asynchronous result
  */
 public function __async_upload()
 {
     /** @var array $result Asynchronous result array */
     $result = array('status' => false);
     /** @var \samsonphp\upload\Upload $upload  Pointer to uploader object */
     $upload = null;
     // If file was uploaded
     if (uploadFile($upload)) {
         $result['status'] = true;
         $result['tag'] = '<img src="' . $upload->fullPath() . '">';
     }
     // Return result
     return $result;
 }
Exemplo n.º 19
0
 function testModel()
 {
     $upload = uploadFile('gambar', false);
     $upload = uploadFile('dokumen', false, 'doc');
     $upload = uploadFile('video', false, 'video');
     $namaFile = $upload['full_name'];
     $sql = "SELECT * FROM user";
     $res = $this->fetch($sql);
     //ngeluarin data
     // $res = $this->query($sql); //ngeluarin data
     if ($res) {
         return $res;
     }
     return false;
 }
Exemplo n.º 20
0
 function add($data)
 {
     if (isset($_POST['is_active'])) {
         $data['is_active'] = 1;
     } else {
         $data['is_active'] = 0;
     }
     // upload image logo
     $name = md5(date('d/m/Y H:i:s'));
     $image = uploadFile("image", BASEPATH . "../public/images/upload/", $name);
     if (!empty($image['file_name'])) {
         $data['image'] = $image['file_name'];
     }
     return $this->db->insert($this->_table, $data);
 }
Exemplo n.º 21
0
Arquivo: index.php Projeto: kynm/php
function checkValueProject($projects, $fileProjects)
{
    $dataProject = [];
    $i = 0;
    foreach ($projects as $key => $project) {
        if ($project['name']) {
            $dataProject[$i] = $project;
            if ($_FILES['projects']['name'][$key]) {
                $dataProject[$i]['file'] = uploadFile($key);
            }
            $i++;
        }
    }
    return $dataProject;
}
Exemplo n.º 22
0
function uploadPath($sc, $dbg, $rootDir, $relativePath)
{
    handleResponse("mkdir {$relativePath}", $dbg, $sc->call("createDirectory", array('relativePath' => $relativePath), "POST"));
    $fullDir = $rootDir . DIRECTORY_SEPARATOR . $relativePath;
    foreach (glob($fullDir . DIRECTORY_SEPARATOR . "*") as $fileName) {
        echo $fileName . "\n";
        if (is_file($fileName)) {
            $r = handleResponse("utoken {$fileName}", $dbg, $sc->call("getUploadToken", array('relativePath' => $relativePath . DIRECTORY_SEPARATOR . basename($fileName), 'fileSize' => filesize($fileName)), "POST"));
            handleResponse("ufile {$fileName}", $dbg, uploadFile($r->data->uploadLocation, $fileName, 1024 * 1024));
        } else {
            if (is_dir($fileName)) {
                uploadPath($sc, $dbg, $rootDir, $relativePath . DIRECTORY_SEPARATOR . basename($fileName));
            }
        }
    }
}
/**
 *编辑商品
 * @param int $id
 * @return string
 */
function editPro($id)
{
    $arr = $_POST;
    $path = "./uploads";
    $uploadFiles = uploadFile($path);
    if (is_array($uploadFiles) && $uploadFiles) {
        foreach ($uploadFiles as $key => $uploadFile) {
            thumb($path . "/" . $uploadFile['name'], "../image_50/" . $uploadFile['name'], 50, 50);
            thumb($path . "/" . $uploadFile['name'], "../image_220/" . $uploadFile['name'], 220, 220);
            thumb($path . "/" . $uploadFile['name'], "../image_350/" . $uploadFile['name'], 350, 350);
            thumb($path . "/" . $uploadFile['name'], "../image_800/" . $uploadFile['name'], 800, 800);
        }
    }
    $where = "id={$id}";
    $res = update("imooc_pro", $arr, $where);
    $pid = $id;
    if ($res && $pid) {
        //判断是否有图片上传
        if ($uploadFiles && is_array($uploadFiles)) {
            foreach ($uploadFiles as $uploadFile) {
                $arr1['pid'] = $pid;
                $arr1['albumPath'] = $uploadFile['name'];
                addAlbum($arr1);
            }
        }
        $mes = "<p>编辑成功!</p><a href='listPro.php' target='mainFrame'>查看商品列表</a>";
    } else {
        if (is_array($uploadFiles) && $uploadFiles) {
            foreach ($uploadFiles as $uploadFile) {
                if (file_exists("../image_800/" . $uploadFile['name'])) {
                    unlink("../image_800/" . $uploadFile['name']);
                }
                if (file_exists("../image_50/" . $uploadFile['name'])) {
                    unlink("../image_50/" . $uploadFile['name']);
                }
                if (file_exists("../image_220/" . $uploadFile['name'])) {
                    unlink("../image_220/" . $uploadFile['name']);
                }
                if (file_exists("../image_350/" . $uploadFile['name'])) {
                    unlink("../image_350/" . $uploadFile['name']);
                }
            }
        }
        $mes = "<p>编辑失败!</p><a href='listPro.php' target='mainFrame'>重新编辑</a>";
    }
    return $mes;
}
Exemplo n.º 24
0
function zip_install_preview_admin()
{
    global $main_smarty, $the_template, $db, $my_pligg_base;
    force_authentication();
    $amIgod = 0;
    $amIgod = $amIgod + checklevel('admin');
    if ($amIgod == 1) {
        $navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel');
        $navwhere['link1'] = getmyurl('admin', '');
        $main_smarty->display(zip_install_tpl_path . '/blank.tpl');
        $navwhere['text2'] = 'ZIP Install';
        $navwhere['link2'] = my_pligg_base . '/module.php?module=zip_install';
        $navwhere['text3'] = '';
        $navwhere['link3'] = '';
        $navwhere['text4'] = '';
        $navwhere['link4'] = '';
        $main_smarty = do_sidebar($main_smarty);
        $main_smarty->assign('navbar_where', $navwhere);
        $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
        $action = $_REQUEST['action'];
        switch ($action) {
            case "modules":
                $main_smarty->assign('tpl_center', zip_install_tpl_path . 'zip_install_modules');
                $main_smarty->display($template_dir . '/admin/admin.tpl');
                break;
            case "templates":
                $main_smarty->assign('tpl_center', zip_install_tpl_path . 'zip_install_templates');
                $main_smarty->display($template_dir . '/admin/admin.tpl');
                break;
            case "filemod":
                if (uploadFile(zip_install_absolute_path, $_FILES, "modules")) {
                    redirect(my_pligg_base . '/admin/admin_modules.php?status=uninstalled');
                }
                break;
            case "filetem":
                if (uploadFile(zip_install_absolute_path, $_FILES, "templates")) {
                    redirect(my_pligg_base . '/admin/admin_config.php?page=Template');
                }
                break;
            default:
                $main_smarty->assign('tpl_center', zip_install_tpl_path . 'zip_install');
                $main_smarty->display($template_dir . '/admin/admin.tpl');
                break;
        }
    }
}
Exemplo n.º 25
0
 public function proc()
 {
     if ($_FILES['file']['name'] != '') {
         $image = uploadFile('file', null, 'all');
         if ($image['status']) {
             $dataArr['title'] = $_POST['judul'];
             $dataArr['filename'] = $image['full_name'];
             $dataArr['type'] = 50;
             $dataArr['n_status'] = 1;
             $dataArr['create_date'] = date('Y-m-d H:i:s');
             $dataArr['publish_date'] = date('Y-m-d H:i:s');
             $ref_nama_kegiatan = $this->model->ceck($dataArr);
         }
     } else {
     }
     exit;
 }
Exemplo n.º 26
0
 /**
  * 更新用户
  * @param $id
  * @param $data
  * @return bool
  */
 public static function updateUserInfo($id, $data)
 {
     if (!empty($id) && !empty($data)) {
         $user = self::find($id);
         $user->name = $data['name'];
         $user->email = $data['email'];
         if (!empty($data['password'])) {
             $user->password = bcrypt($data['password']);
         }
         $photo = uploadFile('img', 'photo', 'uploads');
         if (!empty($photo)) {
             $user->photo = $photo;
         }
         $user->desc = $data['desc'];
         return $user->save();
     }
     return false;
 }
Exemplo n.º 27
0
 /**
  * 实际上该函数仅作为上传文件/页面跳转/提交模式变化的功能。
  * 用户基本信息已经由saveBaseInfo完成了。
  */
 public function submitForm()
 {
     $compItemID = I('post.comp_item_id');
     $compId = I('post.comp_id');
     $fileName = $_FILES['compApplyFile']['name'];
     $fileName = explode('.', $fileName)[0];
     // 检测操作者是否是该报名的参与者。
     $this->isParticipant($compItemID);
     $status = $this->getTemplateValue($compId, 'update', true);
     $status['comp_item_id'] = $compItemID;
     //将上传的文件放置在./Public/CompItemApply目录下的$compItemID目录下,如果fileName为空,不调用此函数。
     if ($fileName != '') {
         //$fileName = iconv("UTF-8","gb2312",$fileName);
         uploadFile('./Public/CompItemApply', "/{$compItemID}/", "{$fileName}");
     }
     $this->assign($status);
     $this->display("CompApply");
 }
 function __construct()
 {
     adminGateKeeper();
     \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey());
     $container_guid = getInput("container_guid");
     $title = getInput("title");
     $description = getInput('description');
     $interval = getInput("interval");
     $price = getInput("price");
     $product = new Product();
     $product->title = $title;
     $product->description = $description;
     $product->price = $price;
     $product->container_guid = $container_guid;
     $product->interval = $interval;
     $product->access_id = "public";
     $product->save();
     $product->createAvatar();
     if (isset($_FILES["download"]) && $_FILES["download"]["name"]) {
         $file = new File();
         $file->access_id = "product";
         $file->container_guid = $product->guid;
         $guid = $file->save();
         uploadFile("download", $guid, array("zip"));
         $product->download = $guid;
     }
     if ($interval != "one_time") {
         $stripe_plan = \Stripe\Plan::create(array("amount" => $price * 100, "interval" => $interval, "name" => $title, "currency" => "usd", "id" => $product->guid));
         $id = $stripe_plan->id;
         $product->stripe_id = $id;
         $product->save();
     } else {
         // Create product and SKU in stripe
         $stripe_product = \Stripe\Product::create(array("name" => $product->title, "description" => $product->description, "shippable" => false));
         $product->stripe_product_id = $stripe_product->id;
         // Create SKU
         $stripe_sku = \Stripe\SKU::create(array("product" => $stripe_product->id, "price" => $product->price * 100, "currency" => "usd", "inventory" => array("type" => "infinite"), "metadata" => array("guid" => $product->guid)));
         $product->stripe_sku = $stripe_sku->id;
         $product->save();
     }
     new SystemMessage("Your product has been saved.");
     forward("store");
 }
Exemplo n.º 29
0
/**
 * 添加记录
 * @return string
 */
function post()
{
    if (getPostNumByUid($_SESSION['uid']) >= maxPost) {
        $msg = "你的记录总数达到上限 (" . maxPost . "条),已不能继续发布记录. <br>若有疑问请联系管理员:huang_hao521@163.com";
        return $msg;
    }
    $arr = $_POST;
    array_splice($arr, 1, 1);
    //删除数组中注册不需要用到的submit和verify元素
    $arr['date'] = date("Y-m-j" . " " . "H:i:s");
    //匹配数据库中的datetime时间格式
    $arr['uid'] = $_SESSION['uid'];
    // 判断是否有记录图片都没有
    if (empty($arr['post']) && empty($_FILES['postImage']['name'])) {
        $msg = "填写内容或添加图片后再添加!<meta http-equiv='refresh' content='1;url=user.php'/>";
        return $msg;
        exit;
    }
    $res = insert("zhx_post", $arr);
    if ($res) {
        $pmsg = "记录发布成功!";
    }
    $pid = getInsertId();
    //获取记录pid用来插入图片
    // return print_r($arr);
    //若有图片添加,则上传图片
    if (!empty($_FILES['postImage']['name'])) {
        // print_r($uploadFile);exit;
        $uploadFile = uploadFile("images/uploads/postImage/");
        if ($uploadFile && is_array($uploadFile)) {
            $album['image'] = $uploadFile[0]['name'];
            thumb("images/uploads/postImage/" . $album['image'], "images/uploads/postImage_500/" . $album['image'], 500);
            $album['pid'] = $pid;
            insert("zhx_album", $album);
            $imsg = "添加图片成功!";
        } else {
            $imsg = "添加图片失败!";
        }
    }
    $msg = $pmsg . " " . @$imsg . "<meta http-equiv='refresh' content='1;url=user.php'/>";
    return $msg;
}
Exemplo n.º 30
0
 protected static function boot()
 {
     parent::boot();
     static::addGlobalScope('content', function (Builder $builder) {
         $builder->where('types', 'advertise');
     });
     Advertise::creating(function ($advertise) {
         $advertise->image = uploadFile($advertise->image, 'advertise', 'images');
         if (Auth::user()) {
             $advertise->user_id = Auth::user()->id;
         }
         $advertise->types = 'advertise';
     });
     Advertise::updating(function ($advertise) {
         $advertise->image = uploadFile($advertise->image, 'advertise', 'images');
         if (Auth::user()) {
             $advertise->user_id = Auth::user()->id;
         }
         $advertise->types = 'advertise';
     });
 }