Пример #1
0
 function uploadModelAliases()
 {
     global $db;
     set_time_limit(0);
     if (isset($_FILES['modelaliases']['tmp_name'])) {
         if (!empty($_FILES['modelaliases']['error'])) {
             flash('error', gt('There was an error uploading your file.  Please try again.'));
             redirect_to(array('controller' => 'store', 'action' => 'uploadModelAliases'));
         }
         $file->path = $_FILES['modelaliases']['tmp_name'];
         echo "Validating file...<br/>";
         $checkhandle = fopen($file->path, "r");
         $checkdata = fgetcsv($checkhandle, 10000, ",");
         $fieldCount = count($checkdata);
         $count = 1;
         while (($checkdata = fgetcsv($checkhandle, 10000, ",")) !== FALSE) {
             $count++;
             if (count($checkdata) != $fieldCount) {
                 echo "Line " . $count . " of your CSV import file does not contain the correct number of columns.<br/>";
                 echo "Found " . $fieldCount . " header fields, but only " . count($checkdata) . " field in row " . $count . " Please check your file and try again.";
                 exit;
             }
         }
         fclose($checkhandle);
         echo "<br/>CSV File passed validation...<br/><br/>Importing....<br/><br/>";
         $handle = fopen($file->path, "r");
         $data = fgetcsv($handle, 10000, ",");
         //clear the db
         $db->delete('model_aliases_tmp');
         while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) {
             $tmp->field1 = expString::onlyReadables($data[0]);
             $tmp->field2 = expString::onlyReadables($data[1]);
             $db->insertObject($tmp, 'model_aliases_tmp');
         }
         redirect_to(array('controller' => 'store', 'action' => 'processModelAliases'));
         echo "Done!";
     }
     //check if there are interrupted model alias in the db
     $res = $db->selectObjectsBySql("SELECT * FROM exponent_model_aliases_tmp WHERE is_processed = 0");
     if (!empty($res)) {
         assign_to_template(array('continue' => '1'));
     }
 }
Пример #2
0
     continue;
 }
 if (in_array($prod->sef_url, $counter) || isset($counter[$prod->id])) {
     echo "No no..." . $prod->id . "\r\n";
     continue;
 } else {
     $counter[$prod->id] = $prod->sef_url;
 }
 $count++;
 $columns = $prod->id . chr(9);
 $prod->feed_title = expString::convertXMLFeedSafeChar(html_entity_decode(strip_tags($prod->feed_title)));
 $prod->feed_title = htmlspecialchars($prod->feed_title);
 $prod->feed_title = expString::onlyReadables($prod->feed_title);
 $columns .= $prod->feed_title . chr(9);
 $columns .= "http://www.militaryuniformsupply.com/" . strip_tags($prod->sef_url) . chr(9);
 $columns .= expString::onlyReadables($prod->feed_body) . chr(9);
 $columns .= "http://www.militaryuniformsupply.com/" . $prod->directory . $prod->filename . chr(9);
 if (!empty($prod->company)) {
     $columns .= $prod->company . chr(9);
 } else {
     $columns .= chr(9);
 }
 $columns .= $prod->model . chr(9);
 if ($prod->use_special_price && !empty($prod->special_price)) {
     $columns .= $prod->special_price . chr(9);
 } else {
     $columns .= $prod->base_price . chr(9);
 }
 if ($prod->active_type == 0) {
     if ($prod->availability_type == 0) {
         $columns .= 'In Stock' . chr(9);