本文整理汇总了PHP中Audit::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Audit::instance方法的具体用法?PHP Audit::instance怎么用?PHP Audit::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Audit
的用法示例。
在下文中一共展示了Audit::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* @param Registry $registry
* @return Audit
*/
public static function getInstance($registry)
{
if (empty(Audit::$instance)) {
Audit::$instance = new Audit($registry);
}
return Audit::$instance;
}
示例2: __construct
function __construct()
{
parent::__construct();
$this->user = new \DB\SQL\Mapper($this->db, 'users');
$this->audit = \Audit::instance();
$this->bcrypt = \BCrypt::instance();
}
示例3: addPlugin
private function addPlugin()
{
$audit = \Audit::instance();
$this->f3->scrub($_POST);
$this->f3->set('SESSION.flash', array());
// process form if > 0 plugins have been selected
if ($this->f3->exists('POST.plugins') && count($this->f3->get('POST.plugins')) > 0) {
foreach ($this->f3->get('POST.plugins') as $package) {
// validate plugin
if ($this->plugins->getPackage($package) !== false) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => '"' . $package . '" is already installed. Skipping.'));
} else {
if (!($config = $this->plugins->getRemoteConfig($package))) {
$this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => '"' . $package . '" could not be installed. (missing mytcg.json config file)'));
} else {
if (!isset($config['name']) || !isset($config['author']) || !isset($config['version']) || !isset($config['description'])) {
$this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => '"' . $package . '" could not be installed. (invalid mytcg.json config file)'));
}
}
}
// process install if there are no errors
if (count($this->f3->get('SESSION.flash')) === 0) {
if ($this->plugins->install($package, $this->plugins)) {
$this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => '"' . $package . '" has been installed successfully!'));
} else {
$this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => '"' . $package . '" could not be installed.'));
}
}
}
}
}
示例4: process
private function process()
{
$this->f3->scrub($_POST);
$audit = \Audit::instance();
$this->f3->set('SESSION.flash', array());
// validate form
if (!preg_match("/^[\\w\\- ]{2,30}\$/", $this->f3->get('POST.name'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid name.'));
}
if (!$audit->email($this->f3->get('POST.email'), FALSE)) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid email address'));
}
if (!empty($this->f3->get('POST.url')) && !$audit->url($this->f3->get('POST.url'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid URL.'));
}
if (empty($this->f3->get('POST.message'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please include a message!'));
}
// honey pot
if ($this->f3->get('POST.username') !== '') {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please do not use autofill or similar tools!'));
}
// if there are no errors, process the form
if (count($this->f3->get('SESSION.flash')) === 0) {
$this->f3->set('POST.level', $this->f3->get('member')->level + 1);
$mailer = new Mailer();
$message = $mailer->message()->setSubject($this->f3->get('tcgname') . ': Contact Form')->setFrom(array($this->f3->get('noreplyemail') => 'MyTCG'))->setTo(array($this->f3->get('tcgemail')))->setReplyTo(array($this->f3->get('POST.email')))->setBody(Template::instance()->render('app/templates/emails/contact.htm'), 'text/html');
if ($mailer->send($message)) {
$this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Your form has been sent. Thanks for contacting us!'));
} else {
$this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'There was a problem processing your request. Please try again or contact us for assistance!'));
}
}
}
示例5: setActive
public static function setActive()
{
if (!\Audit::instance()->isbot()) {
if (class_exists('\\Activity\\Models\\Actors')) {
$actor = \Activity\Models\Actors::fetch();
if ($actor->isExcluded()) {
return;
}
}
if (\Dsc\System::instance()->get('input')->get('ping', null, 'int') != 1) {
$fw = \Base::instance();
$path = $fw->hive()['PATH'];
switch ($path) {
// ignore certain paths, even if they aren't specifically pings
case strpos($path, '/minify/') === 0 ? true : false:
case "/minify/css":
case "/minify/js":
break;
default:
(new \Dsc\Mongo\Collections\Sessions())->store();
break;
}
}
}
\Dsc\Mongo\Collections\Sessions::throttledCleanup();
}
示例6: email
/**
* validate email address
* @param string $val
* @param string $context
* @param bool $mx
* @return bool
*/
function email($val, $context = null, $mx = true)
{
$valid = true;
if (!$context) {
$context = 'error.validation.email';
}
if (!empty($val)) {
if (!\Audit::instance()->email($val, false)) {
$val = NULL;
if (!$this->f3->exists($context . '.invalid', $errText)) {
$errText = 'e-mail is not valid';
}
$this->f3->error(400, $errText);
$valid = false;
} elseif ($mx && !\Audit::instance()->email($val, true)) {
$val = NULL;
if (!$this->f3->exists($context . '.host', $errText)) {
$errText = 'unknown mail mx.host';
}
$this->f3->error(400, $errText);
$valid = false;
}
}
if (!$valid) {
\Flash::instance()->setKey($context, 'has-error');
}
return $valid;
}
示例7: set_email
/**
* validate and set a email address for this user
* @param $email
* @return mixed
*/
public function set_email($email)
{
if (\Audit::instance()->email($email) == false) {
// no valid email address
$this->throwValidationError('email');
}
return $email;
}
示例8: __construct
function __construct()
{
$f3 = Base::instance();
$db = new DB\SQL($f3->get('db_dns') . $f3->get('db_name'), $f3->get('db_user'), $f3->get('db_pass'));
$audit = \Audit::instance();
$this->f3 = $f3;
$this->db = $db;
$this->audit = $audit;
}
示例9: install
protected function install()
{
$audit = \Audit::instance();
$this->f3->scrub($_POST);
$this->f3->set('SESSION.flash', array());
if (!$this->f3->exists('POST.tag') || $this->f3->get('POST.tag') === '') {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid request. Please try again.'));
}
// process form if there are no errors
if (count($this->f3->get('SESSION.flash')) === 0) {
$this->releases->install($this->f3->get('POST.tag'));
}
}
示例10: edit
public function edit($id = '')
{
/***********************************
Edit form
************************************/
$this->f3->scrub($_POST);
$members = new Members($this->db);
$this->f3->set('member', $members->read(array('id=?', $id), [])[0]);
$this->f3->set('SESSION.flash', array());
$this->f3->set('status', array('Active', 'Hiatus'));
$cards = new Cards($this->db);
$this->f3->set('decks', $cards->allAlpha());
$this->f3->set('months', array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));
// form submitted
if ($this->f3->exists('POST.edit')) {
$audit = \Audit::instance();
// validate form
if (!preg_match("/^[\\w\\-]{2,30}\$/", $this->f3->get('POST.name'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid name. Only letters, numbers, underscores (_), and dashes (-) are allowed.'));
}
if (!$audit->email($this->f3->get('POST.email'), FALSE)) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid email address'));
}
if (!$audit->url($this->f3->get('POST.url'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid trade post URL.'));
}
if (!in_array($this->f3->get('POST.birthday'), $this->f3->get('months'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid birthday'));
}
if ($cards->count(array('id=?', $this->f3->get('POST.collecting'))) == 0) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid collecting deck.'));
}
if ($this->f3->get('member')->status !== 'Pending' && !in_array($this->f3->get('POST.status'), $this->f3->get('status'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid status.'));
}
// if there are no errors, process the form
if (count($this->f3->get('SESSION.flash')) === 0) {
$this->f3->set('collectingID', $this->f3->get('POST.collecting'));
$this->f3->set('POST.collecting', $cards->getById($this->f3->get('POST.collecting'))->filename);
if ($members->edit($this->f3->get('POST.id'))) {
$this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Member ' . $this->f3->get('POST.name') . ' edited!'));
$this->f3->reroute('/mytcg/members');
} else {
$this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'There was a problem processing your request. Please try again!'));
}
}
}
$this->f3->set('content', 'app/views/mytcg/members_edit.htm');
echo Template::instance()->render('app/templates/admin.htm');
}
示例11: save
public function save($f3)
{
if (!$this->configuration->load()) {
$audit = \Audit::instance();
$values = $f3->get('POST');
if (!strlen($values['site-name']) || !strlen($values['password']) || !strlen($values['repeat-password']) || $values['password'] != $values['repeat-password'] || !$audit->email($values['admin-email'])) {
$f3->set('SESSION.form_values', $values);
$messages = array();
if (!$audit->email($values['admin-email'])) {
$messages[] = 'The email must be a valid email';
}
if (!strlen($values['password'])) {
$messages[] = 'The password field are required';
}
if ($values['password'] != $values['repeat-password']) {
$messages[] = 'The password must be equal';
}
if (!strlen($values['site-name'])) {
$messages[] = 'The site name are required';
}
$f3->set('SESSION.form_messages', $messages);
$f3->reroute('/setup');
} else {
$configuration = $this->configuration;
$user = array("firstName" => "Administrator", "lastName" => "", "userName" => "admin", "password" => password_hash($values['password'], PASSWORD_DEFAULT), "email" => $values['admin-email'], "phone" => "", "country" => "", "city" => "", "address" => "");
$f3->set('users', new \DB\Jig\Mapper($this->db, 'users.json'));
$f3->get('users')->copyFrom((array) $user);
$users = $f3->get('users')->save();
$users = $this->db->read('users.json');
reset($users);
$user_id = key($users);
$configuration = array('system_name' => $values['site-name'], 'theme' => 'basic', 'date_format' => 'YYYY');
$f3->set('sysconfig', new \DB\Jig\Mapper($this->db, 'sysconfig.json'));
$f3->get('sysconfig')->copyFrom((array) $configuration);
$f3->get('sysconfig')->save();
$f3->set('roles', new \DB\Jig\Mapper($this->db, 'roles.json'));
$role = array('role' => 'Administrator', 'status' => 1, 'users' => array($user_id), 'qty' => 0);
$f3->get('roles')->copyFrom((array) $role);
$f3->get('roles')->save();
$f3->set('roles', new \DB\Jig\Mapper($this->db, 'roles.json'));
$role = array('role' => 'Guest', 'status' => 1, 'users' => array(), 'qty' => 0);
$f3->get('roles')->copyFrom((array) $role);
$f3->get('roles')->save();
echo Template::instance()->render('templates/setup-created.html');
}
} else {
echo Template::instance()->render('templates/setup-created.html');
}
}
示例12: postSite
protected function postSite()
{
parent::postSite();
if (!\Audit::instance()->isbot()) {
$actor = \Activity\Models\Actors::fetch();
$app = \Base::instance();
// Track the site visit if it hasn't been done today for this actor
if (empty($actor->last_visit) || $actor->last_visit < date('Y-m-d', strtotime('today'))) {
\Activity\Models\Actions::track('Visited Site');
$actor->set('last_visit', date('Y-m-d', strtotime('today')))->set('visited', time())->save();
}
if ($this->input->get('ping', null, 'int') != 1) {
$actor->markActive(!empty($this->auth->getIdentity()->id));
}
}
}
示例13: generic_request
public function generic_request(\Base $f3)
{
$web = \Web::instance();
$this->response->data['SUBPART'] = 'websaccre_generic_request.html';
$audit_instance = \Audit::instance();
if ($f3->get('VERB') == 'POST') {
$error = false;
if ($f3->devoid('POST.url')) {
$error = true;
\Flash::instance()->addMessage('Please enter a url e.g. http://africahackon.com', 'warning');
} else {
$audited_url = $audit_instance->url($f3->get('POST.url'));
if ($audited_url == TRUE) {
/**
*
Shared Hosting Servers Have an issue ..safemode and openbasedir setr and curl gives error enable the lines below and comment out the $request_successful one
$options = array('follow_location'=>FALSE);
$request_successful=$web->request($f3->get('POST.url'),$options);
*
*/
//handle POST data
$postReceive = $f3->get('Post.postReceive');
$postData = explode("&", $postReceive);
$postData = array_map("trim", $postData);
$address = $f3->get('POST.url');
if ($f3->get('POST.means') == "POST") {
$options = array('method' => $f3->get('POST.means'), 'content' => http_build_query($postData));
} else {
$options = array('method' => $f3->get('POST.means'));
}
$request_successful = $web->request($address, $options);
if (!$request_successful) {
\Flash::instance()->addMessage('You have entered an invalid URL try something like: http://africahackon.com', 'warning');
} else {
$result_body = $request_successful['body'];
$result_headers = $request_successful['headers'];
$engine = $request_successful['engine'];
$headers_max = implode("\n", $result_headers);
$myFinalRequest = "Headers: \n\n" . $headers_max . "\n\n Body:\n\n" . $result_body . "\n\n Engine Used: " . $engine;
$this->response->data['content'] = $myFinalRequest;
}
} else {
\Flash::instance()->addMessage('You have entered an invalid URL try something like: http://africahackon.com', 'danger');
}
}
}
}
示例14: generic_request
/**
* Handles Your little Hurl.it like service to make requests to remote servers using various methods
* @package Controller
*/
public function generic_request(\Base $f3)
{
$web = \Web::instance();
$this->response->data['SUBPART'] = 'websaccre_generic_request.html';
$audit_instance = \Audit::instance();
if ($f3->get('VERB') == 'POST') {
$error = false;
if ($f3->devoid('POST.url')) {
$error = true;
\Flash::instance()->addMessage('Please enter a url e.g. http://africahackon.com', 'warning');
} else {
$audited_url = $audit_instance->url($f3->get('POST.url'));
if ($audited_url == TRUE) {
//handle POST data
$postReceive = $f3->get('POST.postReceive');
$createPostArray = parse_str($postReceive, $postData);
if (ini_get('safe_mode')) {
$follow_loc = FALSE;
} else {
$follow_loc = TRUE;
}
$address = $f3->get('POST.url');
if ($f3->get('POST.means') == "POST") {
$options = array('method' => $f3->get('POST.means'), 'content' => http_build_query($postData), 'follow_location' => $follow_loc);
$request_successful = $web->request($address, $options);
} elseif ($f3->get('POST.means') == "GET" or $f3->get('POST.means') == "TRACE" or $f3->get('POST.means') == "OPTIONS" or $f3->get('POST.means') == "HEAD") {
$options = array('method' => $f3->get('POST.means'), 'follow_location' => $follow_loc);
$request_successful = $web->request($address, $options);
} else {
\Flash::instance()->addMessage('Unsupported Header Method', 'danger');
}
if (!$request_successful) {
\Flash::instance()->addMessage('Something went wrong your request could not be completed.', 'warning');
} else {
$result_body = $request_successful['body'];
$result_headers = $request_successful['headers'];
$engine = $request_successful['engine'];
$headers_max = implode("\n", $result_headers);
$myFinalRequest = "Headers: \n\n" . $headers_max . "\n\n Body:\n\n" . $result_body . "\n\n Engine Used: " . $engine;
$this->response->data['content'] = $myFinalRequest;
}
} else {
\Flash::instance()->addMessage('You have entered an invalid URL try something like: http://africahackon.com', 'danger');
}
}
}
}
示例15: __construct
function __construct()
{
global $f3;
$this->f3 = $f3;
$this->log = new Log('error.log');
$this->db = new \DB\SQL('mysql:host=' . $this->dbinfo['dbhost'] . ';port=' . $this->dbinfo['dbport'] . ';dbname=' . $this->dbinfo['dbname'], $this->dbinfo['dbuser'], $this->dbinfo['dbpass']);
$this->smtp = new SMTP($this->EmailInfo['host'], $this->EmailInfo['port'], $this->EmailInfo['scheme'], $this->EmailInfo['user'], $this->EmailInfo['pass']);
$this->smtp->set('Errors-to', '');
$this->smtp->set('From', '');
$this->smtp->set('CC', '');
$this->smtp->set('In-Reply-To', '');
$this->geo = \Web\Geo::instance();
$this->md = \Markdown::instance();
$this->audit = \Audit::instance();
$this->theme = new theme();
$this->theme->set_siteURL($this->site);
$this->request['ip-address'] = $this->get_remote_address();
}