本文整理汇总了PHP中upload::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP upload::exists方法的具体用法?PHP upload::exists怎么用?PHP upload::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类upload
的用法示例。
在下文中一共展示了upload::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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()));
}
示例2: 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;
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
//.........这里部分代码省略.........
示例7: uploadAttachment
function uploadAttachment()
{
global $toC_Json, $osC_Language, $osC_Session;
$error = false;
$path = DIR_FS_CACHE_ADMIN . 'emails/attachments/' . $osC_Session->getID();
if (!file_exists($path)) {
if (!mkdir($path, 0777)) {
$error = true;
}
}
if ($error === false) {
$attachment = new upload('file_upload', $path);
if (!($attachment->exists() && $attachment->parse() && $attachment->save())) {
$error = true;
}
}
if ($error === false) {
$response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
} else {
$response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed'));
}
header('Content-type:text/html');
echo $toC_Json->encode($response);
}
示例8: save
//.........这里部分代码省略.........
foreach ($data['accessories_ids'] as $accessories_id) {
$Qinsert = $osC_Database->query('insert into :table_products_accessories (products_id, accessories_id) values (:products_id, :accessories_id)');
$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;
示例9: save
public static function save($id = null, $data)
{
global $osC_Database, $osC_Language, $osC_Image;
$error = false;
$osC_Database->startTransaction();
if (is_numeric($id)) {
$Qproduct = $osC_Database->query('update :table_products set products_quantity = :products_quantity, products_price = :products_price, products_model = :products_model, products_weight = :products_weight, products_weight_class = :products_weight_class, products_status = :products_status, products_tax_class_id = :products_tax_class_id, products_last_modified = now() where products_id = :products_id');
$Qproduct->bindInt(':products_id', $id);
} else {
$Qproduct = $osC_Database->query('insert into :table_products (products_quantity, products_price, products_model, products_weight, products_weight_class, products_status, products_tax_class_id, products_date_added) values (:products_quantity, :products_price, :products_model, :products_weight, :products_weight_class, :products_status, :products_tax_class_id, :products_date_added)');
$Qproduct->bindRaw(':products_date_added', 'now()');
}
$Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
$Qproduct->bindInt(':products_quantity', $data['quantity']);
$Qproduct->bindFloat(':products_price', $data['price']);
$Qproduct->bindValue(':products_model', $data['model']);
$Qproduct->bindFloat(':products_weight', $data['weight']);
$Qproduct->bindInt(':products_weight_class', $data['weight_class']);
$Qproduct->bindInt(':products_status', $data['status']);
$Qproduct->bindInt(':products_tax_class_id', $data['tax_class_id']);
// $Qproduct->setLogging($_SESSION['module'], $id);
$Qproduct->execute();
if ($osC_Database->isError()) {
$error = true;
} else {
if (is_numeric($id)) {
$products_id = $id;
} else {
$products_id = $osC_Database->nextID();
}
$Qcategories = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id');
$Qcategories->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
$Qcategories->bindInt(':products_id', $products_id);
// $Qcategories->setLogging($_SESSION['module'], $products_id);
$Qcategories->execute();
if ($osC_Database->isError()) {
$error = true;
} else {
if (isset($data['categories']) && !empty($data['categories'])) {
foreach ($data['categories'] as $category_id) {
$Qp2c = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');
$Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
$Qp2c->bindInt(':products_id', $products_id);
$Qp2c->bindInt(':categories_id', $category_id);
// $Qp2c->setLogging($_SESSION['module'], $products_id);
$Qp2c->execute();
if ($osC_Database->isError()) {
$error = true;
break;
}
}
}
}
}
if ($error === false) {
$images = array();
$products_image = new upload('products_image');
$products_image->set_extensions(array('gif', 'jpg', 'jpeg', 'png'));
if ($products_image->exists()) {
$products_image->set_destination(realpath('../images/products/originals'));
if ($products_image->parse() && $products_image->save()) {
$images[] = $products_image->filename;
}
}
if (isset($data['localimages'])) {
foreach ($data['localimages'] as $image) {
$image = basename($image);
if (file_exists('../images/products/_upload/' . $image)) {
copy('../images/products/_upload/' . $image, '../images/products/originals/' . $image);
@unlink('../images/products/_upload/' . $image);
$images[] = $image;
}
}
}
$default_flag = 1;
foreach ($images as $image) {
$Qimage = $osC_Database->query('insert into :table_products_images (products_id, image, default_flag, sort_order, date_added) values (:products_id, :image, :default_flag, :sort_order, :date_added)');
$Qimage->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
$Qimage->bindInt(':products_id', $products_id);
$Qimage->bindValue(':image', $image);
$Qimage->bindInt(':default_flag', $default_flag);
$Qimage->bindInt(':sort_order', 0);
$Qimage->bindRaw(':date_added', 'now()');
// $Qimage->setLogging($_SESSION['module'], $products_id);
$Qimage->execute();
if ($osC_Database->isError()) {
$error = true;
} else {
foreach ($osC_Image->getGroups() as $group) {
if ($group['id'] != '1') {
$osC_Image->resize($image, $group['id']);
}
}
}
$default_flag = 0;
}
}
if ($error === false) {
foreach ($osC_Language->getAll() as $l) {
if (is_numeric($id)) {
//.........这里部分代码省略.........
示例10: upload
function osC_Products_Importer($parameters)
{
parent::toC_Importer($parameters);
if (!empty($parameters['image_file'])) {
$this->_image_file = $parameters['image_file'];
$temp_file = new upload($this->_image_file, DIR_FS_CACHE);
if ($temp_file->exists() && $temp_file->parse() && $temp_file->save()) {
require_once '../ext/zip/pclzip.lib.php';
$archive = new PclZip($temp_file->destination . $temp_file->filename);
$path = realpath($temp_file->destination . $temp_file->filename);
if ($archive->extract(PCLZIP_OPT_PATH, realpath(DIR_FS_CATALOG . DIR_WS_IMAGES . 'products/_upload/')) == 0) {
return false;
} else {
@unlink($path);
}
}
}
}
示例11: save
function save($id = null, $data)
{
global $osC_Database, $osC_Language, $osC_Image;
$error = false;
$osC_Database->startTransaction();
//products
if (is_numeric($id)) {
$Qproduct = $osC_Database->query('update :table_products set products_type = :products_type, products_sku = :products_sku, products_model = :products_model, products_price = :products_price, products_quantity = :products_quantity, products_moq = :products_moq, products_max_order_quantity = :products_max_order_quantity, order_increment = :order_increment, quantity_unit_class = :quantity_unit_class, products_date_available = :products_date_available, products_weight = :products_weight, products_weight_class = :products_weight_class, products_status = :products_status, products_tax_class_id = :products_tax_class_id, manufacturers_id = :manufacturers_id, quantity_discount_groups_id = :quantity_discount_groups_id, products_last_modified = now(), products_attributes_groups_id = :products_attributes_groups_id where products_id = :products_id');
$Qproduct->bindInt(':products_id', $id);
} else {
$Qproduct = $osC_Database->query('insert into :table_products (products_type, products_sku, products_model, products_price, products_quantity, products_moq, products_max_order_quantity, order_increment, quantity_unit_class, products_date_available, products_weight, products_weight_class, products_status, products_tax_class_id, manufacturers_id, products_date_added, quantity_discount_groups_id, products_attributes_groups_id) values (:products_type, :products_sku, :products_model, :products_price, :products_quantity, :products_moq, :products_max_order_quantity, :order_increment, :quantity_unit_class, :products_date_available, :products_weight, :products_weight_class, :products_status, :products_tax_class_id, :manufacturers_id, :products_date_added, :quantity_discount_groups_id, :products_attributes_groups_id)');
$Qproduct->bindRaw(':products_date_added', 'now()');
}
$Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
$Qproduct->bindInt(':products_type', $data['products_type']);
$Qproduct->bindValue(':products_sku', $data['products_sku']);
$Qproduct->bindValue(':products_model', $data['products_model']);
$Qproduct->bindValue(':products_price', $data['price']);
$Qproduct->bindInt(':products_quantity', $data['quantity']);
$Qproduct->bindInt(':products_moq', $data['products_moq']);
$Qproduct->bindInt(':products_max_order_quantity', $data['products_max_order_quantity']);
$Qproduct->bindInt(':order_increment', $data['order_increment']);
$Qproduct->bindInt(':quantity_unit_class', $data['quantity_unit_class']);
if (date('Y-m-d') < $data['date_available']) {
$Qproduct->bindValue(':products_date_available', $data['date_available']);
} else {
$Qproduct->bindRaw(':products_date_available', 'null');
}
$Qproduct->bindValue(':products_weight', $data['weight']);
$Qproduct->bindInt(':products_weight_class', $data['weight_class']);
$Qproduct->bindInt(':products_status', $data['status']);
$Qproduct->bindInt(':products_tax_class_id', $data['tax_class_id']);
$Qproduct->bindInt(':manufacturers_id', $data['manufacturers_id']);
$Qproduct->bindInt(':quantity_discount_groups_id', $data['quantity_discount_groups_id']);
if (empty($data['products_attributes_groups_id'])) {
$Qproduct->bindRaw(':products_attributes_groups_id', 'null');
} else {
$Qproduct->bindInt(':products_attributes_groups_id', $data['products_attributes_groups_id']);
}
$Qproduct->setLogging($_SESSION['module'], $id);
$Qproduct->execute();
if ($osC_Database->isError()) {
$error = true;
} else {
if (is_numeric($id)) {
$products_id = $id;
} else {
$products_id = $osC_Database->nextID();
}
//products_to_categories
$Qcategories = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id');
$Qcategories->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
$Qcategories->bindInt(':products_id', $products_id);
$Qcategories->setLogging($_SESSION['module'], $products_id);
$Qcategories->execute();
if ($osC_Database->isError()) {
$error = true;
} else {
if (isset($data['categories']) && !empty($data['categories'])) {
foreach ($data['categories'] as $category_id) {
$Qp2c = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');
$Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
$Qp2c->bindInt(':products_id', $products_id);
$Qp2c->bindInt(':categories_id', $category_id);
$Qp2c->setLogging($_SESSION['module'], $products_id);
$Qp2c->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);
}
//.........这里部分代码省略.........
示例12: save
function save($id = null, $data)
{
global $osC_Database, $osC_Language;
$error = false;
$osC_Database->startTransaction();
if (is_numeric($id)) {
$Qmanufacturer = $osC_Database->query('update :table_manufacturers set manufacturers_name = :manufacturers_name, last_modified = now() where manufacturers_id = :manufacturers_id');
$Qmanufacturer->bindInt(':manufacturers_id', $id);
} else {
$Qmanufacturer = $osC_Database->query('insert into :table_manufacturers (manufacturers_name, date_added) values (:manufacturers_name, now())');
}
$Qmanufacturer->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
$Qmanufacturer->bindValue(':manufacturers_name', $data['name']);
$Qmanufacturer->setLogging($_SESSION['module'], $id);
$Qmanufacturer->execute();
if (!$osC_Database->isError()) {
if (is_numeric($id)) {
$manufacturers_id = $id;
} else {
$manufacturers_id = $osC_Database->nextID();
}
$image = new upload('manufacturers_image', realpath('../' . DIR_WS_IMAGES . 'manufacturers'));
if ($image->exists()) {
if ($image->parse() && $image->save()) {
$Qimage = $osC_Database->query('update :table_manufacturers set manufacturers_image = :manufacturers_image where manufacturers_id = :manufacturers_id');
$Qimage->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
$Qimage->bindValue(':manufacturers_image', $image->filename);
$Qimage->bindInt(':manufacturers_id', $manufacturers_id);
$Qimage->setLogging($_SESSION['module'], $manufacturers_id);
$Qimage->execute();
if ($osC_Database->isError()) {
$error = true;
}
}
}
} else {
$error = true;
}
if ($error === false) {
foreach ($osC_Language->getAll() as $l) {
if (is_numeric($id)) {
$Qurl = $osC_Database->query('update :table_manufacturers_info set manufacturers_url = :manufacturers_url where manufacturers_id = :manufacturers_id and languages_id = :languages_id');
} else {
$Qurl = $osC_Database->query('insert into :table_manufacturers_info (manufacturers_id, languages_id, manufacturers_url) values (:manufacturers_id, :languages_id, :manufacturers_url)');
}
$Qurl->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO);
$Qurl->bindInt(':manufacturers_id', $manufacturers_id);
$Qurl->bindInt(':languages_id', $l['id']);
$Qurl->bindValue(':manufacturers_url', $data['url'][$l['id']]);
$Qurl->setLogging($_SESSION['module'], $manufacturers_id);
$Qurl->execute();
if ($osC_Database->isError()) {
$error = true;
break;
}
}
}
if ($error === false) {
$osC_Database->commitTransaction();
osC_Cache::clear('manufacturers');
osC_Cache::clear('sefu-manufacturers');
return true;
}
$osC_Database->rollbackTransaction();
return false;
}
示例13: add
public function add($product_id, $quantity = null)
{
global $lC_Database, $lC_Services, $lC_Language, $lC_Customer, $lC_Product;
if (!is_numeric($product_id)) {
return false;
}
$Qproduct = $lC_Database->query('select p.*, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag) where p.products_id = :products_id');
$Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
$Qproduct->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
$Qproduct->bindInt(':default_flag', 1);
$Qproduct->bindInt(':products_id', $product_id);
$Qproduct->execute();
if ($Qproduct->value('image') == null) {
// check for parent image
$Qimage = $lC_Database->query('select image from :table_products_images where products_id = :parent_id');
$Qimage->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
$Qimage->bindInt(':default_flag', 1);
$Qimage->bindInt(':parent_id', $Qproduct->valueInt('parent_id'));
$Qimage->execute();
$image = $Qimage->value('image');
} else {
$image = $Qproduct->value('image');
}
if ($Qproduct->valueInt('products_status') === 1) {
if ($this->exists($product_id)) {
$item_id = $this->getBasketID($product_id);
if (is_numeric($quantity)) {
$quantity = $this->getQuantity($item_id) + 1;
}
$this->_contents[$item_id]['quantity'] = $quantity;
if ($lC_Customer->isLoggedOn()) {
$Qupdate = $lC_Database->query('update :table_shopping_carts set quantity = :quantity where customers_id = :customers_id and item_id = :item_id');
$Qupdate->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS);
$Qupdate->bindInt(':quantity', $quantity);
$Qupdate->bindInt(':customers_id', $lC_Customer->getID());
$Qupdate->bindInt(':item_id', $item_id);
$Qupdate->execute();
}
} else {
if (!is_numeric($quantity)) {
$quantity = 1;
}
$Qdescription = $lC_Database->query('select products_name, products_keyword, products_description, products_tags, products_url from :table_products_description where products_id = :products_id and language_id = :language_id');
$Qdescription->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
$Qdescription->bindInt(':products_id', $product_id);
$Qdescription->bindInt(':language_id', $lC_Language->getID());
$Qdescription->execute();
$desc = $Qdescription->toArray();
if ($Qproduct->valueInt('parent_id') > 0) {
$Qmaster = $lC_Database->query('select products_name as parent_name, products_description as description, products_keyword as keyword, products_tags as tags, products_url as url from :table_products_description where products_id = :products_id and language_id = :language_id limit 1');
$Qmaster->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
$Qmaster->bindInt(':products_id', $Qproduct->valueInt('parent_id'));
$Qmaster->bindInt(':language_id', $lC_Language->getID());
$Qmaster->execute();
if ($Qproduct->valueInt('is_subproduct') > 0) {
$desc['products_name'] = $Qmaster->value('parent_name') . ' - ' . $desc['products_name'];
} else {
$desc['products_name'] = $Qmaster->value('parent_name');
}
$desc['products_description'] = $Qmaster->value('description');
$desc['products_keyword'] = $Qmaster->value('keyword');
$desc['products_tags'] = $Qmaster->value('tags');
$desc['products_url'] = $Qmaster->value('url');
}
// we get the product price from the product class - price already includes options, etc.
if (!isset($lC_Product)) {
$lC_Product = new lC_Product($product_id);
}
$price = $lC_Product->getPrice($product_id, $lC_Customer->getCustomerGroup(), $_POST);
if ($lC_Customer->isLoggedOn()) {
$Qid = $lC_Database->query('select max(item_id) as item_id from :table_shopping_carts where customers_id = :customers_id');
$Qid->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS);
$Qid->bindInt(':customers_id', $lC_Customer->getID());
$Qid->execute();
$item_id = $Qid->valueInt('item_id') + 1;
} else {
if (empty($this->_contents)) {
$item_id = 1;
} else {
$item_id = max(array_keys($this->_contents)) + 1;
}
}
$this->_contents[$item_id] = array('item_id' => $item_id, 'id' => $product_id, 'parent_id' => $Qproduct->valueInt('parent_id'), 'name' => $desc['products_name'], 'model' => $Qproduct->value('products_model'), 'sku' => $Qproduct->value('products_sku'), 'keyword' => $desc['products_keyword'], 'tags' => $desc['products_tags'], 'url' => $desc['products_url'], 'description' => $desc['products_description'], 'image' => $image, 'price' => $price, 'quantity' => $quantity, 'weight' => $Qproduct->value('products_weight'), 'tax_class_id' => $Qproduct->valueInt('products_tax_class_id'), 'date_added' => lC_DateTime::getShort(lC_DateTime::getNow()), 'weight_class_id' => $Qproduct->valueInt('products_weight_class'));
// simple options
if (isset($_POST['simple_options']) && empty($_POST['simple_options']) === false) {
foreach ($_POST['simple_options'] as $options_id => $values_id) {
if (is_array($values_id)) {
$text_value = current($values_id);
// for text fields
$values_id = key($values_id);
}
$QsimpleOptionsValues = $lC_Database->query('select price_modifier from :table_products_simple_options_values where options_id = :options_id and values_id = :values_id and customers_group_id = :customers_group_id');
$QsimpleOptionsValues->bindTable(':table_products_simple_options_values', TABLE_PRODUCTS_SIMPLE_OPTIONS_VALUES);
$QsimpleOptionsValues->bindInt(':options_id', $options_id);
$QsimpleOptionsValues->bindInt(':values_id', $values_id);
$QsimpleOptionsValues->bindInt(':customers_group_id', '1');
$QsimpleOptionsValues->execute();
$Qvariants = $lC_Database->query('select pvg.title as group_title, pvg.module, pvv.title as value_title from :table_products_variants_groups pvg, :table_products_variants_values pvv where pvg.id = :options_id and pvv.id = :values_id and pvv.languages_id = :languages_id and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id limit 1');
$Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
$Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
//.........这里部分代码省略.........
示例14: save
public static 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 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, sort_order, date_added) values (:parent_id, :sort_order, now())');
$Qcat->bindInt(':parent_id', $data['parent_id']);
}
$Qcat->bindTable(':table_categories', TABLE_CATEGORIES);
$Qcat->bindInt(':sort_order', $data['sort_order']);
$Qcat->setLogging($_SESSION['module'], $id);
$Qcat->execute();
if (!$osC_Database->isError()) {
$category_id = is_numeric($id) ? $id : $osC_Database->nextID();
foreach ($osC_Language->getAll() as $l) {
if (is_numeric($id)) {
$Qcd = $osC_Database->query('update :table_categories_description set categories_name = :categories_name 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) values (:categories_id, :language_id, :categories_name)');
}
$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->setLogging($_SESSION['module'], $category_id);
$Qcd->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()) {
$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);
$Qcf->bindInt(':categories_id', $category_id);
$Qcf->setLogging($_SESSION['module'], $category_id);
$Qcf->execute();
if ($osC_Database->isError()) {
$error = true;
}
}
}
}
if ($error === false) {
$osC_Database->commitTransaction();
osC_Cache::clear('categories');
osC_Cache::clear('category_tree');
osC_Cache::clear('also_purchased');
return true;
}
$osC_Database->rollbackTransaction();
return false;
}
示例15: upload
function _upload_new_template(&$result)
{
global $osC_Language, $osC_Database;
$template_file = new upload('template_file', realpath('../templates'), '777', 'zip');
if ($template_file->exists()) {
if ($template_file->parse() && $template_file->save()) {
$module_name = substr($template_file->filename, 0, strpos($template_file->filename, '.'));
$directory = realpath('../templates') . '/' . $module_name;
if (is_dir($directory)) {
$result[] = $osC_Language->get('ms_error_template_directory_exist');
osc_remove(realpath('../templates') . '/' . $template_file->filename);
return false;
}
require_once '../ext/zip/pclzip.lib.php';
$archive = new PclZip(realpath('../templates') . '/' . $template_file->filename);
if ($archive->extract(PCLZIP_OPT_PATH, realpath('../templates')) == 0) {
return false;
}
osc_remove(realpath('../templates') . '/' . $template_file->filename);
if (file_exists('../templates/' . $module_name . '/template.php')) {
include '../templates/' . $module_name . '/template.php';
$class = 'osC_Template_' . $module_name;
if (!class_exists($class)) {
$result[] = $osC_Language->get('ms_error_template_class_not_exist');
osc_remove(realpath('../templates') . '/' . $module_name);
return false;
}
$module = new $class();
$Qtemplate = $osC_Database->query('select id from :table_templates where code = :code');
$Qtemplate->bindTable(':table_templates', TABLE_TEMPLATES);
$Qtemplate->bindvalue(':code', $module->_code);
$Qtemplate->execute();
if ($Qtemplate->numberOfRows() > 0) {
$result[] = $osC_Language->get('ms_error_template_code_exist');
osc_remove(realpath('../templates') . '/' . $module_name);
return false;
}
return true;
} else {
$result[] = $osC_Language->get('ms_error_template_file_not_exist');
osc_remove(realpath('../templates') . '/' . $module_name);
return false;
}
} else {
$result[] = $osC_Language->get('ms_error_wrong_zip_file');
osc_remove(realpath('../templates') . '/' . $template_file->filename);
}
}
return false;
}