示例#1
0
 public function afterAction()
 {
     //$time = microtime(true);
     //echo '<center style="color: gray;padding: 10px;">'."Page generated in ".(($time-Rays::$startTime)*1000) . " ms"."</center>";
     $accessLog = new AccessLog(array('host' => Rays::app()->request()->getUserHostAddress(), 'path' => Rays::uri(), 'title' => $this->getHeaderTitle(), 'uri' => Rays::referrerUri(), 'timestamp' => date('Y-m-d H:i:s')));
     $accessLog->userId = Rays::isLogin() ? Rays::user()->id : 0;
     $accessLog->save();
 }
示例#2
0
 public static function create($userId, $sessionId)
 {
     $ip = $_SERVER["REMOTE_ADDR"];
     $userAgent = $_SERVER["HTTP_USER_AGENT"];
     $uri = $_SERVER["REQUEST_URI"];
     $log = new AccessLog();
     $log->user = $userId;
     $log->session = $sessionId;
     $log->ip = $ip;
     $log->userAgent = UserAgent::getId($userAgent);
     $log->uri = $uri;
     $log->date = Database::now();
     $log->save();
     return $log;
 }
示例#3
0
 /**
  * @return User
  *
  * Fetches the session user if one is logged in.
  * Otherwise returns null.
  */
 public static function getUser()
 {
     if (!Session::$sessionUser) {
         if (!Session::getSessionCookie()) {
             return null;
         }
         $sessionToken = Session::getSessionCookie();
         $session = UserSession::findByToken($sessionToken);
         if (!$session) {
             return null;
         }
         // increase expire date
         $session->updateExpireDate(time() + 15 * 60);
         $session->save();
         Session::$sessionUser = $session->getUser();
         AccessLog::create(Session::$sessionUser->id, $session->id);
     }
     return Session::$sessionUser;
 }
示例#4
0
 // all OK, proceed!
 $query = "SELECT username FROM {$GLOBALS['CONFIG']['db_prefix']}user WHERE id='{$_SESSION['uid']}'";
 $result = mysql_query($query, $GLOBALS['connection']) or die("Error in query: {$query}. " . mysql_error());
 list($username) = mysql_fetch_row($result);
 // update revision log
 $query = "UPDATE {$GLOBALS['CONFIG']['db_prefix']}log set revision='" . intval(intval($lrevision_num) - 1) . "' WHERE id = '{$id}' and revision = 'current'";
 mysql_query($query, $GLOBALS['connection']) or die("Error in query: {$query}. " . mysql_error());
 $query = "INSERT INTO {$GLOBALS['CONFIG']['db_prefix']}log (id, modified_on, modified_by, note, revision) VALUES('{$id}', NOW(), '" . addslashes($username) . "', '" . addslashes($_POST['note']) . "', 'current')";
 $result = mysql_query($query, $GLOBALS['connection']) or die("Error in query: {$query}. " . mysql_error());
 // update file status
 $query = "UPDATE {$GLOBALS['CONFIG']['db_prefix']}data SET status = '0', publishable='{$lpublishable}', realname='{$filename}' WHERE id='{$id}'";
 $result = mysql_query($query, $GLOBALS['connection']) or die("Error in query: {$query}. " . mysql_error());
 // rename and save file
 $newFileName = $id . '.dat';
 copy($_FILES['file']['tmp_name'], $GLOBALS['CONFIG']['dataDir'] . $newFileName);
 AccessLog::addLogEntry($id, 'I');
 /**
  * Send out email notifications to reviewers
  */
 $file_obj = new FileData($id, $GLOBALS['connection'], DB_NAME);
 $get_full_name = $user_obj->getFullName();
 $full_name = $get_full_name[0] . ' ' . $get_full_name[1];
 $department = $file_obj->getDepartment();
 $reviewer_obj = new Reviewer($id, $GLOBALS['connection'], DB_NAME);
 $reviewer_list = $reviewer_obj->getReviewersForDepartment($department);
 $date = date('Y-m-d H:i:s T');
 // Build email for general notices
 $mail_subject = msg('checkinpage_file_was_checked_in');
 $mail_body2 = msg('checkinpage_file_was_checked_in') . "\n\n";
 $mail_body2 .= msg('label_filename') . ':  ' . $file_obj->getName() . "\n\n";
 $mail_body2 .= msg('label_status') . ': ' . msg('addpage_new') . "\n\n";
示例#5
0
            header('Location:error.php?ec=23&last_message=' . urlencode($last_message));
            exit;
        }
    }
    for ($i = 0; $i < $_REQUEST['num_checkboxes']; $i++) {
        if (isset($_REQUEST['id' . $i])) {
            $id = $_REQUEST['id' . $i];
            if (strchr($id, '_')) {
                header('Location:error.php?ec=20');
            }
            if ($userperm_obj->canAdmin($id)) {
                $file_obj = new FileData($id, $pdo);
                $file_obj->temp_delete();
                fmove($GLOBALS['CONFIG']['dataDir'] . $id . '.dat', $GLOBALS['CONFIG']['archiveDir'] . $id . '.dat');
            }
            AccessLog::addLogEntry($_REQUEST['id' . $i], 'X', $pdo);
        }
    }
    // delete from directory
    // clean up and back to main page
    $last_message = msg('message_document_has_been_archived');
    // Call the plugin API call for this section
    callPluginMethod('onAfterArchiveFile');
    header('Location: out.php?last_message=' . urlencode($last_message));
} elseif (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'view_del_archive') {
    //publishable=2 for archive deletion
    $query = "SELECT id FROM {$GLOBALS['CONFIG']['db_prefix']}data WHERE publishable=2";
    $stmt = $pdo->prepare($query);
    $stmt->execute();
    $result = $stmt->fetchAll();
    $array_id = array();
示例#6
0
    } else {
        echo msg('message_file_does_not_exist');
    }
} elseif ($_GET['submit'] == 'Download') {
    $file_obj = new FileData($_REQUEST['id'], $GLOBALS['connection'], DB_NAME);
    // Added this check to keep unauthorized users from downloading - Thanks to Chad Bloomquist
    checkUserPermission($_REQUEST['id'], $file_obj->READ_RIGHT, $file_obj);
    $realname = $file_obj->getName();
    if (isset($lrevision_id)) {
        $filename = $lrevision_dir . $lrequest_id . ".dat";
    } elseif ($file_obj->isArchived()) {
        $filename = $GLOBALS['CONFIG']['archiveDir'] . $_REQUEST['id'] . ".dat";
    } else {
        $filename = $GLOBALS['CONFIG']['dataDir'] . $_REQUEST['id'] . ".dat";
    }
    if (file_exists($filename)) {
        // send headers to browser to initiate file download
        header('Cache-control: private');
        header('Content-Type: ' . $_GET['mimetype']);
        header('Content-Disposition: attachment; filename="' . $realname . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        readfile($filename);
        AccessLog::addLogEntry($_REQUEST['id'], 'D');
    } else {
        echo msg('message_file_does_not_exist');
    }
} else {
    echo msg('message_nothing_to_do');
    echo 'submit is ' . $_GET['submit'];
}
示例#7
0
文件: add.php 项目: PramodhKG/dms
 // Search for similar names in the two array (merge the array.  repetitions are deleted)
 // In case of repetitions, higher priority ones stay.
 // Priority is in this order (admin, modify, read, view)
 foreach ($_REQUEST['user_permission'] as $user_id => $permission) {
     $user_perms_query = "INSERT INTO {$GLOBALS['CONFIG']['db_prefix']}user_perms (fid, uid, rights) VALUES({$fileId}, :user_id, :permission)";
     $user_perms_stmt = $pdo->prepare($user_perms_query);
     $user_perms_stmt->bindParam(':user_id', $user_id);
     $user_perms_stmt->bindParam(':permission', $permission);
     $user_perms_stmt->execute();
 }
 // use id to generate a file name
 // save uploaded file with new name
 $newFileName = $fileId . '.dat';
 move_uploaded_file($tmp_name[$count], $GLOBALS['CONFIG']['dataDir'] . '/' . $newFileName);
 //copy($GLOBALS['CONFIG']['dataDir'] . '/' . ($fileId-1) . '.dat', $GLOBALS['CONFIG']['dataDir'] . '/' . $newFileName);
 AccessLog::addLogEntry($fileId, 'A', $pdo);
 // back to main page
 $message = urlencode(msg('message_document_added'));
 /**
  * Send out email notifications to reviewers
  */
 $file_obj = new FileData($fileId, $pdo);
 $get_full_name = $user_obj->getFullName();
 $full_name = $get_full_name[0] . ' ' . $get_full_name[1];
 $from = $user_obj->getEmailAddress();
 $department = $file_obj->getDepartment();
 $reviewer_obj = new Reviewer($fileId, $pdo);
 $reviewer_list = $reviewer_obj->getReviewersForDepartment($department);
 $date = date('Y-m-d H:i:s T');
 // Build email for general notices
 $mail_subject = msg('addpage_new_file_added');
 public static function handle()
 {
     if (!isset(self::$_instance)) {
         $c = __CLASS__;
         self::$_instance = new $c();
     }
     return self::$_instance;
 }
示例#9
0
     $mail_body1 = $comments . PHP_EOL . PHP_EOL;
     $mail_body1 .= msg('email_your_file_has_been_authorized') . PHP_EOL . PHP_EOL;
     $mail_body1 .= msg('label_filename') . ':  ' . $file_obj->getName() . PHP_EOL . PHP_EOL;
     $mail_body1 .= msg('label_status') . ': ' . msg('message_authorized') . PHP_EOL . PHP_EOL;
     $mail_body1 .= msg('date') . ': ' . $date . PHP_EOL . PHP_EOL;
     $mail_body1 .= msg('label_reviewer') . ': ' . $full_name . PHP_EOL . PHP_EOL;
     $mail_body1 .= msg('email_thank_you') . ',' . PHP_EOL . PHP_EOL;
     $mail_body1 .= msg('email_automated_document_messenger') . PHP_EOL . PHP_EOL;
     $mail_body1 .= $GLOBALS['CONFIG']['base_url'] . PHP_EOL . PHP_EOL;
     if ($GLOBALS['CONFIG']['demo'] == 'False') {
         mail($mail_to, $mail_subject . " " . $file_obj->getName(), $mail_body1, $mail_headers);
     }
 }
 $file_obj->Publishable(1);
 $file_obj->setReviewerComments($reviewer_comments);
 AccessLog::addLogEntry($fileid, 'Y', $pdo);
 // Build email for general notices
 $mail_subject = !empty($_REQUEST['subject']) ? stripslashes($_REQUEST['subject']) : $file_obj->getName() . ' ' . msg('email_added_to_repository');
 $mail_body2 = $comments . PHP_EOL . PHP_EOL;
 $mail_body2 .= msg('email_a_new_file_has_been_added') . PHP_EOL . PHP_EOL;
 $mail_body2 .= msg('label_filename') . ':  ' . $file_obj->getName() . PHP_EOL . PHP_EOL;
 $mail_body2 .= msg('label_status') . ': New' . PHP_EOL . PHP_EOL;
 $mail_body2 .= msg('date') . ': ' . $date . PHP_EOL . PHP_EOL;
 $mail_body2 .= msg('label_reviewer') . ': ' . $full_name . PHP_EOL . PHP_EOL;
 $mail_body2 .= msg('email_thank_you') . ',' . PHP_EOL . PHP_EOL;
 $mail_body2 .= msg('email_automated_document_messenger') . PHP_EOL . PHP_EOL;
 $mail_body2 .= $GLOBALS['CONFIG']['base_url'] . PHP_EOL . PHP_EOL;
 if (isset($_POST['send_to_all'])) {
     email_all($mail_subject, $mail_body2, $mail_headers);
 }
 if (isset($_POST['send_to_dept'])) {
示例#10
0
 $username = $result['username'];
 // update revision log
 $query = "UPDATE {$GLOBALS['CONFIG']['db_prefix']}log set revision='" . intval(intval($revision_number) - 1) . "' WHERE id = :id and revision = 'current'";
 $stmt = $pdo->prepare($query);
 $stmt->execute(array(':id' => $id));
 $query = "INSERT INTO {$GLOBALS['CONFIG']['db_prefix']}log (id, modified_on, modified_by, note, revision) VALUES(:id, NOW(), :username, :note, 'current')";
 $stmt = $pdo->prepare($query);
 $stmt->execute(array(':id' => $id, ':username' => $username, ':note' => $_POST['note']));
 // update file status
 $query = "UPDATE {$GLOBALS['CONFIG']['db_prefix']}data SET status = '0', publishable = :publishable, realname = :filename WHERE id = :id";
 $stmt = $pdo->prepare($query);
 $stmt->execute(array(':publishable' => $publishable, ':filename' => $filename, ':id' => $id));
 // rename and save file
 $newFileName = $id . '.dat';
 copy($_FILES['file']['tmp_name'], $GLOBALS['CONFIG']['dataDir'] . $newFileName);
 AccessLog::addLogEntry($id, 'I', $pdo);
 /**
  * Send out email notifications to reviewers
  */
 $file_obj = new FileData($id, $pdo);
 $get_full_name = $user_obj->getFullName();
 $full_name = $get_full_name[0] . ' ' . $get_full_name[1];
 $department = $file_obj->getDepartment();
 $reviewer_obj = new Reviewer($id, $pdo);
 $reviewer_list = $reviewer_obj->getReviewersForDepartment($department);
 $date = date('Y-m-d H:i:s T');
 // Build email for general notices
 $mail_subject = msg('checkinpage_file_was_checked_in');
 $mail_body2 = msg('checkinpage_file_was_checked_in') . PHP_EOL;
 $mail_body2 .= msg('label_filename') . ':  ' . $file_obj->getName() . PHP_EOL;
 $mail_body2 .= msg('label_status') . ': ' . msg('addpage_new') . PHP_EOL;
示例#11
0
     $mail_body1 = $lcomments . "\n\n";
     $mail_body1 .= msg('email_your_file_has_been_authorized') . "\n\n";
     $mail_body1 .= msg('label_filename') . ':  ' . $file_obj->getName() . "\n\n";
     $mail_body1 .= msg('label_status') . ': ' . msg('message_authorized') . "\n\n";
     $mail_body1 .= msg('date') . ': ' . $date . "\n\n";
     $mail_body1 .= msg('label_reviewer') . ': ' . $full_name . "\n\n";
     $mail_body1 .= msg('email_thank_you') . ',' . "\n\n";
     $mail_body1 .= msg('email_automated_document_messenger') . "\n\n";
     $mail_body1 .= $GLOBALS['CONFIG']['base_url'] . "\n\n";
     if ($GLOBALS['CONFIG']['demo'] == 'False') {
         mail($mail_to, $mail_subject . " " . $file_obj->getName(), $mail_body1, $mail_headers);
     }
 }
 $file_obj->Publishable(1);
 $file_obj->setReviewerComments($reviewer_comments);
 AccessLog::addLogEntry($fileid, 'Y');
 // Build email for general notices
 $mail_subject = !empty($_REQUEST['subject']) ? stripslashes($_REQUEST['subject']) : $file_obj->getName() . ' ' . msg('email_added_to_repository');
 $mail_body2 = $lcomments . "\n\n";
 $mail_body2 .= msg('email_a_new_file_has_been_added') . "\n\n";
 $mail_body2 .= msg('label_filename') . ':  ' . $file_obj->getName() . "\n\n";
 $mail_body2 .= msg('label_status') . ': New' . "\n\n";
 $mail_body2 .= msg('date') . ': ' . $date . "\n\n";
 $mail_body2 .= msg('label_reviewer') . ': ' . $full_name . "\n\n";
 $mail_body2 .= msg('email_thank_you') . ',' . "\n\n";
 $mail_body2 .= msg('email_automated_document_messenger') . "\n\n";
 $mail_body2 .= $GLOBALS['CONFIG']['base_url'] . "\n\n";
 if (isset($_POST['send_to_all'])) {
     email_all($mail_subject, $mail_body2, $mail_headers);
 }
 if (isset($_POST['send_to_dept'])) {
示例#12
0
    if (isset($_REQUEST['file_owner'])) {
        $filedata->setOwner(mysql_real_escape_string($_REQUEST['file_owner']));
    }
    if (isset($_REQUEST['file_department'])) {
        $filedata->setDepartment(mysql_real_escape_string($_REQUEST['file_department']));
    }
    // Update the file with the new values
    $filedata->updateData();
    udf_edit_file_update();
    // clean out old permissions
    $query = "DELETE FROM {$GLOBALS['CONFIG']['db_prefix']}user_perms WHERE fid = '{$fileId}'";
    $result = mysql_query($query, $GLOBALS['connection']) or die("Error in query: {$query}. " . mysql_error());
    $result_array = array();
    // init;
    foreach ($_REQUEST['user_permission'] as $user_id => $permission) {
        $query = "INSERT INTO {$GLOBALS['CONFIG']['db_prefix']}user_perms (fid, uid, rights) VALUES({$fileId}, {$user_id}, {$permission})";
        //echo $query."<br>";
        $result = mysql_query($query, $GLOBALS['connection']) or die("Error in query: {$query}" . mysql_error());
    }
    //UPDATE Department Rights into dept_perms
    foreach ($_POST['department_permission'] as $dept_id => $dept_perm) {
        $query = "UPDATE {$GLOBALS['CONFIG']['db_prefix']}dept_perms SET rights = {$dept_perm} where fid=" . $filedata->getId() . " and {$GLOBALS['CONFIG']['db_prefix']}dept_perms.dept_id = {$dept_id}";
        mysql_query($query, $GLOBALS['connection']) or die("Error in query: {$query}. " . mysql_error());
    }
    $message = urlencode('Document successfully updated');
    AccessLog::addLogEntry($fileId, 'M');
    // Call the plugin API
    callPluginMethod('onAfterEditFile', $fileId);
    header('Location: details.php?id=' . $fileId . '&last_message=' . $message);
}
draw_footer();
示例#13
0
    // shell_exec("zip -r $filename.zip $filename ");
    $mailer->IsHTML(true);
    $mailer->Subject = $subject;
    $mailer->Body = $content;
    // $tarName = $filename.'.zip';
    // $mailer->AddAttachment('./'.$tarName, "$tarName");//附件的路径和附件名称
    if ($mailer->Send()) {
        echo "send email {$subject} successful!";
    } else {
        echo "sendmail wrong" . $mailer->ErrorInfo;
    }
    // shell_exec("rm $tarName");
    // shell_exec("rm $filename");
}
header("Content-Type: text/html; charset=utf-8");
$rl = new AccessLog();
$filename = 'C:\\Users\\N010D90001\\Downloads\\abc.log';
// 对文件名的编码,避免中文文件名乱码
$filename = iconv("UTF-8", "GBK", $filename);
$files = array($filename);
$logdate = $rl->getLogDate($files[0]);
$title = 'Nginx日志统计 ' . $logdate;
$html = <<<HTML
<html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>{$title}</title>
        </head>
<style type="text/css">
body {font-size: 12px; font-family: Arial, Helvetica, sans-serif; }
table#dd {background-color: #6CADD9;white-space:nowrap;}