public function send($to, $subject, $message, $from = NULL, $attachments = NULL)
 {
     if ($attachments != NULL) {
         throw new ServiceException("INVALID_CONFIGURATION", "Default mailer does not support sending attachments");
     }
     if (Logging::isDebug()) {
         Logging::logDebug("Sending mail to [" . Util::array2str($to) . "]: [" . $message . "]");
     }
     if (!$this->enabled) {
         return;
     }
     $isHtml = stripos($message, "<html>") !== FALSE;
     $f = $from != NULL ? $from : $this->env->settings()->setting("mail_notification_from");
     $validRecipients = $this->getValidRecipients($to);
     if (count($validRecipients) === 0) {
         Logging::logDebug("No valid recipient email addresses, no mail sent");
         return;
     }
     $toAddress = '';
     $headers = $isHtml ? 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=utf-8' . "\r\n" : 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n";
     $headers .= 'From:' . $f;
     if (count($validRecipients) == 1) {
         $toAddress = $this->getRecipientString($validRecipients[0]);
     } else {
         $headers .= PHP_EOL . $this->getBccHeaders($validRecipients);
     }
     mail($toAddress, $subject, $isHtml ? $message : str_replace("\n", "\r\n", wordwrap($message)), $headers);
 }
 /**
  * Writes the given log entry using the logger. Or writes it to stdout if logger is null.
  * 
  * @param int $level The level of the log entry
  * @param string $msg The message of the log entry
  * @param Logging $logger The logger object to use to log the message
  */
 public static function writeLog($level, $msg, $logger)
 {
     if ($logger == null) {
         printf("[Level: %d][Time: %s][IP: %s][Message: %s]", $level, date('d-m-Y H:i:s', time()), $_SERVER['REMOTE_ADDR'], $message);
         //            if ($level == LoggingImpl::LEVEL_ERROR) {
         //                die;
         //            }
     }
     $logger->logEntry($level, $msg);
     if ($level == LoggingImpl::LEVEL_ERROR) {
         die;
     }
 }
 public function processAPI()
 {
     if ($this->sqlInjection($_SERVER['REQUEST_URI'])) {
         $log = new Logging();
         $log->lfile('/var/www/web1162/html/tankUp/log_error.txt');
         $log->lwrite("SQL_Injection?: " . $_SERVER['REQUEST_URI']);
         $log->lclose();
         return $this->_response("Unexpected Parameters", 400);
     }
     if ((int) method_exists($this, $this->endpoint) > 0) {
         return $this->_response($this->{$this->endpoint}($this->args));
     }
     return $this->_response("No Endpoint: {$this->endpoint}", 404);
 }
Exemple #4
0
 public function GetDataByCoords($article, $distance, $sortBy, location $coords)
 {
     try {
         $log = new Logging();
         $log->lfile('/var/www/web1162/html/tankUp/log_debug.txt');
         $log->lwrite($article . $distance . $sortBy . $coords->latitude . $coords->longitude);
         $log->lclose();
         $param = new GetDataByCoordsRequest($article, $distance, $coords, $sortBy);
         $response = $this->__construct()->__soapCall("getDataByCoords", array($param));
         return $response->petrolStation;
     } catch (Exception $e) {
         // Umwandlung Soap-Exception zu HTTP
         return $e;
     }
 }
 public function __toString()
 {
     //if show error or save in logfile
     $msg = "[{$this->code}]: {$this->message}\n";
     return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
     $config = new Config();
     if ($config->logfile == true) {
         $logfile = new Logging();
         $logfile->lwrite($msg);
         return "";
     }
     if ($config->showerror == true) {
         return $msg;
     }
 }
Exemple #6
0
 public function beforeControllerAction($controller, $action)
 {
     if (parent::beforeControllerAction($controller, $action)) {
         if ($controller->getId() != 'index' && $action->getId() != 'index') {
             $logging = new Logging();
             $app = Yii::app();
             $request = $app->getRequest();
             $user = $app->getUser();
             $logging->attributes = ['user_id' => $user->getState('id', 0), 'username' => $user->getState('username', '匿名'), 'request' => $request->getRequestUrl(), 'param' => $request->getParamString(), 'type' => $request->getRequestType(), 'controller' => $controller->getId(), 'action' => $action->getId(), 'time' => time(), 'date' => date('Y-m-d'), 'ip' => $request->getUserHostAddress()];
             $logging->save();
         }
         return true;
     } else {
         return false;
     }
 }
 public function processPost()
 {
     $data = $this->request->data;
     if (!isset($data['to']) or !isset($data['title']) or !isset($data['msg']) or !isset($data['items'])) {
         throw $this->invalidRequestException("Data missing");
     }
     $to = $data['to'];
     $message = $data['msg'];
     $title = $data['title'];
     $items = $this->items($data['items']);
     if (count($items) == 0) {
         throw $this->invalidRequestException("Items missing");
     }
     if (Logging::isDebug()) {
         Logging::logDebug("SENDVIAEMAIL: Sending mail " . $to . ":" . Util::array2str($items));
     }
     $attachments = array();
     foreach ($items as $i) {
         $attachments[] = $i->internalPath();
     }
     //TODO stream
     if ($this->env->mailer()->send(array($to), $title, $message, NULL, $attachments)) {
         $this->response()->success(array());
     } else {
         $this->response()->error("REQUEST_FAILED", NULL);
     }
 }
 public function onResponseSent()
 {
     if (!$this->settings->hasSetting("debug_log") or !$this->environment->request()) {
         return;
     }
     $path = $this->environment->request()->path();
     if (count($path) > 0 and strcasecmp($path[0], "debug") == 0) {
         return;
     }
     $log = $this->settings->setting("debug_log");
     $handle = @fopen($log, "a");
     if (!$handle) {
         Logging::logError("Could not write to log file: " . $log);
         return;
     }
     $trace = Logging::getTrace();
     try {
         foreach ($trace as $d) {
             fwrite($handle, Util::toString($d));
         }
         fclose($handle);
     } catch (Exception $e) {
         Logging::logError("Could not write to log file: " . $log);
         Logging::logException($e);
     }
 }
function StoreFile($_visitor, $_browserId, $_partner, $_fullname, $_chatId)
{
    $filename = IOStruct::GetNamebase($_FILES['form_userfile']['name']);
    Logging::GeneralLog($filename);
    if (!IOStruct::IsValidUploadFile($filename)) {
        return false;
    }
    if (empty($_fullname)) {
        $_fullname = Visitor::GetNoName($_visitor->UserId . Communication::GetIP());
    }
    $fileid = md5($filename . $_visitor->UserId . $_browserId);
    $fileurid = EX_FILE_UPLOAD_REQUEST . "_" . $fileid;
    $filemask = $_visitor->UserId . "_" . $fileid;
    $request = new FileUploadRequest($fileurid, $_partner, $_chatId);
    $request->Load();
    if ($request->Permission == PERMISSION_FULL) {
        if (move_uploaded_file($_FILES["form_userfile"]["tmp_name"], PATH_UPLOADS . $request->FileMask)) {
            KnowledgeBase::CreateFolders($_partner, false);
            KnowledgeBase::Process($_partner, $_visitor->UserId, $_fullname, 0, $_fullname, 0, 5, 3);
            KnowledgeBase::Process($_partner, $fileid, $filemask, 4, $_FILES["form_userfile"]["name"], 0, $_visitor->UserId, 4, $_FILES["form_userfile"]["size"]);
            $request->Download = true;
            $request->Save();
            return true;
        } else {
            $request->Error = true;
            $request->Save();
        }
    }
    return false;
}
 public function testImport()
 {
     print "\n" . "Testing import ... ";
     $response = RequestResponse::ImportConceptRequest(self::$client, self::$postData, self::$boundaryNumeric);
     Logging::var_error_log("\n Response body ", $response->getBody(), __DIR__ . "/ImportResponse.html");
     $this->AssertEquals(200, $response->getStatus(), 'Failed to import concept');
     $output = array('0' => "The ouput of sending jobs: ");
     $retvar = 0;
     $sendjob = exec(PHP_JOBS_PROCESS, $output, $retvar);
     // check via spraql query
     //$sparqlResult = $this ->sparqlRetrieveTriplesForNotation(self::$notation);
     //var_dump($sparqlResult);
     self::$client->setUri(BASE_URI_ . '/public/api/find-concepts?q=prefLabel:' . self::$prefLabel);
     $responseGet = self::$client->request(Zend_Http_Client::GET);
     $this->AssertEquals(200, $responseGet->getStatus(), $responseGet->getMessage());
     $dom = new Zend_Dom_Query();
     $namespaces = RequestResponse::setNamespaces();
     $dom->registerXpathNamespaces($namespaces);
     $xml = $responseGet->getBody();
     $dom->setDocumentXML($xml);
     var_dump($xml);
     $results1 = $dom->query('rdf:RDF');
     $this->AssertEquals(1, $results1->current()->getAttribute('openskos:numFound'));
     $results2 = $dom->queryXpath('/rdf:RDF/rdf:Description');
     $this->AssertEquals(1, count($results2));
 }
 function log()
 {
     if (!Logging::isDebug()) {
         return;
     }
     Logging::logDebug("PLUGIN (" . get_class($this) . ")");
 }
 public function send($to, $subject, $message, $from = NULL, $attachments = NULL)
 {
     if (!$this->enabled) {
         return;
     }
     $isHtml = stripos($message, "<html>") !== FALSE;
     $f = $from != NULL ? $from : $this->env->settings()->setting("mail_notification_from");
     $validRecipients = $this->getValidRecipients($to);
     if (count($validRecipients) === 0) {
         Logging::logDebug("No valid recipient email addresses, no mail sent");
         return;
     }
     if (Logging::isDebug()) {
         Logging::logDebug("Sending mail from [" . $f . "] to [" . Util::array2str($validRecipients) . "]: [" . $message . "]");
     }
     set_include_path("vendor/PHPMailer" . DIRECTORY_SEPARATOR . PATH_SEPARATOR . get_include_path());
     require 'class.phpmailer.php';
     $mailer = new PHPMailer();
     $smtp = $this->env->settings()->setting("mail_smtp");
     if ($smtp != NULL and isset($smtp["host"])) {
         $mailer->isSMTP();
         $mailer->Host = $smtp["host"];
         if (isset($smtp["username"]) and isset($smtp["password"])) {
             $mailer->SMTPAuth = true;
             $mailer->Username = $smtp["username"];
             $mailer->Password = $smtp["password"];
         }
         if (isset($smtp["secure"])) {
             $mailer->SMTPSecure = $smtp["secure"];
         }
     }
     $mailer->From = $f;
     foreach ($validRecipients as $recipient) {
         $mailer->addBCC($recipient["email"], $recipient["name"]);
     }
     if (!$isHtml) {
         $mailer->WordWrap = 50;
     } else {
         $mailer->isHTML(true);
     }
     if ($attachments != NULL) {
         //TODO use stream
         foreach ($attachments as $attachment) {
             $mailer->addAttachment($attachment);
         }
     }
     $mailer->Subject = $subject;
     $mailer->Body = $message;
     try {
         if (!$mailer->send()) {
             Logging::logError('Message could not be sent: ' . $mailer->ErrorInfo);
             return FALSE;
         }
         return TRUE;
     } catch (Exception $e) {
         Logging::logError('Message could not be sent: ' . $e);
         return FALSE;
     }
 }
 private function putToCache($name, $subject, $value)
 {
     if (!array_key_exists($name, $this->permissionCaches)) {
         $this->permissionCaches[$name] = array();
     }
     $this->permissionCaches[$name][$subject] = $value;
     Logging::logDebug("Permission cache put [" . $name . "/" . $subject . "]=" . $value);
 }
Exemple #14
0
 /**
  * CSRF対策のトークンをチェックする。
  * 異常時はログに書き込む
  * @return boolean
  */
 static function chkCSRFToken($file = null, $line = null)
 {
     if (ENABLE_CSRF == TRUE) {
         return true;
     }
     if ($_POST) {
         // CSRF トークンが正しいかチェック
         if (\Security::check_token()) {
             return true;
         }
     }
     $msg2 = 'Invalid CSRF Token';
     //		Log::error($msg2);
     $log = new Logging();
     $log->writeLog_Warning($msg2, $file, $line);
     return false;
 }
 /**
  * reset attributes to initial values
  * @return void
  */
 function reset()
 {
     $this->_log->trace("resetting Result");
     $this->error_message_str = "";
     $this->error_log_str = "";
     $this->error_str = "";
     $this->error_element = "";
     $this->result_str = "";
 }
 public function getShareItem($id)
 {
     $ic = $this->dao()->getItemCollection($id);
     if (!$ic) {
         Logging::logDebug("Invalid share request, no item collection found with id " . $id);
         return NULL;
     }
     return array("name" => $ic["name"]);
 }
Exemple #17
0
 /**
  * Forward the user to a specified url
  *
  * @param string $url The URL to forward to
  * @param integer $code [optional] HTTP status code
  */
 public function forward($url, $code = 200)
 {
     if (Context::getRequest()->isAjaxCall() || Context::getRequest()->getRequestedFormat() == 'json') {
         $this->getResponse()->ajaxResponseText($code, Context::getMessageAndClear('forward'));
     }
     Logging::log("Forwarding to url {$url}");
     Logging::log('Triggering header redirect function');
     $this->getResponse()->headerRedirect($url, $code);
 }
 public function getShareInfo($id, $share)
 {
     $ic = $this->dao()->getItemCollection($id);
     if (!$ic) {
         Logging::logDebug("Invalid share request, no item collection found with id " . $id);
         return NULL;
     }
     return array("name" => $ic["name"], "type" => "prepared_download");
 }
 static function initialize($settings, $version = "-")
 {
     self::$version = $version;
     self::$debug = (isset($settings) and isset($settings["debug"]) and $settings['debug'] === TRUE);
     self::$firebug = (isset($settings) and isset($settings["firebug_logging"]) and $settings['firebug_logging'] === TRUE);
     if (self::$firebug) {
         require_once 'FirePHPCore/fb.php';
         FB::setEnabled(true);
     }
 }
Exemple #20
0
 protected function getBackend()
 {
     Logging::initialize(self::$CONFIGURATION, "Test");
     $this->responseHandler = new TestResponseHandler();
     $db = PDODatabase::createFromObj(self::$pdo, "sqlite");
     $settings = new Settings(self::$CONFIGURATION);
     $backend = new MollifyBackend($settings, $db, $this->responseHandler);
     //$backend->processRequest(new Request());
     return $backend;
 }
 public function run()
 {
     $log = new Logging();
     //        $parenClass = new ParentClass();
     // set path and name of log file (optional)
     $log->lfile('log.txt');
     $json = file_get_contents('php://input');
     $log->lwrite("post: " . $json);
     $update = new Update($json);
     $message = $update->getMessage();
     $chat = $message->getChat();
     $chat_id = $chat->getId();
     $text = $message->getText();
     $client = new Client();
     $client->sendMessage($chat_id, $text, null, null, null);
     $client->sendLocation($chat_id, 53.480759, -2.242631, null, null);
     $client->sendPhoto($chat_id, 'pic.jpg', 'sweety', null, null);
     $log->lclose();
 }
 public function search($begin, $end)
 {
     $condition = 'time>=:begin AND time<=:end';
     $params = ['begin' => $begin, 'end' => $end];
     $model = Logging::model();
     $pager = new CPagination($model->count($condition, $params));
     $pager->setPageSize(100);
     $logging = $model->findAll(['condition' => $condition, 'params' => $params, 'offset' => $pager->getOffset(), 'limit' => $pager->getLimit(), 'order' => 'time desc']);
     $this->render('index', ['logging' => new RedArrayDataProvider($logging), 'pager' => $pager]);
 }
Exemple #23
0
 public static function add($key, $value)
 {
     if (!self::isInMemorycacheEnabled()) {
         Logging::log('Key "' . $key . '" not cached (cache disabled)', 'cache');
         return false;
     }
     apc_store($key, $value);
     Logging::log('Caching value for key "' . $key . '"', 'cache');
     return true;
 }
Exemple #24
0
 /**
  * Check recording folder on writable
  */
 public static function checkRecordingFolderOnWritable()
 {
     if (self::$recordingWritable) {
         return;
     }
     if (!is_writeable(DIR . 'recording')) {
         crash('The folder "recording" is closed for writing');
     }
     self::$recordingWritable = true;
 }
 public function getTimelineDatatableAction()
 {
     $start = microtime(true);
     $data = Application_Model_Preference::getTimelineDatatableSetting();
     if (!is_null($data)) {
         $this->view->settings = $data;
     }
     $end = microtime(true);
     Logging::debug("getting timeline datatables info took:");
     Logging::debug(floatval($end) - floatval($start));
 }
Exemple #26
0
 public static function enablePropelLogging()
 {
     $logger = Logging::getLogger();
     Propel::setLogger($logger);
     $con = Propel::getConnection();
     $con->useDebug(true);
     $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
     $config->setParameter('debugpdo.logging.details.method.enabled', true);
     $config->setParameter('debugpdo.logging.details.time.enabled', true);
     $config->setParameter('debugpdo.logging.details.mem.enabled', true);
 }
Exemple #27
0
function globalExceptionHandler($e)
{
    global $responseHandler;
    Logging::logException($e);
    Logging::logDebug(Util::array2str(debug_backtrace()));
    if ($responseHandler == NULL) {
        $responseHandler = new ResponseHandler(new OutputHandler());
    }
    $responseHandler->unknownServerError($e->getMessage());
    die;
}
 /**
  * check if given table exists in database
  * @param string $table name of table
  * @return bool indicates if given table exists in database
  */
 function table_exists($table)
 {
     $query = "SHOW TABLES";
     $this->_log->debug("check if table exists (table=" . $table . ")");
     $result = $this->query($query);
     while ($row = $this->fetch($result)) {
         if ($row[0] == $table) {
             return TRUE;
         }
     }
     return FALSE;
 }
 /**
  * Converts the response in JSON format to the value object i.e Log
  *
  * @param json
  *            - response in JSON format
  *
  * @return Log object filled with json data
  *
  */
 function buildResponse($json)
 {
     $logObj = new Logging();
     $msgList = array();
     $logObj->setMessageList($msgList);
     $logObj->setStrResponse($json);
     $jsonObj = new JSONObject($json);
     $jsonObjApp42 = $jsonObj->__get("app42");
     $jsonObjResponse = $jsonObjApp42->__get("response");
     $logObj->setResponseSuccess($jsonObjResponse->__get("success"));
     $jsonObjLog = $jsonObjResponse->__get("logs");
     if (!$jsonObjLog->has("log")) {
         return $logObj;
     }
     if ($jsonObjLog->__get("log") instanceof JSONObject) {
         // Only One attribute is there
         $jsonObjLogMessage = $jsonObjLog->__get("log");
         $messageItem = new Message($logObj);
         $this->buildObjectFromJSONTree($messageItem, $jsonObjLogMessage);
     } else {
         // There is an Array of attribute
         $jsonObjMessageArray = $jsonObjLog->getJSONArray("log");
         for ($i = 0; $i < count($jsonObjMessageArray); $i++) {
             // Get Individual Attribute Node and set it into Object
             $jsonObjLogMessage = $jsonObjMessageArray[$i];
             $messageItem = new Message($logObj);
             $jsonObjLogMessage = new JSONObject($jsonObjLogMessage);
             $this->buildObjectFromJSONTree($messageItem, $jsonObjLogMessage);
         }
     }
     return $logObj;
 }
 public function retrieve($url)
 {
     if (Logging::isDebug()) {
         Logging::logDebug("Retrieving [{$url}]");
     }
     $h = curl_init();
     if (!$h) {
         throw new ServiceException("INVALID_CONFIGURATION", "Failed to initialize curl: " . curl_errno() . " " . curl_error());
     }
     if (!curl_setopt($h, CURLOPT_URL, $url)) {
         curl_close($h);
         throw new ServiceException("INVALID_CONFIGURATION", "Failed to initialize curl: " . curl_errno() . " " . curl_error());
     }
     $tempFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('Kloudspeaker', true);
     $fh = @fopen($tempFile, "wb");
     if (!$fh) {
         curl_close($h);
         throw new ServiceException("INVALID_CONFIGURATION", "Could not open temporary file for writing: " . $tempFile);
     }
     if (!curl_setopt($h, CURLOPT_FILE, $fh) or !curl_setopt($h, CURLOPT_HEADER, 0)) {
         fclose($fh);
         curl_close($h);
         throw new ServiceException("INVALID_CONFIGURATION", "Failed to initialize curl: " . curl_errno() . " " . curl_error());
     }
     set_time_limit(0);
     $success = curl_exec($h);
     $status = FALSE;
     $errorNo = 0;
     $error = NULL;
     if ($success) {
         $status = curl_getinfo($h, CURLINFO_HTTP_CODE);
     } else {
         $errorNo = curl_errno($h);
         $error = curl_error($h);
         Logging::logDebug("Failed to retrieve url: {$errorNo} {$error}");
     }
     fclose($fh);
     curl_close($h);
     if (!$success) {
         if ($errorNo === 6) {
             return array("success" => false, "result" => 404);
         }
         throw new ServiceException("REQUEST_FAILED", $error);
     }
     if ($status !== 200) {
         if (file_exists($tempFile)) {
             unlink($tempFile);
         }
         return array("success" => false, "result" => $status);
     }
     return array("success" => true, "file" => $tempFile, "stream" => @fopen($tempFile, "rb"), "name" => $this->getName($url));
 }