本文整理汇总了PHP中upload::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP upload::parse方法的具体用法?PHP upload::parse怎么用?PHP upload::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类upload
的用法示例。
在下文中一共展示了upload::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save($id = null, $data)
{
global $osC_Database, $osC_Language, $osC_Image;
if (is_numeric($id)) {
foreach ($osC_Language->getAll() as $l) {
$image_upload = new upload('image' . $l['id'], DIR_FS_CATALOG . 'images/');
if ($image_upload->exists() && $image_upload->parse() && $image_upload->save()) {
$Qdelete = $osC_Database->query('select image from :table_slide_images where image_id = :image_id and language_id=:language_id');
$Qdelete->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES);
$Qdelete->bindInt(':image_id', $id);
$Qdelete->bindValue(':language_id', $l['id']);
$Qdelete->execute();
if ($Qdelete->numberOfRows() > 0) {
@unlink(DIR_FS_CATALOG . 'images/' . $Qdelete->value('image'));
}
$Qimage = $osC_Database->query('update :table_slide_images set image = :image, description = :description, image_url = :image_url, sort_order = :sort_order, status = :status where image_id = :image_id and language_id=:language_id');
$Qimage->bindValue(':image', $image_upload->filename);
} else {
$Qimage = $osC_Database->query('update :table_slide_images set description = :description, image_url = :image_url, sort_order = :sort_order, status = :status where image_id = :image_id and language_id=:language_id');
}
$Qimage->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES);
$Qimage->bindValue(':description', $data['description'][$l['id']]);
$Qimage->bindValue(':image_url', $data['image_url'][$l['id']]);
$Qimage->bindValue(':sort_order', $data['sort_order']);
$Qimage->bindValue(':status', $data['status']);
$Qimage->bindInt(':image_id', $id);
$Qimage->bindValue(':language_id', $l['id']);
$Qimage->execute();
}
} else {
$Qmaximage = $osC_Database->query('select max(image_id) as image_id from :table_slide_images');
$Qmaximage->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES);
$Qmaximage->execute();
$image_id = $Qmaximage->valueInt('image_id') + 1;
foreach ($osC_Language->getAll() as $l) {
$products_image = new upload('image' . $l['id'], DIR_FS_CATALOG . 'images/');
if ($products_image->exists() && $products_image->parse() && $products_image->save()) {
$Qimage = $osC_Database->query('insert into :table_slide_images (image_id,language_id ,description,image ,image_url ,sort_order,status) values (:image_id,:language_id,:description ,:image,:image_url ,:sort_order,:status)');
$Qimage->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES);
$Qimage->bindValue(':image_id', $image_id);
$Qimage->bindValue(':language_id', $l['id']);
$Qimage->bindValue(':description', $data['description'][$l['id']]);
$Qimage->bindValue(':image', $products_image->filename);
$Qimage->bindValue(':image_url', $data['image_url'][$l['id']]);
$Qimage->bindValue(':sort_order', $data['sort_order']);
$Qimage->bindValue(':status', $data['status']);
$Qimage->execute();
}
}
}
if ($osC_Database->isError()) {
return false;
} else {
osC_Cache::clear('slide-images');
return true;
}
}
示例2: storeFileUpload
function storeFileUpload($file, $directory)
{
if (is_writeable($directory)) {
$upload = new upload($file, $directory);
if ($upload->exists() && $upload->parse() && $upload->save()) {
return true;
}
}
return false;
}
示例3: execute
function execute()
{
global $osC_Session, $osC_Product, $toC_Customization_Fields, $osC_Language, $messageStack;
if (!isset($osC_Product)) {
$id = false;
foreach ($_GET as $key => $value) {
if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) {
$id = $key;
}
break;
}
if ($id !== false && osC_Product::checkEntry($id)) {
$osC_Product = new osC_Product($id);
}
}
if (isset($osC_Product)) {
$errors = array();
$data = array();
$customizations = $osC_Product->getCustomizations();
foreach ($customizations as $field) {
$fields_id = $field['customization_fields_id'];
if ($field['type'] == CUSTOMIZATION_FIELD_TYPE_INPUT_TEXT) {
$value = isset($_POST['customizations'][$fields_id]) ? $_POST['customizations'][$fields_id] : null;
if ($field['is_required'] && $value == null) {
$messageStack->add_session('products_customizations', sprintf($osC_Language->get('error_customization_field_must_be_specified'), $field['name']), 'error');
} else {
if ($value != null) {
$data[$fields_id] = array('customization_fields_id' => $field['customization_fields_id'], 'customization_fields_name' => $field['name'], 'customization_type' => CUSTOMIZATION_FIELD_TYPE_INPUT_TEXT, 'customization_value' => $value);
}
}
} else {
$file = new upload('customizations_' . $fields_id, DIR_FS_CACHE . '/products_customizations/');
if ($field['is_required'] && !$file->exists() && !$toC_Customization_Fields->hasCustomizationField($osC_Product->getID(), $fields_id)) {
$messageStack->add_session('products', sprintf($osC_Language->get('error_customization_field_must_be_specified'), $field['name']), 'error');
} else {
if ($file->exists()) {
if ($file->parse() && $file->save()) {
$filename = $file->filename;
$cache_filename = md5($filename . time());
rename(DIR_FS_CACHE . '/products_customizations/' . $filename, DIR_FS_CACHE . '/products_customizations/' . $cache_filename);
$data[$fields_id] = array('customization_fields_id' => $field['customization_fields_id'], 'customization_fields_name' => $field['name'], 'customization_type' => CUSTOMIZATION_FIELD_TYPE_INPUT_FILE, 'customization_value' => $filename, 'cache_filename' => $cache_filename);
} else {
$messageStack->add_session('products_customizations', $file->getLastError(), 'error');
}
}
}
}
}
//var_dump($data);exit;
if ($messageStack->size('products_customizations') === 0) {
$toC_Customization_Fields->set($osC_Product->getID(), $data);
}
}
osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID()));
}
示例4: array
function get_upload_file($fld)
{
global $UploadCache;
if (!isset($UploadCache)) {
$UploadCache = array();
}
if (!isset($UploadCache[$fld])) {
$model_image_obj = new upload($fld);
$model_image_obj->set_destination(DIR_FS_CATALOG_IMAGES);
$UploadCache[$fld] = $model_image_obj->parse() && $model_image_obj->save() ? $model_image_obj->filename : '';
}
//echo 'get_upload_file('.$fld.")=".$UploadCache[$fld]."\n";
return $UploadCache[$fld];
}
示例5: save
public static function save($id = null, $data)
{
global $osC_Database;
$error = false;
if (empty($data['html_text']) && empty($data['image_local']) && !empty($data['image'])) {
$image = new upload($data['image'], realpath('../images/' . $data['image_target']));
if (!$image->exists() || !$image->parse() || !$image->save()) {
$error = true;
}
}
if ($error === false) {
$image_location = !empty($data['image_local']) ? $data['image_local'] : (isset($image) ? $data['image_target'] . $image->filename : null);
if (is_numeric($id)) {
$Qbanner = $osC_Database->query('update :table_banners set banners_title = :banners_title, banners_url = :banners_url, banners_image = :banners_image, banners_group = :banners_group, banners_html_text = :banners_html_text, expires_date = :expires_date, expires_impressions = :expires_impressions, date_scheduled = :date_scheduled, status = :status where banners_id = :banners_id');
$Qbanner->bindInt(':banners_id', $id);
} else {
$Qbanner = $osC_Database->query('insert into :table_banners (banners_title, banners_url, banners_image, banners_group, banners_html_text, expires_date, expires_impressions, date_scheduled, status, date_added) values (:banners_title, :banners_url, :banners_image, :banners_group, :banners_html_text, :expires_date, :expires_impressions, :date_scheduled, :status, now())');
}
$Qbanner->bindTable(':table_banners', TABLE_BANNERS);
$Qbanner->bindValue(':banners_title', $data['title']);
$Qbanner->bindValue(':banners_url', $data['url']);
$Qbanner->bindValue(':banners_image', $image_location);
$Qbanner->bindValue(':banners_group', !empty($data['group_new']) ? $data['group_new'] : $data['group']);
$Qbanner->bindValue(':banners_html_text', $data['html_text']);
if (empty($data['date_expires'])) {
$Qbanner->bindRaw(':expires_date', 'null');
$Qbanner->bindInt(':expires_impressions', $data['expires_impressions']);
} else {
$Qbanner->bindValue(':expires_date', $data['date_expires']);
$Qbanner->bindInt(':expires_impressions', 0);
}
if (empty($data['date_scheduled'])) {
$Qbanner->bindRaw(':date_scheduled', 'null');
$Qbanner->bindInt(':status', $data['status'] === true ? 1 : 0);
} else {
$Qbanner->bindValue(':date_scheduled', $data['date_scheduled']);
$Qbanner->bindInt(':status', $data['date_scheduled'] > date('Y-m-d') ? 0 : ($data['status'] === true ? 1 : 0));
}
$Qbanner->setLogging($_SESSION['module'], $id);
$Qbanner->execute();
if (!$osC_Database->isError()) {
return true;
}
}
return false;
}
示例6: mkdir
function put_logo_image($action = '')
{
$newname = DIR_FS_CATALOG . 'images/' . $this->store_id . '_images';
if (!is_dir($newname)) {
mkdir($newname);
}
$allowed_files_types = array('gif', 'jpg', 'png');
if (is_dir($newname)) {
$store_logo_image = new upload($this->store_logo);
$store_logo_image->set_destination($newname);
$store_logo_image->set_extensions($allowed_files_types);
$parsed = $store_logo_image->parse();
if (!$parsed && $action == '') {
if (copy(DIR_FS_CATALOG . 'images/store_images/default/default_store_logo.gif', $newname . '/default_store_logo.gif')) {
smn_db_query("update " . TABLE_STORE_MAIN . " set store_image = 'default_store_logo.gif' where store_id = '" . (int) $this->store_id . "'");
}
} else {
if ($store_logo_image->file['size'] > MAX_IMAGE_FILE_SIZE && $parsed) {
if (copy(DIR_FS_CATALOG . 'images/store_images/default/default_store_logo.gif', $newname . '/default_store_logo.gif')) {
smn_db_query("update " . TABLE_STORE_MAIN . " set store_image = 'default_store_logo.gif' where store_id = '" . (int) $this->store_id . "'");
}
return sprintf(ERROR_IMAGE_FILE_SIZE_EXCEED, MAX_IMAGE_FILE_SIZE);
} elseif ($parsed) {
$ext = substr($store_logo_image->filename, -4);
$store_logo_image->set_filename('logo' . $ext);
$saved = $store_logo_image->save();
if ($saved) {
smn_db_query("update " . TABLE_STORE_MAIN . " set store_image = '" . $store_logo_image->filename . "' where store_id = '" . (int) $this->store_id . "'");
} elseif ($action == '') {
$this->store_logo_image_name = '';
if (copy(DIR_FS_CATALOG . 'images/store_images/default/default_store_logo.gif', $newname . '/default_store_logo.gif')) {
smn_db_query("update " . TABLE_STORE_MAIN . " set store_image = 'default_store_logo.gif' where store_id = '" . (int) $this->store_id . "'");
}
}
}
}
} else {
return ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST;
}
return '';
}
示例7: upload
function upload()
{
$logo_image = new upload('logo_image');
if ($logo_image->exists()) {
self::deleteLogo('originals');
$img_type = substr($_FILES['logo_image']['name'], strrpos($_FILES['logo_image']['name'], '.') + 1);
$original = DIR_FS_CATALOG . DIR_WS_IMAGES . 'logo_originals.' . $img_type;
$logo_image->set_destination(realpath(DIR_FS_CATALOG . 'images/'));
if ($logo_image->parse() && $logo_image->save()) {
copy(DIR_FS_CATALOG . 'images/' . $logo_image->filename, $original);
@unlink(DIR_FS_CATALOG . 'images/' . $logo_image->filename);
$osC_DirectoryListing = new osC_DirectoryListing('../templates');
$osC_DirectoryListing->setIncludeDirectories(true);
$osC_DirectoryListing->setIncludeFiles(false);
$osC_DirectoryListing->setExcludeEntries('system');
$templates = $osC_DirectoryListing->getFiles();
foreach ($templates as $template) {
$code = $template['name'];
if (file_exists('../templates/' . $code . '/template.php')) {
include '../templates/' . $code . '/template.php';
$class = 'osC_Template_' . $code;
self::deleteLogo($code);
if (class_exists($class)) {
$module = new $class();
$logo_height = $module->getLogoHeight();
$logo_width = $module->getLogoWidth();
$dest_image = DIR_FS_CATALOG . DIR_WS_IMAGES . 'logo_' . $code . '.' . $img_type;
osc_gd_resize($original, $dest_image, $logo_width, $logo_height);
}
}
}
return true;
}
}
return false;
}
示例8: array
smn_reset_cache_block('also_purchased');
}
}
smn_redirect(html_entity_decode(smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, 'cPath=' . $categories_id . '&ID='.$store_id.'&pID=' . $products_id)));
break;
case 'new_product_preview':
if (! checkVoucherPermissions($store_id, $_POST['products_model'])) {
$messageStack->add(ERROR_VENDORS_CANT_ADD_VOUCHERS, 'error');
$allow_insert = 'false';
} else {
// copy image only if modified
$allowed_files_types = array('gif', 'jpg', 'jpeg', 'png');
$products_image = new upload('products_image');
$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
$products_image->set_extensions($allowed_files_types);
if ($products_image->parse() && $products_image->save()) {
$products_image_name = $products_image->filename;
} else {
$products_image_name = (isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '');
}
}
break;
}
}
// check if the catalog image directory exists
if (is_dir(DIR_FS_CATALOG_IMAGES)) {
if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
} else {
$messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
}
示例9: array
}
$manufacturers_name = tep_db_prepare_input($HTTP_POST_VARS['manufacturers_name']);
$sql_data_array = array('manufacturers_name' => $manufacturers_name);
if ($action == 'insert') {
$insert_sql_data = array('date_added' => 'now()');
$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
tep_db_perform(TABLE_MANUFACTURERS, $sql_data_array);
$manufacturers_id = tep_db_insert_id();
} elseif ($action == 'save') {
$update_sql_data = array('last_modified' => 'now()');
$sql_data_array = array_merge($sql_data_array, $update_sql_data);
tep_db_perform(TABLE_MANUFACTURERS, $sql_data_array, 'update', "manufacturers_id = '" . (int) $manufacturers_id . "'");
}
$manufacturers_image = new upload('manufacturers_image');
$manufacturers_image->set_destination(DIR_FS_CATALOG_IMAGES);
if ($manufacturers_image->parse() && $manufacturers_image->save()) {
tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . tep_db_input($manufacturers_image->filename) . "' where manufacturers_id = '" . (int) $manufacturers_id . "'");
}
$languages = tep_get_languages();
for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
$manufacturers_url_array = $HTTP_POST_VARS['manufacturers_url'];
$language_id = $languages[$i]['id'];
$sql_data_array = array('manufacturers_url' => tep_db_prepare_input($manufacturers_url_array[$language_id]));
if ($action == 'insert') {
$insert_sql_data = array('manufacturers_id' => $manufacturers_id, 'languages_id' => $language_id);
$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
tep_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array);
} elseif ($action == 'save') {
tep_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array, 'update', "manufacturers_id = '" . (int) $manufacturers_id . "' and languages_id = '" . (int) $language_id . "'");
}
}
示例10: actionAddProduct
/**
* Method to handle cart Action - add product
*
* @param string forward destination
* @param url parameters
*/
function actionAddProduct($goto, $parameters)
{
global $db, $messageStack;
if ($this->display_debug_messages) {
$messageStack->add_session('header', 'A: FUNCTION ' . __FUNCTION__, 'caution');
}
if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
// verify attributes and quantity first
if ($this->display_debug_messages) {
$messageStack->add_session('header', 'A2: FUNCTION ' . __FUNCTION__, 'caution');
}
$the_list = '';
$adjust_max = 'false';
if (isset($_POST['id'])) {
foreach ($_POST['id'] as $key => $value) {
$check = zen_get_attributes_valid($_POST['products_id'], $key, $value);
if ($check == false) {
$the_list .= TEXT_ERROR_OPTION_FOR . '<span class="alertBlack">' . zen_options_name($key) . '</span>' . TEXT_INVALID_SELECTION . '<span class="alertBlack">' . ($value == (int) PRODUCTS_OPTIONS_VALUES_TEXT_ID ? TEXT_INVALID_USER_INPUT : zen_values_name($value)) . '</span>' . '<br />';
}
}
}
if (!is_numeric($_POST['cart_quantity']) || $_POST['cart_quantity'] < 0) {
// adjust quantity when not a value
$chk_link = '<a href="' . zen_href_link(zen_get_info_page($_POST['products_id']), 'cPath=' . zen_get_generated_category_path_rev(zen_get_products_category_id($_POST['products_id'])) . '&products_id=' . $_POST['products_id']) . '">' . zen_get_products_name($_POST['products_id']) . '</a>';
$messageStack->add_session('header', ERROR_CORRECTIONS_HEADING . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . $chk_link . ' ' . PRODUCTS_ORDER_QTY_TEXT . zen_output_string_protected($_POST['cart_quantity']), 'caution');
$_POST['cart_quantity'] = 0;
}
// verify qty to add
$add_max = zen_get_products_quantity_order_max($_POST['products_id']);
$cart_qty = $this->in_cart_mixed($_POST['products_id']);
if ($this->display_debug_messages) {
$messageStack->add_session('header', 'B: FUNCTION ' . __FUNCTION__ . ' Products_id: ' . $_POST['products_id'] . ' cart_qty: ' . $cart_qty . ' $_POST[cart_quantity]: ' . $_POST['cart_quantity'] . ' <br>', 'caution');
}
$new_qty = $_POST['cart_quantity'];
$new_qty = $this->adjust_quantity($new_qty, $_POST['products_id'], 'shopping_cart');
// bof: adjust new quantity to be same as current in stock
$chk_current_qty = zen_get_products_stock($_POST['products_id']);
$this->flag_duplicate_msgs_set = FALSE;
if (STOCK_ALLOW_CHECKOUT == 'false' && $cart_qty + $new_qty > $chk_current_qty) {
$new_qty = $chk_current_qty;
$messageStack->add_session('shopping_cart', ($this->display_debug_messages ? 'C: FUNCTION ' . __FUNCTION__ . ': ' : '') . WARNING_PRODUCT_QUANTITY_ADJUSTED . zen_get_products_name($_POST['products_id']), 'caution');
$this->flag_duplicate_msgs_set = TRUE;
}
// eof: adjust new quantity to be same as current in stock
if ($add_max == 1 and $cart_qty == 1) {
// do not add
$new_qty = 0;
$adjust_max = 'true';
} else {
// bof: adjust new quantity to be same as current in stock
if (STOCK_ALLOW_CHECKOUT == 'false' && $new_qty + $cart_qty > $chk_current_qty) {
$adjust_new_qty = 'true';
$alter_qty = $chk_current_qty - $cart_qty;
$new_qty = $alter_qty > 0 ? $alter_qty : 0;
if (!$this->flag_duplicate_msgs_set) {
$messageStack->add_session('shopping_cart', ($this->display_debug_messages ? 'D: FUNCTION ' . __FUNCTION__ . ': ' : '') . WARNING_PRODUCT_QUANTITY_ADJUSTED . zen_get_products_name($_POST['products_id']), 'caution');
}
}
// eof: adjust new quantity to be same as current in stock
// adjust quantity if needed
if ($new_qty + $cart_qty > $add_max and $add_max != 0) {
$adjust_max = 'true';
$new_qty = $add_max - $cart_qty;
}
}
if (zen_get_products_quantity_order_max($_POST['products_id']) == 1 and $this->in_cart_mixed($_POST['products_id']) == 1) {
// do not add
} else {
// process normally
// bof: set error message
if ($the_list != '') {
$messageStack->add('product_info', ERROR_CORRECTIONS_HEADING . $the_list, 'caution');
} else {
// process normally
// iii 030813 added: File uploading: save uploaded files with unique file names
$real_ids = isset($_POST['id']) ? $_POST['id'] : "";
if (isset($_GET['number_of_uploads']) && $_GET['number_of_uploads'] > 0) {
/**
* Need the upload class for attribute type that allows user uploads.
*
*/
include DIR_WS_CLASSES . 'upload.php';
for ($i = 1, $n = $_GET['number_of_uploads']; $i <= $n; $i++) {
if (zen_not_null($_FILES['id']['tmp_name'][TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]]) and $_FILES['id']['tmp_name'][TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] != 'none') {
$products_options_file = new upload('id');
$products_options_file->set_destination(DIR_FS_UPLOADS);
$products_options_file->set_output_messages('session');
if ($products_options_file->parse(TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i])) {
$products_image_extension = substr($products_options_file->filename, strrpos($products_options_file->filename, '.'));
if ($_SESSION['customer_id']) {
$db->Execute("insert into " . TABLE_FILES_UPLOADED . " (sesskey, customers_id, files_uploaded_name) values('" . zen_session_id() . "', '" . $_SESSION['customer_id'] . "', '" . zen_db_input($products_options_file->filename) . "')");
} else {
$db->Execute("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name) values('" . zen_session_id() . "', '" . zen_db_input($products_options_file->filename) . "')");
}
//.........这里部分代码省略.........
示例11: fputs
if (is_writable($_SESSION['current_path']) && ($fp = fopen($_SESSION['current_path'] . '/' . basename($_POST['filename']), 'w+'))) {
fputs($fp, stripslashes($_POST['file_contents']));
fclose($fp);
xos_redirect(xos_href_link(FILENAME_FILE_MANAGER, 'info=' . urlencode(basename($_POST['filename']))));
}
} else {
$action = 'new_file';
$directory_writeable = true;
$messageStack->add('header', ERROR_FILENAME_EMPTY, 'error');
}
break;
case 'processuploads':
for ($i = 1; $i < 6; $i++) {
if (!empty($_FILES['file_' . $i]['name'])) {
$upload = new upload('file_' . $i, $_SESSION['current_path'], '644');
$upload->parse();
$upload->save();
}
}
xos_redirect(xos_href_link(FILENAME_FILE_MANAGER));
break;
case 'download':
header_remove();
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . @filesize($_SESSION['current_path'] . '/' . urldecode($_GET['filename'])));
header('Content-Disposition: attachment; filename="' . urldecode($_GET['filename']) . '"');
示例12: save
//.........这里部分代码省略.........
$Qinsert->bindTable(':table_products_accessories', TABLE_PRODUCTS_ACCESSORIES);
$Qinsert->bindInt(':products_id', $products_id);
$Qinsert->bindInt(':accessories_id', $accessories_id);
$Qinsert->setLogging($_SESSION['module'], $products_id);
$Qinsert->execute();
if ($osC_Database->isError()) {
$error = true;
break;
}
}
}
}
//downloadable products & gift certificates
if ($data['products_type'] == PRODUCT_TYPE_DOWNLOADABLE) {
if (is_numeric($id)) {
$Qdownloadables = $osC_Database->query('update :table_products_downloadables set number_of_downloads = :number_of_downloads, number_of_accessible_days = :number_of_accessible_days where products_id = :products_id');
} else {
$Qdownloadables = $osC_Database->query('insert into :table_products_downloadables (products_id, number_of_downloads, number_of_accessible_days) values (:products_id, :number_of_downloads, :number_of_accessible_days)');
}
$Qdownloadables->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
$Qdownloadables->bindInt(':products_id', $products_id);
$Qdownloadables->bindInt(':number_of_downloads', $data['number_of_downloads']);
$Qdownloadables->bindInt(':number_of_accessible_days', $data['number_of_accessible_days']);
$Qdownloadables->setLogging($_SESSION['module'], $products_id);
$Qdownloadables->execute();
if ($osC_Database->isError()) {
$error = true;
} else {
$filename = null;
$cache_filename = null;
$file = new upload('downloadable_file');
if ($file->exists()) {
$file->set_destination(realpath('../download'));
if ($file->parse() && $file->save()) {
$filename = $file->filename;
$cache_filename = md5($filename . time());
rename(DIR_FS_DOWNLOAD . $filename, DIR_FS_DOWNLOAD . $cache_filename);
}
}
if (!is_null($filename)) {
if (is_numeric($id)) {
$Qfile = $osC_Database->query('select cache_filename from :table_products_downloadables where products_id = :products_id');
$Qfile->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
$Qfile->bindInt(':products_id', $products_id);
$Qfile->execute();
if ($Qfile->numberOfRows() > 0) {
$file = $Qfile->value('cache_filename');
unlink(DIR_FS_DOWNLOAD . $file);
}
}
$Qupdate = $osC_Database->query('update :table_products_downloadables set filename = :filename, cache_filename = :cache_filename where products_id = :products_id');
$Qupdate->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
$Qupdate->bindInt(':products_id', $products_id);
$Qupdate->bindValue(':filename', $filename);
$Qupdate->bindValue(':cache_filename', $cache_filename);
$Qupdate->setLogging($_SESSION['module'], $products_id);
$Qupdate->execute();
if ($osC_Database->isError()) {
$error = true;
}
}
if ($error === false) {
$sample_filename = null;
$cache_sample_filename = null;
$sample_file = new upload('sample_downloadable_file');
if ($sample_file->exists()) {
示例13: elseif
$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
zen_db_perform(TABLE_RECORD_ARTISTS, $sql_data_array);
$artists_id = zen_db_insert_id();
} elseif ($action == 'save') {
$update_sql_data = array('last_modified' => 'now()');
$sql_data_array = array_merge($sql_data_array, $update_sql_data);
zen_db_perform(TABLE_RECORD_ARTISTS, $sql_data_array, 'update', "artists_id = '" . (int) $artists_id . "'");
}
if ($_POST['artists_image_manual'] != '') {
// add image manually
$artists_image_name = zen_db_input($_POST['img_dir'] . $_POST['artists_image_manual']);
$db->Execute("update " . TABLE_RECORD_ARTISTS . "\r\n set artists_image = '" . $artists_image_name . "'\r\n where artists_id = '" . (int) $artists_id . "'");
} else {
$artists_image = new upload('artists_image');
$artists_image->set_destination(DIR_FS_CATALOG_IMAGES . $_POST['img_dir']);
if ($artists_image->parse() && $artists_image->save()) {
// remove image from database if none
if ($artists_image->filename != 'none') {
$db->Execute("update " . TABLE_RECORD_ARTISTS . "\r\n set artists_image = '" . zen_db_input($_POST['img_dir'] . $artists_image->filename) . "'\r\n where artists_id = '" . (int) $artists_id . "'");
} else {
$db->Execute("update " . TABLE_RECORD_ARTISTS . "\r\n set artists_image = ''\r\n where artists_id = '" . (int) $artists_id . "'");
}
}
}
$languages = zen_get_languages();
for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
$artists_url_array = $_POST['artists_url'];
$language_id = $languages[$i]['id'];
$sql_data_array = array('artists_url' => zen_db_prepare_input($artists_url_array[$language_id]));
if ($action == 'insert') {
$insert_sql_data = array('artists_id' => $artists_id, 'languages_id' => $language_id);
示例14: save
function save($id = null, $data)
{
global $osC_Database, $osC_Language;
$category_id = '';
$error = false;
$osC_Database->startTransaction();
if (is_numeric($id)) {
$Qcat = $osC_Database->query('update :table_categories set categories_status = :categories_status, sort_order = :sort_order, last_modified = now() where categories_id = :categories_id');
$Qcat->bindInt(':categories_id', $id);
} else {
$Qcat = $osC_Database->query('insert into :table_categories (parent_id, categories_status, sort_order, date_added) values (:parent_id, :categories_status, :sort_order, now())');
$Qcat->bindInt(':parent_id', $data['parent_id']);
}
$Qcat->bindTable(':table_categories', TABLE_CATEGORIES);
$Qcat->bindInt(':sort_order', $data['sort_order']);
$Qcat->bindInt(':categories_status', $data['categories_status']);
$Qcat->setLogging($_SESSION['module'], $id);
$Qcat->execute();
if (!$osC_Database->isError()) {
$category_id = is_numeric($id) ? $id : $osC_Database->nextID();
if (is_numeric($id)) {
if ($data['categories_status']) {
$Qpstatus = $osC_Database->query('update :table_products set products_status = 1 where products_id in (select products_id from :table_products_to_categories where categories_id = :categories_id)');
$Qpstatus->bindTable(':table_products', TABLE_PRODUCTS);
$Qpstatus->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
$Qpstatus->bindInt(":categories_id", $id);
$Qpstatus->execute();
} else {
if ($data['flag']) {
$Qpstatus = $osC_Database->query('update :table_products set products_status = 0 where products_id in (select products_id from :table_products_to_categories where categories_id = :categories_id)');
$Qpstatus->bindTable(':table_products', TABLE_PRODUCTS);
$Qpstatus->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
$Qpstatus->bindInt(":categories_id", $id);
$Qpstatus->execute();
}
}
}
if ($osC_Database->isError()) {
$error = true;
}
foreach ($osC_Language->getAll() as $l) {
if (is_numeric($id)) {
$Qcd = $osC_Database->query('update :table_categories_description set categories_name = :categories_name, categories_url = :categories_url, categories_page_title = :categories_page_title, categories_meta_keywords = :categories_meta_keywords, categories_meta_description = :categories_meta_description where categories_id = :categories_id and language_id = :language_id');
} else {
$Qcd = $osC_Database->query('insert into :table_categories_description (categories_id, language_id, categories_name, categories_url, categories_page_title, categories_meta_keywords, categories_meta_description) values (:categories_id, :language_id, :categories_name, :categories_url, :categories_page_title, :categories_meta_keywords, :categories_meta_description)');
}
$Qcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
$Qcd->bindInt(':categories_id', $category_id);
$Qcd->bindInt(':language_id', $l['id']);
$Qcd->bindValue(':categories_name', $data['name'][$l['id']]);
$Qcd->bindValue(':categories_url', $data['url'][$l['id']] == '' ? $data['name'][$l['id']] : $data['url'][$l['id']]);
$Qcd->bindValue(':categories_page_title', $data['page_title'][$l['id']]);
$Qcd->bindValue(':categories_meta_keywords', $data['meta_keywords'][$l['id']]);
$Qcd->bindValue(':categories_meta_description', $data['meta_description'][$l['id']]);
$Qcd->setLogging($_SESSION['module'], $category_id);
$Qcd->execute();
if ($osC_Database->isError()) {
$error = true;
break;
}
}
$Qdelete = $osC_Database->query('delete from :toc_categories_ratings where categories_id = :categories_id');
$Qdelete->bindTable(':toc_categories_ratings', TABLE_CATEGORIES_RATINGS);
$Qdelete->bindInt(':categories_id', $category_id);
$Qdelete->execute();
if (!empty($data['ratings'])) {
$ratings = explode(',', $data['ratings']);
foreach ($ratings as $ratings_id) {
$Qinsert = $osC_Database->query('insert into :toc_categories_ratings (categories_id, ratings_id) values (:categories_id, :ratings_id)');
$Qinsert->bindTable(':toc_categories_ratings', TABLE_CATEGORIES_RATINGS);
$Qinsert->bindInt(':categories_id', $category_id);
$Qinsert->bindInt(':ratings_id', $ratings_id);
$Qinsert->execute();
if ($osC_Database->isError()) {
$error = true;
break;
}
}
}
if ($error === false) {
$categories_image = new upload($data['image'], realpath('../' . DIR_WS_IMAGES . 'categories'));
if ($categories_image->exists() && $categories_image->parse() && $categories_image->save()) {
$Qimage = $osC_Database->query('select categories_image from :table_categories where categories_id = :categories_id');
$Qimage->bindTable(':table_categories', TABLE_CATEGORIES);
$Qimage->bindInt(':categories_id', $category_id);
$Qimage->execute();
$old_image = $Qimage->value('categories_image');
if (!empty($old_image)) {
$Qcheck = $osC_Database->query('select count(*) as image_count from :table_categories where categories_image = :categories_image');
$Qcheck->bindTable(':table_categories', TABLE_CATEGORIES);
$Qcheck->bindValue(':categories_image', $old_image);
$Qcheck->execute();
if ($Qcheck->valueInt('image_count') == 1) {
$path = realpath('../' . DIR_WS_IMAGES . 'categories') . '/' . $old_image;
unlink($path);
}
}
$Qcf = $osC_Database->query('update :table_categories set categories_image = :categories_image where categories_id = :categories_id');
$Qcf->bindTable(':table_categories', TABLE_CATEGORIES);
$Qcf->bindValue(':categories_image', $categories_image->filename);
//.........这里部分代码省略.........
示例15: intval
}
if (isset($_POST['action']) && $_POST['action'] == 'add_customers_image' && (isset($_SESSION['formid']) && $_SESSION['formid'] == $_POST['formid'])) {
if ($_POST['remove_image'] == 'yes' && isset($_SESSION['customer_id'])) {
$customerstable = $oostable['customers'];
$query = "SELECT customers_image\n FROM {$customerstable}\n WHERE customers_id = '" . intval($_SESSION['customer_id']) . "'";
$customers_image = $dbconn->GetOne($query);
@unlink(OOS_ABSOLUTE_PATH . OOS_IMAGES . OOS_CUSTOMERS_IMAGES . $customers_image);
$customerstable = $oostable['customers'];
$query = "UPDATE {$customerstable}" . " SET customers_image = ?" . " WHERE customers_id = ?";
$result =& $dbconn->Execute($query, array('', (int) $_SESSION['customer_id']));
}
require_once 'includes/classes/class_upload.php';
if (oos_is_not_null($_FILES['id']['tmp_name']) and $_FILES['id']['tmp_name'] != 'none') {
$customers_image_file = new upload('id');
$customers_image_file->set_destination(OOS_ABSOLUTE_PATH . OOS_IMAGES . OOS_CUSTOMERS_IMAGES);
if ($customers_image_file->parse()) {
if (isset($_SESSION['customer_id'])) {
$extension = oos_get_extension($_FILES['id']['name']);
$picture_tempname = oos_get_random_picture_name(26, $extension);
$customers_image_file->set_filename($picture_tempname);
$customerstable = $oostable['customers'];
$query = "UPDATE {$customerstable}" . " SET customers_image = ?" . " WHERE customers_id = ?";
$result =& $dbconn->Execute($query, array((string) $picture_tempname, (int) $_SESSION['customer_id']));
$customers_image_file->save();
}
}
}
}
require 'includes/languages/' . $sLanguage . '/user_customers_image.php';
$customerstable = $oostable['customers'];
$address_bookstable = $oostable['address_book'];