本文整理汇总了PHP中AError::toLog方法的典型用法代码示例。如果您正苦于以下问题:PHP AError::toLog方法的具体用法?PHP AError::toLog怎么用?PHP AError::toLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AError
的用法示例。
在下文中一共展示了AError::toLog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run_system_check
/**
* Main driver for running system check
* @since 1.2.4
* @param $registry
* @param $mode ('log', 'return')
* @return array
*
* Note: This is English text only. Can be call before database and languges are loaded
*/
function run_system_check($registry, $mode = 'log')
{
$mlog = $counts = array();
$mlog[] = check_install_directory($registry);
$mlog = array_merge($mlog, check_file_permissions($registry));
$mlog = array_merge($mlog, check_php_configuraion($registry));
$mlog = array_merge($mlog, check_server_configuration($registry));
$counts['error_count'] = $counts['warning_count'] = $counts['notice_count'] = 0;
foreach ($mlog as $message) {
if ($message['type'] == 'E') {
if ($mode == 'log') {
//only save errors to the log
$error = new AError($message['body']);
$error->toLog()->toDebug();
$registry->get('messages')->saveError($message['title'], $message['body']);
}
$counts['error_count']++;
} else {
if ($message['type'] == 'W') {
if ($mode == 'log') {
$registry->get('messages')->saveWarning($message['title'], $message['body']);
}
$counts['warning_count']++;
} else {
if ($message['type'] == 'N') {
if ($mode == 'log') {
$registry->get('messages')->saveNotice($message['title'], $message['body']);
}
$counts['notice_count']++;
}
}
}
}
return array($mlog, $counts);
}
示例2: writeToLog
/**
* SOAP request/response logging to a file
*/
function writeToLog($client)
{
if (!($logfile = fopen(TRANSACTIONS_LOG_FILE, "a"))) {
$error = new AError("Cannot open " . TRANSACTIONS_LOG_FILE . " file.\n");
$error->toLog()->toMessages->toDebug();
exit(1);
}
fwrite($logfile, sprintf("\r%s:- %s", date("D M j G:i:s T Y"), $client->__getLastRequest() . "\n\n" . $client->__getLastResponse()));
}
示例3: __construct
/**
* @param string $type
*/
public function __construct($type)
{
$this->registry = Registry::getInstance();
//NOTE: Storefront can not access all resource at once. Resource type required
if ($type) {
$this->type = $type;
//get type details
$this->_loadType();
}
if (!$this->type_id) {
$message = "Error: Incorrect or missing resource type ";
$error = new AError($message);
$error->toLog()->toDebug();
}
}
示例4: addStatus
public function addStatus($order_status_id, $status_text_id)
{
$order_status_id = (int) $order_status_id;
//preformat text_id at first
$status_text_id = preformatTextID($status_text_id);
if (in_array($order_status_id, array_keys($this->statuses)) || in_array($status_text_id, $this->statuses)) {
$error_text = 'Error: Cannot add new order status with id ' . $order_status_id . ' and text id ' . $status_text_id . ' into AOrderStatus class.';
$e = new AError($error_text);
$e->toLog()->toDebug();
return false;
}
if (!$status_text_id) {
$error_text = 'Error: Cannot add new order status with id ' . $order_status_id . ' and empty text id';
$e = new AError($error_text);
$e->toLog()->toDebug();
return false;
}
$this->statuses[$order_status_id] = $status_text_id;
return true;
}
示例5: escape
public function escape($value)
{
if (is_array($value)) {
$dump = var_export($value, true);
$backtrace = debug_backtrace();
$dump .= ' (file: ' . $backtrace[1]['file'] . ' line ' . $backtrace[1]['line'] . ')';
$message = 'aMySQLi class error: Try to escape non-string value: ' . $dump;
$error = new AError($message);
$error->toLog()->toDebug()->toMessages();
return false;
}
$search = array("\\", "", "\n", "\r", "", "'", '"');
$replace = array("\\\\", "\\0", "\\n", "\\r", "\\Z", "\\'", '\\"');
return str_replace($search, $replace, $value);
}
示例6: compressTarGZ
function compressTarGZ($tar_filename, $tar_dir, $compress_level = 5)
{
$compress_level = $compress_level < 1 || $compress_level > 9 ? 5 : $compress_level;
$exit_code = 0;
if (pathinfo($tar_filename, PATHINFO_EXTENSION) == 'gz') {
$filename = rtrim($tar_filename, '.gz');
} else {
$filename = $tar_filename . '.tar.gz';
}
$tar = rtrim($tar_filename, '.gz');
//remove archive if exists
if (is_file($tar_filename)) {
unlink($tar_filename);
}
if (is_file($filename)) {
unlink($filename);
}
if (is_file($tar)) {
unlink($tar);
}
if (class_exists('PharData')) {
try {
$a = new PharData($tar);
$a->buildFromDirectory($tar_dir);
// this code creates tar-file
if (file_exists($tar)) {
// remove tar-file after zipping
gzip($tar, $compress_level);
unlink($tar);
}
} catch (Exception $e) {
$error = new AError($e->getMessage());
$error->toLog()->toDebug();
$exit_code = 1;
}
} else {
$exit_code = 1;
}
if ($exit_code) {
$registry = Registry::getInstance();
$registry->get('load')->library('targz');
$targz = new Atargz();
return $targz->makeTar($tar_dir . $tar_filename, $filename, $compress_level);
} else {
return true;
}
}
示例7: AError
}
//before install validate it is unique
$lng_code = 'es';
$lng_name = 'Español';
$lng_directory = 'spanish';
$lng_locale = 'es_ES.UTF-8,es_ES,spanish';
$lng_flag_path = 'extensions/default_spanish/storefront/language/spanish/flag.png';
$lng_sort = 2;
// sorting order with other langauges
$lng_status = 0;
// Status on installation of extension
$query = $this->db->query("SELECT language_id FROM " . $this->db->table('languages') . " WHERE code='" . $lng_code . "'");
if ($query->row['language_id']) {
$this->session->data['error'] = "Error: Language with " . $lng_code . " code is already installed! Can not install duplicate languages! Uninstall this extension before attempting again.";
$error = new AError($this->session->data['error']);
$error->toLog()->toDebug();
return false;
}
$this->db->query("INSERT INTO " . $this->db->table('languages') . " (`name`,`code`,`locale`,`image`,`directory`,`filename`,`sort_order`, `status`)\n\t\t\t\t VALUES ('" . $lng_name . "', '" . $lng_code . "', '" . $lng_locale . "', '" . $lng_flag_path . "','" . $lng_directory . "','" . $lng_directory . "','" . $lng_sort . "'," . $lng_status . ");");
$new_language_id = $this->db->getLastId();
$xml = simplexml_load_file(DIR_EXT . 'default_spanish/menu.xml');
$routes = array('text_index_home_menu' => 'index/home', 'text_account_login_menu' => 'account/login', 'text_account_logout_menu' => 'account/logout', 'text_account_account_menu' => 'account/account', 'text_checkout_cart_menu' => 'checkout/cart', 'text_checkout_shipping_menu' => 'checkout/shipping');
if ($xml) {
foreach ($xml->definition as $item) {
$translates[$routes[(string) $item->key]] = (string) $item->value;
}
$storefront_menu = new AMenu_Storefront();
$storefront_menu->addLanguage($new_language_id, $translates);
}
//Load core content
$this->db->query("INSERT INTO " . $this->db->table('country_descriptions') . "\n(`country_id`,`language_id`, `name`) VALUES \n(1, " . $new_language_id . ",'Afganistán'),\n(2, " . $new_language_id . ",'Albania'),\n(3, " . $new_language_id . ",'Argelia'),\n(4, " . $new_language_id . ",'Samoa Americana'),\n(5, " . $new_language_id . ",'Andorra'),\n(6, " . $new_language_id . ",'Angola'),\n(7, " . $new_language_id . ",'Anguilla'),\n(8, " . $new_language_id . ",'Antártida'),\n(9, " . $new_language_id . ",'Antigua y Barbuda'),\n(10, " . $new_language_id . ",'Argentina'),\n(11, " . $new_language_id . ",'Armenia'),\n(12, " . $new_language_id . ",'Aruba'),\n(13, " . $new_language_id . ",'Australia'),\n(14, " . $new_language_id . ",'Austria'),\n(15, " . $new_language_id . ",'Azerbaiyán'),\n(16, " . $new_language_id . ",'Bahamas'),\n(17, " . $new_language_id . ",'Bahrein'),\n(18, " . $new_language_id . ",'Bangladesh'),\n(19, " . $new_language_id . ",'Barbados'),\n(20, " . $new_language_id . ",'Bielorrusia'),\n(21, " . $new_language_id . ",'Bélgica'),\n(22, " . $new_language_id . ",'Belice'),\n(23, " . $new_language_id . ",'Benin'),\n(24, " . $new_language_id . ",'Bermuda'),\n(25, " . $new_language_id . ",'Bhutan'),\n(26, " . $new_language_id . ",'Bolivia'),\n(27, " . $new_language_id . ",'Bosnia y Herzegovina'),\n(28, " . $new_language_id . ",'Botswana'),\n(29, " . $new_language_id . ",'Bouvet Island'),\n(30, " . $new_language_id . ",'Brasil'),\n(31, " . $new_language_id . ",'Territorio Británico del Océano Índico'),\n(32, " . $new_language_id . ",'Brunei Darussalam'),\n(33, " . $new_language_id . ",'Bulgaria'),\n(34, " . $new_language_id . ",'Burkina Faso'),\n(35, " . $new_language_id . ",'Burundi'),\n(36, " . $new_language_id . ",'Camboya'),\n(37, " . $new_language_id . ",'Camerún'),\n(38, " . $new_language_id . ",'Canadá'),\n(39, " . $new_language_id . ",'Cabo Verde'),\n(40, " . $new_language_id . ",'Islas Caimán'),\n(41, " . $new_language_id . ",'República Centroafricana'),\n(42, " . $new_language_id . ",'Chad'),\n(43, " . $new_language_id . ",'Chile'),\n(44, " . $new_language_id . ",'China'),\n(45, " . $new_language_id . ",'Isla de Navidad'),\n(46, " . $new_language_id . ",'Islas Cocos (Keeling)'),\n(47, " . $new_language_id . ",'Colombia'),\n(48, " . $new_language_id . ",'Comoras'),\n(49, " . $new_language_id . ",'Congo'),\n(50, " . $new_language_id . ",'Islas Cook'),\n(51, " . $new_language_id . ",'Costa Rica'),\n(52, " . $new_language_id . ",'Cote D'Ivoire'),\n(53, " . $new_language_id . ",'Croacia'),\n(54, " . $new_language_id . ",'Cuba'),\n(55, " . $new_language_id . ",'Chipre'),\n(56, " . $new_language_id . ",'República Checa'),\n(57, " . $new_language_id . ",'Dinamarca'),\n(58, " . $new_language_id . ",'Djibouti'),\n(59, " . $new_language_id . ",'Dominica'),\n(60, " . $new_language_id . ",'República Dominicana'),\n(61, " . $new_language_id . ",'Timor del Este'),\n(62, " . $new_language_id . ",'Ecuador'),\n(63, " . $new_language_id . ",'Egipto'),\n(64, " . $new_language_id . ",'El Salvador'),\n(65, " . $new_language_id . ",'Guinea Ecuatorial'),\n(66, " . $new_language_id . ",'Eritrea'),\n(67, " . $new_language_id . ",'Estonia'),\n(68, " . $new_language_id . ",'Etiopía'),\n(69, " . $new_language_id . ",'Islas Malvinas (Falkland)'),\n(70, " . $new_language_id . ",'Islas Feroe'),\n(71, " . $new_language_id . ",'Fiji'),\n(72, " . $new_language_id . ",'Finlandia'),\n(73, " . $new_language_id . ",'Francia'),\n(74, " . $new_language_id . ",'France, Metropolitan'),\n(75, " . $new_language_id . ",'Guiana francés'),\n(76, " . $new_language_id . ",'Polinesia francés'),\n(77, " . $new_language_id . ",'Territorios Australes Franceses'),\n(78, " . $new_language_id . ",'Gabón'),\n(79, " . $new_language_id . ",'Gambia'),\n(80, " . $new_language_id . ",'Georgia'),\n(81, " . $new_language_id . ",'Alemania'),\n(82, " . $new_language_id . ",'Ghana'),\n(83, " . $new_language_id . ",'Gibraltar'),\n(84, " . $new_language_id . ",'Grecia'),\n(85, " . $new_language_id . ",'Groenlandia'),\n(86, " . $new_language_id . ",'Granada'),\n(87, " . $new_language_id . ",'Guadalupe'),\n(88, " . $new_language_id . ",'Guam'),\n(89, " . $new_language_id . ",'Guatemala'),\n(90, " . $new_language_id . ",'Guinea'),\n(91, " . $new_language_id . ",'Guinea-Bissau'),\n(92, " . $new_language_id . ",'Guayana'),\n(93, " . $new_language_id . ",'Haití'),\n(94, " . $new_language_id . ",'Heard y Mc Donald Islas'),\n(95, " . $new_language_id . ",'Honduras'),\n(96, " . $new_language_id . ",'Hong Kong'),\n(97, " . $new_language_id . ",'Hungría'),\n(98, " . $new_language_id . ",'Islandia'),\n(99, " . $new_language_id . ",'India'),\n(100, " . $new_language_id . ",'Indonesia'),\n(101, " . $new_language_id . ",'Irán (República Islámica del)'),\n(102, " . $new_language_id . ",'Irak'),\n(103, " . $new_language_id . ",'Irlanda'),\n(104, " . $new_language_id . ",'Israel'),\n(105, " . $new_language_id . ",'Italia'),\n(106, " . $new_language_id . ",'Jamaica'),\n(107, " . $new_language_id . ",'Japón'),\n(108, " . $new_language_id . ",'Jordania'),\n(109, " . $new_language_id . ",'Kazajstán'),\n(110, " . $new_language_id . ",'Kenia'),\n(111, " . $new_language_id . ",'Kiribati'),\n(112, " . $new_language_id . ",'Corea del Norte'),\n(113, " . $new_language_id . ",'Corea, República de'),\n(114, " . $new_language_id . ",'Kuwait'),\n(115, " . $new_language_id . ",'Kirguistán'),\n(116, " . $new_language_id . ",'República Democrática Popular Lao'),\n(117, " . $new_language_id . ",'Letonia'),\n(118, " . $new_language_id . ",'Líbano'),\n(119, " . $new_language_id . ",'Lesoto'),\n(120, " . $new_language_id . ",'Liberia'),\n(121, " . $new_language_id . ",'Jamahiriya Árabe Libia'),\n(122, " . $new_language_id . ",'Liechtenstein'),\n(123, " . $new_language_id . ",'Lituania'),\n(124, " . $new_language_id . ",'Luxemburgo'),\n(125, " . $new_language_id . ",'Macau'),\n(126, " . $new_language_id . ",'Macedonia'),\n(127, " . $new_language_id . ",'Madagascar'),\n(128, " . $new_language_id . ",'Malawi'),\n(129, " . $new_language_id . ",'Malasia'),\n(130, " . $new_language_id . ",'Maldivas'),\n(131, " . $new_language_id . ",'Malí'),\n(132, " . $new_language_id . ",'Malta'),\n(133, " . $new_language_id . ",'Islas Marshall'),\n(134, " . $new_language_id . ",'Martinica'),\n(135, " . $new_language_id . ",'Mauritania'),\n(136, " . $new_language_id . ",'Mauricio'),\n(137, " . $new_language_id . ",'Mayotte'),\n(138, " . $new_language_id . ",'México'),\n(139, " . $new_language_id . ",'Micronesia, Estados Federados de'),\n(140, " . $new_language_id . ",'Moldova, República de'),\n(141, " . $new_language_id . ",'Mónaco'),\n(142, " . $new_language_id . ",'Mongolia'),\n(143, " . $new_language_id . ",'Montserrat'),\n(144, " . $new_language_id . ",'Marruecos'),\n(145, " . $new_language_id . ",'Mozambique'),\n(146, " . $new_language_id . ",'Myanmar'),\n(147, " . $new_language_id . ",'Namibia'),\n(148, " . $new_language_id . ",'Nauru'),\n(149, " . $new_language_id . ",'Nepal'),\n(150, " . $new_language_id . ",'Países Bajos'),\n(151, " . $new_language_id . ",'Antillas Holandesas'),\n(152, " . $new_language_id . ",'Nueva Caledonia'),\n(153, " . $new_language_id . ",'Nueva Zelandia'),\n(154, " . $new_language_id . ",'Nicaragua'),\n(155, " . $new_language_id . ",'Níger'),\n(156, " . $new_language_id . ",'Nigeria'),\n(157, " . $new_language_id . ",'Niue'),\n(158, " . $new_language_id . ",'Isla Norfolk'),\n(159, " . $new_language_id . ",'Islas Marianas del Norte'),\n(160, " . $new_language_id . ",'Noruega'),\n(161, " . $new_language_id . ",'Omán'),\n(162, " . $new_language_id . ",'Pakistán'),\n(163, " . $new_language_id . ",'Palau'),\n(164, " . $new_language_id . ",'Panamá'),\n(165, " . $new_language_id . ",'Papua Nueva Guinea'),\n(166, " . $new_language_id . ",'Paraguay'),\n(167, " . $new_language_id . ",'Perú'),\n(168, " . $new_language_id . ",'Filipinas'),\n(169, " . $new_language_id . ",'Pitcairn'),\n(170, " . $new_language_id . ",'Polonia'),\n(171, " . $new_language_id . ",'Portugal'),\n(172, " . $new_language_id . ",'Puerto Rico'),\n(173, " . $new_language_id . ",'Katar'),\n(174, " . $new_language_id . ",'Reunión'),\n(175, " . $new_language_id . ",'Rumania'),\n(176, " . $new_language_id . ",'Rusia'),\n(177, " . $new_language_id . ",'Ruanda'),\n(178, " . $new_language_id . ",'Saint Kitts y Nevis'),\n(179, " . $new_language_id . ",'Santa Lucía'),\n(180, " . $new_language_id . ",'San Vicente y las Granadinas'),\n(181, " . $new_language_id . ",'Samoa'),\n(182, " . $new_language_id . ",'San Marino'),\n(183, " . $new_language_id . ",'Santo Tomé y Príncipe'),\n(184, " . $new_language_id . ",'Arabia Saudita'),\n(185, " . $new_language_id . ",'Senegal'),\n(186, " . $new_language_id . ",'Seychelles'),\n(187, " . $new_language_id . ",'Sierra Leona'),\n(188, " . $new_language_id . ",'Singapur'),\n(189, " . $new_language_id . ",'República Eslovaca'),\n(190, " . $new_language_id . ",'Eslovenia'),\n(191, " . $new_language_id . ",'Islas Salomón'),\n(192, " . $new_language_id . ",'Somalia'),\n(193, " . $new_language_id . ",'Sudáfrica'),\n(194, " . $new_language_id . ",'Georgia del Sur y Sandwich del Sur Islas'),\n(195, " . $new_language_id . ",'España'),\n(196, " . $new_language_id . ",'Sri Lanka'),\n(197, " . $new_language_id . ",'St. Helena'),\n(198, " . $new_language_id . ",'San Pedro y Miquelón'),\n(199, " . $new_language_id . ",'Sudán'),\n(200, " . $new_language_id . ",'Suriname'),\n(201, " . $new_language_id . ",'Svalbard y Jan Mayen'),\n(202, " . $new_language_id . ",'Swazilandia'),\n(203, " . $new_language_id . ",'Suecia'),\n(204, " . $new_language_id . ",'Suiza'),\n(205, " . $new_language_id . ",'República Árabe Siria'),\n(206, " . $new_language_id . ",'Taiwan'),\n(207, " . $new_language_id . ",'Tayikistán'),\n(208, " . $new_language_id . ",'Tanzania, República Unida de'),\n(209, " . $new_language_id . ",'Tailandia'),\n(210, " . $new_language_id . ",'Togo'),\n(211, " . $new_language_id . ",'Tokelau'),\n(212, " . $new_language_id . ",'Tonga'),\n(213, " . $new_language_id . ",'Trinidad y Tobago'),\n(214, " . $new_language_id . ",'Túnez'),\n(215, " . $new_language_id . ",'Turquía'),\n(216, " . $new_language_id . ",'Turkmenistán'),\n(217, " . $new_language_id . ",'Turcas y Caicos'),\n(218, " . $new_language_id . ",'Tuvalu'),\n(219, " . $new_language_id . ",'Uganda'),\n(220, " . $new_language_id . ",'Ucrania'),\n(221, " . $new_language_id . ",'Emiratos Árabes Unidos'),\n(222, " . $new_language_id . ",'Reino Unido'),\n(223, " . $new_language_id . ",'Estados Unidos'),\n(224, " . $new_language_id . ",'Estados Unidos Islas menores alejadas de los'),\n(225, " . $new_language_id . ",'Uruguay'),\n(226, " . $new_language_id . ",'Uzbekistán'),\n(227, " . $new_language_id . ",'Vanuatu'),\n(228, " . $new_language_id . ",'Ciudad del Vaticano (Santa Sede)'),\n(229, " . $new_language_id . ",'Venezuela'),\n(230, " . $new_language_id . ",'Viet Nam'),\n(231, " . $new_language_id . ",'Islas Vírgenes (Británicas)'),\n(232, " . $new_language_id . ",'Islas Vírgenes (EE.UU.)'),\n(233, " . $new_language_id . ",'Islas Wallis y Futuna'),\n(234, " . $new_language_id . ",'Sáhara Occidental'),\n(235, " . $new_language_id . ",'Yemen'),\n(236, " . $new_language_id . ",'Yugoslavia'),\n(237, " . $new_language_id . ",'Zaire'),\n(238, " . $new_language_id . ",'Zambia'),\n(239, " . $new_language_id . ",'Zimbabue'),\n(240, " . $new_language_id . ",'Irlanda del Norte');\n");
示例8: run_critical_system_check
/**
* @param Registry $registry
* @param string $mode
* @return array
*/
function run_critical_system_check($registry, $mode = 'log')
{
$mlog = array();
$mlog[] = check_session_save_path();
$output = array();
foreach ($mlog as $message) {
if ($message['body']) {
if ($mode == 'log') {
//only save errors to the log
$error = new AError($message['body']);
$error->toLog()->toDebug();
$registry->get('messages')->saveError($message['title'], $message['body']);
}
$output[] = $message;
}
}
return $output;
}
示例9: dumpTables
/**
* @param array $tables - tables list
* @param string $dump_file - path of file with sql dump
* @return bool|string - path of dump file or false
*/
public function dumpTables($tables = array(), $dump_file = '')
{
if (!$tables || !is_array($tables) || !$this->backup_dir) {
$error_text = 'Error: Cannot to dump of tables during sql-dumping. Empty table list or unknown destination folder.';
$error = new AError($error_text);
$error->toLog()->toDebug();
return false;
}
foreach ($tables as $table) {
if (!is_string($table)) {
continue;
}
// clean
$table_list[] = $this->db->escape($table);
}
$driver = DB_DRIVER;
/**
* @var $db AMySQLi
*/
$db = new $driver(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
// use driver directly to exclude hooks calls
$prefix_len = strlen(DB_PREFIX);
// get sizes of tables
$sql = "SELECT TABLE_NAME AS 'table_name',\n\t\t\t\t\ttable_rows AS 'num_rows', (data_length + index_length - data_free) AS 'size'\n\t\t\t\tFROM information_schema.TABLES\n\t\t\t\tWHERE information_schema.TABLES.table_schema = '" . DB_DATABASE . "'\n\t\t\t\t\tAND TABLE_NAME IN ('" . implode("','", $table_list) . "')\t";
if ($prefix_len) {
$sql .= " AND TABLE_NAME like '" . DB_PREFIX . "%'";
}
$result = $this->db->query($sql);
$memory_limit = (getMemoryLimitInBytes() - memory_get_usage()) / 4;
// sql-file for small tables
$dump_file = $this->backup_dir . 'data/dump_' . DB_DATABASE . '_' . date('Y-m-d-His') . '.sql';
$file = fopen($dump_file, 'w');
if (!$file) {
$error_text = 'Error: Cannot create file as "' . $dump_file . '" during sql-dumping. Check is it writable.';
$error = new AError($error_text);
$error->toLog()->toDebug();
return false;
}
foreach ($result->rows as $table_info) {
$table_name = $table_info['table_name'];
if ($this->sql_dump_mode == 'data_only') {
fwrite($file, "TRUNCATE TABLE `" . $table_name . "`;\n\n");
} elseif ($this->sql_dump_mode == 'recreate') {
$sql = "SHOW CREATE TABLE `" . $table_name . "`;";
$r = $db->query($sql);
$ddl = $r->row['Create Table'];
fwrite($file, "DROP TABLE IF EXISTS `" . $table_name . "`;\n\n");
fwrite($file, $ddl . "\n\n");
}
//then try to get table data by pagination.
// to split data by pages use range of values of column that have PRIMARY KEY. NOT LIMIT-OFFSET!!!
// 1. - get column name with primary key and data type integer
$sql = "SELECT COLUMN_NAME\n\t\t\t\t\tFROM information_schema.COLUMNS c\n\t\t\t\t\tWHERE c.`TABLE_SCHEMA` = '" . DB_DATABASE . "'\n\t\t\t\t\t\tAND c.`TABLE_NAME` = '" . $table_name . "'\n\t\t\t\t\t\tAND c.`COLUMN_KEY` = 'PRI'\n\t\t\t\t\t AND c.`DATA_TYPE`='int'\n\t\t\t\t\tLIMIT 0,1;";
$r = $db->query($sql);
$column_name = $r->row['COLUMN_NAME'];
$small_table = false;
if ($column_name) {
$sql = "SELECT MAX(`" . $column_name . "`) as max, MIN(`" . $column_name . "`) as min\n\t\t\t\t\t\tFROM `" . $table_name . "`";
$r = $db->query($sql);
$column_max = $r->row['max'];
$column_min = $r->row['min'];
} else {
// if table have no PRIMARY KEY - try to dump it by one pass
$column_max = $table_info['num_rows'];
$start = $stop = $column_min = 0;
$small_table = true;
}
unset($r);
// for tables greater than $memory_limit (for ex. if php memory limit 64mb $memory_limit equal 10mb)
if ($table_info['size'] > $memory_limit && !$small_table) {
// for tables greater than 20 MB
//max allowed rows count for safe fetching
$limit = 10000;
//break export aparts to prevent memory overflow
$start = $column_min;
$stop = $column_min + $limit;
$small_table = false;
} else {
// for small table get data by one pass
$column_max = $limit = $table_info['num_rows'];
$start = $stop = $column_min = 0;
$small_table = true;
}
while ($start < $column_max) {
if (!$small_table) {
$sql = "SELECT *\n\t\t\t\t\t\t FROM `" . $table_name . "`\n\t\t\t\t\t\t WHERE `" . $column_name . "` >= '" . $start . "' AND `" . $column_name . "`< '" . $stop . "'";
} else {
$sql = "SELECT * FROM `" . $table_name . "`";
}
// dump data with using "INSERT"
$r = $db->query($sql, true);
foreach ($r->rows as $row) {
$fields = '';
$arr_keys = array_keys($row);
foreach ($arr_keys as $value) {
//.........这里部分代码省略.........
示例10: send
/**
* @param string $sendpoint
* @param array $msg_details
* @return null
$msg_details structure:
array(
0 => array(
message => 'text',
)
1 => array(
message => 'text',
)
);
0 - storefront (customer) and 1 - Admin (user)
notes: If message is not provided, message text will be takes from languages based on checkpoint text key.
*/
public function send($sendpoint, $msg_details = array())
{
$this->load->language('common/im');
$customer_im_settings = array();
if (IS_ADMIN !== true) {
$sendpoints_list = $this->sendpoints;
//do have storefront sendpoint?
if (!empty($sendpoints_list[$sendpoint][0])) {
$this->load->model('account/customer');
$customer_im_settings = $this->getCustomerNotificationSettings();
}
$this->registry->set('force_skip_errors', true);
} else {
$sendpoints_list = $this->admin_sendpoints;
//this method forbid sending notifications to customers from admin-side
$customer_im_settings = array();
}
//check sendpoint
if (!in_array($sendpoint, array_keys($sendpoints_list))) {
$error = new AError('IM error: Unrecognized SendPoint ' . $sendpoint . '. Nothing sent.');
$error->toLog()->toMessages();
return false;
}
$sendpoint_data = $sendpoints_list[$sendpoint];
foreach ($this->protocols as $protocol) {
$driver = null;
//check protocol status
if ($protocol == 'email') {
//email notifications always enabled
$protocol_status = 1;
} else {
if ((int) $this->config->get('config_storefront_' . $protocol . '_status') || (int) $this->config->get('config_admin_' . $protocol . '_status')) {
$protocol_status = 1;
} else {
$protocol_status = 0;
}
}
if (!$protocol_status) {
continue;
}
if ($protocol == 'email') {
//see AMailAIM class below
$driver = new AMailIM();
} else {
$driver_txt_id = $this->config->get('config_' . $protocol . '_driver');
//if driver not set - skip protocol
if (!$driver_txt_id) {
continue;
}
if (!$this->config->get($driver_txt_id . '_status')) {
$error = new AError('Cannot send notification. Communication driver ' . $driver_txt_id . ' is disabled!');
$error->toLog()->toMessages();
continue;
}
//use safe usage
$driver_file = DIR_EXT . $driver_txt_id . '/core/lib/' . $driver_txt_id . '.php';
if (!is_file($driver_file)) {
$error = new AError('Cannot find file ' . $driver_file . ' to send notification.');
$error->toLog()->toMessages();
continue;
}
try {
/** @noinspection PhpIncludeInspection */
include_once $driver_file;
//if class of driver
$classname = preg_replace('/[^a-zA-Z]/', '', $driver_txt_id);
if (!class_exists($classname)) {
$error = new AError('IM-driver ' . $driver_txt_id . ' load error.');
$error->toLog()->toMessages();
continue;
}
$driver = new $classname();
} catch (Exception $e) {
}
}
//if driver cannot be initialized - skip protocol
if ($driver === null) {
continue;
}
$store_name = $this->config->get('store_name') . ": ";
if (!empty($sendpoint_data[0])) {
//send notification to customer, check if selected or forced
$force_arr = $sendpoint_data[0]['force_send'];
//.........这里部分代码省略.........
示例11: addResource
/**
* upload resources to directory with type name (example: image)
*
* @param array $resource
* @return int resource id
*/
public function addResource($resource)
{
if (!$this->type_id) {
$message = "Error: Incorrect or missing resource type. Please set type using setType() method ";
$error = new AError($message);
$error->toLog()->toDebug();
return false;
}
$sql = "INSERT INTO " . DB_PREFIX . "resource_library\n SET type_id = '" . $this->type_id . "',\n created = NOW()";
$this->db->query($sql);
$resource_id = $this->db->getLastId();
if (!empty($resource['resource_path'])) {
$resource_path = $this->getHexPath($resource_id) . strtolower(substr(strrchr($resource['resource_path'], '.'), 0));
$resource_dir = dirname($resource_path);
if (!is_dir(DIR_RESOURCE . $this->type_dir . $resource_dir)) {
$path = '';
$directories = explode('/', $resource_dir);
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!is_dir(DIR_RESOURCE . $this->type_dir . $path)) {
@mkdir(DIR_RESOURCE . $this->type_dir . $path, 0777);
chmod(DIR_RESOURCE . $this->type_dir . $path, 0777);
}
}
}
if (is_file(DIR_RESOURCE . $this->type_dir . $resource_path)) {
unlink(DIR_RESOURCE . $this->type_dir . $resource_path);
}
if (!rename(DIR_RESOURCE . $this->type_dir . $resource['resource_path'], DIR_RESOURCE . $this->type_dir . $resource_path)) {
$message = "Error: Cannot move resource to resources directory.";
$error = new AError($message);
$error->toLog()->toDebug();
return false;
}
} else {
$resource_path = '';
}
foreach ($resource['name'] as $language_id => $name) {
if ($this->config->get('translate_override_existing') && $language_id != $resource['language_id']) {
continue;
}
$this->language->replaceDescriptions('resource_descriptions', array('resource_id' => (int) $resource_id), array((int) $language_id => array('name' => $resource['name'][$language_id], 'title' => $resource['title'][$language_id], 'description' => $resource['description'][$language_id], 'resource_path' => $resource_path, 'resource_code' => $resource['resource_code'], 'created' => date('Y-m-d H:i:s'))));
}
$this->cache->delete('resources.' . $this->type);
return $resource_id;
}
示例12: agreement
public function agreement()
{
$package_info =& $this->session->data['package_info'];
// if we got decision
if ($this->request->is_POST()) {
// if does not agree with agreement of filesize
if ($this->request->post['disagree'] == 1) {
$this->_removeTempFiles();
unset($this->session->data['package_info']);
$this->redirect($this->html->getSecureURL('extension/extensions/extensions'));
} elseif ($this->request->post['agree_incompatibility']) {
$package_info['confirm_version_incompatibility'] = true;
$this->redirect($this->html->getSecureURL('tool/package_installer/agreement'));
} elseif ($this->request->post['agree']) {
$this->redirect($this->html->getSecureURL('tool/package_installer/install'));
} elseif (!$this->request->post['agree'] && !isset($this->request->post['ftp_user'])) {
$this->_removeTempFiles('dir');
$this->redirect($this->_get_begin_href());
}
}
$this->loadLanguage('tool/package_installer');
$package_name = $package_info['package_name'];
if (!$package_name) {
// if direct link - redirect to the begining
$this->redirect($this->_get_begin_href());
}
$pmanager = new APackageManager();
//unpack package
// if package not unpacked - redirect to the begin and show error message
if (!is_dir($package_info['tmp_dir'] . $package_info['extension_key'])) {
mkdir($package_info['tmp_dir'] . $package_info['extension_key'], 0777);
}
if (!$pmanager->unpack($package_info['tmp_dir'] . $package_name, $package_info['tmp_dir'] . $package_info['extension_key'] . '/')) {
$this->session->data['error'] = str_replace('%PACKAGE%', $package_info['tmp_dir'] . $package_name, $this->language->get('error_unpack'));
$error = new AError($pmanager->error);
$error->toLog()->toDebug();
$this->redirect($this->_get_begin_href());
}
$package_dirname = $package_info['package_dir'] = $this->_find_package_dir();
if (!$package_info['package_dir']) {
$error = 'Error: Cannot to find package directory after unpacking archive. ';
$error = new AError($error);
$error->toLog()->toDebug();
}
if (!file_exists($package_info['tmp_dir'] . $package_dirname)) {
$this->session->data['error'] = $this->html->convertLinks(sprintf($this->language->get('error_pack_file_not_found'), $package_info['tmp_dir'] . $package_dirname));
$this->redirect($this->_get_begin_href());
}
// so.. we need to know about install mode of this package
/**
* @var DOMNode $config
*/
$config = simplexml_load_string(file_get_contents($package_info['tmp_dir'] . $package_dirname . '/package.xml'));
if (!$config) {
$this->session->data['error'] = $this->html->convertLinks($this->language->get('error_package_config_xml'));
$this->_removeTempFiles();
$this->redirect($this->_get_begin_href());
}
$package_info['package_id'] = (string) $config->id;
$package_info['package_type'] = (string) $config->type;
$package_info['package_priority'] = (string) $config->priority;
$package_info['package_version'] = (string) $config->version;
$package_info['package_content'] = '';
if ((string) $config->package_content->extensions) {
foreach ($config->package_content->extensions->extension as $item) {
if ((string) $item) {
$package_info['package_content']['extensions'][] = (string) $item;
}
}
$package_info['package_content']['total'] = sizeof($package_info['package_content']['extensions']);
}
if ((string) $config->package_content->core) {
foreach ($config->package_content->core->files->file as $item) {
if ((string) $item) {
$package_info['package_content']['core'][] = (string) $item;
}
}
}
if (!$package_info['package_content'] || $package_info['package_content']['core'] && $package_info['package_content']['extensions']) {
$this->session->data['error'] = $this->language->get('error_package_structure');
$this->_removeTempFiles();
$this->redirect($this->_get_begin_href());
}
//check cart version compability
if (!isset($package_info['confirm_version_incompatibility'])) {
if (!$this->_check_cart_version($config)) {
if ($this->_isCorePackage()) {
$this->session->data['error'] = $this->language->get('error_package_version_compatibility');
$this->redirect($this->html->getSecureURL('tool/package_installer'));
} else {
$this->redirect($this->html->getSecureURL('tool/package_installer/agreement'));
}
}
}
// if we were redirected
if ($this->request->is_GET()) {
//check write permissions
// find directory from app_root_dir
$non_writables = array();
if ($package_info['package_content']['extensions']) {
//.........这里部分代码省略.........
示例13: _send_sms
private function _send_sms($phone, $data)
{
if (!$phone || !$data) {
$error = new AError('Error: Cannot send sms. Unknown phone number or empty message.');
$error->toLog()->toMessages();
return false;
}
$driver = null;
$driver_txt_id = $this->config->get('config_sms_driver');
//if driver not set - skip protocol
if (!$driver_txt_id) {
return false;
}
//use safe usage
try {
include_once DIR_EXT . $driver_txt_id . '/core/lib/' . $driver_txt_id . '.php';
//if class of driver
$classname = preg_replace('/[^a-zA-Z]/', '', $driver_txt_id);
if (!class_exists($classname)) {
$error = new AError('IM-driver ' . $driver_txt_id . ' load error.');
$error->toLog()->toMessages();
return false;
}
$driver = new $classname();
} catch (AException $e) {
}
if ($driver === null) {
return false;
}
$text = $this->config->get('store_name') . ": " . $data['message'];
$to = $phone;
$result = true;
if ($text && $to) {
//use safe call
try {
$result = $driver->send($to, $text);
} catch (AException $e) {
return false;
}
}
return $result;
}
示例14: get_image_size
/**
* Function returns image dimensions
* @param $filename
* @return array|bool
*/
function get_image_size($filename)
{
if (file_exists($filename) && ($info = getimagesize($filename))) {
return array('width' => $info[0], 'height' => $info[1], 'mime' => $info['mime']);
}
if ($filename) {
$error = new AError('Error: Cannot get image size of file ' . $filename . '. File not found or it\'s not an image!');
$error->toLog()->toMessages()->toDebug();
}
return array();
}
示例15: send
public function send()
{
if (!$this->config->get('default_pp_pro_test')) {
$api_endpoint = 'https://api-3t.paypal.com/nvp';
} else {
$api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
}
if (!$this->config->get('default_pp_pro_transaction')) {
$payment_type = 'Authorization';
} else {
$payment_type = 'Sale';
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$order_total = $this->currency->format($order_info['total'], $order_info['currency'], '', false);
$products_data = $this->_get_products_data(array('currency' => $order_info['currency'], 'value' => '', 'order_total' => $order_total));
$payment_data = array('METHOD' => 'DoDirectPayment', 'VERSION' => '51.0', 'USER' => html_entity_decode($this->config->get('default_pp_pro_username'), ENT_QUOTES, 'UTF-8'), 'PWD' => html_entity_decode($this->config->get('default_pp_pro_password'), ENT_QUOTES, 'UTF-8'), 'SIGNATURE' => html_entity_decode($this->config->get('default_pp_pro_signature'), ENT_QUOTES, 'UTF-8'), 'CUSTREF' => $order_info['order_id'], 'CUSTOM' => $order_info['order_id'], 'INVNUM' => '#' . $order_info['order_id'], 'PAYMENTACTION' => $payment_type, 'AMT' => $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE), 'ITEMAMT' => (double) $this->data['items_total'], 'TAXAMT' => (double) $this->data['tax_total'], 'SHIPPINGAMT' => (double) $this->data['shipping_total'], 'HANDLINGAMT' => (double) $this->data['handling_total'], 'CREDITCARDTYPE' => $this->request->post['cc_type'], 'ACCT' => str_replace(' ', '', $this->request->post['cc_number']), 'CARDSTART' => $this->request->post['cc_start_date_month'] . $this->request->post['cc_start_date_year'], 'EXPDATE' => $this->request->post['cc_expire_date_month'] . $this->request->post['cc_expire_date_year'], 'CVV2' => $this->request->post['cc_cvv2'], 'CARDISSUE' => $this->request->post['cc_issue'], 'FIRSTNAME' => $order_info['payment_firstname'], 'LASTNAME' => $order_info['payment_lastname'], 'EMAIL' => $order_info['email'], 'PHONENUM' => $order_info['telephone'], 'IPADDRESS' => $this->request->server['REMOTE_ADDR'], 'STREET' => $order_info['payment_address_1'], 'CITY' => $order_info['payment_city'], 'STATE' => $order_info['payment_iso_code_2'] != 'US' ? $order_info['payment_zone'] : $order_info['payment_zone_code'], 'ZIP' => $order_info['payment_postcode'], 'COUNTRYCODE' => $order_info['payment_iso_code_2'], 'CURRENCYCODE' => $order_info['currency'], 'BUTTONSOURCE' => 'Abante_Cart', 'NOTIFYURL' => $this->html->getSecureURL('extension/default_pp_pro/callback'));
if ($this->cart->hasShipping()) {
$payment_data = array_merge($payment_data, array('SHIPTONAME' => $order_info['shipping_firstname'] . ' ' . $order_info['shipping_lastname'], 'SHIPTOSTREET' => $order_info['shipping_address_1'], 'SHIPTOCITY' => $order_info['shipping_city'], 'SHIPTOSTATE' => $order_info['shipping_iso_code_2'] != 'US' ? $order_info['shipping_zone'] : $order_info['shipping_zone_code'], 'SHIPTOCOUNTRYCODE' => $order_info['shipping_iso_code_2'], 'SHIPTOZIP' => $order_info['shipping_postcode']));
} else {
$payment_data = array_merge($payment_data, array('SHIPTONAME' => $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'], 'SHIPTOSTREET' => $order_info['payment_address_1'], 'SHIPTOCITY' => $order_info['payment_city'], 'SHIPTOSTATE' => $order_info['payment_iso_code_2'] != 'US' ? $order_info['payment_zone'] : $order_info['payment_zone_code'], 'SHIPTOCOUNTRYCODE' => $order_info['payment_iso_code_2'], 'SHIPTOZIP' => $order_info['payment_postcode']));
}
//items list
//check amounts
$calc_total = $this->data['items_total'] + $this->data['shipping_total'] + $this->data['tax_total'] + $this->data['handling_total'];
if ($calc_total - $order_total !== 0.0) {
$skip_item_list = true;
$payment_data['ITEMAMT'] = 0;
$payment_data['TAXAMT'] = 0;
$payment_data['SHIPPINGAMT'] = 0;
$payment_data['HANDLINGAMT'] = 0;
}
if (!$skip_item_list) {
foreach ($products_data as $key => $product) {
$payment_data['L_NAME' . $key] = $product['name'];
$payment_data['L_AMT' . $key] = (double) $product['price'];
$payment_data['L_NUMBER' . $key] = $product['model'];
$payment_data['L_QTY' . $key] = $product['quantity'];
}
}
$curl = curl_init($api_endpoint);
curl_setopt($curl, CURLOPT_PORT, 443);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($payment_data));
$response = curl_exec($curl);
$json = array();
if (!$response) {
$json['error'] = 'Cannot establish a connection to the server';
$err = new AError('Paypal Pro Error: DoDirectPayment failed: ' . curl_error($curl) . '(' . curl_errno($curl) . ')');
$err->toLog()->toMessages()->toDebug();
} else {
$response_data = array();
parse_str($response, $response_data);
if ($response_data['ACK'] == 'Success' || $response_data['ACK'] == 'SuccessWithWarning') {
$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('config_order_status_id'));
$message = '';
if (isset($response_data['AVSCODE'])) {
$message .= 'AVSCODE: ' . $response_data['AVSCODE'] . "\n";
}
if (isset($response_data['CVV2MATCH'])) {
$message .= 'CVV2MATCH: ' . $response_data['CVV2MATCH'] . "\n";
}
if (isset($response_data['TRANSACTIONID'])) {
$message .= 'TRANSACTIONID: ' . $response_data['TRANSACTIONID'] . "\n";
}
$response_data['PAYMENTACTION'] = $payment_type;
$response_data['payment_method'] = 'default_pp_pro';
$this->model_checkout_order->updatePaymentMethodData($this->session->data['order_id'], serialize($response_data));
$this->model_checkout_order->update($this->session->data['order_id'], $this->config->get('default_pp_pro_order_status_id'), $message, false);
$json['success'] = $this->html->getSecureURL('checkout/success');
} else {
$json['error'] = $response_data['L_LONGMESSAGE0'];
}
}
curl_close($curl);
$this->load->library('json');
$this->response->setOutput(AJson::encode($json));
}