'Australia', 'AUT' => 'Austria', 'Awa' => 'Awards Ceremonies', 'awa' => 'Awards Ceremonies', 'BER' => 'Bermuda', 'BIG' => 'Bosnia', 'BUL' => 'Bulgaria', 'BRA' => 'Brazil', 'CAN' => 'Canada', 'CZE' => 'Czech Republic', 'FRA' => 'France', 'GER' => 'Germany', 'GBR' => 'Great Britain', 'GRE' => 'Greece', 'HUN' => 'Hungary', 'IRE' => 'Ireland', 'ITA' => 'Italy', 'JPN' => 'Japan', 'LAT' => 'Latvia', 'MIS' => 'Miscellaneous', 'MON' => 'Monaco', 'NED' => 'Netherlands', 'NZL' => 'New Zealand', 'NOR' => 'Norway', 'POL' => 'Poland', 'ROM' => 'Romania', 'RUS' => 'Russia', 'SRB' => 'Serbia', 'SVK' => 'Slovakia', 'SWE' => 'Sweden', 'SUI' => 'Switzerland', 'ISV' => 'US Virgin Islands', 'USA' => 'USA', ); while (false !== ($filename = readdir($dir))) { if($filename != '.' and $filename != '..') { $files[] = $filename; } } sort($files); mysql_connect("mysql09.powweb.com",'fti','friend3'); mysql_select_db("bobsleighphotos"); if(!isset($_POST['doadding'])) { $cats = array(); $res = mysql_query("SELECT cd.categories_name, cd.categories_id,c.parent_id FROM zc_categories c, zc_categories_description cd WHERE cd.categories_id = c.categories_id ORDER BY cd.categories_name;"); # gather all categories while($row = mysql_fetch_assoc($res)) { $cats[] = $row; } # retrieve all the categories hierarchically $options = ''; for($idx = 0; $idx < count($cats); $idx++) { if($cats[$idx]['parent_id'] != 0) { for($c = 0; $c < count($cats); $c++) { if($cats[$c]['categories_id'] == $cats[$idx]['parent_id']) { $cats[$c]['subcategories'][] = $cats[$idx]; break; } } } } print "
\n"; foreach($files as $file) { $team = explode('.',$file); $team = explode('-',$team[0]); // EXTRA PARSING THAT I DON'T ALWAYS NEED // $number = ''; // // foreach($parts as $part) // { // if(preg_match("/([IV]+)$/",$part,$matches)) // { // $team[0] = str_replace($matches[1],'',$part); // $team[1] = "Team {$matches[1]},"; // } // else if($part == 'W') // { $team[3] = 'Womens,'; } // else if(preg_match("/^\d+$/",$part)) // { $number = $part; } // else if($team[0] !== $part) // { $team[2] = $part.','; } // } $country_code = substr($team[0],0,3); $country_name = $countries[$country_code]; $team[] = $event_readable_name; // if(!empty($number)) // { $team[] = "($number)"; } $title = implode(' ',$team); list($width,$height) = getimagesize("/home/users/web/b2373/pow.fti/htdocs/bobsleighphotos/download/$event_name/$file"); print "Title: ($file)\n"; print ""; print ""; print "Category: "; if(!$found_cat) { print "COULD NOT FIND CATEGORY!!"; } print "

\n"; } print "
"; } else { foreach($files as $file) { $name = str_replace('.','_',$file); $name = str_replace(' ','_',$name); $width = $_POST['width_'.$name]; $height = $_POST['height_'.$name]; $title = $_POST['title_'.$name]; $cat = $_POST['cat_'.$name]; $desc = "Width: {$width}px
\n"; $desc .= "Height: {$height}px
\n"; $desc .= "Format: JPEG
\n"; $sql = "INSERT INTO zc_products (products_type,products_quantity,products_image,products_price, products_virtual,products_date_added,products_weight,products_status, manufacturers_id,products_ordered,products_quantity_order_min, products_quantity_order_units,products_priced_by_attribute,product_is_free,product_is_call, products_quantity_mixed,product_is_always_free_shipping,products_qty_box_status, products_quantity_order_max,products_sort_order,products_discount_type,products_discount_type_from, products_price_sorter,master_categories_id,products_tax_class_id) VALUES(1,10000,'bobsleighphotos/{$event_name}/$file',10.00, 1,NOW(),0,1, 0,0,1, 1,0,0,0, 1,0,1, 0,0,0,0, 10.00,$cat,1);"; mysql_query($sql); $new_id = mysql_insert_id(); if(mysql_error()) { print "Product $file: ".mysql_error()."
"; continue; } $sql = "INSERT INTO zc_products_description (products_name,products_description) VALUES('$title','$desc');"; mysql_query($sql); if(mysql_error()) { print "Desc $file: ".mysql_error()."
"; continue; } $sql = "INSERT INTO zc_products_to_categories (products_id,categories_id) VALUES($new_id,$cat);"; mysql_query($sql); if(mysql_error()) { print "ProdtoCat $file: ".mysql_error()."
"; continue; } } print 'Done!'; } ?>