예제 #1
0
 /**
  * Returns the current instance of the FPBDatabase object
  * @static
  * @return FPBDatabase
  */
 public static function Instance()
 {
     if (!self::$_instance) {
         self::$_instance = new FPBDatabase();
     }
     return self::$_instance;
 }
예제 #2
0
 public function Load()
 {
     $config = FPBDatabase::Instance()->GetConfigArray();
     if (!array_key_exists('Plugins', $config)) {
         return;
     }
     $this->_plugin_data = unserialize($config['Plugins']);
     if (count($this->_plugin_data) == 0) {
         return;
     }
     foreach ($this->_plugin_data as $index => $plugin) {
         if (file_exists(BASEDIR . '/fpb-content/plugins/' . $plugin['IncludeFile'])) {
             include_once BASEDIR . '/fpb-content/plugins/' . $plugin['IncludeFile'];
         } else {
             trigger_error("The plugin " . $plugin['PluginName'] . " could not be found and was disabled!", E_USER_WARNING);
             self::UninstallPlugin($plugin['PluginName']);
         }
     }
     FPBDatabase::Instance()->SetConfigElement('Plugins', serialize($this->_plugin_data));
 }
예제 #3
0
파일: load.php 프로젝트: JiffSoft/FacePress
Plugins::RunHook('body_post_action');
$body_contents = ob_get_contents();
ob_clean();
$tpl_file = $action;
/**
 * The 'post_action' hook runs just after we have run the requested action, just before
 * it is finished and then rendered
 * @see Hooks
 */
Plugins::RunHook('post_action');
$smarty->assign('body_contents', $body_contents);
// Grab all archives for the $archives variable to be populated
$archives = FPBDatabase::Instance()->GetArchiveList();
$smarty->assign('archives', $archives);
// Grab array of all pages
$pages = FPBDatabase::Instance()->GetPageArray();
$smarty->assign('pages', $pages);
/**
 * The 'pre_render' hook runs just before we render the smarty template to the client
 * @see Hooks
 */
Plugins::RunHook('pre_render');
// make it happen!
header('Content-type: text/html; charset=UTF-8;', true);
$smarty->display($tpl_file . '.tpl');
/**
 * The 'page_ended' hook is executed at the very end of execution, this is a good
 * place to put plugin cleanup
 * @see Hooks
 */
Plugins::RunHook('page_ended');
예제 #4
0
<?php

/**
 * @package FacePress
 * @version $Id$
 * @copyright (c) 2010 JiffSoft
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3
 */
$sub_action = strtolower(strlen($_POST['sub']) > 0 ? $_POST['sub'] : 'list');
if (strlen($_POST['tid']) > 0) {
    // Gather the post ID we are talking about
    $post = FPBDatabase::Instance()->GatherPostById($_POST['tid']);
}
echo '<h3>Plugin Management</h3>';
// Load plugin list
$yaml_files = find_files(BASEDIR . '/fpb-content/plugins', '/ya?ml$/i');
$plugins = array();
foreach ($yaml_files as $yaml) {
    array_push($plugins, Spyc::YAMLLoad($yaml));
}
switch ($sub_action) {
    case 'activate':
        break;
    case 'deactivate':
        /**
         * @todo Deactivation should look for if the plugin is core (MissionCritical: true) in the YML, or
         * if it is required (RequiresPlugins:) from another plugin
         */
        break;
    case 'list':
    default:
예제 #5
0
파일: auth.php 프로젝트: JiffSoft/FacePress
 /**
  * Checks the current Facebook session for validity and logs the user in (or creates the user in our local
  * database if necessary)
  * @return void
  * @access private
  */
 public function CheckFBStatus()
 {
     /**
      * The 'pre_fb_auth_check' is run prior to validating the current Facebook session
      * @see Hooks
      */
     Plugins::RunHook('pre_fb_auth_check');
     if ($this->_facebook->getSession()) {
         $fbid = $this->_facebook->getUser();
         // We have a Facebook session - check it
         $user_record = FPBDatabase::Instance()->GetUserFromFBId($fbid);
         if (!$user_record) {
             // we must make the user!
             $user_data = array();
             $this->_fb_api = $this->_facebook->api('/me');
             $user = $this->_facebook->getUser();
             $user_data['id'] = $user;
             /**
              * the password table is kind of superfluous, but is here in case plugins want to override
              * the column's use - perhaps an OpenID/Google Federated Login? Until then this is
              * @deprecated
              */
             $user_data['password'] = md5($user);
             $url = "https://api.facebook.com/method/fql.query";
             $url .= "?access_token=" . $this->_facebook->getAccessToken();
             $url .= "&query=SELECT email, name FROM user WHERE uid={$user}";
             $userData = simplexml_load_file($url);
             $user_data['username'] = (string) $userData->user->email;
             $user_data['displayname'] = (string) $userData->user->name;
             if (strlen($user_data['username']) == 0) {
                 $params = array();
                 $params["canvas"] = "1";
                 $params["fbconnect"] = "0";
                 $params["next"] = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                 $params["req_perms"] = "email,user_website,user_about_me";
                 $loginUrl = $this->_facebook->getLoginUrl($params);
                 header("Location: {$loginUrl}");
                 echo '<meta http-equiv="refresh" content="0;url=' . $loginUrl . '"/>';
                 die;
             }
             /**
              * The 'pre_fb_useradd' hook is run before inserting a new user record into the database
              * @see Hooks
              */
             Plugins::RunHook('pre_fb_useradd');
             FPBDatabase::Instance()->AddUser($user_data);
             $this->_user = $user_data;
         } else {
             $this->_user = $user_record[0];
         }
     } else {
         $this->_user = null;
     }
     /**
      * The 'post_fb_auth_check' is run after the validation of the curent Facebook session
      * @see Hooks
      */
     Plugins::RunHook('post_fb_auth_check');
 }
예제 #6
0
<?php

/**
 * @package FacePress
 * @version $Id$
 * @copyright (c) 2010 JiffSoft
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3
 */
$sub_action = strtolower(strlen($_POST['sub']) > 0 ? $_POST['sub'] : 'list');
if (strlen($_POST['tid']) > 0) {
    // Gather the post ID we are talking about
    $post = FPBDatabase::Instance()->GatherPostById($_POST['tid']);
}
echo '<h3>Posts</h3>';
switch ($sub_action) {
    case 'edit':
        break;
    case 'save':
        break;
    case 'del':
        break;
    case 'pub':
        break;
    case 'list':
    default:
        $page = (int) (strlen($_POST['p']) > 0 ? $_POTS['p'] : 1);
        $posts = FPBDatabase::Instance()->GatherPosts(20, $page);
        break;
}