本文整理汇总了PHP中utils::keysOk方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::keysOk方法的具体用法?PHP utils::keysOk怎么用?PHP utils::keysOk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::keysOk方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pingUrl
public function pingUrl()
{
if (!utils::keysOk($this->data, ['url', 'title'])) {
return $this->response('ERROR', 'required keys not set');
}
$url = $this->data['url'];
if (!utils::validUrl($url)) {
return $this->response('ERROR', 'invalid url');
}
$title = $this->data['title'];
main::loadLibs(['httpRequest/httpRequest.class.php']);
$pingomaticUrl = 'http://pingomatic.com/ping/' . '?title=' . urlencode($title) . '&blogurl=' . urlencode($url) . '&rssurl=' . '&chk_weblogscom=on' . '&chk_blogs=on' . '&chk_feedburner=on' . '&chk_newsgator=on' . '&chk_myyahoo=on' . '&chk_pubsubcom=on' . '&chk_blogdigger=on' . '&chk_weblogalot=on' . '&chk_newsisfree=on' . '&chk_topicexchange=on' . '&chk_google=on' . '&chk_tailrank=on' . '&chk_skygrid=on' . '&chk_collecta=on' . '&chk_superfeedr=on' . '&chk_audioweblogs=on' . '&chk_rubhub=on' . '&chk_a2b=on' . '&chk_blogshares=on';
$request = new httpRequest($pingomaticUrl);
$request->setRandUserAgent();
if (array_key_exists('proxy', $this->data)) {
try {
$request->setProxy($this->data['proxy']);
} catch (Exception $e) {
return $this->response('ERROR', $e->getMessage());
}
}
$request = $request->exec();
if (!$request['status'] == 'OK') {
return $this->response('ERROR', $request['message']);
}
if (strrpos($request['data'], 'Pinging complete!') === false) {
return $this->response('ERROR', 'pingomatic failed to ping ' . $url);
}
return $this->response('OK', 'successfully pinged ' . $url);
}
示例2: renderPage
public function renderPage()
{
if (!utils::keysOk($this->data, ['url'])) {
return $this->response('ERROR', 'required keys not set');
}
$url = $this->data['url'];
if (!utils::validUrl($url)) {
return $this->response('ERROR', 'invalid URL: ' . $url);
}
$pUrl = parse_url($url);
$hostData = $this->hostData($pUrl['host']);
if (!$hostData) {
return $this->response('ERROR', 'could not get host data for ' . $pUrl['host']);
}
$hostData['request']['url'] = $url;
list($ltBool, $ltData) = template::loadTemplate($hostData);
if (!$ltBool) {
return $this->response('ERROR', $ltData);
}
list($content, $content_type) = $ltData;
return $this->response('OK', sprintf('render successful [%s]', $url), base64_encode($content), $content_type);
}
示例3: header
header('Content Type: text/plain');
define('wm_absolute_path', dirname(__FILE__) . '/');
define('wm_lib_path', wm_absolute_path . 'lib/');
define('wm_acts_path', wm_absolute_path . 'acts/');
define('wm_templates_path', wm_absolute_path . 'templates/');
define('wm_log_path', wm_absolute_path . 'log/');
define('wm_db_file', wm_absolute_path . 'db.sqlite');
require wm_absolute_path . 'main.php';
require wm_absolute_path . 'template.php';
require wm_absolute_path . 'utils.php';
$inputData = trim(file_get_contents('php://input'));
if (!$inputData) {
main::log('ERROR', sprintf('[%s] no input data provided', $_SERVER['REMOTE_ADDR']), true);
}
$inputData = json_decode($inputData, true);
if (!($inputData && is_array($inputData))) {
main::log('ERROR', sprintf('[%s] invalid input data', $_SERVER['REMOTE_ADDR']), true);
}
if (!utils::keysOk($inputData, ['act', 'data'])) {
main::log('ERROR', sprintf('[%s] required keys not set', $_SERVER['REMOTE_ADDR']), true);
}
$act = $inputData['act'];
$data = $inputData['data'];
main::loadLibs(['sqliteDB/sqliteDB.class.php']);
main::initDB();
list($laBool, $laMsg) = main::loadAct($act);
if (!$laBool) {
main::log('ERROR', $lsMsg, true);
}
$actOb = new $act($data);
print_r($actOb->exec());
示例4: loadTemplate
public static function loadTemplate($hostData)
{
if (!$hostData) {
return [false, 'hostData not defined'];
}
if (!utils::keysOk($hostData, ['request', 'template'])) {
return [false, 'required hostData keys not set'];
}
if (!utils::keysOk($hostData['request'], ['hostname', 'url'])) {
return [false, 'required request keys not set'];
}
if (!utils::keysOk($hostData['template'], ['path', 'data'])) {
return [false, 'required template keys not set'];
}
$tmplPath = rtrim($hostData['template']['path'], '/') . '/';
if (!is_dir($tmplPath)) {
return [false, sprintf('template path does not exist [%s]', $tmplPath)];
}
$tmplLoader = $tmplPath . 'index.php';
if (!is_file($tmplLoader)) {
return [false, 'template loader file not found'];
}
$tmplConfigFile = $tmplPath . 'config.php';
if (!is_file($tmplConfigFile)) {
return [false, 'template config file not found'];
}
require $tmplConfigFile;
if (!function_exists('wm_templateConfig')) {
return [false, 'wm_templateConfig function missing from config file'];
}
$parsedReqUrl = parse_url($hostData['request']['url']);
$reqPath = ltrim($parsedReqUrl['path'], '/');
$hostData['template']['url_data'] = $reqPath;
$possibleFile = $tmplPath . $reqPath;
if (is_file($possibleFile)) {
$content = file_get_contents($possibleFile);
$type = utils::fileMimeType($possibleFile);
return [true, [$content, $type]];
}
$tmplConfig = wm_templateConfig();
if ($tmplConfig) {
if (!is_array($tmplConfig)) {
return [false, 'invalid config type'];
}
if (array_key_exists('required_data', $tmplConfig)) {
$reqData = $tmplConfig['required_data'];
$tmplData = $hostData['template']['data'];
if (!$tmplData) {
return [false, 'template data not defined(properly)'];
}
if (!template::checkRequiredData($reqData, $tmplData)) {
return [false, 'required template data not set'];
}
}
if (array_key_exists('rewrite_rules', $tmplConfig)) {
$rwRules = $tmplConfig['rewrite_rules'];
if (count($rwRules) > 0) {
$hostData['template']['url_data'] = template::rwRulesBreakdown($parsedReqUrl, $rwRules);
}
}
}
$_data = $hostData;
ob_start();
require $tmplLoader;
$templateResult = ob_get_contents();
ob_end_clean();
return [true, [$templateResult, 'text/html']];
}