authenticator(true); exit; } if ($argv[1] == "--purge-cache") { $GLOBALS["OUTPUT"] = true; purge_cache($argv[2]); exit; } if ($argv[1] == "--purge-all-caches") { $GLOBALS["OUTPUT"] = true; purge_all_caches(); exit; } if ($argv[1] == "--import-file") { $GLOBALS["OUTPUT"] = true; import_file(); exit; } if ($argv[1] == "--import-bulk") { $GLOBALS["OUTPUT"] = true; import_bulk(); exit; } if ($argv[1] == "--mem") { $GLOBALS["OUTPUT"] = true; parse_memory(); exit; } if ($argv[1] == "--mymem") { $GLOBALS["OUTPUT"] = true; max_memory();
<?php require "settings.php"; if (isset($_POST["key"])) { $OUTPUT = import_file($_POST); } else { $OUTPUT = get_file(); } require "template.php"; function get_file($err = "") { $display = "\n\t\t<h3>Import Email Addresses To Email Marketing Queue</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t<form action='" . SELF . "' method='POST' enctype='multipart/form-data'>\n\t\t\t<input type='hidden' name='key' value='import'>\n\t\t\t{$err}\n\t\t\t<tr>\n\t\t\t\t<th>Enter Name Of Queue</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><input type='text' size='40' name='upload_name'></td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<th>Select File To Upload</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><input type='file' name='upload_file'></td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<th>Format: 1 email per line</th>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Eg. </th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>test@test.com<br>\n\t\t\t\ttest2@test.com<br>\n\t\t\t\ttest3@test.com</li></td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<td><input type='submit' value='Import'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>"; return $display; } function import_file($_POST) { $errorlist = ""; $counter = 0; $newarr = array(); extract($_POST); #check if we have a queue name ... if (!isset($upload_name) or strlen($upload_name) < 1) { return get_file("<li class='err'>Please enter a valid email queue name.</li><br>"); } pglib_transaction("BEGIN") or errDie("Unable to start database transaction."); #add the group $sql1 = "INSERT INTO egroups (grouptitle,groupname) VALUES ('" . strtolower($upload_name) . "','{$upload_name}')"; $run_sql1 = db_exec($sql1) or errDie("Unable to record new email group information."); $file = file($_FILES["upload_file"]["tmp_name"]); foreach ($file as $each) { $each = trim($each);
if (isset($_POST['import_form'])) { //form has been submitted $subtitle = T_("Validating and uploading"); xhtml_head(T_("Import sample") . ":", true, $css, $js_head, false, false, false, $subtitle); echo "<a href='?' class='btn btn-default pull-left' ><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a>"; //verify each GET field is unique (except import_form) $sfields = array(); foreach ($_POST as $getv => $val) { //clean up? $sfields[$getv] = $val; } $error = verify_fields($sfields); $description = $_POST['description']; if ($error == "") { //verified so upload if (import_file($_POST['filename'], $description, $sfields)) { print "<div class='well text-primary col-md-offset-2'><p>" . T_("Successfully imported sample") . " <h3>{$description}</h3></p></div>"; } else { print "<div class='alert alert-danger col-md-offset-2'><p>" . T_("Error importing file. Please try again") . "</p></div>"; } } else { print "<div class='alert alert-danger col-md-offset-2'><p>" . T_("Error:") . " {$error} </p><p>" . T_("Please check imported file, go back in your browser and fix the problem") . "</p></div>"; } //verifiy that exactly one primary phone number is selected //upload to database xhtml_foot($js_foot); } else { if (isset($_POST['import_file'])) { //file has been submitted $subtitle = T_("Select columns to import"); xhtml_head(T_("Import sample") . ":", true, $css, $js_head, false, false, false, $subtitle);
} if ($worthit) { // when doing an update we leave access and owner untouched $query .= " lastmoddate='{$lastmoddate}', lastmodby='{$lastmodby}' WHERE id={$recordid}"; if ($r = $db->Execute($query)) { // keep count of new and modified records if ($makeNewId) { $inserted++; } else { $modified++; } for ($i = 0; $i < $nrfields; $i++) { if ($to_datatypes[$i] == 'file') { $fileids = explode(',', $fields[$i]); foreach ($fileids as $fileid) { import_file($db, $tableid, $recordid, $_POST["fields_{$i}"], $to_fields[$i], $fileid, $system_settings); } } elseif ($to_datatypes[$i] == 'mpulldown') { addmpulldown($db, $tableinfo, $recordid, $to_fields[$i], $fields[$i]); } } } //$db->debug=false; } } } // communicate results if (!isset($inserted)) { $inserted = 0; } if (!isset($modified)) {
function import_img($path = '', $col_name = "logo", $col_sn = '', $desc = "", $safe_name = false) { global $xoopsDB; if (strpos($path, "http") !== false) { $path = str_replace(XOOPS_URL, XOOPS_ROOT_PATH, $path); } if (empty($path)) { return; } if (!is_dir($path) and !is_file($path)) { return; } $db_files = array(); $sql = "select files_sn,file_name,original_filename from " . $xoopsDB->prefix("tad_web_files_center") . " where col_name='{$col_name}' and col_sn='{$col_sn}'"; $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error() . "<br>" . $sql); $db_files_amount = 0; while (list($files_sn, $file_name, $original_filename) = $xoopsDB->fetchRow($result)) { $db_files[$files_sn] = $original_filename; $db_files_amount++; } if (!empty($db_files_amount)) { return; } if (is_dir($path)) { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { if ($file == "." or $file == ".." or $file == "Thumbs.db") { continue; } $type = filetype($path . "/" . $file); if ($type != "dir") { if (!in_array($file, $db_files)) { import_file($path . "/" . $file, $col_name, $col_sn, null, null, $desc, $safe_name); } } } closedir($dh); } } elseif (is_file($path)) { import_file($path, $col_name, $col_sn, null, null, $desc, $safe_name); } }
<?php require "settings.php"; if (isset($_REQUEST["key"])) { switch ($_REQUEST["key"]) { default: case "get_file": $OUTPUT = get_file(); break; case "confirm": $OUTPUT = confirm(); break; case "write": $OUTPUT = import_file(); break; } } else { $OUTPUT = get_file(); } require "template.php"; function get_file() { $display = "\r\n\t\t<h3>Import Assets</h3>\r\n\t\t<table " . TMPL_tblDflts . ">\r\n\t\t<form action='" . SELF . "' method='POST' enctype='multipart/form-data'>\r\n\t\t\t<input type='hidden' name='key' value='confirm'>\r\n\t\t\t<tr>\r\n\t\t\t\t<td><li class='err'>The File To Imported Should Be\tDelimited By a Pipe \"|\" And Have No Text Qualifier</li></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td><li class='err'>File Must Contain The Following Fields:</li></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td><li class='err'>\r\n\t\t\t\tProductCode|SerialNumber|Description|VatCode|Barcode|QuantityAvailable|QuantityTotal|Category|SubCategory|Price1|<br>\r\n\t\t\t\tUnitOfMeasure1|Price2|UnitOfMeasure2|Price3|UnitOfMeasure3|Price4|UnitOfMeasure4|Price5|UnitOfMeasure5|StockUnit|<br>\r\n\t\t\t\tHireDaysBetweenService1|DateOfLastService1|ServiceType1|HireDaysBetweenService2|DateOfLastService2|ServiceType2|<br>\r\n\t\t\t\tHireDaysBetweenService3|DateOfLastService3|ServiceType3|SupplierName|CostPrice|HireItem|DateBought|OtherBranch|<br>\r\n\t\t\t\tOtherBranchSerialNumber|EngineNumber|EngineSerial|EngineType|DateModified|DepreciationType|DepreciationValue|<br>\r\n\t\t\t\tDepreciationPercentage|DepreciatedValue|InWorkshop|UserDefined1|UserDefined2|UserDefined3|UserDefined4|UserDefined5|<br>\r\n\t\t\t\tDeleted|ServiceType|ServiceItem</li></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Select File To Import</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td><input type='file' name='filename'></td>\r\n\t\t\t</tr>\r\n\t\t\t" . TBL_BR . "\r\n\t\t\t<tr>\r\n\t\t\t\t<td><input type='submit' value='Upload'></td>\r\n\t\t\t</tr>\r\n\t\t</form>\r\n\t\t</table>"; return $display; } function confirm() { extract($_REQUEST); $sql = "DROP TABLE cubit.import_assets"; db_exec($sql); $sql = "CREATE TABLE cubit.import_assets (\r\n\t\t\t\tid serial,\r\n\t\t\t\tserial varchar,\r\n\t\t\t\tlocat varchar,\r\n\t\t\t\tdes varchar,\r\n\t\t\t\tdate date,\r\n\t\t\t\tbdate date,\r\n\t\t\t\tamount numeric default 0,\r\n\t\t\t\tdiv numeric default 2,\r\n\t\t\t\tgrpid numeric default 0,\r\n\t\t\t\taccdep numeric default 0,\r\n\t\t\t\tdep_perc numeric default 0,\r\n\t\t\t\tdep_month varchar,\r\n\t\t\t\tserial2 varchar,\r\n\t\t\t\tteam_id numeric default 0,\r\n\t\t\t\tpuramt numeric default 0,\r\n\t\t\t\tconacc numeric default 0,\r\n\t\t\t\tsaledate date,\r\n\t\t\t\tsaleamt numeric default 0,\r\n\t\t\t\tinvid numeric default 0,\r\n\t\t\t\tautodepr_date date,\r\n\t\t\t\tsdate date,\r\n\t\t\t\ttemp_asset varchar default 'n',\r\n\t\t\t\tnonserial varchar,\r\n\t\t\t\ttype_id numeric default 0,\r\n\t\t\t\tsplit_from numeric default 1,\r\n\t\t\t\tdays numeric default 0,\r\n\t\t\t\ton_hand numeric default 0,\r\n\t\t\t\tsvdate date,\r\n\t\t\t\tprice numeric(16,2) default 0,\r\n\t\t\t\tper_day numeric(16,2) default 0,\r\n\t\t\t\tper_hour numeric(16,2) default 0,\r\n\t\t\t\tper_week numeric(16,2) default 0\r\n\t\t\t)";
<?php require "connect_db.php"; function import_file($filename) { if ($file = file_get_contents($filename)) { foreach (explode(";", $file) as $query) { $query = trim($query); if (!empty($query) && $query != ";") { mysql_query($query); } } } } import_file("croupierweb.sql");
<?php # ScriptUpdate - Management # $Id: index.php,v 1.24 2008/09/24 00:18:38 nobu Exp $ include '../../../include/cp_header.php'; include_once '../package.class.php'; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; $myts =& MyTextSanitizer::getInstance(); $op = isset($_GET['op']) ? $_GET['op'] : ''; $file_state = array('del' => _AM_DEL, 'chg' => _AM_CHG, 'new' => _AM_NEW, 'ok' => _AM_OK, 'extra' => _AM_EXTRA); if (isset($_POST['import'])) { redirect_result(import_file(), 'index.php?op=pkgs', _AM_NODATAINFILE); } elseif (isset($_POST['pkgdel'])) { redirect_result(delete_package(), 'index.php?op=pkgs'); } elseif (isset($_POST['accept'])) { redirect_result(modify_package(), 'index.php'); } elseif (isset($_POST['opts_select'])) { redirect_result(options_setting(), 'index.php'); } elseif (isset($_POST['clear'])) { $pkgid = intval($_POST['pkgid']); redirect_result(clear_package($pkgid), 'index.php?op=detail&pkgid=' . $pkgid); } elseif ($op == 'rollback') { redirect_result(rollback_update(), 'index.php'); } if (!empty($_GET['lib'])) { global $mydirpath; $mydirpath = dirname(dirname(__FILE__)); $mydirname = basename($mydirpath); // common libs (eg. altsys) $lib = preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['lib']); $page = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_GET['page']);