Example #1
0
	@license http://creativecommons.org/licenses/by-nc/3.0/
**/
include '../configs.php';
include "../lang/{$LANG}.php";
include 'common.php';
$dir = $_POST['dir'];
$file = $_POST['file'];
$directory = $PUBLIC_HTML_DIR . $dir;
$path = $directory . $file;
if ($dir == "") {
    die(xml_response('alert', $DLG['select_dir']));
}
if (!is_writable($directory)) {
    die(xml_response('error', $DLG['no_permission']));
}
if (!validate_path($dir)) {
    die(xml_response('error', $DLG['invalid_dir'] . " [b]({$directory})[/b]"));
}
//cheking file name
if (ereg("[^a-zA-Z0-9._ -]", $file) || substr($file, 0, 1) == ".") {
    die(xml_response('alert', $DLG['invalid_dirname']));
}
//check is file name exists
if (file_exists($directory . $file)) {
    die(xml_response('alert', $DLG['dir_exists']));
}
umask(02);
if (mkdir($directory . $file, 0775)) {
    die(xml_response('done', "[b]'{$file}'[/b] " . $DLG['dir_add_success']));
}
die(xml_response('error', "[b]'{$file}'[/b] " . $DLG['dir_add_failure']));
Example #2
0
function find_files_recursive($dir, $base, $extnames, $excludes, $level)
{
    $list = array();
    $handle = opendir($dir);
    while ($file = readdir($handle)) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        $path = $dir . DIRECTORY_SEPARATOR . $file;
        $is_file = is_file($path);
        if (validate_path($base, $file, $is_file, $extnames, $excludes)) {
            if ($is_file) {
                $list[] = $path;
            } elseif ($level) {
                $list = array_merge($list, find_files_recursive($path, $base . '/' . $file, $extnames, $excludes, $level - 1));
            }
        }
    }
    closedir($handle);
    return $list;
}
Example #3
0
$file = $_POST['file'];
$directory = $PUBLIC_HTML_DIR . $dir;
$path = $directory . $file;
if ($file == "") {
    die(msg('alert', $DLG['select_file']));
}
if ($dir == "") {
    die(msg('alert', $DLG['select_dir']));
}
if (!file_exists($path)) {
    die(msg('error', $DLG['file_not_found'] . " <b>({$file})</b>"));
}
if (is_dir($path)) {
    die(msg('alert', $DLG['not_file'] . " <b>({$file})</b>"));
}
if (!validate_path($path)) {
    die(msg('error', $DLG['invalid_dir'] . " <b>({$dir}{$file})</b>"));
}
$info = swampy_pathinfo($path);
switch ($info['extension']) {
    case "jpeg":
    case "jpg":
    case "gif":
    case "png":
    case "bmp":
        die(show_image($dir . $file));
        break;
    case "txt":
    case "php":
    case "js":
        die(show_text($path));
Example #4
0
 function retrieveLabel($sInfo)
 {
     global $messageStack;
     $ups_results = array();
     if (in_array($sInfo->ship_method, array('I2DEam', 'I2Dam', 'I3D', 'GndFrt'))) {
         // unsupported ship methods
         $messageStack->add('The ship method requested is not supported by this tool presently. Please ship the package via a different tool.', 'error');
         return false;
     }
     $strXML = $this->FormatUPSShipRequest($sInfo, $key);
     if (DEBUG) {
         $messageStack->debug('Ship Request xmlString = ' . htmlspecialchars($strXML));
     }
     $this->labelRequest = $strXML;
     //echo 'Ship Request xmlString = ' . htmlspecialchars($strXML) . '<br />';
     $url = MODULE_SHIPPING_UPS_TEST_MODE == 'Test' ? MODULE_SHIPPING_UPS_SHIP_URL_TEST : MODULE_SHIPPING_UPS_SHIP_URL;
     $SubmitXML = GetXMLString($strXML, $url, "POST");
     if (DEBUG) {
         $messageStack->debug('Ship Request response string = ' . htmlspecialchars($SubmitXML['xmlString']));
     }
     $this->labelResponse = $SubmitXML['xmlString'];
     //echo 'Ship Request response string = ' . htmlspecialchars($SubmitXML['xmlString']) . '<br />';
     // Check for XML request errors
     if ($SubmitXML['result'] == 'error') {
         $messageStack->add(SHIPPING_UPS_CURL_ERROR . $SubmitXML['message'], 'error');
         return false;
     }
     $ResponseXML = $SubmitXML['xmlString'];
     $XMLFail = GetNodeData($ResponseXML, 'ShipmentConfirmResponse:Response:Error:ErrorCode');
     // Check for errors returned from UPS
     $XMLWarn = GetNodeData($ResponseXML, 'ShipmentConfirmResponse:Response:Error:ErrorSeverity');
     // Check for warnings returned from UPS (process continues)
     if ($XMLFail && $XMLWarn == 'Warning') {
         // soft error, report it and continue
         $messageStack->add('UPS Label Request Warning # ' . $XMLFail . ' - ' . GetNodeData($ResponseXML, 'ShipmentConfirmResponse:Response:Error:ErrorDescription'), 'caution');
     } elseif ($XMLFail && $XMLWarn != 'Warning') {
         // hard error - return with bad news
         $messageStack->add('UPS Label Request Error # ' . $XMLFail . ' - ' . GetNodeData($ResponseXML, 'ShipmentConfirmResponse:Response:Error:ErrorDescription'), 'error');
         return false;
     }
     $digest = GetNodeData($ResponseXML, 'ShipmentConfirmResponse:ShipmentDigest');
     // Check for errors returned from UPS
     // Now resend request with digest to get the label
     $strXML = $this->FormatUPSAcceptRequest($digest);
     if (DEBUG) {
         $messageStack->debug('Accept Request xmlString = ' . htmlspecialchars($strXML));
     }
     $this->labelFetchRequest = $strXML;
     //echo 'Accept Request xmlString = ' . htmlspecialchars($strXML) . '<br />';
     $url = MODULE_SHIPPING_UPS_TEST_MODE == 'Test' ? MODULE_SHIPPING_UPS_LABEL_URL_TEST : MODULE_SHIPPING_UPS_LABEL_URL;
     $SubmitXML = GetXMLString($strXML, $url, "POST");
     if (DEBUG) {
         $messageStack->debug('Accept Response response string = ' . htmlspecialchars($SubmitXML['xmlString']));
     }
     $this->labelFetchReturned = $SubmitXML['xmlString'];
     //echo 'Accept Response response string = ' . htmlspecialchars($SubmitXML['xmlString']) . '<br />';
     // Check for XML request errors
     if ($SubmitXML['result'] == 'error') {
         $messageStack->add(SHIPPING_UPS_CURL_ERROR . $SubmitXML['message'], 'error');
         return false;
     }
     $ResponseXML = $SubmitXML['xmlString'];
     $XMLFail = GetNodeData($ResponseXML, 'ShipmentAcceptResponse:Response:Error:ErrorCode');
     // Check for errors returned from UPS
     $XMLWarn = GetNodeData($ResponseXML, 'ShipmentAcceptResponse:Response:Error:ErrorSeverity');
     // Check for warnings returned from UPS (process continues)
     if ($XMLFail && $XMLWarn == 'Warning') {
         // soft error, report it and continue
         $messageStack->add('UPS Label Retrieval Warning # ' . $XMLFail . ' - ' . GetNodeData($ResponseXML, 'ShipmentAcceptResponse:Response:Error:ErrorDescription'), 'caution');
     } elseif ($XMLFail && $XMLWarn != 'Warning') {
         // hard error - return with bad news
         $messageStack->add('UPS Label Retrieval Error # ' . $XMLFail . ' - ' . GetNodeData($ResponseXML, 'ShipmentAcceptResponse:Response:Error:ErrorDescription'), 'error');
         return false;
     }
     // Fetch the UPS shipment information information
     $ups_results = array('dim_weight' => GetNodeData($ResponseXML, 'ShipmentAcceptResponse:ShipmentResults:BillingWeight:Weight'), 'zone' => 'N/A', 'billed_weight' => GetNodeData($ResponseXML, 'ShipmentAcceptResponse:ShipmentResults:BillingWeight:Weight'), 'net_cost' => GetNodeData($ResponseXML, 'ShipmentAcceptResponse:ShipmentResults:NegotiatedRates:NetSummaryCharges:GrandTotal:MonetaryValue'), 'book_cost' => GetNodeData($ResponseXML, 'ShipmentAcceptResponse:ShipmentResults:ShipmentCharges:TotalCharges:MonetaryValue'), 'delivery_date' => 'Not Provided');
     // Fetch the package information and label
     $Container = 'PackageResults';
     // base location in the XML string (repeated)
     $TagsToFind = array('tracking' => 'TrackingNumber', 'graphic_image' => 'GraphicImage', 'html_image' => 'HTMLImage');
     $results = GetPackageArray($ResponseXML, $Container, $TagsToFind);
     $returnArray = array();
     if (sizeof($results) > 0) {
         foreach ($results as $label) {
             $returnArray[] = $ups_results + array('tracking' => $label['tracking']);
             $date = explode('-', $sInfo->terminal_date);
             // date format YYYY-MM-DD
             $file_path = DIR_FS_MY_FILES . $_SESSION['company'] . '/shipping/labels/' . $this->code . '/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/';
             validate_path($file_path);
             // check for label to be for thermal printer or plain paper
             if (MODULE_SHIPPING_UPS_PRINTER_TYPE == 'Thermal') {
                 // keep the thermal label encoded for now
                 $output_label = base64_decode($label['graphic_image']);
                 $file_name = $label['tracking'] . '.lpt';
                 // thermal printer
             } else {
                 $output_label = base64_decode($label['graphic_image']);
                 $file_name = $label['tracking'] . '.gif';
                 // plain paper
             }
             if (!($handle = fopen($file_path . $file_name, 'w'))) {
                 $messageStack->add('Cannot open file (' . $file_path . $file_name . ')', 'error');
                 return false;
             }
             if (fwrite($handle, $output_label) === false) {
                 $messageStack->add('Cannot write to file (' . $file_path . $file_name . ')', 'error');
                 return false;
             }
             $this->labelFilePath = $file_path . $file_name;
             fclose($handle);
         }
         $messageStack->add_session('Successfully retrieved the UPS shipping label. Tracking # ' . $ups_results[$key]['tracking'], 'success');
     } else {
         $messageStack->add('Error - No label found in return string.', 'error');
         return false;
     }
     if (DEBUG) {
         $messageStack->write_debug();
     }
     return $returnArray;
 }
Example #5
0
 function closeFedEx($close_date = '', $report_only = false, $report_type = 'MANIFEST')
 {
     global $messageStack;
     $today = date('Y-m-d');
     if (!$close_date) {
         $close_date = $today;
     }
     $report_only = $close_date == $today ? false : true;
     $date = explode('-', $close_date);
     $error = false;
     foreach (array('FDXG', 'FDXE') as $code) {
         $strXML = $this->FormatFedExCloseRequest($code, $close_date, $report_only);
         //echo 'strXML = ' . htmlspecialchars($strXML) . '<br /><br />';
         $SubmitXML = GetXMLString($strXML, $this->rate_url, "POST");
         // Check for XML request errors
         if ($SubmitXML['result'] == 'error') {
             $messageStack->add(SHIPPING_FEDEX_CURL_ERROR . $SubmitXML['message'], 'error');
             $error = true;
             continue;
         }
         $ResponseXML = $SubmitXML['xmlString'];
         //echo 'ResponseXML = ' . htmlspecialchars($ResponseXML) . '<br /><br />';
         // Check for errors returned from FedEx
         $XMLFail = GetNodeData($ResponseXML, 'Error:Code');
         if ($XMLFail) {
             // fetch the error code
             $messageStack->add('FedEx service: ' . $code . ' Close Error # ' . $XMLFail . ' - ' . GetNodeData($ResponseXML, 'Error:Message'), 'caution');
             $error = true;
             continue;
         }
         // Fetch the FedEx reports
         $file_path = DIR_FS_MY_FILES . $_SESSION['company'] . '/shipping/reports/' . $this->code . '/' . $date[0] . '/' . $date[1] . '/';
         validate_path($file_path);
         //echo 'file_path = ' . ($file_path) . '<br />';
         $file_name = $date[2] . '-' . GetNodeData($ResponseXML, 'Manifest:FileName') . '.txt';
         //echo 'file_name = ' . ($file_name) . '<br />';
         $mwReport = base64_decode(GetNodeData($ResponseXML, 'MultiweightReport'));
         $closeReport = base64_decode(GetNodeData($ResponseXML, 'Manifest:File'));
         //echo 'close report = ' . $closeReport . '<br />';
         $codReport = base64_decode(GetNodeData($ResponseXML, 'CODReport'));
         //			$hazMatReport = base64_decode(GetNodeData($ResponseXML, 'HazMatCertificate'));
         if (!($handle = fopen($file_path . $file_name, 'w'))) {
             echo 'Cannot open file (' . $file_path . $file_name . ')';
             $error = true;
             continue;
         }
         if (fwrite($handle, $closeReport) === false) {
             $messageStack->add('Cannot write close report to file (' . $file_path . $file_name . ')', 'error');
             $error = true;
             continue;
         }
         if (fwrite($handle, $mwReport) === false) {
             $messageStack->add('Cannot write multi-weight report to file (' . $file_path . $file_name . ')', 'error');
             $error = true;
             continue;
         }
         if (fwrite($handle, $codReport) === false) {
             $messageStack->add('Cannot write COD report to file (' . $file_path . $file_name . ')', 'error');
             $error = true;
             continue;
         }
         /*
         			if (fwrite($handle, $hazMatReport) === false) {
         				$messageStack->add('Cannot write Hazmat report to file (' . $file_path . $file_name . ')','error');
         				$error = true;
         				continue;
         			}
         */
         fclose($handle);
     }
     if (!$error) {
         $messageStack->add('Successfully closed the FedEx shipments for today.', 'success');
     }
     return true;
 }
Example #6
0
 function save()
 {
     global $db, $currencies, $fields, $messageStack;
     $sql_data_array = $fields->what_to_save();
     // handle the checkboxes
     $sql_data_array['inactive'] = isset($_POST['inactive']) ? $_POST['inactive'] : '0';
     // else unchecked
     foreach (array('quantity_on_hand', 'quantity_on_order', 'quantity_on_sales_order', 'quantity_on_allocation', 'creation_date', 'last_update', 'last_journal_date') as $key) {
         unset($sql_data_array[$key]);
     }
     $sql_data_array['last_update'] = date('Y-m-d H-i-s');
     if ($_SESSION['admin_security'][SECURITY_ID_PURCHASE_INVENTORY] > 1) {
         $sql_data_array['item_cost'] = $this->store_purchase_array();
         $sql_data_array['vendor_id'] = $this->min_vendor_id;
     } else {
         if (isset($sql_data_array['item_cost'])) {
             unset($sql_data_array['item_cost']);
         }
     }
     $file_path = DIR_FS_MY_FILES . $_SESSION['company'] . '/inventory/images';
     if ($this->remove_image == '1') {
         // update the image with relative path
         if ($this->image_with_path && file_exists($file_path . '/' . $this->image_with_path)) {
             unlink($file_path . '/' . $this->image_with_path);
         }
         $this->image_with_path = '';
         $sql_data_array['image_with_path'] = '';
         unset($this->remove_image);
         // this is not a db field, just an action
     }
     if (is_uploaded_file($_FILES['inventory_image']['tmp_name'])) {
         if ($this->image_with_path && file_exists($file_path . '/' . $this->image_with_path)) {
             unlink($file_path . '/' . $this->image_with_path);
         }
         $this->inventory_path = str_replace('\\', '/', $this->inventory_path);
         // strip beginning and trailing slashes if present
         if (substr($this->inventory_path, 0, 1) == '/') {
             $this->inventory_path = substr($this->inventory_path, 1);
         }
         // remove leading '/' if there
         if (substr($this->inventory_path, -1, 1) == '/') {
             $this->inventory_path = substr($this->inventory_path, 0, -1);
         }
         // remove trailing '/' if there
         if ($this->inventory_path) {
             $file_path .= '/' . $this->inventory_path;
         }
         $temp_file_name = $_FILES['inventory_image']['tmp_name'];
         $file_name = $_FILES['inventory_image']['name'];
         if (!validate_path($file_path)) {
             $messageStack->add(INV_IMAGE_PATH_ERROR, 'error');
             return false;
         } elseif (!validate_upload('inventory_image', 'image', 'jpg')) {
             $messageStack->add(INV_IMAGE_FILE_TYPE_ERROR, 'error');
             return false;
         } else {
             // passed all test, write file
             $result = $db->Execute("select * from " . TABLE_INVENTORY . " where image_with_path = '" . ($this->inventory_path ? $this->inventory_path . '/' : '') . $file_name . "'");
             if ($result->RecordCount() != 0) {
                 $messageStack->add(INV_IMAGE_DUPLICATE_NAME, 'error');
                 return false;
             }
             if (!copy($temp_file_name, $file_path . '/' . $file_name)) {
                 $messageStack->add(INV_IMAGE_FILE_WRITE_ERROR, 'error');
                 return false;
             } else {
                 $this->image_with_path = ($this->inventory_path ? $this->inventory_path . '/' : '') . $file_name;
                 $sql_data_array['image_with_path'] = $this->image_with_path;
                 // update the image with relative path
             }
         }
     }
     if ($this->id != '') {
         $result = $db->Execute("select attachments from " . TABLE_INVENTORY . " where id = {$this->id}");
         $this->attachments = $result->fields['attachments'] ? unserialize($result->fields['attachments']) : array();
         $image_id = 0;
         while ($image_id < 100) {
             // up to 100 images
             if (isset($_POST['rm_attach_' . $image_id])) {
                 @unlink(INVENTORY_DIR_ATTACHMENTS . "inventory_{$this->id}_{$image_id}.zip");
                 unset($this->attachments[$image_id]);
             }
             $image_id++;
         }
         if (is_uploaded_file($_FILES['file_name']['tmp_name'])) {
             // find an image slot to use
             $image_id = 0;
             while (true) {
                 if (!file_exists(INVENTORY_DIR_ATTACHMENTS . 'inventory_' . $this->id . '_' . $image_id . '.zip')) {
                     break;
                 }
                 $image_id++;
             }
             saveUploadZip('file_name', INVENTORY_DIR_ATTACHMENTS, 'inventory_' . $this->id . '_' . $image_id . '.zip');
             $this->attachments[$image_id] = $_FILES['file_name']['name'];
         }
         $sql_data_array['attachments'] = sizeof($this->attachments) > 0 ? serialize($this->attachments) : '';
     }
     unset($sql_data_array['last_journal_date]']);
     if ($this->id != '') {
         if ($this->price_sheet == '') {
             $db->Execute("DELETE FROM " . TABLE_INVENTORY_SPECIAL_PRICES . " WHERE inventory_id = {$this->id} and price_sheet_id IN ( SELECT id FROM " . TABLE_PRICE_SHEETS . " WHERE type = 'c' )");
         }
         unset($sql_data_array['creation_date]']);
         db_perform(TABLE_INVENTORY, $sql_data_array, 'update', "id = " . $this->id);
         gen_add_audit_log(INV_LOG_INVENTORY . TEXT_UPDATE, $this->sku . ' - ' . $sql_data_array['description_short']);
     } else {
         db_perform(TABLE_INVENTORY, $sql_data_array, 'insert');
         $this->id = db_insert_id();
         $result = $db->Execute("select price_sheet_id, price_levels from " . TABLE_INVENTORY_SPECIAL_PRICES . " where inventory_id = " . $this->id);
         while (!$result->EOF) {
             $output_array = array('inventory_id' => $this->id, 'price_sheet_id' => $result->fields['price_sheet_id'], 'price_levels' => $result->fields['price_levels']);
             db_perform(TABLE_INVENTORY_SPECIAL_PRICES, $output_array, 'insert');
             $result->MoveNext();
         }
         gen_add_audit_log(INV_LOG_INVENTORY . TEXT_COPY, " id " . $this->id . ' new sku = ' . $this->sku);
     }
     return $sql_data_array;
 }
Example #7
0
 function retrieveLabel($sInfo, $key = 0)
 {
     global $messageStack;
     $ups_results = array();
     if (in_array($sInfo->ship_method, array('I2DEam', 'I2Dam', 'I3D', 'GndFrt', 'EcoFrt'))) {
         // unsupported ship methods
         $messageStack->add('The ship method requested is not supported by this tool presently. Please ship the package via a different tool.', 'error');
         return false;
     }
     $strXML = $this->FormatUPSShipRequest($sInfo);
     //echo 'Ship Request xmlString = <pre>' . $strXML . '</pre><br />';
     $url = MODULE_SHIPPING_UPS_TEST_MODE == 'Test' ? MODULE_SHIPPING_UPS_SHIP_URL_TEST : MODULE_SHIPPING_UPS_SHIP_URL;
     $SubmitXML = GetXMLString($strXML, $url, "POST");
     //echo 'Ship Request response string = ' . htmlspecialchars($SubmitXML['xmlString']) . '<br />';
     // Check for XML request errors
     if ($SubmitXML['result'] == 'error') {
         $messageStack->add(SHIPPING_UPS_CURL_ERROR . $SubmitXML['message'], 'error');
         return false;
     }
     $ResponseXML = xml_to_object($SubmitXML['xmlString']);
     $XMLFail = $ResponseXML->ShipmentConfirmResponse->Response->Error->ErrorCode;
     $XMLWarn = $ResponseXML->ShipmentConfirmResponse->Response->Error->ErrorSeverity;
     if ($XMLFail && $XMLWarn == 'Warning') {
         // soft error, report it and continue
         $messageStack->add('UPS Label Request Warning # ' . $XMLFail . ' - ' . $ResponseXML->ShipmentConfirmResponse->Response->Error->ErrorDescription, 'caution');
     } elseif ($XMLFail && $XMLWarn != 'Warning') {
         // hard error - return with bad news
         $messageStack->add('UPS Label Request Error # ' . $XMLFail . ' - ' . $ResponseXML->ShipmentConfirmResponse->Response->Error->ErrorDescription, 'error');
         return false;
     }
     $digest = $ResponseXML->ShipmentConfirmResponse->ShipmentDigest;
     // Now resend request with digest to get the label
     $strXML = $this->FormatUPSAcceptRequest($digest);
     //echo 'Accept Request xmlString = ' . htmlspecialchars($strXML) . '<br />';
     $url = MODULE_SHIPPING_UPS_TEST_MODE == 'Test' ? MODULE_SHIPPING_UPS_LABEL_URL_TEST : MODULE_SHIPPING_UPS_LABEL_URL;
     $SubmitXML = GetXMLString($strXML, $url, "POST");
     //echo 'Accept Response response string = ' . htmlspecialchars($SubmitXML['xmlString']) . '<br />';
     // Check for XML request errors
     if ($SubmitXML['result'] == 'error') {
         $messageStack->add(SHIPPING_UPS_CURL_ERROR . $SubmitXML['message'], 'error');
         return false;
     }
     $ResponseXML = xml_to_object($SubmitXML['xmlString']);
     $XMLFail = $ResponseXML->ShipmentAcceptResponse->Response->Error->ErrorCode;
     $XMLWarn = $ResponseXML->ShipmentAcceptResponse->Response->Error->ErrorSeverity;
     if ($XMLFail && $XMLWarn == 'Warning') {
         // soft error, report it and continue
         $messageStack->add('UPS Label Retrieval Warning # ' . $XMLFail . ' - ' . $ResponseXML->ShipmentAcceptResponse->Response->Error->ErrorDescription, 'caution');
     } elseif ($XMLFail && $XMLWarn != 'Warning') {
         // hard error - return with bad news
         $messageStack->add('UPS Label Retrieval Error # ' . $XMLFail . ' - ' . $ResponseXML->ShipmentAcceptResponse->Response->Error->ErrorDescription, 'error');
         return false;
     }
     // Fetch the UPS shipment information information
     $ups_results = array('ref_id' => $sInfo->purchase_invoice_id . '-' . ($key + 1), 'dim_weight' => $ResponseXML->ShipmentAcceptResponse->ShipmentResults->BillingWeight->Weight, 'zone' => 'N/A', 'billed_weight' => $ResponseXML->ShipmentAcceptResponse->ShipmentResults->BillingWeight->Weight, 'net_cost' => $ResponseXML->ShipmentAcceptResponse->ShipmentResults->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue, 'book_cost' => $ResponseXML->ShipmentAcceptResponse->ShipmentResults->ShipmentCharges->TotalCharges->MonetaryValue, 'delivery_date' => 'Not Provided');
     // Fetch the package information and label
     $returnArray = array();
     if (!$ResponseXML->ShipmentAcceptResponse->ShipmentResults->PackageResults) {
         $messageStack->add('Error - No label found in return string.', 'error');
         return false;
     } else {
         if (!is_array($ResponseXML->ShipmentAcceptResponse->ShipmentResults->PackageResults)) {
             $ResponseXML->ShipmentAcceptResponse->ShipmentResults->PackageResults = array($ResponseXML->ShipmentAcceptResponse->ShipmentResults->PackageResults);
         }
         foreach ($ResponseXML->ShipmentAcceptResponse->ShipmentResults->PackageResults as $label) {
             $returnArray[] = $ups_results + array('tracking' => $label->TrackingNumber);
             $date = explode('-', $sInfo->ship_date);
             // date format YYYY-MM-DD
             $file_path = DIR_FS_MY_FILES . $_SESSION['company'] . '/shipping/labels/' . $this->code . '/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/';
             validate_path($file_path);
             $output_label = base64_decode($label->LabelImage->GraphicImage);
             $file_name = MODULE_SHIPPING_UPS_PRINTER_TYPE == 'EPL' ? $label->TrackingNumber . '.lpt' : $label->TrackingNumber . '.gif';
             if (!($handle = fopen($file_path . $file_name, 'w'))) {
                 $messageStack->add('Cannot open file (' . $file_path . $file_name . ')', 'error');
                 return false;
             }
             if (fwrite($handle, $output_label) === false) {
                 $messageStack->add('Cannot write to file (' . $file_path . $file_name . ')', 'error');
                 return false;
             }
             fclose($handle);
         }
         $messageStack->add_session('Successfully retrieved the UPS shipping label. Tracking # ' . $ups_results[$key]['tracking'], 'success');
     }
     return $returnArray;
 }
Example #8
0
 function closeFedEx($close_date = '', $report_only = false, $report_type = 'MANIFEST')
 {
     global $messageStack;
     if (MODULE_SHIPPING_FEDEX_V7_TEST_MODE == 'Test') {
         $client = new SoapClient(PATH_TO_TEST_CLOSE_WSDL, array('trace' => 1));
     } else {
         $client = new SoapClient(PATH_TO_CLOSE_WSDL, array('trace' => 1));
     }
     $today = date('c');
     if (!$close_date) {
         $close_date = $today;
     }
     $report_only = $close_date == $today ? false : true;
     $date = explode('-', $close_date);
     $error = false;
     $request = $this->FormatFedExCloseRequest($close_date, $report_only, $report_type);
     //echo 'request = '; print_r($request); echo '<br />';
     try {
         $response = $client->groundClose($request);
         //echo 'Request <pre>' . htmlspecialchars($client->__getLastRequest()) . '</pre>';
         //echo 'Response <pre>' . htmlspecialchars($client->__getLastResponse()) . '</pre>';
         //echo 'close response array = '; print_r($response); echo '<br />';
         if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
             // Fetch the FedEx reports
             $file_path = DIR_FS_MY_FILES . $_SESSION['company'] . '/shipping/reports/' . $this->code . '/' . $date[0] . '/' . $date[1] . '/';
             validate_path($file_path);
             $file_name = $date[2] . '-' . $response->Manifest->FileName . '.txt';
             $closeReport = base64_decode($response->Manifest->File);
             $mwReport = base64_decode($response->MultiweightReport);
             $codReport = base64_decode($response->CODReport);
             //				$hazMatReport = base64_decode($response->HazMatCertificate);
             //echo 'file_path = '   . $file_path   . ' and file_name = '   . $file_name   . '<br />';
             if (!($handle = fopen($file_path . $file_name, 'w'))) {
                 echo 'Cannot open file (' . $file_path . $file_name . ')';
                 $error = true;
                 continue;
             }
             if (fwrite($handle, $closeReport) === false) {
                 $messageStack->add('Cannot write close report to file (' . $file_path . $file_name . ')', 'error');
                 $error = true;
                 continue;
             }
             if (fwrite($handle, $mwReport) === false) {
                 $messageStack->add('Cannot write multi-weight report to file (' . $file_path . $file_name . ')', 'error');
                 $error = true;
                 continue;
             }
             if (fwrite($handle, $codReport) === false) {
                 $messageStack->add('Cannot write COD report to file (' . $file_path . $file_name . ')', 'error');
                 $error = true;
                 continue;
             }
             /*
             				if (fwrite($handle, $hazMatReport) === false) {
             					$messageStack->add('Cannot write Hazmat report to file (' . $file_path . $file_name . ')','error');
             					$error = true;
             					continue;
             				}
             */
             fclose($handle);
             if (!$error) {
                 $messageStack->add(SHIPPING_FEDEX_V7_CLOSE_SUCCESS, 'success');
                 return true;
             }
         } else {
             foreach ($response->Notifications as $notification) {
                 if (is_object($notification)) {
                     $message .= ' (' . $notification->Severity . ') ' . $notification->Message;
                 } else {
                     $message .= ' ' . $notification;
                 }
             }
             $messageStack->add(SHIPPING_FEDEX_V7_DEL_ERROR . $message, 'error');
         }
     } catch (SoapFault $exception) {
         //echo 'Error Request <pre>' . htmlspecialchars($client->__getLastRequest()) . '</pre>';
         //echo ' Error Response <pre>' . htmlspecialchars($client->__getLastResponse()) . '</pre>';
         $message = " ({$exception->faultcode}) {$exception->faultstring}";
         $messageStack->add(SHIPPING_FEDEX_CURL_ERROR . $message, 'error');
     }
     return false;
 }
Example #9
0
    die(xml_response('error', $DLG['invalid_dir'] . " [b]({$directory})[/b]"));
}
$files = function_exists("scandir") ? scandir($directory) : php4_scandir($directory);
/* Make directories first */
$ofiles = $odirs = array();
foreach ($files as $file) {
    if (is_dir($directory . $file)) {
        array_push($odirs, $file);
    } else {
        array_push($ofiles, $file);
    }
}
$files = array_merge($odirs, $ofiles);
/* Parent dir */
$parent_dir = str_replace(basename($dir) . "/", "", $dir);
if (validate_path($parent_dir)) {
    $xml = "\t<file type='parent' dir='{$parent_dir}' file='' extension='' size='' dimentions='' bg=''>{$DLG['up']}</file>\n";
}
//	echo "<div onDblClick=\"browser.enterDir('$parent_dir');\" class='fim-thumb'>\n\t<div class='image ext-parent'></div>\n\t<div class='filename'>{$DLG['up']}</div>\n</div>\n";
/* Prints file thubms */
foreach ($files as $file) {
    $xml .= fileXML($file);
}
die(xml_response('data', $xml));
function fileXML($file)
{
    global $HOST, $PUBLIC_HTML_DIR, $IMAGE_EXTENSIONS, $IMAGE_FORMATS, $dir, $directory, $DLG;
    if (substr($file, 0, 1) == ".") {
        return;
    }
    $path = $directory . $file;
Example #10
0
$shipping_module = 'ups';
load_method_language(DEFAULT_MOD_DIR, $shipping_module);
require DIR_FS_WORKING . 'functions/shipping.php';
require DIR_FS_WORKING . 'classes/shipping.php';
require DIR_FS_WORKING . 'methods/' . $shipping_module . '/' . $shipping_module . '.php';
require DIR_FS_WORKING . 'pages/ups_qualify/data.php';
/**************   page specific initialization  *************************/
$error = false;
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
/***************   Act on the action request   *************************/
switch ($action) {
    case 'go':
        validate_security($security_level, 3);
        // retrieve the sample ship to addresses and query UPS
        $file_path = DIR_FS_MY_FILES . $_SESSION['company'] . '/temp/ups_cal/';
        validate_path($file_path);
        $count = 1;
        foreach ($shipto as $pkg) {
            $sInfo = new shipment();
            // load defaults
            // overwrite the defaults with data from the file
            while (list($key, $value) = each($pkg)) {
                $sInfo->{$key} = db_prepare_input($value);
            }
            $sInfo->ship_date = date('Y-m-d', strtotime($sInfo->ship_date));
            // load package information
            $sInfo->package = array();
            foreach ($pkg['package'] as $item) {
                $sInfo->package[] = array('weight' => $item['weight'], 'length' => $item['length'], 'width' => $item['width'], 'height' => $item['height'], 'value' => $item['value']);
            }
            if (count($sInfo->package) > 0) {
Example #11
0
	@copyright 2009 SwampyFoot
	@license SwampyBrowser is licensed under a Creative Commons Attribution-Noncommercial 3.0
	@license http://creativecommons.org/licenses/by-nc/3.0/
**/
include '../configs.php';
include "../lang/{$LANG}.php";
include 'common.php';
$dir = $_POST['dir'];
$directory = $PUBLIC_HTML_DIR . $dir;
if ($dir == "") {
    die(msg('alert', $DLG['select_dir']));
}
if (!is_writable($directory)) {
    die(msg('error', $DLG['no_permission']));
}
if (!validate_path($directory)) {
    die(msg('error', $DLG['invalid_dir'] . " <b>({$dir})</b>"));
}
if ($_POST['upload']) {
    //cheking is file selected
    if ($_FILES['file']['name'] == "") {
        die(stopUpload('alert', $DLG['select_file']));
    }
    //geting file/path info
    $info = swampy_pathinfo($_FILES['file']['name']);
    $filename = $_POST['filename'] != "" ? $_POST['filename'] : $info['filename'];
    $filename = format_filename($filename);
    //cheking file name
    if (ereg("[^a-zA-Z0-9._-]", $filename)) {
        die(stopUpload('alert', $DLG['invalid_filename']));
    }
 if (!$error && is_uploaded_file($_FILES['asset_image']['tmp_name'])) {
     $file_path = DIR_FS_MY_FILES . $_SESSION['company'] . '/assets/images';
     $asset_path = str_replace('\\', '/', $asset_path);
     // strip beginning and trailing slashes if present
     if (substr($asset_path, -1, 1) == '/') {
         $asset_path = substr($asset_path, 0, -1);
     }
     if (substr($asset_path, 0, 1) == '/') {
         $asset_path = substr($asset_path, 1);
     }
     if ($asset_path) {
         $file_path .= '/' . $asset_path;
     }
     $temp_file_name = $_FILES['asset_image']['tmp_name'];
     $file_name = $_FILES['asset_image']['name'];
     if (!validate_path($file_path)) {
         $messageStack->add(ASSETS_IMAGE_PATH_ERROR, 'error');
         $error = true;
     } elseif (!validate_upload('asset_image', 'image', 'jpg')) {
         $messageStack->add(ASSETS_IMAGE_FILE_TYPE_ERROR, 'error');
         $error = true;
     } else {
         // passed all test, write file
         if (!copy($temp_file_name, $file_path . '/' . $file_name)) {
             $messageStack->add(ASSETS_IMAGE_FILE_WRITE_ERROR, 'error');
             $error = true;
         } else {
             $image_with_path = ($asset_path ? $asset_path . '/' : '') . $file_name;
             $_POST['image_with_path'] = $image_with_path;
             $sql_data_array['image_with_path'] = $image_with_path;
             // update the image with relative path
Example #13
0
 function retrieveLabel($sInfo)
 {
     global $messageStack;
     $endicia_results = array();
     if (in_array($sInfo->ship_method, array('I2DEam', 'I2Dam', 'I3D'))) {
         // unsupported ship methods
         $messageStack->add('The ship method requested is not supported by this tool presently. Please ship the package via a different tool.', 'error');
         return false;
     }
     $labels = array();
     $xml = $this->FormatEndiciaShipRequest($sInfo);
     //echo 'Endicia XML Label Submit String:'; print_r($xml); echo '<br />'; //return false;
     //	$client = new SoapClient((MODULE_SHIPPING_ENDICIA_TEST_MODE=='Test')?PATH_TO_TEST_RATE_WSDL:PATH_TO_RATE_WSDL, array('trace'=>1));
     $url = MODULE_SHIPPING_ENDICIA_TEST_MODE == 'Prod' ? MODULE_SHIPPING_ENDICIA_WSDL_URL : MODULE_SHIPPING_ENDICIA_TEST_WSDL_URL;
     $client = new SoapClient($url, array('trace' => 1));
     try {
         $response = $client->GetPostageLabel($xml);
         //echo 'Request <pre>' . htmlspecialchars($client->__getLastRequest()) . '</pre>';
         //echo 'Response <pre>' . htmlspecialchars($client->__getLastResponse()) . '</pre>';
         //echo 'label response array = '; print_r($response); echo '<br />';
         if ($response->LabelRequestResponse->Status == 0) {
             $net_cost = $response->LabelRequestResponse->FinalPostage;
             $book_cost = $response->LabelRequestResponse->FinalPostage;
             $del_date = '';
             $tracking = $response->LabelRequestResponse->TrackingNumber;
             $zone = '';
             $label = $response->LabelRequestResponse->Base64LabelImage;
             $endicia_results[] = array('ref_id' => $sInfo->purchase_invoice_id, 'tracking' => $tracking, 'book_cost' => $book_cost, 'net_cost' => $net_cost);
             if ($label) {
                 $date = explode('-', $sInfo->ship_date);
                 $file_path = SHIPPING_DEFAULT_LABEL_DIR . $this->code . '/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/';
                 validate_path($file_path);
                 $this->returned_label = $label;
                 $file_name = $tracking . '.lpt';
                 // assume thermal printer
                 // decode label if necessary
                 //echo 'label raw = '.$label.'<br>';
                 //echo 'label decoded = '.base64_decode($label).'<br>';
                 //		  if (!in_array(MODULE_SHIPPING_ENDICIA_PRINTER_TYPE, array('EPL2','ZPLII'))) $label = base64_decode($label);
                 $label = base64_decode($label);
                 if (!($handle = fopen($file_path . $file_name, 'w'))) {
                     $messageStack->add('Cannot open file (' . $file_path . $file_name . ')', 'error');
                     return false;
                 }
                 if (fwrite($handle, $label) === false) {
                     $messageStack->add('Cannot write to file (' . $file_path . $file_name . ')', 'error');
                     return false;
                 }
                 fclose($handle);
                 $messageStack->add(sprintf(SHIPPING_ENDICIA_LABEL_STATUS, $tracking, $response->LabelRequestResponse->PostageBalance), 'success');
             } else {
                 $messageStack->add('Error - No label found in return string.', 'error');
                 return false;
             }
         } else {
             $messageStack->add(TEXT_ERROR . ' (' . $response->LabelRequestResponse->Status . ') ' . $response->LabelRequestResponse->ErrorMessage, 'error');
             return false;
         }
     } catch (SoapFault $exception) {
         //echo 'Fault Request <pre>'  . htmlspecialchars($client->__getLastRequest()) . '</pre>';
         //echo 'Fault Response <pre>' . htmlspecialchars($client->__getLastResponse()) . '</pre>';
         $messageStack->add("Soap Error ({$exception->faultcode}) {$exception->faultstring}", 'error');
         return false;
     }
     return $endicia_results;
 }
Example #14
0
require DIR_FS_WORKING . 'functions/shipping.php';
require DIR_FS_WORKING . 'classes/shipping.php';
require DIR_FS_MODULES . 'phreedom/classes/backup.php';
require DIR_FS_WORKING . 'methods/fedex_v7/fedex_v7.php';
require DIR_FS_WORKING . 'pages/fedex_v7_qualify/sample_data.php';
/**************   page specific initialization  *************************/
$error = false;
$backup = new backup();
$backup->source_dir = DIR_FS_MY_FILES . $_SESSION['company'] . '/temp/fedex_qual/';
$backup->dest_dir = DIR_FS_MY_FILES . 'backups/';
$backup->dest_file = 'fedex_qual.zip';
/***************   Act on the action request   *************************/
switch ($_REQUEST['action']) {
    case 'go':
        // retrieve the sample ship to addresses and query FEDEX_V7
        validate_path($backup->source_dir);
        $count = 1;
        foreach ($shipto as $pkg) {
            $sInfo = new shipment();
            // load defaults
            while (list($key, $value) = each($pkg)) {
                $sInfo->{$key} = db_prepare_input($value);
            }
            $sInfo->ship_date = date('Y-m-d');
            // load package information
            $sInfo->package = array();
            foreach ($pkg['package'] as $item) {
                $sInfo->package[] = array('weight' => $item['weight'], 'length' => $item['length'], 'width' => $item['width'], 'height' => $item['height'], 'value' => $item['value']);
            }
            if (count($sInfo->package) > 0) {
                $shipment = new fedex_v7();