Jump to content

userb

Members
  • Content count

    10
  • Joined

  • Last visited

  1. Hi, I have a problem I have two shops and i want to use one cataloge of images for those two shops. It look like this: public_html/ShopA/images - those I want to use in both shops public_html/ShopB/images - in that shop I want to use catalgo of images of shop one. Standard in catalog/includes/configure.php is: define('DIR_WS_IMAGES', 'images/'); I tried to chang it to: define('DIR_WS_IMAGES', 'public_html/ShopA/images/'); or define('DIR_WS_IMAGES', 'ShopA/images/'); or define('DIR_WS_IMAGES', '/home/users/mydomain/public_html/ShopA/images/'); Non of above work. Can anybody send some idea how to do it? Best regards,
  2. Hi Guys, How to change the Ajax upload code to change image name when uploading from original name to model name eg.: Product XXX model A112 image name w1.jpg w2.jpg w3.jpg After uplad we should get: A112.jpg original was w1.jpg A112-1.jpg original was w2.jpg A112-2.jpg original was w3.jpg Here is the code: <?php function uploadImage($fileName, $maxSize, $maxW, $fullPath, $relPath, $colorR, $colorG, $colorB, $maxH = null){ $folder = $relPath; $maxlimit = $maxSize; $allowed_ext = "jpg,jpeg,gif,png,bmp"; $match = ""; $filesize = $_FILES[$fileName]['size']; if($filesize > 0){ $filename = strtolower($_FILES[$fileName]['name']); $filename = preg_replace('/\s/', '_', $filename); if($filesize < 1){ $errorList[] = "File size is empty."; } if($filesize > $maxlimit){ $errorList[] = "File size is too big."; } if(count($errorList)<1){ $file_ext = preg_split("/\./",$filename); $allowed_ext = preg_split("/\,/",$allowed_ext); foreach($allowed_ext as $ext){ if($ext==end($file_ext)){ $match = "1"; // File is allowed $NUM = time(); $front_name = substr($file_ext[0], 0, 15); $newfilename = $front_name.".".end($file_ext); $front_name = $_FILES[$fileName]['name']; $newfilename = $front_name; $filetype = end($file_ext); $save = $folder.$newfilename; #var_dump($save); #var_dump($_FILES); #print "</pre><br /><br />";exit; move_uploaded_file( $_FILES[$fileName]['tmp_name'], $save); } } } }else{ $errorList[]= "NO FILE SELECTED"; } if(!$match){ $errorList[]= "File type isn't allowed: $filename"; } if(sizeof($errorList) == 0){ return $fullPath.$newfilename; }else{ $eMessage = array(); for ($x=0; $x<sizeof($errorList); $x++){ $eMessage[] = $errorList[$x]; } return $eMessage; } } $filename = strip_tags($_REQUEST['filename']); $maxSize = strip_tags($_REQUEST['maxSize']); $maxW = strip_tags($_REQUEST['maxW']); $fullPath = strip_tags($_REQUEST['fullPath']); $relPath = strip_tags($_REQUEST['relPath']); $colorR = strip_tags($_REQUEST['colorR']); $colorG = strip_tags($_REQUEST['colorG']); $colorB = strip_tags($_REQUEST['colorB']); $maxH = strip_tags($_REQUEST['maxH']); $filesize_image = $_FILES[$filename]['size']; $new_picture=false; if($_FILES['new_picture']['name']!='') $new_picture=true; /* print "<pre>"; var_dump($_POST); var_dump($filename); var_dump($_FILES); print "</pre><br /><br />"; exit; */ if($filesize_image > 0){ $upload_image = uploadImage($filename, $maxSize, $maxW, $fullPath, $relPath, $colorR, $colorG, $colorB, $maxH); if(is_array($upload_image)){ foreach($upload_image as $key => $value) { if($value == "-ERROR-") { unset($upload_image[$key]); } } $document = array_values($upload_image); for ($x=0; $x<sizeof($document); $x++){ $errorList[] = $document[$x]; } $imgUploaded = false; }else{ $imgUploaded = true; } }else{ $imgUploaded = false; $errorList[] = "File Size Empty: ".$filename; } ?> <?php if($imgUploaded) { ?> <table style="margin-bottom: 10px;" width="100%"> <?php require_once('newfileupload.inc.php'); if($filename=='new_picture') { $sql="insert into `products_pictures` set `products_id`='".$_POST['pID']."', `products_pictures_image`='".$_FILES[$filename]['name']."', `products_pictures_order`='0', `products_pictures_size`='".$filesize_image."';"; mysql_query($sql); }//new_picture else { $sql="update `products_pictures` set `products_id`='".$_POST['pID']."', `products_pictures_image`='".$_FILES[$filename]['name']."', `products_pictures_order`='0', `products_pictures_size`='".$filesize_image."' where `products_pictures_id` = '".$_POST['products_pictures_id']."' ;"; mysql_query($sql); if($_POST['pNR']==1) mysql_query($sql="update `products` set `products_image`='".$_FILES[$filename]['name']."' where `products_id`='".$_POST['pID']."'"); }//else - podmiana /* print "<pre>"; var_dump($filename); var_dump($_POST['pNR']); // var_dump($_FILES); print "</pre>"; */ }else{ echo '<img src="images/error.gif" width="16" height="16px" border="0" style="marin-bottom: -3px;" /> Error(s) Found: '; foreach($errorList as $value){ echo $value.', '; } } ?> Any ideas? Thanks! This helps in orginal upload: open admin/includes/classes/upload.php find parse() function replace: $this->set_filename($file['name']); with: if (isset($this->filename)) $this->set_filename($this->filename.strstr($file['name'], '.')); else $this->set_filename($file['name']); AND open admin/categories.php find in line 442 (but i have installed several contributions) case 'new_product_preview': // copy image only if modified $products_image = new upload('products_image'); and insert: $products_image->filename = $HTTP_POST_VARS['products_model']; But i cannot apply it to Ajax.
  3. Hi, I need to add browse button to every picture I'm adding to my products. Now i have only one button. The code which is responsible for images should be here. I added also image to show what I want to add. Hope somebody will help. Uploaded with ImageShack.us function update_stock($product_id, $quantity = 0) { $get_quantity_query = tep_db_query("select sum(options_quantity) as total_quantity from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int)$product_id . "'"); $get_quantity = tep_db_fetch_array($get_quantity_query); $total_quantity = $get_quantity['total_quantity'] + $quantity; tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $total_quantity . "' where products_id = '" . (int)$product_id . "'"); } function action_productPictures($request) { global $smarty; $args = array(); $args['products_id'] = $products_id = (int)$request['products_id']; if ($products_id == 0) return; //print_r($request);die; $zmiana = false; if (isset($request['productPicture_file']) || (isset($_FILES) && $_FILES)) $zmiana = true; // usuwanie zdjęcia if (isset($request['products_picture_delete']) && $request['products_picture_delete']) { foreach($request['products_picture_delete'] as $order) { $product_pictures = M('OsCommerceProductPicture')->find(sql(array(" products_id = %products_id AND products_pictures_order = %order ", "products_id" => $products_id, "order" => $order ))); if ($product_pictures) { $products_pictures_image = $product_pictures[0]['products_pictures_image']; $product_pictures[0]->delete(); // usunięcie fizyczne pliku jeżeli już nie jest używany $otherOroductPicture = M('OsCommerceProductPicture')->findByProductsPicturesImage($products_pictures_image); if (empty($otherOroductPicture)) { @unlink(DIR_FS_CATALOG . DIR_WS_IMAGES . $products_pictures_image); } } // jeżeli pierwsze to zmodyfikować też produkt if (M('OsCommerceProductPicture')->getNextOrder($products_id) == 1) { $products = M('OsCommerceProduct')->find($products_id); $products[0]['products_image'] = ''; $products[0]->save(); } } } // dodawanie zdjęcia if (isset($_FILES) && $_FILES) { //print_r($_FILES['productPicture_file']);die; if (is_uploaded_file($_FILES['productPicture_file']['tmp_name'])) { $destination_name = strtolower(preg_replace('`[^a-zA-Z0-9\.\-\_]`', '', $_FILES['productPicture_file']['name'])); //if (file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $destination_name)) //$destination_name = substr(md5(time()), 0, 4) . ".". $destination_name; if (move_uploaded_file($_FILES['productPicture_file']['tmp_name'], DIR_FS_CATALOG . DIR_WS_IMAGES . $destination_name)) { $product_picture = M('OsCommerceProductPicture')->create(); $product_picture['products_id'] = $products_id; $product_picture['products_pictures_image'] = $destination_name; $product_picture['products_pictures_order'] = M('OsCommerceProductPicture')->getNextOrder($products_id); $product_picture['products_pictures_size'] = $_FILES['productPicture_file']['size']; $product_picture->save(); // jeżeli pierwsze to zmodyfikować też produkt if ($product_picture['products_pictures_order'] == 1) { $products = M('OsCommerceProduct')->find($products_id); $products[0]['products_image'] = $destination_name; $products[0]->save(); } } } } $products = M('OsCommerceProduct')->find($products_id); if ($products) { $product = $products[0]; $product_pictures = $product->OsCommerceProductPicture; // poniższy warunek ma na celu tylko synchronizację tego co jest w tabelce products_pictures i products if ($product_pictures) { if ($product['products_image'] != $product_pictures[0]['products_pictures_image']) { $product['products_image'] = $product_pictures[0]['products_pictures_image']; $product->save(); } } elseif($product['products_image'] != '') { $product_picture = M('OsCommerceProductPicture')->create(); $product_picture['products_id'] = $products_id; $product_picture['products_pictures_image'] = $product['products_image']; $product_picture['products_pictures_order'] = 1; $product_picture['products_pictures_size'] = @filesize(DIR_FS_CATALOG.DIR_WS_IMAGES . $product['products_image']); $product_picture->save(); } $product_pictures = $product->OsCommerceProductPicture; if ($product_pictures) $args['pictures'] = $product_pictures->asArray(); } $args['SMALL_IMAGE_WIDTH'] = SMALL_IMAGE_WIDTH; $args['SMALL_IMAGE_HEIGHT'] = SMALL_IMAGE_HEIGHT; //$args['random'] = md5(time()); $smarty->assign($args); if (!$zmiana) $smarty->display(file_name . '.' . $request['action'] . '.tpl'); else print $products_id; die; } function action_productFiles($request) { global $smarty; $args = array(); $args['products_id'] = $products_id = (int)$request['products_id']; if ($products_id == 0) return; $args['DIR_WS_IMAGES'] = DIR_WS_CATALOG . DIR_WS_IMAGES; //print_r($request);die; $zmiana = false; if (isset($request['productFile_file']) || (isset($_FILES) && $_FILES)) $zmiana = true; // dodawanie pliku if (isset($_FILES) && $_FILES) { if (is_uploaded_file($_FILES['productFile_file']['tmp_name'])) { $destination_name = strtolower(preg_replace('`[^a-zA-Z0-9\.\-\_]`', '', $_FILES['productFile_file']['name'])); //if (file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $destination_name)) //$destination_name = substr(md5(time()), 0, 4) . ".". $destination_name; if (move_uploaded_file($_FILES['productFile_file']['tmp_name'], DIR_FS_CATALOG . DIR_WS_IMAGES . $destination_name)) { $product_file = M('OsCommerceProductFile')->create(); $product_file['products_id'] = $products_id; $product_file['products_files_file'] = $destination_name; $product_file['products_files_title'] = $request['productFile_title']; $product_file['products_files_order'] = M('OsCommerceProductFile')->getNextOrder($products_id); $product_file['products_files_size'] = $_FILES['productFile_file']['size']; $product_file->save(); } } } // usuwanie pliku if (isset($request['products_file_delete']) && $request['products_file_delete']) { foreach($request['products_file_delete'] as $order) { $product_files = M('OsCommerceProductFile')->find(sql(array(" products_id = %products_id AND products_files_order = %order ", "products_id" => $products_id, "order" => $order ))); if ($product_files) { // usunięcie fizyczne pliku @unlink(DIR_FS_CATALOG . DIR_WS_IMAGES . $product_files[0]['products_files_file']); $product_files[0]->delete(); } } } $products = M('OsCommerceProduct')->find($products_id); if ($products) { $product = $products[0]; $product_files = $product->OsCommerceProductFile; if ($product_files) $args['files'] = $product_files->asArray(); } $smarty->assign($args); if (!$zmiana) $smarty->display(file_name . '.' . $request['action'] . '.tpl'); else print $products_id; die; } $action = false; if (isset($_REQUEST['action'])) { $action = preg_replace('`[^a-zA-Z]`', '', $_REQUEST['action']); $function_name = 'action_'.$action; if (function_exists($function_name)) $function_name($_REQUEST); else $action = false; }
  4. Hi, I need module that will add in checkout_payment.php two radio buttons: Billing method: *Receipt *Invoice If customer take Invoice he will need to add all information to get Invoice(Company name, Vat number, etc) This is ned in Europe to send correct invoice for the customer with Vat number. I know that there should be that kind of contribution. Maybe anybody know? Best regards,
  5. I of course set up temp file with permision 777
  6. Hello, Sorry but I really read tons of replys in that topic but cannot find- I suppose for You- simple answer:-) When I update file in cvs the databes is not updated and none of updated products show. I dont have any Error ro sthing like thet. It show me that product are updated but when i get into the catlogue i dont see new files. I use XP and MS EXCEL Please give me info because I have no idea:) Settings & Info EP vers: 2.76i-MS2 osCommerce Online Merchant v2.2 RC2a OS: Linux 2.6.32.8.core2.34 HTTP: Apache DB: MySQL 5.0.91+tld0-log PHP: 5.2.4-0+tld0 (Zend: 2.2.0) Temp Directory: /home/users/cqbtactical/public_html/hurt/temp/ Temp Dir is Writable Magic Quotes is: off register_globals is: on Split files on: 300 records Model Num Size: 12 Price with tax: false Calc Precision: 2 Replace quotes: false Field seperator: comma Excel safe output: true Preserve tab/cr/lf: false Category depth: 7 Enable attributes: true SEF Froogle URLS: false Other Support: MVS Support: false Additional Images: false More Pics: false UltraPics Pics: false HTC: false SPPC: false Extra Fields: false PDF Upload: false I will be thankful- Im not lazy I spend more than 3 hours to find it so please help. Sorry for my poor English.
×