コード例 #1
0
ファイル: app.php プロジェクト: pshreez/PHP
 function create()
 {
     if (!F3::get('SESSION.sid')) {
         F3::reroute('/home');
     }
     // F3::set('keyword','Poll::add()');
     $this->set('title', 'Create poll');
     f3::set('heading', 'Create your polls');
     echo Template::serve("template/create.htm");
     // }
 }
コード例 #2
0
ファイル: currency.php プロジェクト: killsaw/f3-plugins
 /**
 		Retrieve currency conversion from Google Finance.
 			@return bool|float
 			@param $amount float
 			@param $from string Currency to convert from. e.g. USD
 			@param $to string Currency to convert to. e.g. EUR
 			@public
 	**/
 public static function convertAmount($amount, $from, $to, $quiet = false)
 {
     $from = strtoupper($from);
     $to = strtoupper($to);
     if (!is_numeric($amount)) {
         trigger_error(self::TEXT_AmountNotNumber);
         return false;
     }
     // Workaround for empty ENV. Causes an issue in f3::http()
     if (!isset($_ENV['OS'])) {
         $_ENV['OS'] = 'Windows';
     }
     $data = f3::http("GET http://www.google.com/finance/converter", http_build_query(array('a' => $amount, 'from' => $from, 'to' => $to)));
     if (preg_match('/<span class=bld>(.+) (.+)<\\/span>/', $data, $match)) {
         if ($match[2] == $to) {
             return (double) $match[1];
         }
     }
     if (!$quiet) {
         trigger_error(self::TEXT_NoConversion);
     }
     return false;
 }
コード例 #3
0
ファイル: index.php プロジェクト: nian2go/fatfree
    Graphics::identicon(f3::get('PARAMS.id'), f3::get('PARAMS.size'));
});
$app->route('GET /invert', function () {
    Graphics::invert('{{@GUI}}test.jpg');
});
$app->route('GET /thumb', function () {
    Graphics::thumb('{{@GUI}}large.jpg', 256, 192);
}, 60);
$app->route('GET /screenshot', function () {
    Graphics::screenshot('http://www.yahoo.com', 150, 200);
});
$app->route('GET /google/map', function () {
    Google::staticmap('Brooklyn Bridge', 12, '256x256');
});
$app->route('GET /minified/@script', function () use($app) {
    Web::minify($app->get('GUI'), array(f3::get('PARAMS.script')));
});
$app->run();
class Obj
{
    public function hello()
    {
        echo 'hello';
    }
}
class CustomObj
{
    public function hello()
    {
        echo 'hello';
    }
コード例 #4
0
ファイル: axonrest.php プロジェクト: killsaw/f3-plugins
 /**
 		View one or more records.
 			@public
 	**/
 public static function get()
 {
     $object_name = self::getObjectName();
     $object_id = F3::get('PARAMS["id"]');
     if (!self::hasAccess($object_name, 'view', $object_id)) {
         self::reportStatus(self::Status_Failure, self::TEXT_NoAccess);
         return;
     }
     if (!empty($object_id)) {
         $object = self::getObject($object_name, $object_id);
         if ($object->dry()) {
             f3::http404();
         } else {
             echo json_encode($object->fields);
         }
     } else {
         // It's a listing.
         $object = self::getObject($object_name);
         $fields = '*';
         $where = null;
         $group_by = isset($_GET['group_by']) ? $_GET['group_by'] : null;
         $order_by = isset($_GET['order_by']) ? $_GET['order_by'] : null;
         $limit = isset($_GET['limit']) ? $_GET['limit'] : null;
         $offset = isset($_GET['offset']) ? $_GET['offset'] : null;
         $find = array();
         foreach (array_keys($object->fields) as $key) {
             if (isset($_GET[$key]) && !empty($_GET[$key])) {
                 $value = $_GET[$key];
                 if (preg_match('/^([<>!]+)/', $value, $match)) {
                     $find[] = $key . $value;
                 } elseif ($value[0] == '%' || substr($value, -1) == '%') {
                     $find[] = $key . " LIKE '" . $value . "'";
                 } else {
                     $find[] = sprintf("%s='%s'", $key, $value);
                 }
             }
         }
         if (count($find) > 0) {
             $where = join(' AND ', $find);
         }
         $show_rows = array();
         $all_rows = $object->select($fields, $where, $group_by, $order_by, $limit, $offset);
         // Support row-level access filtering.
         foreach ($all_rows as $a) {
             if (self::hasAccess($object_name, 'view', $a['id'])) {
                 $show_rows[] = $a;
             }
         }
         echo json_encode($show_rows);
     }
 }