Exemple #1
0
 public static function log($message)
 {
     if (class_exists('Current_User') && isset($_SESSION['User'])) {
         $username = Current_User::getUsername();
     } else {
         $username = _('Unknown user');
     }
     $ip = $_SERVER['REMOTE_ADDR'];
     if (isset($_SERVER['HTTP_REFERER'])) {
         $via = sprintf(_('Coming from: %s'), $_SERVER['HTTP_REFERER']);
     } else {
         $via = _('Unknown source');
     }
     $infraction = sprintf('%s@%s %s -- %s', $username, $ip, $via, $message);
     PHPWS_Core::log(escapeshellcmd($infraction), 'security.log', _('Warning'));
 }
Exemple #2
0
 public static function moduleWarning($module)
 {
     // disabling as it is broken
     return;
     if (!LOG_DEPRECATIONS) {
         return;
     }
     $dep_name = $module . '_deprecated';
     $last_warned = PHPWS_Settings::get('users', $dep_name);
     $spacing = time() - 86400 * DEPRECATE_DAY_SPACING;
     // It hasn't been long enough to log the warning.
     if ($last_warned && $last_warned > $spacing) {
         return;
     }
     $warning = "The {$module} module is deprecated and support is discontinued. Please consider uninstalling it.";
     PHPWS_Core::log($warning, 'deprecated.log');
     PHPWS_Settings::set('users', $dep_name, time());
     PHPWS_Settings::save('users');
 }
Exemple #3
0
    private static function logScheduleCompletion(PulseSchedule $schedule, $result)
    {
        $id = $schedule->getId();
        $start_time = $schedule->getStartTime('%c');
        $end_time = $schedule->getEndTime('%c');
        $log = <<<EOF
Schedule #{$id} was executed at {$start_time} and completed at {$end_time}.
Returned result: {$result}
EOF;
        \PHPWS_Core::log($log, 'pulse.log');
    }
 /**
  * Logs this request to PHPWS' soap.log file
  */
 private function logRequest($functionName, $result, array $params)
 {
     $args = implode(', ', $params);
     $msg = "{$functionName}({$args}) result: {$result}";
     \PHPWS_Core::log($msg, 'soap.log', 'SOAP');
 }
Exemple #5
0
 /**
  * Uses the PHPWS_Core log public function to 'manually' log soap requests
  *
  * @param String $function The name of the function that's doing the logging.
  * @param String $result A string indicating the result of the function call. Could be anything (usually "success").
  * @return void
  */
 protected static function logSoap($function, $result, array $params)
 {
     $args = implode(', ', $params);
     $msg = "{$function}({$args}) result: {$result}";
     PHPWS_Core::log($msg, 'soap.log', 'SOAP');
 }
Exemple #6
0
 private function sendEmail($subject, $student_id, $content)
 {
     $transport = $this->getSwiftTransport();
     $student = StudentFactory::getById($student_id);
     if (!is_object($student)) {
         \PHPWS_Core::log("Student #{$student_id} does not exist.", 'tailgate_error.txt');
         return;
     }
     $message = \Swift_Message::newInstance();
     $message->setSubject($subject);
     $message->setFrom(\Settings::get('tailgate', 'reply_to'));
     $message->setTo($student->getEmail());
     $message->setBody($content, 'text/html');
     $mailer = \Swift_Mailer::newInstance($transport);
     $log = "Subject: {$subject}, To: " . $student->getEmail();
     \PHPWS_Core::log($log, 'tailgate_email.log');
     $mailer->send($message);
 }
Exemple #7
0
 public static function addLog($module, $message)
 {
     $message = dgettext('boost', 'Module') . ' - ' . $module . ' : ' . $message;
     PHPWS_Core::log($message, 'boost.log');
 }
Exemple #8
0
 /**
  * PHPWS_Email has a built-in simple logging function.  This replicates
  * the functionality of that function for SwiftMail.
  */
 public static function logSwiftmailMessage(Swift_Message $message)
 {
     $id = 'id:' . $message->getId();
     $from = 'from:' . $message->getSender();
     $to = 'to:' . implode(',', array_keys($message->getTo()));
     // Optional fields, If the message has them, implode the arrays to simple strings.
     $cc = $message->getCc() != null ? 'cc:' . implode(',', array_keys($message->getCc())) : '';
     $bcc = $message->getBcc() != null ? 'bcc:' . implode(',', array_keys($message->getBcc())) : '';
     $replyto = $message->getReplyTo() != null ? 'reply-to:' . implode(',', array_keys($message->getReplyTo())) : '';
     $subject = 'subject:' . $message->getSubject();
     $module = 'module:' . PHPWS_Core::getCurrentModule();
     $user = '******' . (Current_User::isLogged() ? Current_User::getUsername() : '');
     PHPWS_Core::log("{$id} {$module} {$user} {$subject} {$from} {$to} {$cc} {$bcc} {$replyto}", 'phpws-mail.log', 'mail');
 }
Exemple #9
0
 private function ignoreReport($id)
 {
     \PHPWS_Core::initModClass('properties', 'Report.php');
     \PHPWS_Core::initModClass('properties', 'Message.php');
     $report = new Report($id);
     $message = new Message($report->message_id);
     try {
         $report->delete();
     } catch (\Exception $e) {
         \PHPWS_Core::log($e->getMessage(), 'properties.log');
         exit('Could not remove report');
     }
     $message->reported = 0;
     $message->save();
 }
Exemple #10
0
 public static function logDB($sql)
 {
     if (!defined('LOG_DB') || LOG_DB != true) {
         return;
     }
     PHPWS_Core::log($sql, 'db.log');
 }
Exemple #11
0
    /**
     * Trying to find out why Users changes authentication script. If cause
     * is found, this will be removed.
     */
    public static function trackAuthentication($message)
    {
        $url = \Server::getCurrentUrl(false, false);
        $request = \Server::getCurrentRequest();
        if ($request->isPost()) {
            $type = 'POST';
        } else {
            $type = 'GET';
        }
        $vars = $request->getVars();
        if (empty($vars)) {
            $variables = 'No variables';
        } else {
            foreach ($vars['vars'] as $k => $v) {
                if (is_array($v)) {
                    $v = serialize($v);
                }
                $varlist[] = "{$k}: {$v}";
            }
            $variables = implode("\n", $varlist);
        }
        $content = <<<EOF

MESSAGE: {$message}
REQUEST TYPE: {$type}
VARIABLES:
{$variables}
----
EOF;
        \PHPWS_Core::log($content, 'default_authorization.log');
    }
Exemple #12
0
 public function post()
 {
     $this->setTitle($_POST['title']);
     $this->setPropertyId($_POST['pid']);
     $photo =& $_FILES['photo'];
     if (!$this->pid) {
         throw new \Exception('Photo missing property id');
     }
     \PHPWS_Core::initModClass('properties', 'Property.php');
     $property = new Property($this->pid);
     $this->setContactId($property->contact_id);
     $destination_directory = 'images/properties/c' . $this->cid . '/';
     if (!is_dir($destination_directory)) {
         if (!@mkdir($destination_directory)) {
             throw new \Exception('Could not create photo directory');
         }
     }
     $filename = time() . '.' . \PHPWS_File::getFileExtension($photo['name']);
     $path = $destination_directory . $filename;
     if (!empty($photo['error'])) {
         switch ($photo['error']) {
             case UPLOAD_ERR_INI_SIZE:
             case UPLOAD_ERR_FORM_SIZE:
                 throw new \Exception('Image file size is too large.');
             case UPLOAD_ERR_NO_FILE:
                 throw new \Exception('No file upload');
             case UPLOAD_ERR_NO_TMP_DIR:
                 \PHPWS_Core::log('Temporary file directory is not writable', 'error.log', _('Error'));
                 throw new \Exception('File could not be written');
         }
     }
     list($this->width, $this->height, $image_type, $image_attr) = getimagesize($photo['tmp_name']);
     if (!in_array($image_type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
         throw new \Exception('Unacceptable image file type.');
     }
     if (\PHPWS_File::scaleImage($photo['tmp_name'], $path, PROPERTIES_MAX_WIDTH, PROPERTIES_MAX_HEIGHT)) {
         $this->path = $path;
         $this->save();
         $tn = Photo::thumbnailPath($path);
         $this->resize($path, $tn, PROP_THUMBNAIL_WIDTH, PROP_THUMBNAIL_HEIGHT);
     } else {
         throw new \Exception('Could not save image');
     }
 }
 public function __construct($message, $code = 0)
 {
     parent::__construct($message, $code);
     PHPWS_Core::log('Room Swap failed! : ' . $message, 'error.log');
 }
Exemple #14
0
 protected static function log($to, $headers, $result)
 {
     $id = 'id:' . $headers['Message-Id'];
     $from = 'from:' . (isset($headers['From']) ? $headers['From'] : '');
     $to = 'to:' . $to;
     $cc = 'cc:' . (isset($headers['Cc']) ? $headers['Cc'] : '');
     $bcc = 'bcc:' . (isset($headers['Bcc']) ? $headers['Bcc'] : '');
     $replyto = 'reply-to:' . (isset($headers['Reply-To']) ? $headers['Reply-To'] : '');
     $subject = 'subject:' . (isset($headers['Subject']) ? $headers['Subject'] : '');
     $module = 'module:' . PHPWS_Core::getCurrentModule();
     $user = '******' . (Current_User::isLogged() ? Current_User::getUsername() : '');
     $result = 'result:' . (PHPWS_Error::isError($result) ? 'Failure' : 'Success');
     PHPWS_Core::log("{$id} {$module} {$user} {$subject} {$from} {$to} {$cc} {$bcc} {$replyto} {$result}", 'phpws-mail.log', 'mail');
 }
 public function __construct($message, $code = 0, $functionName, $params)
 {
     parent::__construct($message, $code);
     $errorMsg = $functionName . '(' . implode(',', $params) . '): ' . $code;
     PHPWS_Core::log($errorMsg, 'soapError.log', 'BannerError');
 }