public function initialize() { add_include_path(RUN_BASE . DS . "tests"); $this->defineEnvironmentByOption("e", TEST); if ((ENVIRONMENT & PRODUCTION) > 0) { error_reporting(0); } else { error_reporting(E_ALL | E_STRICT); } }
public static function create($model_path, $model_name, $model_package, $path_prefix) { $hooksFile = $model_path . $model_name . "Hooks.php"; if (file_exists($hooksFile)) { add_include_path($model_path); $hooksClass = $model_name . "Hooks"; } else { $hooksClass = "XMLDefinedSQLDatabaseModelHooks"; } return new XMLDefinedSQLDatabaseModel($model_path . "model.xml", $model_package, $path_prefix, $hooksClass); }
/** * Class registry * * This function acts as a singleton. If the requested class does not * exist it is instantiated and set to a static variable. If it has * previously been instantiated the variable is returned. * only use for app, orange, base files * * @access public * @param string the class name being requested * @param string the directory where the class should be found * @param string the class name prefix * @return object * * OVERRIDDEN because the include_if_exists will search all of our include paths * Not just APPPATH and BASEPATH * */ function &load_class($class, $directory = 'libraries', $param = NULL) { static $_classes = array(); /* is $_classes empty? if so it's the first time here add the packages to the search path */ if (count($_classes) == 0) { include APPPATH . 'config/autoload.php'; if (file_exists(APPPATH . 'config/' . ENVIRONMENT . '/autoload.php')) { include APPPATH . 'config/' . ENVIRONMENT . '/autoload.php'; } /* add packages */ foreach ($autoload['packages'] as $package) { add_include_path($package); } } // Does the class exist? If so, we're done... if (isset($_classes[$class])) { return $_classes[$class]; } $name = false; /* is this a core CI_ class? these are only in the system "basepath" folder */ if (file_exists(BASEPATH . $directory . '/' . $class . '.php')) { $name = 'CI_' . $class; if (class_exists($name, false) === false) { require BASEPATH . $directory . '/' . $class . '.php'; } } /* is this a orange extended class? these are only in the orange package folder */ if (file_exists(ORANGEPATH . '/' . $directory . '/' . config_item('subclass_prefix') . $class . '.php')) { $name = config_item('subclass_prefix') . $class; if (class_exists($name, false) === false) { require_once ORANGEPATH . '/' . $directory . '/' . $name . '.php'; } } // Did we find the class? if ($name === false) { // Note: We use exit() rather then show_error() in order to avoid a // self-referencing loop with the Exceptions class set_status_header(503); echo 'Unable to locate the specified class: ' . $class . '.php'; exit; } // Keep track of what we just loaded is_loaded($class); $_classes[$class] = isset($param) ? new $name($param) : new $name(); return $_classes[$class]; }
public function getWidgetsList($path = "") { $prefix = "app/modules/"; $d = dir($prefix . $path); $list = array(); while (false !== ($entry = $d->read())) { if ($entry != "." && $entry != ".." && is_dir("{$prefix}{$path}/{$entry}")) { if (file_exists("{$prefix}{$path}/{$entry}/" . Application::camelize("{$path}/{$entry}", "/") . "Widget.php")) { add_include_path("{$prefix}{$path}/{$entry}"); $widgetClass = Application::camelize("{$path}/{$entry}", "/") . "Widget"; $widget = new $widgetClass(); Application::camelize("{$path}/{$entry}"); $list[] = array("label" => "{$widget->label} Widget", "name" => substr("{$path}/{$entry}", 1)); } $list = array_merge($list, $this->getWidgetsList("{$path}/{$entry}")); } } return $list; }
OPENID as is now, is not trust system. It is a great single-sign on method. If you want to store information about OpenID in your database for later use, make sure you handle url identities properly. For example: https://steve.myopenid.com/ https://steve.myopenid.com http://steve.myopenid.com/ http://steve.myopenid.com ... are representing one single user. Some OpenIDs can be in format openidserver.com/users/user/ - keep this in mind when storing identities To help you store an OpenID in your DB, you can use function: $openid_db_safe = $openid->OpenID_Standarize($upenid); This may not be comatible with current specs, but it works in current enviroment. Use this function to get openid in one format like steve.myopenid.com (without trailing slashes and http/https). Use output to insert Identity to database. Don't use this for validation - it may fail. */ add_include_path(library_path() . DIRECTORY_SEPARATOR . 'Yadis', true); require_once 'Services/Yadis/Yadis.php'; class SimpleOpenID { var $openid_url_identity; var $URLs = array(); var $error = array(); var $fields = array('required' => array(), 'optional' => array()); var $arr_ax_types = array('nickname' => 'http://axschema.org/namePerson/friendly', 'email' => 'http://axschema.org/contact/email', 'fullname' => 'http://axschema.org/namePerson', 'dob' => 'http://axschema.org/birthDate', 'gender' => 'http://axschema.org/person/gender', 'postcode' => 'http://axschema.org/contact/postalCode/home', 'country' => 'http://axschema.org/contact/country/home', 'language' => 'http://axschema.org/pref/language', 'timezone' => 'http://axschema.org/pref/timezone', 'prefix' => 'http://axschema.org/namePerson/prefix', 'firstname' => 'http://axschema.org/namePerson/first', 'lastname' => 'http://axschema.org/namePerson/last', 'suffix' => 'http://axschema.org/namePerson/suffix'); function SimpleOpenID() { if (!function_exists('curl_exec')) { die('Error: Class SimpleOpenID requires curl extension to work'); } } function SetOpenIDServer($a)
function site_setup() { error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); //error_reporting(E_ALL ); //error_reporting (E_ALL & ~E_NOTICE & ~E_DEPRECATED); // I use this only for testing include_once dirname(__FILE__) . '/../serverspfc/dbstup.php'; // Your custom class dir //define('CLASS_DIR', 'class/') // Add your class dir to include path //set_include_path(get_include_path().PATH_SEPARATOR.CLASS_DIR); // You can use this trick to make autoloader look for commonly used "My.class.php" type filenames //spl_autoload_extensions('.class.php'); //print_r( $_SERVER); //echo dirname($_SERVER['PHP_SELF']); //echo dirname(dirname(__FILE__)); die(); $app_root = dirname(dirname(__FILE__)); define("APP_ROOT", $app_root); define("URL_APP_ROOT", str_replace($_SERVER['DOCUMENT_ROOT'], "", $app_root)); // add_include_path($app_root); $incl_dirs = array(); $incl_dirs[] = $app_root . "/classes/AppLibrary/"; $incl_dirs[] = $app_root . "/classes/ApplicationEntities/"; $incl_dirs[] = $app_root . "/classes/ClientServerDataOps/"; $incl_dirs[] = $app_root . "/classes/MainClient/"; $incl_dirs[] = $app_root . "/classes/MetaDataOps/"; $incl_dirs[] = $app_root . "/classes/Notification/"; $incl_dirs[] = $app_root . "/classes/OutputSystem/"; $incl_dirs[] = $app_root . "/classes/PropertyTypeEntity/"; $incl_dirs[] = $app_root . "/classes/Props/"; $incl_dirs[] = $app_root . "/classes/RecordsSystem/"; $incl_dirs[] = $app_root . "/classes/Security/"; $incl_dirs[] = $app_root . "/classes/thirdparty/"; $incl_dirs[] = $app_root . "/classes/thirdparty/HTTP_Upload/"; $incl_dirs[] = $app_root . "/classes/thirdparty/phpMailer/"; $incl_dirs[] = $app_root . "/classes/TransactionSystem/"; $incl_dirs[] = $app_root . "/site_specific_classes/MainClient/"; $incl_dirs[] = $app_root . "/site_specific_classes/OutputSystem/"; $incl_dirs[] = $app_root . "_locspfc/"; add_include_path($incl_dirs); // test_cookie_headers();echo "done";die(); //echo $app_root."hereeeee"; //die(); // Use default autoload implementation spl_autoload_register('SPL_autoload_suxx'); // echo "done"; flush(); //die(); }
function facebook_login(&$vars) { extract($vars); $app_id = environment('facebookAppId'); $consumer_key = environment('facebookKey'); $consumer_secret = environment('facebookSecret'); $agent = environment('facebookAppName') . " (curl)"; add_include_path(library_path()); add_include_path(library_path() . 'facebook-platform/php'); add_include_path(library_path() . 'facebook_stream'); require_once "facebook.php"; require_once "FacebookStream.php"; require_once "Services/Facebook.php"; $fb = new Facebook($consumer_key, $consumer_secret, true); $_SESSION['fb_session'] = (string) $fb->api_client->session_key; $_SESSION['fb_userid'] = (string) $fb->user; $fs = new FacebookStream($consumer_key, $consumer_secret, $agent); $fieldlist = array('last_name', 'first_name', 'pic_small', 'profile_blurb', 'profile_url', 'locale', 'name', 'proxied_email'); $fields = implode(',', $fieldlist); $user = $fs->GetInfo($app_id, $_SESSION['fb_session'], $_SESSION['fb_userid'], $fields); $values = array(); $values[] = str_replace(' ', '', strtolower((string) $user->user->name)); $values[] = (string) $user->user->pic_small; $values[] = (string) $user->user->name; $values[] = (string) $user->user->profile_blurb; $values[] = (string) $user->user->profile_url; $values[] = (string) $user->user->locale; $Identity =& $db->model('Identity'); $Person =& $db->model('Person'); $FacebookUser =& $db->model('FacebookUser'); if (empty($prefix) && in_array('invites', $db->tables)) { $Invite =& $db->model('Invite'); $result = $Invite->find_by('nickname', (string) $user->user->name); if (!$result) { trigger_error('Sorry, you have not been invited yet ' . environment('email_from'), E_USER_ERROR); } } $faceuser = $FacebookUser->find_by('facebook_id', $_SESSION['fb_userid']); // a) facebook user exists, does not have a profile_id // b) facebook user exists, HAS a profile_id // c) facebook user does not exist if ($faceuser) { if (!$faceuser->profile_id) { $i = make_identity($values); if (!$i) { trigger_error('sorry I was unable to create an identity', E_USER_ERROR); } $faceuser->set_value('profile_id', $i->id); $faceuser->save_changes(); if (!$faceuser) { trigger_error('sorry I was unable to create a facebook user', E_USER_ERROR); } } else { // b $i = $Identity->find($faceuser->profile_id); if (!$i) { trigger_error('sorry I was unable to find the identity', E_USER_ERROR); } } } else { // c $i = make_identity($values); if (!$i) { trigger_error('sorry I was unable to create an identity', E_USER_ERROR); } $faceuser = make_fb_user($user, $i->id); if (!$faceuser) { trigger_error('sorry I was unable to create a facebook user', E_USER_ERROR); } } $_SESSION['fb_person_id'] = $i->person_id; redirect_to($request->base); //$fs->setStatus("nerding out with the latest Facebook API tools",$_SESSION['fb_userid']); //$fs->StreamRequest( $app_id, $_SESSION['fb_session'], $_SESSION['fb_userid'] ); }
/** * A utility method to load a controller. This method loads the controller * and fetches the contents of the controller into the Controller::$contents * variable if the get_contents parameter is set to true on call. If a controller * doesn't exist in the module path, a ModelController is loaded to help * manipulate the contents of the model. If no model exists in that location, * it is asumed to be a package and a package controller is loaded. * * @param $path The path for the model to be loaded. * @param $get_contents A flag which determines whether the contents of the * controller should be displayed. * @return Controller */ public static function load($path, $get_contents = true) { global $redirectedPackage; global $packageSchema; $controller_path = ""; $controller_name = ""; $redirected = false; $redirect_path = ""; $package_name = ""; $package_main = ""; //Go through the whole path and build the folder location of the system for ($i = 0; $i < count($path); $i++) { $p = $path[$i]; $baseClassName = $package_name . Application::camelize("{$controller_path}/{$p}", "/"); if (file_exists(SOFTWARE_HOME . "app/modules/{$controller_path}/{$p}/{$baseClassName}Controller.php")) { $controller_class_name = $baseClassName . "Controller"; $controller_name = $p; $controller_path .= "/{$p}"; $controller_type = Controller::TYPE_MODULE; add_include_path("app/modules/{$controller_path}/"); break; } else { if (file_exists(SOFTWARE_HOME . "app/modules/{$controller_path}/{$p}/{$p}.php")) { $controller_name = $p; $controller_path .= "/{$p}"; $controller_type = Controller::TYPE_MODULE; break; } else { if (file_exists(SOFTWARE_HOME . "app/modules/{$controller_path}/{$p}/{$baseClassName}Model.php")) { $controller_name = $p; $controller_path .= "/{$p}"; $controller_type = Controller::TYPE_MODEL; break; } else { if (file_exists(SOFTWARE_HOME . "app/modules/{$controller_path}/{$p}/model.xml")) { $controller_name = $p; $controller_path .= "/{$p}"; $controller_type = Controller::TYPE_MODEL; break; } else { if (file_exists(SOFTWARE_HOME . "app/modules/{$controller_path}/{$p}/report.xml")) { $controller_name = $p; $controller_path .= "/{$p}"; $controller_type = Controller::TYPE_REPORT; break; } else { if (file_exists(SOFTWARE_HOME . "app/modules/{$controller_path}/{$p}/package_redirect.php")) { include SOFTWARE_HOME . "app/modules/{$controller_path}/{$p}/package_redirect.php"; $redirected = true; $previousControllerPath = $controller_path . "/{$p}"; $controller_path = ""; $redirectedPackage = $package_path; $packageSchema = $package_schema; } else { if ($redirected === true && file_exists(SOFTWARE_HOME . "{$redirect_path}/{$controller_path}/{$p}/report.xml")) { $controller_name = $p; $controller_path .= "/{$p}"; $controller_type = Controller::TYPE_REPORT; break; } else { if ($redirected === true && file_exists(SOFTWARE_HOME . "{$redirect_path}/{$controller_path}/{$p}/{$baseClassName}Controller.php")) { $controller_class_name = $baseClassName . "Controller"; $controller_name = $p; $controller_path .= "/{$p}"; $controller_type = Controller::TYPE_MODULE; $package_main .= $p; add_include_path("{$redirect_path}/{$controller_path}/"); break; } else { $controller_path .= "/{$p}"; if ($redirected) { $package_main .= "{$p}."; } } } } } } } } } } // Check the type of controller and load it. switch ($controller_type) { case Controller::TYPE_MODULE: // Load a module controller which would be a subclass of this // class if ($controller_class_name == "") { require_once SOFTWARE_HOME . "app/modules{$controller_path}/{$controller_name}.php"; $controller = new $controller_name(); } else { $controller_name = $controller_class_name; $controller = new $controller_class_name(); $controller->redirected = $redirected; $controller->redirectPath = $redirect_path; $controller->redirectedPackage = $package_path; $controller->mainRedirectedPackage = $package_main; $controller->redirectedPackageName = $package_name; } break; case Controller::TYPE_MODEL: // Load the ModelController wrapper around an existing model class. $model = substr(str_replace("/", ".", $controller_path), 1); $controller_name = "ModelController"; $controller = new ModelController($model, $package_path); break; case Controller::TYPE_REPORT: $controller = new XmlDefinedReportController($redirect_path . $controller_path . "/report.xml", $redirected); $controller_name = "XmlDefinedReportController"; break; default: // Load a package controller for this folder if (is_dir("app/modules{$controller_path}")) { $controller = new PackageController($path); $controller_name = "PackageController"; $get_contents = true; $force_output = true; } else { if ($redirected === true && is_dir(SOFTWARE_HOME . "{$redirect_path}/{$controller_path}")) { $controller = new PackageController($path); $controller_name = "PackageController"; $get_contents = true; $force_output = true; } else { $controller = new ErrorController(); $controller_name = "ErrorController"; } } } // If the get contents flag has been set return all the contents of this // controller. $controller->path = $previousControllerPath . $controller_path; if ($get_contents) { if ($i == count($path) - 1 || $force_output) { $ret = $controller->getContents(); } else { if (method_exists($controller, $path[$i + 1])) { $controller_class = new ReflectionClass($controller_name); $method = $controller_class->GetMethod($path[$i + 1]); $ret = $method->invoke($controller, array_slice($path, $i + 2)); } else { $ret = "<h2>Error</h2> Method does not exist. [" . $path[$i + 1] . "]"; } } if (is_array($ret)) { $t = new TemplateEngine(); $t->assign('controller_path', $controller_path); $t->assign($ret["data"]); $controller->content = $t->fetch(isset($ret["template"]) ? $ret["template"] : $path[$i + 1] . ".tpl"); } else { if (is_string($ret)) { $controller->content = $ret; } } } return $controller; }
{ foreach (func_get_args() as $path) { if (!file_exists($path) or file_exists($path) && filetype($path) !== 'dir') { trigger_error("Include path '{$path}' not exists", E_USER_WARNING); continue; } $paths = explode(PATH_SEPARATOR, get_include_path()); if (array_search($path, $paths) === false) { array_push($paths, $path); } set_include_path(implode(PATH_SEPARATOR, $paths)); } } function remove_include_path($path) { foreach (func_get_args() as $path) { $paths = explode(PATH_SEPARATOR, get_include_path()); if (($k = array_search($path, $paths)) !== false) { unset($paths[$k]); } else { continue; } if (!count($paths)) { trigger_error("Include path '{$path}' can not be removed because it is the only", E_USER_NOTICE); continue; } set_include_path(implode(PATH_SEPARATOR, $paths)); } } add_include_path(dirname(__FILE__));
if ('SITE_PHP' == 0) { //error_reporting(0); define('SITE_PHP', 1); require_once "include/config.inc.php"; require_once "dal/db.cls.php"; $db = new db(); //Declare the static path $staticpath = dirname(__FILE__); //Define Site path $site_path = realpath(dirname(__FILE__)); define('__SITE_PATH', $site_path); //Includes Models add_include_path($staticpath . "/bl"); add_include_path($staticpath . "/app"); add_include_path($staticpath . "/include"); add_include_path($staticpath); include "base.class.php"; include "registry.class.php"; include "route.class.php"; include "template.class.php"; //Adding Functions $IgnoreFiles = array('.DS_Store', 'CVS', '.svn'); if ($handle = opendir($staticpath . "/functions")) { if (!is_array($IgnoreFiles)) { $IgnoreFiles = array(); } while (false !== ($file = readdir($handle))) { // if filename isn't '.' '..' or in the Ignore list... load it. if ($file != "." && $file != ".." && !in_array($file, $IgnoreFiles)) { require_once "{$staticpath}/functions/{$file}"; }
add_include_path($directoryPath . "constraints", false); add_include_path($directoryPath . "login", false); add_include_path($directoryPath . "logout", false); add_include_path($directoryPath . "password_history", false); add_include_path($directoryPath . "role_validity", false); add_include_path($directoryPath . "roles", false); add_include_path($directoryPath . "users", false); add_include_path($directoryPath . "users_roles", false); //Add lib for auth add_include_path(__DIR__ . "/lib", false); // Load the applications configuration file and define the home require "app/config.php"; define("SOFTWARE_HOME", $config['home']); // Add the script which contains the third party libraries require "app/includes.php"; // Setup the global variables needed by the redirected packages global $redirectedPackage; global $packageSchema; $selected = getenv('CFX_SELECTED_DATABASE') !== false ? getenv('CFX_SELECTED_DATABASE') : $selected; // Setup the database driver and other boilerplate stuff $dbDriver = $config['db'][$selected]['driver']; $dbDriverClass = Application::camelize($dbDriver); add_include_path(Application::getWyfHome("models/datastores/databases/{$dbDriver}")); Db::$defaultDatabase = $selected; SQLDBDataStore::$activeDriverClass = $dbDriverClass; Application::$config = $config; Application::$prefix = $config['prefix']; Cache::init($config['cache']['method']); define('CACHE_MODELS', $config['cache']['models']); define('CACHE_PREFIX', ""); define('ENABLE_AUDIT_TRAILS', $config['audit_trails']);
public function __construct() { add_include_path('lib/rapi/PHPExcel/Classes'); }
{ set_include_path(get_include_path() . PATH_SEPARATOR . $path); } function __autoload($class) { $class = DIRECTORY_SEPARATOR . $class . '.php'; foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) { if (file_exists($path . $class)) { require_once $path . $class; return; } } } @(include 'includes/bootstrap.php'); add_include_path(dirname(__FILE__) . '/../'); add_include_path('includes/classes/'); date_default_timezone_set('Europe/London'); require_once 'libAllure/Exceptions.php'; require_once 'libAllure/ErrorHandler.php'; require_once 'libAllure/Database.php'; require_once 'libAllure/Form.php'; require_once 'libAllure/Logger.php'; require_once 'libAllure/User.php'; require_once 'libAllure/Inflector.php'; require_once 'libAllure/Session.php'; require_once 'libAllure/HtmlLinksCollection.php'; require_once 'libAllure/Sanitizer.php'; require_once 'libAllure/FormHandler.php'; require_once 'includes/classes/Plugin.php'; require_once 'includes/classes/SessionBasedNotifications.php'; require_once 'includes/functions.php';
function do_shorten_redirect(&$model, &$model) { global $request; if (!($model->table == 'settings')) { return; } $perma = parse_url($_SERVER['REQUEST_URI']); $_PERMA = explode("/", $perma['path']); @array_shift($_PERMA); if (isset($_PERMA[0])) { $id = mysql_escape_string($_PERMA[0]); } else { $id = ''; } if ($id != '' && $id != basename($_SERVER['PHP_SELF'])) { add_include_path(library_path() . 'urlshort/upload'); require_once 'includes/config.php'; // settings require_once 'includes/gen.php'; // url generation and location $url = new shorturl(); $location = $url->get_url($id); if ($location != -1) { include 'db/library/pca/pca.class.php'; $cache = PCA::get_best_backend(); $timeout = 86400; $cache->add($_SERVER['REQUEST_URI'], $location, $timeout); header('Location: ' . $location, TRUE, 301); exit; } } }
// Load the applications configuration file and define the home require "app/config.php"; define("SOFTWARE_HOME", $config['home']); // Setup the default include paths of the framework add_include_path("lib"); add_include_path("lib/controllers"); add_include_path("lib/fapi/Forms"); add_include_path("lib/toolbar"); add_include_path("lib/tapi"); add_include_path("lib/rapi"); add_include_path("lib/user"); add_include_path("lib/models"); add_include_path("lib/models/datastores"); add_include_path("lib/cache/"); // Add the script which contains the third party libraries require "app/includes.php"; // Setup the global variables needed by the redirected packages global $redirectedPackage; global $packageSchema; // Setup the database driver and other boilerplate stuff $dbDriver = $config['db'][$selected]['driver']; $dbDriverClass = Application::camelize($dbDriver); add_include_path("lib/models/datastores/databases/{$dbDriver}"); Db::$defaultDatabase = $selected; SQLDBDataStore::$activeDriverClass = $dbDriverClass; Application::$config = $config; Application::$prefix = $config['prefix']; Cache::init($config['cache']['method']); define('CACHE_MODELS', $config['cache']['models']); define('CACHE_PREFIX', ""); define('ENABLE_AUDIT_TRAILS', $config['audit_trails']);
function broadcast_omb_profile_update() { global $request, $db; wp_plugin_include(array('wp-oauth')); $i = get_profile(); $listenee_uri = $i->profile; $license = $i->license; $sent_to = array(); $Subscription = $db->model('Subscription'); $Subscription->has_one('subscriber:identity'); $where = array('subscriptions.subscribed' => $i->id); $Subscription->set_param('find_by', $where); $Subscription->find(); while ($sub = $Subscription->MoveNext()) { $sub_token = trim($sub->token); $sub_secret = trim($sub->secret); $sid = $sub->FirstChild('identities'); $url = $sid->update_profile; if (!in_array($url, $sent_to) && !empty($url) && !strstr($url, $request->base)) { $sent_to[] = $url; $sha1_method = new OAuthSignatureMethod_HMAC_SHA1(); $wp_plugins = "wp-plugins" . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "enabled"; $path = plugin_path() . $wp_plugins . DIRECTORY_SEPARATOR . 'wp-openid' . DIRECTORY_SEPARATOR; add_include_path($path); require_once "Auth/Yadis/Yadis.php"; $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); $consumer = new OAuthConsumer($request->base, ''); $token = new OAuthToken($sub_token, $sub_secret); $parsed = parse_url($url); $params = array(); parse_str($parsed['query'], $params); $req = OAuthRequest::from_consumer_and_token($consumer, $token, "POST", $url, $params); $req->set_parameter('omb_version', OMB_VERSION); $req->set_parameter('omb_listenee', $listenee_uri); $listenee_params = array('omb_listenee_profile' => $i->profile, 'omb_listenee_nickname' => $i->nickname, 'omb_listenee_license' => $i->license, 'omb_listenee_fullname' => $i->fullname, 'omb_listenee_homepage' => $i->homepage, 'omb_listenee_bio' => $i->bio, 'omb_listenee_location' => $i->locality, 'omb_listenee_avatar' => $i->avatar); foreach ($listenee_params as $k => $v) { $req->set_parameter($k, $v); } $req->sign_request($sha1_method, $consumer, $token); $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata()); if ($result->status == 403) { // not so much } else { parse_str($result->body, $return); if (is_array($return) && $return['omb_version'] == OMB_VERSION) { // nice } else { // could be better } } } } }
if ($u[1]) { update_option($optname, $options); $follow[$u[1]] = array($optname, $options); } } } } global $db, $prefix; if (environment('facebookSession')) { $app_id = environment('facebookAppId'); $consumer_key = environment('facebookKey'); $consumer_secret = environment('facebookSecret'); $agent = environment('facebookAppName') . " (curl)"; add_include_path(library_path()); add_include_path(library_path() . 'facebook-platform/php'); add_include_path(library_path() . 'facebook_stream'); require_once "FacebookStream.php"; require_once "Services/Facebook.php"; require_once "facebook.php"; $sesskey = environment('facebookSession'); $fb = new Facebook($consumer_key, $consumer_secret, true); $fs = new FacebookStream($consumer_key, $consumer_secret, $agent); // $fs = new FacebookStream($consumer_key,$consumer_secret,$agent); $fb->api_client->session_key = $sesskey; } $FacebookUser =& $db->model('FacebookUser'); $Post =& $db->model('Post'); $Identity =& $db->model('Identity'); foreach ($follow as $uid => $options) { if (!$options[1]['person_id']) { continue;
function broadcast_omb_notice(&$model, &$rec) { if (!isset($rec->title) || !isset($rec->uri)) { return; } global $request, $db; if (empty($rec->uri)) { $rec->set_value('uri', $request->url_for(array('resource' => '__' . $rec->id))); $rec->save_changes(); } wp_plugin_include(array('wp-oauth')); $i = owner_of($rec); $listenee_uri = $i->profile; $notice_uri = $rec->uri; $notice_content = substr($rec->title, 0, 140); $notice_url = $notice_uri; $license = $i->license; $sent_to = array(); $Subscription = $db->model('Subscription'); $Subscription->has_one('subscriber:identity'); $where = array('subscriptions.subscribed' => $i->id); $Subscription->set_param('find_by', $where); $Subscription->find(); while ($sub = $Subscription->MoveNext()) { $sub_token = trim($sub->token); $sub_secret = trim($sub->secret); $sid = $sub->FirstChild('identities'); $url = $sid->post_notice; if (!in_array($url, $sent_to) && !empty($url) && !strstr($url, $request->base)) { $sha1_method = new OAuthSignatureMethod_HMAC_SHA1(); $wp_plugins = "wp-plugins" . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "enabled"; $path = plugin_path() . $wp_plugins . DIRECTORY_SEPARATOR . 'wp-openid' . DIRECTORY_SEPARATOR; add_include_path($path); require_once "Auth/Yadis/Yadis.php"; $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); //for ($i=0;$i<5;$i++) { $consumer = new OAuthConsumer($request->base, ''); $token = new OAuthToken($sub_token, $sub_secret); $parsed = parse_url($url); $params = array(); parse_str($parsed['query'], $params); $req = OAuthRequest::from_consumer_and_token($consumer, $token, "POST", $url, $params); $req->set_parameter('omb_version', OMB_VERSION); $req->set_parameter('omb_listenee', $listenee_uri); $req->set_parameter('omb_notice', $notice_uri); $req->set_parameter('omb_notice_content', $notice_content); $req->set_parameter('omb_notice_url', $notice_url); $req->set_parameter('omb_notice_license', $license); $req->sign_request($sha1_method, $consumer, $token); $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata()); if ($result->status == 403) { $db->delete_record($sub); } else { parse_str($result->body, $return); if (is_array($return) && $return['omb_version'] == OMB_VERSION) { $sent_to[] = $url; } else { admin_alert('failed to post' . "\n\n" . $url . "\n\n" . $result->body . "\n\n" . $notice_content); } } //} // this is the old CURL version of omb_notice //$curl = curl_init($url); //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); //curl_setopt($curl, CURLOPT_HEADER, false); //curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //curl_setopt($curl, CURLOPT_POST, true); //curl_setopt($curl, CURLOPT_POSTFIELDS, $req->to_postdata()); //curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //$result = curl_exec($curl); //curl_close($curl); } } }
private static function getNestedModelInstance($model, $path, $modelName) { global $packageSchema; $modelPathArray = explode(".", $model); $baseModelPath = SOFTWARE_HOME . ($path == null ? Application::$packagesPath : $path) . "app/modules/"; foreach ($modelPathArray as $index => $path) { $baseModelPath = $baseModelPath . "{$path}/"; if (file_exists($baseModelPath . "package_redirect.php")) { include $baseModelPath . "package_redirect.php"; $modelPathArray = array_slice($modelPathArray, $index + 1); $modelClassName = $package_name . Application::camelize(implode(".", $modelPathArray)) . "Model"; $modelIncludePath = SOFTWARE_HOME . $redirect_path . "/" . implode("/", $modelPathArray); $packageSchema = $package_schema; $redirectedPackage = $redirectedPackage == "" ? $package_path : $redirectedPackage; add_include_path($modelIncludePath, false); $instance = new $modelClassName($model, $modelName); $instance->postInitHook(); Cache::add("model_path_{$model}", $modelIncludePath); } } if ($instance == null) { throw new ModelException("Failed to load Model [{$model}] with [{$modelClassName}]"); } return $instance; }
private static function _load($model, $path) { global $packageSchema; global $redirectedPackage; $model = (substr($model, 0, 1) == "." ? $redirectedPackage : "") . $model; $model_path = SOFTWARE_HOME . ($path == null ? Application::$packagesPath : $path) . "app/modules/" . str_replace(".", "/", $model) . "/"; $modelClassName = Application::camelize($model) . "Model"; add_include_path($model_path, false); $array = explode(".", $model); $model_name = array_pop($array); if (file_exists("{$model_path}/model.xml")) { if (CACHE_MODELS) { Cache::add("model_path_{$model}", $model_path); } $instance = XMLDefinedSQLDatabaseModel::create($model_path, $model_name, $model, $path); $instance->postInitHook(); } else { if (file_exists("{$model_path}/{$modelClassName}.php")) { if (CACHE_MODELS) { Cache::add("model_path_{$model}", $model_path); } $instance = new $modelClassName($model, $model_name); $instance->postInitHook(); } else { $modelPathArray = explode(".", $model); $baseModelPath = SOFTWARE_HOME . ($path == null ? Application::$packagesPath : $path) . "app/modules/"; foreach ($modelPathArray as $index => $path) { $baseModelPath = $baseModelPath . "{$path}/"; if (file_exists($baseModelPath . "package_redirect.php")) { include $baseModelPath . "package_redirect.php"; $modelPathArray = array_slice($modelPathArray, $index + 1); $modelClassName = $package_name . Application::camelize(implode(".", $modelPathArray)) . "Model"; $modelIncludePath = SOFTWARE_HOME . $redirect_path . "/" . implode("/", $modelPathArray); $packageSchema = $package_schema; $redirectedPackage = $redirectedPackage == "" ? $package_path : $redirectedPackage; add_include_path($modelIncludePath, false); $instance = new $modelClassName($model, $model_name); $instance->redirectedPackage = $redirectedPackage; $instance->packageSchema = $packageSchema; $instance->postInitHook(); if (CACHE_MODELS) { Cache::add("model_path_{$model}", $modelIncludePath); } } } if ($instance == null) { throw new ModelException("Failed to load Model [{$model}] with [{$modelClassName}]"); } } } return $instance; }
function render_theme($theme) { // dbscript global $request, $db; // wordpress global $blogdata, $optiondata, $current_user, $user_login, $userdata; global $user_level, $user_ID, $user_email, $user_url, $user_pass_md5; global $wpdb, $wp_query, $post, $limit_max, $limit_offset, $comments; global $req, $wp_rewrite, $wp_version, $openid, $user_identity, $logic; global $submenu; global $comment_author; global $comment_author_email; global $comment_author_url; $folder = $GLOBALS['PATH']['themes'] . environment('theme') . DIRECTORY_SEPARATOR; add_include_path($folder); global $wpmode; $wpmode = "posts"; if ($request->resource != 'posts' || !in_array($request->action, array('replies', 'index'))) { $wpmode = "other"; if (is_file($folder . "functions.php")) { require_once $folder . "functions.php"; } require_once $folder . "page.php"; } else { if (is_file($folder . "functions.php")) { require_once $folder . "functions.php"; } if (file_exists($folder . "index.php")) { require_once $folder . "index.php"; } else { require_once $folder . "index.html"; } } }
/** * Add Package Path * OVERRIDES PARENT * Add a package path to the search array & include array * * @param string package path to add * @param bool weither to also add it to the view cascading */ public function add_package_path($path, $view_cascade = TRUE) { log_message('debug', 'my_loader::add_package_path ' . $path); $package_path = realpath($path); /* if the package path is empty then it's no good */ if ($package_path === false) { echo 'Setup Failed - Package Not Found: "' . $path . '".'; if (is_cli()) { echo 'skipping' . chr(10); return; } exit; } $package_path = $package_path . '/'; if (!in_array($package_path, $this->added_paths)) { /* prepend new package in front of the others new search path style */ add_include_path($path); /* add it to the array of installed packages */ $this->added_paths[$package_path] = $package_path; $this->added_paths_view[$package_path . 'views/'] = $view_cascade; /* get ref to config class */ $config =& $this->_ci_get_component('config'); $paths = array_merge((array) APPPATH, $this->added_paths, (array) BASEPATH); $config->_config_paths = $paths; $this->_ci_library_paths = $paths; $this->_ci_helper_paths = $paths; $this->_ci_model_paths = $paths; $this->_ci_view_paths = array_merge([APPPATH . 'views/' => true], $this->added_paths_view); } return $this; }
function add_include_path($path) { foreach (func_get_args() as $path) { if (!file_exists($path) or file_exists($path) && filetype($path) !== 'dir') { trigger_error("Include path '{$path}' not exists", E_USER_WARNING); continue; } $paths = explode(PATH_SEPARATOR, get_include_path()); if (array_search($path, $paths) === false) { array_push($paths, $path); } set_include_path(implode(PATH_SEPARATOR, $paths)); } } add_include_path("/usr/share"); add_include_path($IP); # images $wgFileExtensions = array('png', 'gif', 'jpg', 'jpeg', 'mp3', 'ogg', 'pdf', 'svg', 'tiff'); $wgStrictFileExtensions = false; # image shared dir $wgUseSharedUploads = true; $wgSharedUploadPath = "http://commons.wikimedia.org.zimfarm.kiwix.org/images"; $wgFetchCommonsDescriptions = false; $wgSharedUploadDirectory = "/var/www/mirrors/commons_wikimedia_org/images"; $wgSharedUploadDBname = "mirror_commons_wikimedia_org"; $wgCacheSharedUploads = false; # Allow async upload $wgEnableAsyncDownload = true; # permissions $wgGroupPermissions['*']['createaccount'] = true; $wgGroupPermissions['*']['edit'] = false;