function safe_updates()
 {
     global $network_info;
     PA::$network_info = $network_info = Network::get_mothership_info();
     PA::$extra = unserialize(PA::$network_info->extra);
     $this->create_announce_tables();
     $this->add_all_users_to_mother_network();
     // run project specific updates and init settings
     if (!empty(PA::$config->project_safe_updates)) {
         // see if the settings file exists
         $file_path = PA::$core_dir . "/web/extra/" . PA::$config->project_safe_updates . "_safe_updates.php";
         if (file_exists($file_path)) {
             include $file_path;
         }
     }
 }
 /**
  *  BOOT main network, detect local networks
  *
  * detect network name and work out $base_url
  *
  **/
 public function detectNetwork()
 {
     global $network_prefix;
     $host = PA_SERVER_NAME;
     // URL to the root of the server.
     $base_url = "http://%network_name%.{$this->domain_suffix}";
     if (PA::$ssl_force_https_urls == true) {
         $base_url = str_replace('http', 'https', $base_url);
     }
     if (preg_match('/^\\./', $this->domain_suffix)) {
         throw new BootStrapException("Invalid domain sufix detected. Value: " . $this->domain_suffix, 1);
     }
     PA::$domain_suffix = $this->domain_suffix;
     if (!PA::$config->enable_networks) {
         // spawning disabled
         $network_prefix = 'default';
         $network_url_prefix = PA::$config->domain_prefix;
         define('CURRENT_NETWORK_URL_PREFIX', PA::$config->domain_prefix);
         define('CURRENT_NETWORK_FSPATH', PA::$project_dir . '/networks/default');
         // turn off spawning, and guess domain suffix
         PA::$config->enable_network_spawning = FALSE;
     } else {
         // network operation is enabled - figure out which network we're on
         PA::$network_capable = TRUE;
         // Make sure $domain_suffix is formatted correctly
         if (!empty($this->domain_prefix) && $this->domain_prefix != PA::$config->domain_prefix) {
             $network_prefix = $this->domain_prefix;
             $network_url_prefix = $this->domain_prefix;
         } else {
             // domain prefix points to home network
             $network_prefix = 'default';
             $network_url_prefix = PA::$config->domain_prefix;
             define('CURRENT_NETWORK_URL_PREFIX', $network_url_prefix);
             define('CURRENT_NETWORK_FSPATH', PA::$project_dir . '/networks/default');
         }
     }
     // Allow sessions to persist across entire domain
     ini_set('session.cookie_domain', $this->domain_suffix);
     $network_folder = getShadowedPath("networks/{$network_prefix}");
     if ($network_folder) {
         // network exists
         if (!defined('CURRENT_NETWORK_URL_PREFIX')) {
             define('CURRENT_NETWORK_URL_PREFIX', $network_url_prefix);
         }
         if (!defined('CURRENT_NETWORK_FSPATH')) {
             define('CURRENT_NETWORK_FSPATH', $network_folder);
         }
         if (file_exists(CURRENT_NETWORK_FSPATH . '/local_config.php')) {
             // and it has its own config file
             include CURRENT_NETWORK_FSPATH . '/local_config.php';
         }
     } elseif ($this->domain_prefix != PA::$config->domain_prefix) {
         throw new BootStrapException("Unable to locate network: " . htmlspecialchars($network_prefix) . "." . $this->domain_suffix, 1);
     }
     // at this point, network is detected and we can start to work with the variables they define.
     // put network prefix in $base_url
     $base_url_pa = str_replace('%network_name%', PA::$config->domain_prefix, $base_url);
     // LOCAL
     $base_url = PA::$url = str_replace('%network_name%', CURRENT_NETWORK_URL_PREFIX, $base_url);
     // now we are done with $base_url - it gets define()d and we work out
     // the relative version (for ajax)
     define('BASE_URL_PA', $base_url_pa);
     define('BASE_URL', $base_url);
     $base_url_parts = parse_url($base_url);
     PA::$local_url = preg_replace('|/$|', '', @$base_url_parts['path'] ? $base_url_parts['path'] : '');
     define('BASE_URL_REL', PA::$local_url);
     // work out theme path and check that it exists
     define('CURRENT_THEME_REL_URL', PA::$local_url . '/' . PA::$theme_rel);
     define('CURRENT_THEME_FSPATH', PA::$theme_path);
     define('CURRENT_THEME_FS_CACHE_PATH', PA::$project_dir . '/web/cache');
     // Finally - Load network!
     PA::$network_info = get_network_info($network_prefix);
     // NOTE this should be retrieved from network XML config file
     PA::$extra = unserialize(PA::$network_info->extra);
 }
 function some_joins_a_network($array_of_data)
 {
     $extra = unserialize(PA::$network_info->extra);
     $destination = $extra['notify_owner']['some_joins_a_network']['value'];
     if ($destination == NET_NONE) {
         //if no notification
         return;
     }
     $uid = $array_of_data['params']['uid'];
     $login = User::get_login_name_from_id($uid);
     /*
         $current_url = PA::$url .'/' .FILE_USER_BLOG .'?uid='.$uid;
         $url_perms = array('current_url' => $current_url,
                                   'login' => $login
                                 );
         $url = get_url(FILE_USER_BLOG, $url_perms);
     */
     $url = PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $login;
     $user = new User();
     $user->load((int) $uid);
     $joinee_name = $user->login_name;
     $this->network_owner_name = $array_of_data['owner_name'];
     PA::$network_info = get_network_info();
     $member_count = PA::$network_info->member_count;
     $this->mail_type = 'network_join';
     $member_moderation_url = PA::$url . '/' . FILE_NETWORK_MANAGE_USER;
     $this->mail_sub_msg_array = array('joinee' => $joinee_name, 'network_name' => PA::$network_info->name, 'network_owner_name' => $this->network_owner_name, 'member_count' => $member_count, 'joinee_id' => $uid, 'joinee_url' => $url, 'config_site_name' => PA::$site_name, 'network_url' => PA::$url, 'member_moderation_url' => $member_moderation_url);
     $this->from = $uid;
     $this->switch_destination($destination);
 }
Ejemplo n.º 4
0
 function handle_request()
 {
     $json = new Services_JSON();
     try {
         global $_PA, $HTTP_RAW_POST_DATA;
         if (!@$_PA->enable_widgetization_server) {
             $this->fail("Widget server is not enabled; you must set \$_PA->enable_widgetization_server = TRUE in local_config.php.");
         }
         if ($_SERVER['REQUEST_METHOD'] != 'POST') {
             $this->fail("This URL handles POST requests only");
         }
         if ($_SERVER['CONTENT_TYPE'] != 'application/x-javascript') {
             $this->fail("Content-Type of application/x-javascript required");
         }
         // Parse input
         $request = $json->decode($HTTP_RAW_POST_DATA);
         if ($request == NULL) {
             $this->fail("Null request");
         }
         if (@$_PA->log_widget_requests) {
             Logger::log("WidgetServer::handle_request(): request={$HTTP_RAW_POST_DATA}", LOGGER_ACTION);
         }
         $this->global = $request->global;
         // This should probably be in config.inc.  For the moment
         // we figure out the network based on the URL, as with the
         // rest of the system.
         PA::$network_info = get_network_info();
         $lang = "english";
         if (!empty($this->global->language)) {
             switch ($this->global->language) {
                 case 'en':
                     break;
                 case 'fr':
                     $lang = "french";
                     break;
                 default:
                     $this->fail("Unknown language: {$this->global}->language");
             }
         }
         PA::load_language($lang);
         // Create items as required
         if (!empty($this->global->items)) {
             foreach ($this->global->items as $item) {
                 $item_params = array();
                 foreach ($item as $k => $v) {
                     $item_params[$k] = $v;
                 }
                 Item::sync($item_params);
                 // create or update row in 'items' database table
             }
         }
         // Set up globals - network, user etc
         if (!empty($this->global->user)) {
             $user_info = array("user_id" => $this->global->user->id, "login_name" => $this->global->user->login, "email" => $this->global->user->email, "first_name" => $this->global->user->first_name, "last_name" => $this->global->user->last_name, "url" => $this->global->user->url, "thumbnail_url" => $this->global->user->thumbnail_url);
             // load (and sync!) or create a shadow user for the current remote user
             PA::$login_user = new ShadowUser($this->global->user->namespace);
             if (!PA::$login_user->load($user_info)) {
                 // we haven't seen this remote user before - create account
                 PA::$login_user = ShadowUser::create($this->global->user->namespace, $user_info, PA::$network_info);
                 //FIXME: need to define what remote urls mean.  in this case "url" should be used instead of /users/$login_name when generating internal urls, so it should go in a global profile block rather than something specific to the remote site.
                 PA::$login_user->set_profile_field($this->global->user->namespace, "url", $this->global->user->url);
             }
             PA::$login_uid = PA::$login_user->user_id;
         }
         // Render modules
         $modules = array();
         foreach ($request->modules as $req_module) {
             $module = array();
             $module['id'] = $req_module->id;
             $module['name'] = $name = $req_module->name;
             $params = array();
             foreach ($req_module->params as $k => $v) {
                 $params[$k] = $v;
             }
             // clean up URLs that may have the port 80 specified
             // this would lead to cross server AJAX problems in safari etc
             // although we are actually on the same server
             // domain.tld:80/file/ and domain.tld/file/
             foreach (array('get_url', 'ajax_url', 'post_url') as $i => $url) {
                 $req_module->{$url} = preg_replace('|:80/*|', '/', $req_module->{$url});
             }
             // dispatch module
             ob_start();
             $module['html'] = $this->render_module($req_module->method, $req_module->name, $req_module->args, $params, $req_module->get_url, $req_module->ajax_url, $req_module->post_url, $req_module->param_prefix);
             // prefix for input parameters and textareas
             $errors = ob_get_contents();
             ob_end_clean();
             if (!empty($errors)) {
                 $module['errors'] = $errors;
             }
             $modules[] = $module;
         }
         $response = array('modules' => $modules);
         header("Content-Type: application/x-javascript");
         echo $json->encode($response);
     } catch (WidgetException $e) {
         echo $json->encode(array("error" => $e->getMessage()));
     }
 }
 if (!empty($_POST['network_content_moderation'])) {
     $network_basic_controls['network_content_moderation'] = NET_YES;
 }
 $network_basic_controls['default_language'] = $_POST['default_language'];
 $data = array('name' => $form_data['name'], 'tagline' => $form_data['tagline'], 'category_id' => $form_data['category'], 'description' => $form_data['desc'], 'type' => $form_data['type'], 'extra' => serialize($network_basic_controls), 'network_id' => PA::$network_info->network_id, 'changed' => time());
 //add icon image
 if (is_array(@$data_icon_image) && !empty($data_icon_image['inner_logo_image'])) {
     $data = array_merge($data, $data_icon_image);
     $form_data['inner_logo_image'] = $data_icon_image['inner_logo_image'];
 }
 //try following line
 $network = new Network();
 $network->set_params($data);
 try {
     $nid = $network->save();
     PA::$network_info = get_network_info();
     //refreshing the network_info after saving it.
     $error_msg = 'Network Information Successfully Updated';
     if (!empty($_REQUEST['config_action']) && $_REQUEST['config_action'] == 'store_as_defaults') {
         $export_config = new NetworkConfig();
         $export_config->buildNetworkSettings($network);
         $export_config->storeSettingsLocal();
         $error_msg = 'Network default configuration file "' . $export_config->settings_file . '" successfully updated.';
     }
     if (!empty($new_inner_logo_image)) {
         Storage::link($new_inner_logo_image, array("role" => "avatar"));
     }
     //set $form_data['reciprocated_relationship']if reciprocated relationship is saved
     $form_data['reciprocated_relationship'] = $network_basic_controls['reciprocated_relationship'];
     $form_data['email_validation'] = $network_basic_controls['email_validation'];
     $form_data['captcha_required'] = $network_basic_controls['captcha_required'];
Ejemplo n.º 6
0
 * @todo
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * @version 0.0.0-1
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * @author Cyberspace Networks <*****@*****.**>
 * @license GNU General Public License
 * @copyright Copyright (c) 2000-2015 Cyberspace Networks
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * The lastest version of Cyberspace Networks CoreSystem can be obtained from:
 * https://github.com/CyberspaceNetworks/CoreSystem
 * For questions, help, comments, discussion, etc. please visit
 * http://www.cyberspace-networks.com
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 */
require_once "api/CNContent/CNContent.php";
PA::$network_info = Network::get_network_by_address(CURRENT_NETWORK_URL_PREFIX);
// hack: do this here to avoid having to include page.php and friends
$uid = (int) $_GET['uid'];
$gid = (int) $_GET['gid'];
$type = $_GET['type'];
if ($uid) {
    $feed = Content::get_content_feed_for_user($uid, 5);
} else {
    if ($gid) {
        $group = ContentCollection::load_collection((int) $gid);
        $contents = $group->get_contents_for_collection($type = 'all', $cnt = FALSE, 5, 1, 'created', 'DESC');
        $content_ids = array();
        foreach ($contents as $i => $con) {
            $content_ids[] = $con['content_id'];
        }
        $feed = Content::get_feed_for_content($content_ids);
 function handle_request()
 {
     $json = new Services_JSON();
     try {
         global $HTTP_RAW_POST_DATA;
         if (!@PA::$config->enable_widgetization_server) {
             $this->fail("Widget server is not enabled; you must set \\PA::{$config->enable_widgetization_server} = TRUE in local_config.php.");
         }
         if ($_SERVER['REQUEST_METHOD'] != 'POST') {
             $this->fail("This URL handles POST requests only");
         }
         if ($_SERVER['CONTENT_TYPE'] != 'application/x-javascript') {
             $this->fail("Content-Type of application/x-javascript required");
         }
         // Parse input
         $request = $json->decode($HTTP_RAW_POST_DATA);
         if ($request == NULL) {
             $this->fail("Null request");
         }
         $this->global = $request->global;
         // Set up globals - network, user etc
         if (!empty($this->global->user)) {
             PA::$login_user = new ShadowUser($this->global->namespace);
             // see if we can load it already
             if (!PA::$login_user->load($this->global->user->user_id)) {
                 // wasn't here before, so we create a shadow account
                 PA::$login_user = ShadowUser::create($this->global->namespace, $this->global->user, PA::$network_info);
             }
             PA::$login_uid = PA::$login_user->user_id;
         }
         // This should probably be in config.inc.  For the moment
         // we figure out the network based on the URL, as with the
         // rest of the system.
         PA::$network_info = get_network_info();
         // Render modules
         $modules = array();
         foreach ($request->modules as $req_module) {
             $module = array();
             $module['id'] = $req_module->id;
             $module['name'] = $name = $req_module->name;
             $params = array();
             foreach ($req_module->params as $k => $v) {
                 $params[$k] = $v;
             }
             // dispatch module
             ob_start();
             $module['html'] = $this->render_module($req_module->method, $req_module->name, $req_module->args, $params, $req_module->post_url, $req_module->param_prefix);
             // prefix for input parameters and textareas
             $errors = ob_get_contents();
             ob_end_clean();
             if (!empty($errors)) {
                 $module['errors'] = $errors;
             }
             $modules[] = $module;
         }
         $response = array('modules' => $modules);
         header("Content-Type: application/x-javascript");
         echo $json->encode($response);
     } catch (WidgetException $e) {
         echo $json->encode(array("error" => $e->getMessage()));
     }
 }
Ejemplo n.º 8
0
<?php
/** !
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* [filename] is a part of PeopleAggregator.
* [description including history]
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* @author [creator, or "Original Author"]
* @license http://bit.ly/aVWqRV PayAsYouGo License
* @copyright Copyright (c) 2010 Broadband Mechanics
* @package PeopleAggregator
*/
?>
<?php
require_once dirname(__FILE__)."/../config.inc";
require_once "api/Content/Content.php";
PA::$network_info = Network::get_network_by_address(CURRENT_NETWORK_URL_PREFIX); // hack: do this here to avoid having to include page.php and friends

$uid = (int)@$_GET['uid'];
$gid = (int)@$_GET['gid'];
$type = @$_GET['type'];


if ($uid) {
    $feed = Content::get_content_feed_for_user($uid, 5);
} else if ($gid) {
	$group = ContentCollection::load_collection((int)$gid);
	$contents = $group->get_contents_for_collection($type = 'all', $cnt=FALSE, 5, 1,'created','DESC');
	$content_ids = array();
	foreach($contents as $i=>$con) {
		$content_ids[] = $con['content_id'];
	}