public static function Init($logFile = 'app.log') { $file_log = PATH_LOG . '/' . $logFile; if (!is_dir(dirname($file_log))) { mkdir(dirname($file_log), 0777, true); } self::$_fp = fopen($file_log, 'a'); }
/** * Обработчик ноды одноименной методу (без учета регистра) * * @param Xml_Object $xml * @return bool * @throws Exception */ public function generation_date(Xml_Object $xml) { $date = $this->CheckDate($xml->Get_Data()); if (is_null($date)) { Zero_Logs::Error('формат даты указан неверно (generation_date) ' . $xml->Get_Data()); throw new Exception(mysqli_connect_error(), 500); } return Zero_Logs::Info('дата обрабатываемого файла: ' . $date->format('Y-m-d H:i:s')); }
/** * Izmenenie danny`kh v BD. * * @param string $source * @return bool */ public function Update($source = '') { $prop_list = $this->Model->Get_Config_Prop(); unset($prop_list['ID']); // sborka svoi`stv dlia sokhraneniia v BD $sql_update = []; foreach ($this->Model->Get_Props(-1) as $prop => $value) { if (!isset($prop_list[$prop])) { continue; } $method = "Escape_" . $prop_list[$prop]['DB']; if (isset($_FILES[$prop])) { if ('File Upload Ok' == $value) { // V fai`lovoi` sisteme $file = strtolower($this->Model->Source) . '/' . Zero_Lib_FileSystem::Get_Path_Cache($this->Model->ID) . '/' . $this->Model->ID . '/' . $_FILES[$prop]['name']; $path = ZERO_PATH_DATA . '/' . $file; if (file_exists($path)) { $pos = strrpos($_FILES[$prop]['name'], ".", -1); $_FILES[$prop]['name'] = substr($_FILES[$prop]['name'], 0, $pos) . '_' . $prop . substr($_FILES[$prop]['name'], $pos); $file = strtolower($this->Model->Source) . '/' . Zero_Lib_FileSystem::Get_Path_Cache($this->Model->ID) . '/' . $this->Model->ID . '/' . $_FILES[$prop]['name']; $path = ZERO_PATH_DATA . '/' . $file; } if (!is_dir(dirname($path))) { mkdir(dirname($path), 0777, true); } if (!rename($_FILES[$prop]['tmp_name'], $path)) { Zero_Logs::Set_Message_Error('Error Copy File'); continue; } $sql_update[] = "`" . $prop . "` = '{$file}'"; $this->Model->{$prop} = $file; // V BD if (isset($prop_list[$prop . 'B'])) { $sql_update[] = "`" . $prop . "B` = '" . self::Escape_B(file_get_contents($path)) . "'"; } } else { if (!$value) { $sql_update[] = "`" . $prop . "` = NULL"; if (isset($prop_list[$prop . 'B'])) { $sql_update[] = "`" . $prop . "B` = NULL"; } } } } else { $sql_update[] = '`' . $prop . '` = ' . self::$method($value); } } $flag = 0; if (0 < count($sql_update)) { // Usloviia Where if (isset($this->Params['Where'])) { $sql_where = 'WHERE ' . $this->Sql_Where_Compilation(); } else { $sql_where = 'WHERE 1'; } // Identifikator if (0 < $this->Model->ID) { $sql_where .= ' AND `ID` = ' . $this->Model->ID; } if ('' == $source) { $source = $this->Model->Source; } $sql = "UPDATE {$source} SET " . implode(', ', $sql_update) . " " . $sql_where; $flag = self::Set($sql); } // Ustanovka statusov $this->Model->Set_Props(); return false !== $flag; }
<?php /** * The entry point to the application. * Initialize and run. */ // Including the class App require 'config.php'; Zero_Logs::Init('app.log'); Zero_DB::Init(); $xml = new Xml_Parser(); $xml->Parser(PATH_EXCHANGE . '/test.xml', 'Xml_Handler_Test'); die('Done');