public static function init() { if (isset($_COOKIE["PHPSESSID"]) && !empty($_COOKIE["PHPSESSID"])) { if (file_exists("../helpers/_getUserInfo.php")) { include_once "../helpers/_getUserInfo.php"; User_get::info(); } } $exception = new Exception(); switch (_MODE_) { case "local": ob_start(); ini_set('display_errors', 1); error_reporting(E_ALL); break; case "production": if (version_compare(PHP_VERSION, '5.4.0', '>=')) { ob_start(null, 0, PHP_OUTPUT_HANDLER_STDFLAGS ^ PHP_OUTPUT_HANDLER_REMOVABLE); } else { ob_start(null, 0, false); Logger::write("index.php; #8; ошибка ob_start PHP < 5.4"); } ini_set("memory_limit", "256M"); break; } }
public function testWrite() { $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->setMethods(array('emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug', 'log'))->getMock(); $logger->expects($this->once())->method('info')->with($this->identicalTo('foobar')); $output = new Logger($logger); $output->write('foobar'); }
/** * Display the log file contents for today * * @param string $q * @param array $matches * @param array $params */ function fn_logs($q, $matches, $params) { $log_file = TITANIUM_ROOT . 'logs/' . date('Y-m-d') . '.txt'; Logger::write("Reading log file: {$log_file}"); if (file_exists($log_file)) { Output::write(file_get_contents($log_file), false, true); } else { Output::write("{$log_file} does not exist.", 'red', true); } }
public function __construct($number, $message) { $this->result['data']['error'] = true; $this->result['data']['pageName'] = 'Error ' . $number; $this->result['data']['errorMessage'] = $message; $this->result['data']['style'] = 'error'; $this->result['view']['content'] = 'viewError.tpl'; //Логируем ошибку Logger::write($message); }
/** * * classic exeption Handler * * @param unknown_type $e */ public static function exceptionHandler($e) { Logger::write('error', $e->getMessage() . PHP_EOL . $e->getFile() . PHP_EOL . $e->getLine()); if (Configuration::getInstance()->get('config.showErrors')) { echo '<h1>' . get_class($e) . '</h1>'; echo implode(PHP_EOL, array($e->getMessage(), $e->getFile(), $e->getLine())); var_dump($e); exit; } return self::_renderErrorPage($e); }
protected function renderTemplate($name) { try { $module = $this->_request->getModuleName(); $this->_view->setScriptPath(APPLICATION_PATH . 'modules/' . $module . '/views/'); return $this->_view->render('templates/' . $name . '.tpl'); } catch (Exception $e) { Logger::write($e->__toString(), Zend_Log::ERR); return false; } return true; }
static function load($name_module) { $modules_data = self::init_modules(); foreach ($modules_data as $key => $value) { if ($key == $name_module) { if (include_once $value) { } else { Logger::write("modules.php; #42; ошибка подключения модуля {$key} по пути {$value}"); } } } }
public function __construct() { if (file_exists("actions/products_action.php")) { require_once "actions/products_action.php"; } else { Logger::write("Ошибка подключения /actions/products_action.php в ../core/controllers/products_controller.php"); } if (file_exists("view/products.php")) { require_once "view/products.php"; } else { Logger::write("Ошибка подключения /view/products.php в ../core/controllers/products_controller.php"); } }
/** * Connects to database object and select database to use * * @return void */ public function __construct() { //Establish connection with the databae $host = $this->host; $dbname = $this->database; try { $this->DBH = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $this->username, $this->password); $this->DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->DBH->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); } catch (PDOExeception $ex) { $error = $ex->getMessage(); Logger::write("PDO", $error); } }
function regenerate_id() { $old_sess_id = session_id(); session_regenerate_id(true); $new_sess_id = session_id(); Logger::write($old_sess_id . '-' . $new_sess_id, 'session.log'); $time = time(); if (!isset($this->u_stmt)) { $this->u_stmt = $this->db->prepare(" UPDATE " . $this->table_name . " set id = ? where id=?"); } $this->u_stmt->bind_param('ss', $new_sess_id, $old_sess_id); $this->u_stmt->execute(); return true; }
/** * 连接数据库 */ public function connect() { try { if (isEmptyString($this->config['username']) || isEmptyString($this->config['password'])) { $this->connection = new MongoClient(sprintf('mongodb://%s:%d', $this->config['host'], $this->config['port'])); } else { $this->connection = new MongoClient(sprintf('mongodb://%s:%d', $this->config['host'], $this->config['port']), array('username' => $this->config['username'], 'password' => $this->config['password'], 'db' => $this->config['db'])); } $this->connection->setReadPreference(MongoClient::RP_SECONDARY_PREFERRED, array()); } catch (Exception $e) { $this->collection = null; $this->connection = null; Logger::write($e->__toString(), ERR); } }
public static function popularBox() { if (file_exists("actions/popularbox_action.php")) { include_once "actions/popularbox_action.php"; $popularlist = Popularbox::popularList(); $cnt = count($popularlist); for ($i = 0; $i <= $cnt; $i++) { if (!empty($popularlist[$i]['id'])) { include "view/popular.php"; } } } else { Logger::write("main controller.php : отстутствует actions/popularbox_action.php"); } }
/** * * resolve class name to filename * @param $class */ public function autoload($class) { $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; foreach ($this->_includePaths as $path) { $filename = $path . DIRECTORY_SEPARATOR . $file; if (is_readable($filename)) { include $filename; break; } } if (!class_exists($class)) { Logger::write('error', $class); trigger_error('Class ' . $class . ' not found'); } return; }
protected static function generic($data, $title, $keyw, $desc) { $data = strtolower($data); $file_gen_controller = "../core/controllers/" . $data . "_controller.php"; $file_gen_view = "../core/view/" . $data . ".php"; $file_gen_action = "../core/actions/" . $data . "_action.php"; $write_controller = '<?php class ' . $data . ' { public function __construct() { if(file_exists("actions/' . $data . '_action.php")) require_once "actions/' . $data . '_action.php"; else Logger::write("Ошибка подключения /actions/' . $data . '_action.php в ../core/controllers/' . $data . '_controller.php"); if(file_exists("view/' . $data . '.php")) require_once "view/' . $data . '.php"; else Logger::write("Ошибка подключения /view/' . $data . '.php в ../core/controllers/' . $data . '_controller.php"); } } ?>'; $write_view = '<?php echo "страница ' . $data . '" ?>'; $write_action = '<?php class ' . $data . '_action { public function __construct() { } } ?>'; $cntr = fopen($file_gen_controller, "a"); $controllerres = fwrite($cntr, $write_controller); fclose($cntr); $vw = fopen($file_gen_view, "a"); $view_res = fwrite($vw, $write_view); fclose($vw); $act = fopen($file_gen_action, "a"); $action_res = fwrite($act, $write_action); fclose($act); if ($controllerres && $view_res && $action_res) { include_once $_SERVER['DOCUMENT_ROOT'] . "/controls/actions/categories_action.php"; Categories_action::writeGenCat($data, $title, $keyw, $desc); } else { Logger::write("_generator.php не удалось сгенерировать один из фвйлов"); } }
static function autoload() { if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/helpers/logger.php")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/helpers/logger.php"; } else { echo "autoloader ERROR! cannot file of the system"; } if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/config/config.php")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/config/config.php"; } else { Logger::write("ошибка require_once /config/config.php в autoloader.php "); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/config/remote.db.php")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/config/remote.db.php"; } else { Logger::write("ошибка require_once /config/remote.db.php в autoloader.php "); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/config/init.php")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/config/init.php"; } else { echo "autoloader ERROR! cannot file of the system"; } if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/helpers/modules.php")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/helpers/modules.php"; } else { Logger::write("ошибка require_once /helpers/modules.php в autoloader.php "); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/helpers/clear_code.php")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/helpers/clear_code.php"; } else { Logger::write("ошибка require_once /helpers/clear_code.php в autoloader.php "); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/helpers/db.operations.php")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/helpers/db.operations.php"; } else { Logger::write("ошибка require_once /helpers/db.operations.php в autoloader.php "); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/helpers/_generator.php")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/helpers/_generator.php"; } else { Logger::write("ошибка require_once /helpers/_generator.php в autoloader.php"); } }
public function autoBid(Person $player, $amount, $finishCallback) { $this->logger->write('Start autobid'); while (true) { $person = $player instanceof Player ? $this->getPlayer($player->id) : $this->getStaff($player->id); if ($person->on_market == false) { $this->logger->write('Person is no sold'); if ($finishCallback) { call_user_func($finishCallback, $person->is_my_last_bid); } break; } $this->logger->write($person->deadline_seconds . ' -> ' . $person->sell_price); if ($person->is_my_last_bid) { $this->logger->write('MY BID'); sleep($person->deadline_seconds > 70 ? $person->deadline_seconds - 70 : 5); continue; } if ($person->is_my_last_bid == false && ($person->deadline_seconds <= 5 || $person->deadline_seconds >= 61 && $person->deadline_seconds <= 63)) { $bid_delta = max(10000, ceil($person->sell_price / 100 * 5)); $new_bid = $person->sell_price + $bid_delta; if ($new_bid > $amount) { $this->logger->write("Next bid is more than limit: FAIL"); if ($finishCallback) { call_user_func($finishCallback, false); } break; } $this->logger->write('Bid: ' . $new_bid); $this->bid($person, $new_bid); sleep(59); } else { $waiting_seconds = $person->deadline_seconds > 60 ? $person->deadline_seconds - 63 : $person->deadline_seconds - 3; $waiting_seconds = max($waiting_seconds, 0); $this->logger->write('Waiting: ' . $waiting_seconds); sleep($waiting_seconds); } } }
<?php include 'db_conn.php'; include_once 'GCM.php'; include 'logger.php'; $logger = new Logger(); $logger->write("INFO :", "PHP Scritp Name =>" . $_SERVER['REQUEST_URI']); $logger->write("INFO :", "Type of Request =>" . $_SERVER['REQUEST_METHOD']); $msg = $_POST['msg']; //$hospital_id=$_POST['hospital_id']; $doctor_id = $_POST['doc_id']; $mobile = ""; $gcm_id = ""; $read_flag_value = "unread"; $hospital_name = ""; //get hospital_details /*$query_get_hos_details=mysql_query("select * from hospital_stub where hospital_id='$hospital_id'"); while($row_get_hospital=mysql_fetch_assoc($query_get_hos_details)){ $hospital_name=$row_get_hospital['hospital_name']; }*/ //changed query $result_query_broadcast_insert = mysql_query("insert into doc_broadcast_msg(message_title,message_content,doctor_id,hospital_id_author,hospital_name,read_flag) values('ReferralIO','{$msg}','{$doctor_id}','{$hospital_id}','{$hospital_name}','{$read_flag_value}')"); $result_get_mob = mysql_query("select * from doctor_stub where Doctor_serial_id='{$doctor_id}'"); while ($row_mobile = mysql_fetch_assoc($result_get_mob)) { $mobile = $row_mobile['Doctor_mobile_number']; } $query_get_gcm_id = mysql_query("select * from gcm_users where mob_number='{$mobile}'"); while ($row_gcm_id = mysql_fetch_assoc($query_get_gcm_id)) { $gcm_id = $row_gcm_id['gcm_regid']; } $read_flag = 'unread';
/** * Display the help page * * @param string $q * @param array $matches * @param array $params */ function fn_help($q, $matches, $params) { Logger::write("Running: " . __FUNCTION__); Output::write(Template::render('functions/help.tpl.php', $data), false, true); }
function verify($text, $signatureBase64, $key, $logMsg = null) { $logger = new Logger(); $logger->write($logMsg . ": " . $text); $path = dirname(__FILE__) . "/keys/"; $key = $path . $key; $fp = fopen($key, "r"); if (!$fp) { throw new Exception("Key not found"); } $public = fread($fp, filesize($key)); fclose($fp); $publicKeyId = openssl_get_publickey($public); $signature = base64_decode($signatureBase64); $res = openssl_verify($text, $signature, $publicKeyId); openssl_free_key($publicKeyId); return $res != '1' ? false : true; }
<?php include 'db_conn.php'; //include_once'GCM.php'; include 'logger.php'; $logger = new Logger(); $logger->write("INFO :", "PHP Scritp Name =>" . $_SERVER['REQUEST_URI']); $logger->write("INFO :", "Type of Request =>" . $_SERVER['REQUEST_METHOD']); //$msg=$_POST['msg']; $hospital_id = $_POST['hospital_id']; $doctor_id = $_POST['doc_id']; //$mobile=""; //$gcm_id=""; //$read_flag_value="unread"; //$hospital_name=""; //get hospital_details /*$query_get_hos_details=mysql_query("select * from hospital_stub where hospital_id='$hospital_id'"); while($row_get_hospital=mysql_fetch_assoc($query_get_hos_details)){ $hospital_name=$row_get_hospital['hospital_name']; }*/ //changed query //delete from hospital_refer_in_doctor_stub $result_query_broadcast_insert = mysql_query("delete from hospital_refer_in_doctor_stub where doc_stub_id='{$doctor_id}' and refer_by_hos_id='{$hospital_id}'"); //delete referral_mapping if any $query_update = "update referral_mapping set referring_doctor_id='' where hospital_id='{$hospital_id}' and referring_doctor_id='{$doctor_id}'"; $result_query_update_referral_mapping = mysql_query("update referral_mapping set referring_doctor_id='' where hospital_id='{$hospital_id}' and referring_doctor_id='{$doctor_id}'"); $logger->write("INFO :", "query_update------------>" . $query_update); /*$result_get_mob=mysql_query("select * from doctor_stub where Doctor_serial_id='$doctor_id'"); while($row_mobile=mysql_fetch_assoc($result_get_mob)) { $mobile=$row_mobile['Doctor_mobile_number'];
public function insert() { $message = json_encode(array('a', 'b')); Logger::write($message, 'log'); }
/** * Load the payment form * @param int $order_id * @return void */ public function receipt_page($order_id) { Logger::write('Receipt Page'); echo "<script>console.log('Receipt Page');</script>"; echo "<script type=\"text\\javascript\">alert('Receipt');</script>"; wp_enqueue_script('eway-credit-card-form'); // Get the order $order = new WC_Order($order_id); try { $token_payment = get_post_meta($order->id, '_eway_token_customer_id', true); if ($token_payment && 'new' == $token_payment) { $result = json_decode($this->get_api()->request_access_code($order, 'TokenPayment', 'Recurring')); } else { $result = json_decode($this->get_api()->request_access_code($order)); } $form_url = $result->FormActionURL; ob_start(); woocommerce_get_template('eway-cc-form.php', array(), 'eway/', plugin_dir_path(__FILE__) . '../templates/'); echo '<input type="hidden" name="EWAY_ACCESSCODE" value="' . $result->AccessCode . '"/>'; echo '<input type="hidden" name="EWAY_CARDNAME" value="' . $order->billing_first_name . ' ' . $order->billing_last_name . '"/>'; echo '<input type="hidden" name="EWAY_CARDNUMBER" id="EWAY_CARDNUMBER" value=""/>'; echo '<input type="hidden" name="EWAY_CARDEXPIRYMONTH" id="EWAY_CARDEXPIRYMONTH" value=""/>'; echo '<input type="hidden" name="EWAY_CARDEXPIRYYEAR" id="EWAY_CARDEXPIRYYEAR" value=""/>'; $form = '<form method="post" action="' . $form_url . '" id="eway_credit_card_form">'; $form .= ob_get_clean(); $form .= '</form>'; echo $form; } catch (Exception $e) { if (defined('WC_VERSION')) { wc_add_notice($e->getMessage() . ': ' . __('Please check your eWAY API key and password.', 'wc-eway'), 'error'); } else { global $woocommerce; $woocommerce->add_error($e->getMessage()); } return; } }
public function getFileIndex() { // Logger::write("File Index wurde geladen"); $ReQuest = new Request(); if (!$this->User->getId()) { return false; } // das verzeichniss auslesen $Controler_Download = new Controler_Download(); $Controler_Download->getFilesRekursiv($this->User->getFolder(), $this->User->getFolder()); return true; }
} $optionsOrderProps[$code]['location'] = 'LOCATION'; if (array_search('CITY', $optionsOrderProps[$code]) == false) { $optionsOrderProps[$code]['city'] = 'CITY'; } if (array_search('ZIP', $optionsOrderProps[$code]) == false) { $optionsOrderProps[$code]['index'] = 'ZIP'; } } $api = new RetailCrm\RestApi($api_host, $api_key); $order = $api->orderGet($idOrderCRM, $by = 'id'); $log = new Logger(); $log->write($order, 'order'); $defaultOrderType = 1; $dbOrderTypesList = CSalePersonType::GetList(array(), array("ACTIVE" => "Y")); if ($arOrderTypesList = $dbOrderTypesList->Fetch()) { $defaultOrderType = $arOrderTypesList['ID']; } $GLOBALS['INTARO_CRM_FROM_HISTORY'] = true; if (function_exists('intarocrm_order_pre_persist')) { $order = intarocrm_order_pre_persist($order); } if (!isset($order['externalId'])) { // custom orderType function
/** * Update and save the current configuration * @param $result * @return mixed */ public function saveSettings($result) { if (!isset($this->name)) { $result['error'] = "A config-set name must be supplied"; return $result; } $this->configMdl = new ConfigModel(); $config = $this->configMdl->get($this->name); if ($config !== false) { if (sizeof($config) > 0) { $this->curconfig = json_decode($config[0]['data']); // get the json object $configbk = $this->curconfig; if (isset($this->data->gcontactcode) && $this->data->gcontactcode != '') { // Get google access token $tokens = GoogleIntegration::processGoogleAuthCode($this->data->gcontactcode); if ($tokens) { $tokens = json_decode($tokens); $this->data->gcontacttoken = $tokens; $this->data->gcontact = 1; } unset($this->data->gcontactcode); } // generate new qr code if ($this->name == "pos") { if ($this->data->recqrcode !== $configbk->recqrcode && $this->data->recqrcode != "") { $this->generateQRCode(); } } foreach ($this->curconfig as $key => $value) { if (isset($this->data->{$key})) { // update the config value if specified in the data $this->curconfig->{$key} = $this->data->{$key}; } } if ($this->configMdl->edit($this->name, json_encode($this->curconfig)) === false) { $result['error'] = "Could not update config record: " . $this->configMdl->errorInfo; } else { $conf = $this->curconfig; if ($this->name == "general") { unset($conf->gcontacttoken); $conf->timezone = $this->data->timezone; if ($conf->timezone != getenv("WPOS_TIMEZONE")) { $this->updateConfigFileValue('timezone', $conf->timezone); } } else { if ($this->name == "accounting") { unset($conf->xerotoken); } } // send config update to POS terminals $socket = new WposSocketIO(); $socket->sendConfigUpdate($conf, $this->name); // Success; log data Logger::write("System configuration updated:" . $this->name, "CONFIG", json_encode($conf)); } } else { // if current settings are null, create a new record with the specified name if ($this->configMdl->create($this->name, json_encode($this->data)) === false) { $result['error'] = "Could not insert new config record: " . $this->configMdl->errorInfo; } } } else { $result['error'] = "Could not retrieve the selected config record: " . $this->configMdl->errorInfo; } return $result; }
exit; }); } } // $a = "hello"; // $b = $a['somthing1']; // $b = $a['somthing2']; // $b = $a['somthing3']; // $b = $a['somthing4']; // $c = $d; $array = ['entryone', 'entryone', 'entryone', ['entryone', 'entryone', 'entryone']]; $object = new \stdClass(); $object->field1 = "field1"; $object->field2 = "field2"; $object->field3 = "field3"; $object->field4 = "field4"; $object2 = new \stdClass(); $object2->field1 = "field1"; $object2->field2 = "field2"; $object2->field3 = "field3"; $object2->field4 = "field4"; $object->subobj = $object2; Logger::write(" we did more after the error "); Logger::writeln("we did more after the error "); Logger::writeln("two strings ---", " ::in one::", "[[call]]", "((we did more after the error "); Logger::writeln("These two things are the parameters to the funtions : ", $array, $object); //set_exception_handler('exceptionHandler'); ErrorHandler::setHandlers(); //trigger_error("error triggered"); //throw new Exception("just testing"); //exit();
public function __TRACKER__($info, $file = '', $line = '', $output = 'file') { Logger::write(HALO_LOG_TRACKER, $this->_domain, $info, $file, $line, $output); }
public function checkAuthorization() { //подключаем модель авторизации $this->addModel('Authorization'); //подключаем модель пользователей $this->addModel('Users'); $userId = null; // echo 'checkAuthorization'; //Нажали кнопку "Log in" if (isset($_POST['logon'])) { // если переданы данные для авторизации // Флаг Remember $username = isset($_POST['username']) ? $_POST['username'] : false; $password = isset($_POST['password']) ? md5($_POST['password']) : false; if (!($username && $password)) { return false; } $remember = isset($_POST['remember']) ? true : false; // авторизуемся $userId = $this->model['Authorization']->logIn($username, $password, $remember); //пишем лог if (!is_null($userId)) { Logger::write('User: '******' log in'); } // echo 'Log in'; // Нажали кнопку "Log out" } elseif (isset($_POST['logout'])) { if (!isset($_SESSION['sessionkey'])) { return false; } //вытаскиваем имя пользователя для логирования $userId = $this->model['Authorization']->checkSession($_SESSION['sessionkey']); $username = $this->model['Users']->getUserById($userId); //пишем лог if (!is_null($userId)) { Logger::write('User: '******' log out'); } $this->model['Authorization']->logOut(); // выходим return false; // echo 'Log out'; //просто гуляем по сайту } elseif (isset($_SESSION['sessionkey'])) { // проверяем есть ли сессия $sessionKey = $_SESSION['sessionkey']; // есть ли она в БД и не просрочена ли она $userId = $this->model['Authorization']->checkSession($sessionKey); //обновляем сессию текущему пользователю $this->model['Authorization']->updateSession($userId, $sessionKey); // echo '_session'; //пришли на сайт } elseif (isset($_COOKIE['sessionkey'])) { // проверяем есть ли сессия в куках $sessionKey = $_COOKIE['sessionkey']; // есть ли она в БД и не просрочена ли она $userId = $this->model['Authorization']->checkSession($sessionKey); // echo '_cookie'; if (is_null($userId)) { return false; } else { $_SESSION['sessionkey'] = $sessionKey; $this->model['Authorization']->updateSession($userId, $sessionKey); //обновляем сессию текущему пользователю } } //если не нашли авторизованного пользователя, то возвращаем соответствующий признак if (is_null($userId)) { return false; } //вытаскиваем имя пользователя $this->currentUser = $this->model['Users']->getUserById($userId); //возвращаем признак того, что авторизованный пользователь найден return true; }
public function removePayment($result) { // validate json if (!isset($this->data->id) || !isset($this->data->paymentid)) { $result['error'] = "Sale & item id must be provided"; return $result; } // delete payment record $payMdl = new SalePaymentsModel(); if ($payMdl->removeById($this->data->paymentid) === false) { $result['error'] = "Could not remove payment record: " . $payMdl->errorInfo; return $result; } // delete item in json foreach ($this->invoice->payments as $key => $item) { if ($this->data->paymentid == $item->id) { unset($this->invoice->payments[$key]); $this->invoice->payments = array_values($this->invoice->payments); break; } } // Update invoice totals $this->calculateInvoice(); // update invoice data if ($this->saveInvoiceData() === false) { $result['error'] = "Could not commit invoice data: " . $this->invMdl->errorInfo; return $result; } else { // Create transaction history record WposTransactions::addTransactionHistory($this->id, $_SESSION['userId'], "Modified", "Payment Removed"); // log data Logger::write("Invoice payment removed for invoice id: " . $this->id, "INVOICE", json_encode($this->data)); } $result['data'] = $this->invoice; return $result; }
function action_edit() { $news = ORM::factory('newsservice', $this->request->param('id', NULL)); if (!$news->loaded() or $news->user_id != $this->user->id) { Message::set(Message::ERROR, Kohana::message('cabinet', 'news_not_found')); $this->request->redirect('cabinet'); } $services = array(); foreach ($this->user->services->find_all() as $service) { $services[$service->id] = $service->name; } if ($_POST) { $this->validation = Validation::factory($_FILES)->rule('news_image', 'Upload::type', array(':value', array('jpg', 'jpeg', 'png', 'gif'))); // Date of edit $current_time = Date::formatted_time(); try { $title = $news->title; $news->values($_POST, array('title', 'text')); $news->active = 1; $news->service_id = Arr::get($_POST, 'service_id', NULL); $news->date_edited = $current_time; $news->update($this->validation); // Image upload if ($this->validation->check() and $_FILES['news_image']['size'] != 0) { echo 1; $file_name = MyHelper::get_file_name($_FILES['news_image']); if (is_writable($this->_image_url)) { Upload::save($_FILES['news_image'], $file_name, $this->_image_url); $name_pies = explode('.', $this->_image_url . '/' . $file_name); $image = Image::factory($this->_image_url . '/' . $file_name); $image->resize(150, NULL); $image->save(); $image->resize(70, NULL); $image->save($name_pies[0] . '_pict.' . $name_pies[1]); $news->image = $this->_image_url . '/' . $file_name; $news->update(); } } // Обновляем дату редактирования у компании DB::update('services')->set(array('date_edited' => $current_time))->where('id', '=', $news->service->id)->execute(); Logger::write(Logger::EDIT, 'Пользователь отредактировал новость ' . HTML::anchor('news/' . $news->id, $news->title), $this->user); Message::set(Message::SUCCESS, 'Новость "' . $title . '" для компании "' . $news->service->name . '" отредактирована'); $this->request->redirect('cabinet/news'); } catch (ORM_Validation_Exception $e) { $this->errors = $e->errors('models'); $this->values = $_POST; } } else { $this->values = $news->as_array(); } $this->view = View::factory('frontend/cabinet/news/form')->set('values', $this->values)->set('errors', $this->errors)->set('services', $services)->set('url', 'cabinet/news/edit/' . $news->id); $this->template->title = $this->site_name . 'Редактирование новости "' . $news->title . '" для автосервиса "' . $news->service->name . '"'; $this->template->bc['#'] = 'Редактирование новости'; $this->template->content = $this->view; }