if ($working->make_dir_tree(DIR_FS_MODULES . $mod . '/', '')) { $error = true; } // read the db if ($working->make_db_info($mod_info->tables)) { $error = true; } // build the output string //echo 'result object = '; print_r($working->output); echo '<br><br>'; $xmlString = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"; $xmlString .= $working->build_xml_string($working->output); //echo 'writing: ' . htmlspecialchars($xmlString) . '<br>'; // store it in a file $handle = fopen(DIR_FS_MY_FILES . $mod . '.xml', "w"); $contents = fwrite($handle, $xmlString, strlen($xmlString)); fclose($handle); // zip it and download $mod_xml->source_dir = DIR_FS_MY_FILES; $mod_xml->source_file = $mod . '.xml'; $mod_xml->dest_dir = DIR_FS_MY_FILES; $mod_xml->dest_file = $mod . '_xml_info.zip'; $mod_xml->make_zip('file', $mod . '.xml'); $mod_xml->download(DIR_FS_MY_FILES, $mod . '_xml_info.zip'); break; default: } /***************** prepare to display templates *************************/ $include_header = true; $include_footer = true; $include_template = 'template_main.php'; define('PAGE_TITLE', XML_BUILDER_PAGE_TITLE);
function saveUploadZip($file_field, $dest_dir, $dest_name) { global $messageStack; if ($_FILES[$file_field]['error']) { // php error uploading file $messageStack->add(TEXT_IMP_ERMSG5 . $_FILES[$file_field]['error'], 'error'); } elseif ($_FILES[$file_field]['size'] > 0) { require_once DIR_FS_MODULES . 'phreedom/classes/backup.php'; $backup = new backup(); $backup->source_dir = $_FILES[$file_field]['tmp_name']; $backup->source_file = ''; $backup->dest_dir = $dest_dir; $backup->dest_file = $dest_name; if (file_exists($dest_dir . $dest_name)) { @unlink($dest_dir . $dest_name); } $backup->make_zip('file', $_FILES[$file_field]['name']); @unlink($backup->source_dir); } }
} $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) { $shipment = new fedex_v7(); if (!($result = $shipment->retrieveLabel($sInfo))) { $error = true; } } // fetch label $ext = MODULE_SHIPPING_FEDEX_V7_PRINTER_TYPE == 'Thermal' ? '.lpt' : '.pdf'; write_file($backup->source_dir . 'Label_' . $count . $ext, $shipment->returned_label); $count++; } // convert session messages to current stack if ($error || $_SESSION['messageToStack']) { for ($i = 0; $i < sizeof($_SESSION['messageToStack']); $i++) { $messageStack->add($_SESSION['messageToStack'][$i]['text'], $_SESSION['messageToStack'][$i]['type']); } unset($_SESSION['messageToStack']); } $backup->make_zip('dir'); // Download file $backup->download($backup->dest_dir, $backup->dest_file, false); // will not return from here if successful /***************** prepare to display templates *************************/ // N/A
set_time_limit(20000); } $backup = new backup(); $backup->source_dir = DIR_FS_MY_FILES . $_SESSION['company'] . '/shipping/labels/' . $carrier . '/' . $fy_year . '/' . $fy_month . '/'; $backup->dest_dir = DIR_FS_MY_FILES . 'backups/'; switch ($conv_type) { case 'bz2': $backup->dest_file = 'ship_' . $carrier . '_' . $fy_year . $fy_month . '.tar.bz2'; if ($backup->make_bz2('dir')) { $error = true; } break; default: case 'zip': $backup->dest_file = 'ship_' . $carrier . '_' . $fy_year . $fy_month . '.zip'; if ($backup->make_zip('dir')) { $error = true; } break; } if (!$error) { gen_add_audit_log(GEN_DB_DATA_BACKUP, TABLE_AUDIT_LOG); $backup->download($backup->dest_dir, $backup->dest_file); // will not return if successful } $default_tab_id = 'tools'; break; case 'clean': $carrier = db_prepare_input($_POST['carrier']); $fy_month = db_prepare_input($_POST['fy_month']); $fy_year = db_prepare_input($_POST['fy_year']);
} break; case 'backup_log': if (ini_get('max_execution_time') < 20000) { set_time_limit(20000); } $backup = new backup(); $backup->db_filename = 'log-' . $_SESSION['company'] . '-' . date('Ymd'); $backup->source_dir = DIR_FS_MY_FILES . $_SESSION['company'] . '/'; $backup->source_file = $backup->db_filename . '.sql'; $backup->dest_dir = DIR_FS_MY_FILES . 'backups/'; $backup->dest_file = $backup->db_filename . '.zip'; if (!($result = $backup->dump_db_table($db, TABLE_AUDIT_LOG, 'both'))) { break; } $backup->make_zip('file'); if (file_exists($backup->source_dir . $backup->source_file)) { unlink($backup->source_dir . $backup->source_file); } if (!$error) { gen_add_audit_log(GEN_AUDIT_DB_DATA_BACKUP); $backup->download($backup->dest_dir, $backup->dest_file, false); } break; case 'clean_log': $temp = gen_get_dates(date('Y-m-d')); $current_date = date('Y-m-d', mktime(0, 0, 0, $temp['ThisMonth'], 1, $temp['ThisYear'])); $result = $db->Execute("delete from " . TABLE_AUDIT_LOG . " where action_date < '" . $current_date . "'"); $messageStack->add('The number of records deleted was:' . ' ' . $result->AffectedRows(), 'success'); gen_add_audit_log(GEN_AUDIT_DB_DATA_CLEAN); break;