function _get_f_list_id($uid) { $facebook = F3::get('Facebook'); $f_list_exists = false; try { // Try and see if they already have a "Single Yet?" friendslist // But maybe deleted their account from our site or somehow // their friendlist field went blank in the DB // And catch general Facebook errors... $f_lists = $facebook->api($uid . '/friendlists'); } catch (FacebookApiException $e) { F3::error('500'); } // Loop through each friendlist and // see if it is the Single Yet? friendlist foreach ($f_lists['data'] as $f_list) { if ($f_list['name'] == 'Single Yet?') { $f_list_exists = true; $f_list_id = $f_list['id']; // If there is a friendlist for Single Yet?, break out of loop. break; } } // If the Single Yet? friendlist doesn't exist, create it. if (!$f_list_exists) { $f_list = $facebook->api($uid . '/friendlists', 'post', array('name' => 'Single Yet?')); $f_list_id = $f_list['id']; } return $f_list_id; }
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; } }
public function show_error($message, $type) { echo json_encode($message); F3::error($type, $message); }
/** Kickstart the framework @public **/ public static function start() { // Get PHP settings $_ini = ini_get_all(NULL, FALSE); $_level = E_ALL ^ E_NOTICE; ini_set('error_reporting', $_level); // Intercept errors and send output to browser set_error_handler(function ($_errno, $_errstr) { // Bypass if error suppression (@) is enabled if (error_reporting()) { F3::error($_errstr, 500, debug_backtrace(FALSE)); } }, $_level); // Do the same for PHP exceptions set_exception_handler(function ($_xcpt) { if (!count($_xcpt->getTrace())) { // Translate exception trace $_trace = debug_backtrace(FALSE); $_arg = $_trace[0]['args'][0]; $_trace = array(array('file' => $_arg->getFile(), 'line' => $_arg->getLine(), 'function' => '{main}', 'args' => array())); } else { $_trace = $_xcpt->getTrace(); } F3::error($_xcpt->getMessage(), $_xcpt->getCode(), $_trace); return; // PHP aborts at this point }); if (isset(self::$global)) { // Multiple framework instances not allowed trigger_error(self::TEXT_Instance); return; } // Hydrate framework variables $_base = self::fixSlashes(realpath('.')) . '/'; self::$global = array('AUTOLOAD' => $_base . 'autoload/', 'BASE' => $_base, 'DEBUG' => FALSE, 'ENCODING' => 'UTF-8', 'FONTS' => $_base, 'GUI' => $_base, 'IMPORTS' => $_base, 'LOADED' => array(), 'LOGS' => $_base . 'logs/', 'MAXSIZE' => self::bytes($_ini['post_max_size']), 'QUIET' => FALSE, 'RELEASE' => FALSE, 'SYNC' => self::SYNC_Default, 'TIME' => time(), 'THROTTLE' => 0, 'VERSION' => self::TEXT_Version); if (!in_array('zlib', get_loaded_extensions())) { // ZLib required self::$global['CONTEXT'] = 'zlib'; trigger_error(self::TEXT_PHPExt); return; } // Create convenience containers for PHP globals foreach (explode('|', self::PHP_Globals) as $_var) { // Sync framework and PHP globals self::$global[$_var] =& $GLOBALS['_' . $_var]; if ($_ini['magic_quotes_gpc'] && preg_match('/^[GPCR]/', $_var)) { // Corrective action on PHP magic quotes array_walk_recursive(self::$global[$_var], function (&$_val) { $_val = stripslashes($_val); }); } } // Use plain old output buffering as default $_handler = NULL; if (PHP_SAPI == 'cli') { // Command line: Parse GET variables in URL, if any preg_match_all('/[\\?&]([^=]+)=([^&$]*)/', $_SERVER['REQUEST_URI'], $_matches, PREG_SET_ORDER); foreach ($_matches as $_match) { $_REQUEST[$_match[1]] = $_match[2]; $_GET[$_match[1]] = $_match[2]; } // Custom server name $_SERVER['SERVER_NAME'] = strtolower($_SERVER['COMPUTERNAME']); // Convert URI to human-readable string self::mock('GET ' . $_SERVER['argv'][1]); } elseif (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('/gzip|deflate/', $_SERVER['HTTP_ACCEPT_ENCODING']) && !$_ini['zlib.output_compression'] && function_exists('apache_get_modules') && in_array('mod_deflate', apache_get_modules())) { // Use a conservative compression level ini_set('zlib.output_compression_level', self::GZIP_Compress); $_handler = 'ob_gzhandler'; } ob_start($_handler); // Initialize profiler self::$global['PROFILE']['MEMORY']['start'] = memory_get_usage(); // Initialize autoload stack spl_autoload_register('self::autoLoad'); }
/** * send 403 if not logged in * * @return void */ public function needsLoggedIn() { if (\F3::get('auth')->isLoggedin() !== true) { \F3::error(403); } }