本文整理汇总了PHP中F3类的典型用法代码示例。如果您正苦于以下问题:PHP F3类的具体用法?PHP F3怎么用?PHP F3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了F3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* returns items
*
* @return mixed items as array
* @param mixed $options search, offset and filter params
*/
public function get($options = array())
{
$options = array_merge(array('starred' => false, 'offset' => 0, 'search' => false, 'items' => \F3::get('items_perpage')), $options);
$items = $this->backend->get($options);
// remove private posts with private tags
if (!\F3::get('auth')->showPrivateTags()) {
foreach ($items as $idx => $item) {
$tags = explode(',', $item['tags']);
foreach ($tags as $tag) {
if (strpos(trim($tag), '@') === 0) {
unset($items[$idx]);
break;
}
}
}
$items = array_values($items);
}
// remove posts with hidden tags
if (!isset($options['tag']) || strlen($options['tag']) === 0) {
foreach ($items as $idx => $item) {
$tags = explode(',', $item['tags']);
foreach ($tags as $tag) {
if (strpos(trim($tag), '#') === 0) {
unset($items[$idx]);
break;
}
}
}
$items = array_values($items);
}
return $items;
}
示例2: logout
function logout()
{
if (F3::get('SESSION.onlineUser')) {
F3::clear('SESSION.onlineUser');
F3::reroute('/');
}
}
示例3: home
function home()
{
$this->view->title = 'Open Postbox | India';
$this->view->caption = 'Latest postboxes added.';
$q = 'select * from post_box order by cast(created_time as int) desc limit 14';
$POSTBOX_DB = \F3::get('POSTBOX_DB');
$result = $POSTBOX_DB->exec($q);
$array_all_postboxes = array();
foreach ($result as $row) {
$single_postbox = array();
$single_postbox['post_id'] = $row["post_id"];
$single_postbox['lat'] = $row["lat"];
$single_postbox['lan'] = $row["lan"];
$single_postbox['pincode'] = $row["pincode"];
$single_postbox['caption'] = $row["caption"];
$single_postbox['img'] = $row["img"];
$single_postbox['picture_url'] = $row["picture_url"];
$array_all_postboxes[$row["post_id"]] = $single_postbox;
}
$this->view->set('array_all_postboxes', $array_all_postboxes);
$q = 'select * from stats order by sl desc limit 1';
$result = $POSTBOX_DB->exec($q);
foreach ($result as $row) {
$post_count = $row["post_count"];
$user_count = $row["user_count"];
$this->view->set('is_home', 1);
$this->view->set('post_count', $post_count);
$this->view->set('user_count', $user_count);
}
$out = Template::instance()->render('basic/sub_home.html');
$this->view->set('sub_out_put', $out);
$this->view->set('enable_maps', 1);
echo Template::instance()->render('basic/main.html');
}
示例4: add
/**
* add new source
*
* @return int new id
* @param string $title
* @param string $tags
* @param string $spout the source type
* @param mixed $params depends from spout
*/
public function add($title, $tags, $spout, $params)
{
// sanitize tag list
$tags = implode(',', preg_split('/\\s*,\\s*/', trim($tags), -1, PREG_SPLIT_NO_EMPTY));
$res = \F3::get('db')->exec('INSERT INTO sources (title, tags, spout, params) VALUES (:title, :tags, :spout, :params) RETURNING id', array(':title' => trim($title), ':tags' => $tags, ':spout' => $spout, ':params' => htmlentities(json_encode($params))));
return $res[0]['id'];
}
示例5: yukle
function yukle($hedef = NULL, $alan = 'file')
{
$yuklenen = F3::get("FILES.{$alan}.tmp_name");
// hedef ve yüklenen dosyanın boş olmasına izin veriyoruz
// herhangi biri boşsa mesele yok, çağırana dön
if (empty($hedef) || empty($yuklenen)) {
return true;
}
// bu bir uploaded dosya olmalı, fake dosyalara izin yok
if (is_uploaded_file($yuklenen)) {
// boyutu sınırla, değeri öylesine seçtim
if (filesize($yuklenen) > 600000) {
F3::set('error', 'Resim çok büyük');
} else {
if (exif_imagetype($yuklenen) != IMAGETYPE_JPEG) {
F3::set('error', 'Resim JPEG değil');
} else {
if (file_exists($hedef)) {
F3::set('error', 'Resim zaten kaydedilmiş');
} else {
if (!move_uploaded_file($yuklenen, $hedef)) {
F3::set('error', 'Dosya yükleme hatası');
}
}
}
}
// yok başka bir ihtimal!
} else {
// bu aslında bir atak işareti
F3::set('error', 'Dosya geçerli bir yükleme değil');
}
return false;
}
示例6: is_table_exists
function is_table_exists($table, $db = NULL)
{
if (is_null($db)) {
$db = F3::get('DB.name');
}
return $db && F3::sql(array("SELECT COUNT(*) AS found " . "FROM information_schema.tables " . "WHERE table_schema='{$db}' " . "AND table_name='{$table}';"));
}
示例7: set_venue_data_from_POST
function set_venue_data_from_POST()
{
F3::set('name', F3::scrub($_POST['name']));
F3::set('address', F3::scrub($_POST['address']));
F3::set('postcode', F3::scrub($_POST['postcode']));
F3::set('info', F3::scrub($_POST['info']));
}
示例8: get
public function get()
{
if ($this->flag['search']) {
if (isset($_GET['q']) && $_GET['q'] != '') {
// Fetch Search Query
$query = F3::scrub($_GET['q']);
$search = new SearchModel();
// Fetch Search Results
if ($this->results = $search->items($query)) {
// Reroute if one match
if (count($this->results) == 1 && $this->redirect) {
F3::reroute('/loot/' . $this->results[0]['urlname']);
}
$this->title = "Search: \"" . $query . "\" - Diablo 2 Database";
$this->heading = "Search: \"" . $query . "\"";
F3::set('NOTIFY.success', "Rejoice! " . count($this->results) . " matches found!");
$this->render('search.php');
} else {
$this->heading = "Search: \"" . $query . "\"";
F3::set('NOTIFY.warning', "Nothing found in the database. Try the <a href=/loot/>Loot Directory</a>.");
$this->render('blank.php');
}
} else {
F3::reroute('/');
}
} else {
F3::set('NOTIFY.warning', "Search is temporarily disabled. Please try again later.");
$this->render('blank.php');
}
}
示例9: item
public function item($identifier, $options = array())
{
try {
// Configurations
$this->options = array_merge($this->options, $options);
// Initialize Item Object
$item = new ItemModel();
// Fetch Shared Item Data
DB::sql($this->query['item'], array("item" => $identifier));
$shared = F3::get('DB')->result[0];
// Presumably, no item data found
if (empty($shared)) {
throw new Exception("No item found.");
}
// Assign Class Attributes
foreach ($shared as $key => $attribute) {
$item->{$key} = $attribute;
}
// Fetch Parent
// Fetch Flags
// Property Collection
if ($this->options['properties']) {
switch ($item->rarity) {
case "normal":
$item->properties['normal'] = DB::sql($this->query['properties'], array("item" => $item->name));
break;
case "unique":
$item->properties['magic'] = DB::sql($this->query['properties_magic'], array("item" => $item->name));
break;
case "set":
$item->properties['magic'] = DB::sql($this->query['properties_magic'], array("item" => $item->name));
$item->properties['set'] = DB::sql($this->query['properties_set'], array("item" => $item->name));
break;
default:
throw new Exception("Unknown rarity.");
}
// Translate Item Properties
$tokens = array("@param", "@min", "@max");
foreach ($item->properties as $type_key => $type) {
if ($type_key != 'normal') {
foreach ($type as $row_key => $row) {
// Determine which string to use
$field = $row['minimum'] == $row['maximum'] ? "translation" : "translation_varies";
// Order must line up with $tokens
$values = array($row['parameter'], $row['minimum'], $row['maximum']);
// Replace database tokens with values
$item->properties[$type_key][$row_key]['translation'] = str_replace($tokens, $values, $row[$field]);
// Unset unecessary string
unset($item->properties[$type_key][$row_key]['translation_varies']);
}
}
}
}
} catch (Excecption $e) {
error_log($e->getMessage());
return false;
}
// Return JSON string
return json_encode($item);
}
示例10: pull_data
function pull_data()
{
$this->view->set('title', 'PostBox - Instagram Data Pull');
$instagram_api_clinet_id = 'b9d4b604105648168c671293d10cc67e';
$instagram_api_url = 'https://api.instagram.com/v1/tags/openpostboxindia/media/recent?client_id=' . $instagram_api_clinet_id;
$data_pull_messages = array();
$ch = curl_init($instagram_api_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$json = curl_exec($ch);
curl_close($ch);
$data = json_decode($json, true);
//var_dump($data);
if ($data['meta']['code'] == 200) {
//echo 'sucess';
$picture_dicts = $data['data'];
foreach ($picture_dicts as $pic) {
$tags = implode(', ', $pic['tags']);
$pincode = 0;
foreach ($pic['tags'] as $tag) {
if ($this->startswith4($tag, 'pin')) {
$pincode = substr($tag, 3, 10);
}
}
$lat = $pic['location']['latitude'];
$lan = $pic['location']['longitude'];
$created_time = $pic['created_time'];
$picture_url = $pic['images']['standard_resolution']['url'];
$post_id = $pic['id'];
$username = 'instagram-' . $pic["user"]["username"];
$website = '';
//$pic["user"]["website"];
$caption = $pic["caption"]["text"];
//check if post_id exists, if yes then go to next one. else insert
$data_pull_messages[] = "Processing the post_id=" . $post_id;
$q = 'select count(*) as count_posts from post_box where post_id="' . $post_id . '"';
$POSTBOX_DB = \F3::get('POSTBOX_DB');
$result = $POSTBOX_DB->exec($q);
//print '\n'.$q;
$count_posts = 0;
foreach ($result as $row) {
$count_posts = $row['count_posts'];
}
if ($count_posts == 0) {
$data_pull_messages[] = "Lets INSERT.";
$i = 'insert into post_box( post_id , picture_url , tags , lat , lan , created_time , username , website,pincode, caption, provider) values(' . '"' . $post_id . '","' . $picture_url . '","' . $tags . '","' . $lat . '","' . $lan . '","' . $created_time . '","' . $username . '","' . $website . '","' . $pincode . '","' . $caption . '"' . ',"Instagram")';
//print $i;
$POSTBOX_DB->exec($i);
} else {
$data_pull_messages[] = "Already exists.";
}
}
}
$this->view->set('data_pull_messages', $data_pull_messages);
$out = Template::instance()->render('basic/sub_data_pull.html');
$this->view->set('sub_out_put', $out);
echo Template::instance()->render('basic/main.html');
}
示例11: jwt_decode
public function jwt_decode($token)
{
try {
return JWT::decode($token, F3::get('custom.SUPER-KEY'));
} catch (Exception $e) {
return false;
}
}
示例12: load
/**
* loads content for given source
*
* @return void
* @param string $url
*/
public function load($params)
{
$this->apiKey = $params['api'];
if (strlen(trim($this->apiKey)) == 0) {
$this->apiKey = \F3::get('readability');
}
parent::load(array('url' => $params['url']));
}
示例13: __call
/**
* pass any method call to the backend.
*
* @return methods return value
* @param string $name name of the function
* @param array $args arguments
*/
public function __call($name, $args)
{
if (method_exists($this->backend, $name)) {
return call_user_func_array(array($this->backend, $name), $args);
} else {
\F3::get('logger')->log('Unimplemented method for ' . \F3::get('db_type') . ': ' . $name, \ERROR);
}
}
示例14: get_how_to_use_content
private function get_how_to_use_content($f3)
{
$content = "How to use content.";
$file = F3::instance()->read('help/README.md');
$html = Markdown::instance()->convert($file);
$f3->set('how_to_use_content', $html);
return $content;
}
示例15: check_configuration
public function check_configuration()
{
$config = new DB\Jig\Mapper($this->db, 'sysconfig.json');
if (!$config->load()) {
echo json_encode(array('message' => 'No config file found'));
F3::error(428);
exit;
}
}