function upgrade() { // check if the files are there and remove them $file1 = BASE . "/framework/modules-1/administrationmodule/actions/trimdatabase.php"; $file2 = BASE . "/framework/modules-1/administrationmodule/actions/trimdatabase_final.php"; if (expUtil::isReallyWritable($file1) && expUtil::isReallyWritable($file2)) { unlink($file1); unlink($file2); return "Complete"; } else { return "Could not delete files."; } }
public function getRates($order) { $a = $order->total; //get the rates for ($i = 0; $i < @count($this->configdata['from']); $i++) { // We need to check if it is not the last in the array since we don't have a 'to' value in the last element if (count($this->configdata['from']) != $i + 1) { if (expUtil::isNumberGreaterThanOrEqualTo($a, $this->configdata['from'][$i]) && expUtil::isNumberLessThanOrEqualTo($a, $this->configdata['to'][$i])) { foreach ($this->shippingspeeds as $item) { $c[] = @$this->configdata[str_replace(' ', '_', $item->speed)][$i]; } break; } } else { if ($a >= floatval($this->configdata['from'][$i])) { foreach ($this->shippingspeeds as $item) { $c[] = @$this->configdata[str_replace(' ', '_', $item->speed)][$i]; } break; } } } //if certain states, add $$ from config $currentMethod = $order->getCurrentShippingMethod(); //third created shipping method //Get the config and parse to get the states/regions only $upcharge = ecomconfig::getConfig('upcharge'); $stateUpcharge = ecomconfig::splitConfigUpCharge($upcharge, 'region'); //2 - alaska //21 - hawaii //52 - PuertoRico // $stateUpcharge = array('2','21','52'); $rates = array(); if (!empty($c)) { for ($i = 0; $i < count($c); $i++) { if (array_key_exists($currentMethod->state, $stateUpcharge)) { $c[$i] += $stateUpcharge[$currentMethod->state]; // $c[$i] += $stateUpcharge[$currentMethod->state]; Commented this though i'm not sure if this is done intentionally } if ($i > 9) { $rates[$i + 1] = array('id' => 0 . ($i + 1), 'title' => @$this->shippingspeeds[$i]->speed, 'cost' => $c[$i]); } else { $rates[0 . ($i + 1)] = array('id' => 0 . ($i + 1), 'title' => @$this->shippingspeeds[$i]->speed, 'cost' => $c[$i]); } } } if (!count($rates)) { $rates['01'] = array('id' => '01', 'title' => "Table Based Shipping is Currently NOT Configured", 'cost' => 0); } return $rates; }
function upgrade() { // global $db; // check if the files are there and remove them $files = array(BASE . "datatypes/definitions/faqmodule_config.php", BASE . "datatypes/definitions/faq.php", BASE . "datatypes/faqmodule_config.php", BASE . "datatypes/faq.php", BASE . "modules/faqmodule/"); // delete the files. $removed = 0; $errors = 0; foreach ($files as $file) { if (expUtil::isReallyWritable($file)) { unlink($file); $removed += 1; } else { $errors += 1; } } return $removed . " files were deleted.<br>" . $errors . " files could not be removed."; }
/** exdoc * Looks at the filesystem structure surrounding the destination * and determines if the web server can create a new file there. * Returns one of the following: * <br>SYS_FILES_NOTWRITABLE - unable to create files in destination * <br>SYS_FILES_SUCCESS - A file or directory can be created in destination * <br>SYS_FILES_FOUNDFILE - Found destination to be a file, not a directory * * @param string $dest Path to the directory to check * @node Model:expFile */ public static function canCreate($dest) { if (substr($dest, 0, 1) == '/') { $dest = str_replace(BASE, '', $dest); } $parts = explode('/', $dest); $working = BASE; for ($i = 0; $i < count($parts); $i++) { if ($parts[$i] != '') { if (!file_exists($working . $parts[$i])) { return expUtil::isReallyWritable($working) ? SYS_FILES_SUCCESS : SYS_FILES_NOTWRITABLE; } $working .= $parts[$i] . '/'; } } // If we got this far, then the file we are asking about already exists. // Check to see if we can overwrite this file. // First however, we need to strip off the '/' that was added a few lines up as the last part of the for loop. $working = substr($working, 0, -1); if (!expUtil::isReallyWritable($working)) { return SYS_FILES_NOTWRITABLE; } else { if (is_file($working)) { return SYS_FILES_FOUNDFILE; } else { return SYS_FILES_FOUNDDIR; } } }
function _extractList($p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path) { $v_result = true; $v_nb = 0; $v_extract_all = true; $v_listing = false; $p_path = $this->_translateWinPath($p_path, false); if ($p_path == '' || substr($p_path, 0, 1) != '/' && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':')) { $p_path = "./" . $p_path; } $p_remove_path = $this->_translateWinPath($p_remove_path); // ----- Look for path to remove format (should end by /) if ($p_remove_path != '' && substr($p_remove_path, -1) != '/') { $p_remove_path .= '/'; } $p_remove_path_size = strlen($p_remove_path); switch ($p_mode) { case "complete": $v_extract_all = TRUE; $v_listing = FALSE; break; case "partial": $v_extract_all = FALSE; $v_listing = FALSE; break; case "list": $v_extract_all = FALSE; $v_listing = TRUE; break; default: $this->_error('Invalid extract mode (' . $p_mode . ')'); return false; } clearstatcache(); while (strlen($v_binary_data = $this->_readBlock()) != 0) { $v_extract_file = FALSE; $v_extraction_stopped = 0; if (!$this->_readHeader($v_binary_data, $v_header)) { return false; } if ($v_header['filename'] == '') { continue; } // ----- Look for long filename if ($v_header['typeflag'] == 'L') { if (!$this->_readLongHeader($v_header)) { return false; } } if (!$v_extract_all && is_array($p_file_list)) { // ----- By default no unzip if the file is not found $v_extract_file = false; for ($i = 0; $i < sizeof($p_file_list); $i++) { // ----- Look if it is a directory if (substr($p_file_list[$i], -1) == '/') { // ----- Look if the directory is in the filename path if (strlen($v_header['filename']) > strlen($p_file_list[$i]) && substr($v_header['filename'], 0, strlen($p_file_list[$i])) == $p_file_list[$i]) { $v_extract_file = TRUE; break; } } elseif ($p_file_list[$i] == $v_header['filename']) { $v_extract_file = TRUE; break; } } } else { $v_extract_file = TRUE; } // ----- Look if this file need to be extracted if ($v_extract_file && !$v_listing) { if ($p_remove_path != '' && substr($v_header['filename'], 0, $p_remove_path_size) == $p_remove_path) { $v_header['filename'] = substr($v_header['filename'], $p_remove_path_size); } if ($p_path != './' && $p_path != '/') { while (substr($p_path, -1) == '/') { $p_path = substr($p_path, 0, strlen($p_path) - 1); } if (substr($v_header['filename'], 0, 1) == '/') { $v_header['filename'] = $p_path . $v_header['filename']; } else { $v_header['filename'] = $p_path . '/' . $v_header['filename']; } } if (file_exists($v_header['filename'])) { if (@is_dir($v_header['filename']) && $v_header['typeflag'] == '') { $this->_error('File ' . $v_header['filename'] . ' already exists as a directory'); return false; } if (is_file($v_header['filename']) && $v_header['typeflag'] == "5") { $this->_error('Directory ' . $v_header['filename'] . ' already exists as a file'); return false; } if (!expUtil::isReallyWritable($v_header['filename'])) { $this->_error('File ' . $v_header['filename'] . ' already exists and is write protected'); return false; } if (filemtime($v_header['filename']) > $v_header['mtime']) { // To be completed : An error or silent no replace ? } } elseif (($v_result = $this->_dirCheck($v_header['typeflag'] == "5" ? $v_header['filename'] : dirname($v_header['filename']))) != 1) { $this->_error('Unable to create path for ' . $v_header['filename']); return false; } if ($v_extract_file) { if ($v_header['typeflag'] == "5") { if (!@file_exists($v_header['filename'])) { if (!@mkdir($v_header['filename'], 0777)) { $this->_error('Unable to create directory {' . $v_header['filename'] . '}'); return false; } } } else { if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { $this->_error('Error while opening {' . $v_header['filename'] . '} in write binary mode'); return false; } else { $n = floor($v_header['size'] / 512); for ($i = 0; $i < $n; $i++) { $v_content = $this->_readBlock(); fwrite($v_dest_file, $v_content, 512); } if ($v_header['size'] % 512 != 0) { $v_content = $this->_readBlock(); fwrite($v_dest_file, $v_content, $v_header['size'] % 512); } @fclose($v_dest_file); // ----- Change the file mode, mtime @touch($v_header['filename'], $v_header['mtime']); if ($v_header['mode'] & 0111) { // make file executable, obey umask $mode = fileperms($v_header['filename']) | ~umask() & 0111; @chmod($v_header['filename'], $mode); } } // ----- Check the file size clearstatcache(); if (filesize($v_header['filename']) != $v_header['size']) { $this->_error('Extracted file ' . $v_header['filename'] . ' does not have the correct file size \'' . filesize($v_filename) . '\' (' . $v_header['size'] . ' expected). Archive may be corrupted.'); return false; } } } else { $this->_jumpBlock(ceil($v_header['size'] / 512)); } } else { $this->_jumpBlock(ceil($v_header['size'] / 512)); } /* TBC : Seems to be unused ... if ($this->_compress) $v_end_of_file = @gzeof($this->_file); else $v_end_of_file = @feof($this->_file); */ if ($v_listing || $v_extract_file || $v_extraction_stopped) { // ----- Log extracted files if (($v_file_dir = dirname($v_header['filename'])) == $v_header['filename']) { $v_file_dir = ''; } if (substr($v_header['filename'], 0, 1) == '/' && $v_file_dir == '') { $v_file_dir = '/'; } $p_list_detail[$v_nb++] = $v_header; } } return true; }
/** * Archive_Zip::_extractFile() * * { Description } * */ function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params) { $v_result = 1; // ----- Read the file header if (($v_result = $this->_readFileHeader($v_header)) != 1) { // ----- Return return $v_result; } // ----- Check that the file header is coherent with $p_entry info // TBC // ----- Look for all path to remove if ($p_remove_all_path == true) { // ----- Get the basename of the path $p_entry['filename'] = basename($p_entry['filename']); } else { if ($p_remove_path != "") { //if (strcmp($p_remove_path, $p_entry['filename'])==0) if ($this->_tool_PathInclusion($p_remove_path, $p_entry['filename']) == 2) { // ----- Change the file status $p_entry['status'] = "filtered"; // ----- Return return $v_result; } $p_remove_path_size = strlen($p_remove_path); if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) { // ----- Remove the path $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); } } } // ----- Add the path if ($p_path != '') { $p_entry['filename'] = $p_path . "/" . $p_entry['filename']; } // ----- Look for pre-extract callback if (isset($p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT]) && $p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT] != '') { // ----- Generate a local information $v_local_header = array(); $this->_convertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. eval('$v_result = ' . $p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT] . '(ARCHIVE_ZIP_PARAM_PRE_EXTRACT, $v_local_header);'); if ($v_result == 0) { // ----- Change the file status $p_entry['status'] = "skipped"; $v_result = 1; } // ----- Update the informations // Only some fields can be modified $p_entry['filename'] = $v_local_header['filename']; } // ----- Trace // ----- Look if extraction should be done if ($p_entry['status'] == 'ok') { // ----- Look for specific actions while the file exist if (file_exists($p_entry['filename'])) { // ----- Look if file is a directory if (is_dir($p_entry['filename'])) { // ----- Change the file status $p_entry['status'] = "already_a_directory"; // ----- Return //return $v_result; } else { if (!expUtil::isReallyWritable($p_entry['filename'])) { // ----- Change the file status $p_entry['status'] = "write_protected"; // ----- Return //return $v_result; } else { if (filemtime($p_entry['filename']) > $p_entry['mtime']) { // ----- Change the file status $p_entry['status'] = "newer_exist"; // ----- Return //return $v_result; } } } } else { if (($p_entry['external'] & 0x10) == 0x10 || substr($p_entry['filename'], -1) == '/') { $v_dir_to_check = $p_entry['filename']; } else { if (!strstr($p_entry['filename'], "/")) { $v_dir_to_check = ""; } else { $v_dir_to_check = dirname($p_entry['filename']); } } if (($v_result = $this->_dirCheck($v_dir_to_check, ($p_entry['external'] & 0x10) == 0x10)) != 1) { // ----- Change the file status $p_entry['status'] = "path_creation_fail"; // ----- Return //return $v_result; $v_result = 1; } } } // ----- Look if extraction should be done if ($p_entry['status'] == 'ok') { // ----- Do the extraction (if not a folder) if (!(($p_entry['external'] & 0x10) == 0x10)) { // ----- Look for not compressed file if ($p_entry['compressed_size'] == $p_entry['size']) { // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { // ----- Change the file status $p_entry['status'] = "write_error"; // ----- Return return $v_result; } // ----- Read the file by ARCHIVE_ZIP_READ_BLOCK_SIZE octets blocks $v_size = $p_entry['compressed_size']; while ($v_size != 0) { $v_read_size = $v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE; $v_buffer = fread($this->_zip_fd, $v_read_size); $v_binary_data = pack('a' . $v_read_size, $v_buffer); @fwrite($v_dest_file, $v_binary_data, $v_read_size); $v_size -= $v_read_size; } // ----- Closing the destination file fclose($v_dest_file); // ----- Change the file mtime touch($p_entry['filename'], $p_entry['mtime']); } else { // ----- Trace // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { // ----- Change the file status $p_entry['status'] = "write_error"; return $v_result; } // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->_zip_fd, $p_entry['compressed_size']); // ----- Decompress the file $v_file_content = gzinflate($v_buffer); unset($v_buffer); // ----- Write the uncompressed data @fwrite($v_dest_file, $v_file_content, $p_entry['size']); unset($v_file_content); // ----- Closing the destination file @fclose($v_dest_file); // ----- Change the file mtime touch($p_entry['filename'], $p_entry['mtime']); } // ----- Look for chmod option if (isset($p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]) && $p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD] != 0) { // ----- Change the mode of the file chmod($p_entry['filename'], $p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]); } } } // ----- Look for post-extract callback if (isset($p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT]) && $p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT] != '') { // ----- Generate a local information $v_local_header = array(); $this->_convertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. eval('$v_result = ' . $p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT] . '(ARCHIVE_ZIP_PARAM_POST_EXTRACT, $v_local_header);'); } // ----- Return return $v_result; }
function upgrade() { global $db; // copy each locationref entry to the sectionref $srs = $db->selectObjects('sectionref', "module = 'headlineController'"); foreach ($srs as $sr) { $sr->module = 'textController'; $db->updateObject($sr, 'sectionref'); } $lrs = $db->selectObjects('locationref', "module = 'headlineController'"); foreach ($lrs as $lr) { $lr->module = 'textController'; $db->updateObject($lr, 'locationref'); } $gps = $db->selectObjects('grouppermission', "module = 'headlineController'"); foreach ($gps as $gp) { $gp->module = 'textController'; $db->updateObject($gp, 'grouppermission'); } $ups = $db->selectObjects('userpermission', "module = 'headlineController'"); foreach ($ups as $up) { $up->module = 'textController'; $db->updateObject($up, 'userpermission'); } // convert each headline module to a text module $modules_converted = 0; $cns = $db->selectObjects('container', "internal LIKE '%headlineController%'"); foreach ($cns as $cn) { $cloc = expUnserialize($cn->internal); $cloc->mod = 'textController'; $cn->internal = serialize($cloc); $cn->view = 'showall'; $cn->action = 'showall'; $db->updateObject($cn, 'container'); $modules_converted += 1; } // create a text item for each headline item $headlines_converted = 0; $headlines = $db->selectObjects('headline', "1"); foreach ($headlines as $hl) { $text = new text(); $loc = expUnserialize($hl->location_data); $loc->mod = "text"; $text->location_data = serialize($loc); $text->title = $hl->title; $text->poster = $hl->poster; $text->save(); $text->created_at = $hl->created_at; $text->edited_at = $hl->edited_at; $text->update(); $headlines_converted += 1; } // FIXME - remove when final return "TEST - We're NOT removing the locationref table nor the files yet...<br>" . $modules_converted . " Headline modules were converted.<br>" . $headlines_converted . " Headlines were converted.<br>"; // delete headline table $db->dropTable('locationref'); // check if the headline controller files are there and remove them $files = array(BASE . "framework/modules/definitions/headline.php", BASE . "framework/modules/models/headline.php", BASE . "framework/modules/headline/"); // delete the files. $removed = 0; $errors = 0; foreach ($files as $file) { if (expUtil::isReallyWritable($file)) { unlink($file); $removed += 1; } else { $errors += 1; } } return $modules_converted . " Headline modules were converted.<br>" . $headlines_converted . " Headlines were converted.<br>" . $removed . " files were deleted.<br>" . $errors . " files could not be removed."; }
/** exdoc * Activates a Configuration Profile. * * @param string $profile The name of the Profile to activate. * @node Subsystems:Config */ public static function activateProfile($profile) { //FIXME this method is never used if (is_readable(BASE . "conf/profiles/{$profile}.php") && expUtil::isReallyWritable(BASE . "conf/config.php")) { copy(BASE . "conf/profiles/{$profile}.php", BASE . "conf/config.php"); $fh = fopen(BASE . "conf/config.php", "a"); fwrite($fh, "\n<?php\ndefine(\"CURRENTCONFIGNAME\",\"{$profile}\");\n?>"); fclose($fh); } }
function _sanity_checkTemp($dir) { $file = tempnam($dir, 'temp'); if (is_readable($file) && expUtil::isReallyWritable($file)) { unlink($file); return array(SANITY_FINE, gt('Passed')); } else { return array(SANITY_ERROR, gt('Failed')); } }
function payment_report() { global $db; $payment_methods = array('-1' => '', 'V' => 'Visa', 'MC' => 'Mastercard', 'D' => 'Discover', 'AMEX' => 'American Express', 'PP' => 'PayPal', 'GC' => 'Google Checkout', 'Other' => 'Other'); //5 paypal //4 credit card - VisaCard, MasterCard, AmExCard, DiscoverCard $oids = "("; eDebug(expSession::get('order_print_query')); if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) { //$sql = expSession::get('order_print_query'); //eDebug($sql); //expSession::set('product_export_query',''); //$orders = $db->selectArraysBySql($sql); $obs = expSession::get('order_export_values'); usort($obs, array("reportController", "sortPrintOrders")); foreach ($obs as $ob) { $oids .= $ob->id . ","; } //eDebug($prods); } else { foreach ($this->params['act-upon'] as $order) { $oids .= $order->id . ","; } } $oids = strrev(expUtil::right(strrev($oids), strlen($oids) - 1)); $oids .= ")"; eDebug($oids); //eDebug($orders,true); }
public function isTempUser() { return is_numeric(expUtil::right($this->username, 10)) ? true : false; }