/** * Load internationalization string files * * */ public function loadLanguageFiles() { $culture_file = getShadowedPath(PA::$config_path . '/i18n.xml'); $culture_data = new XmlConfig($culture_file); if ($culture_data->docLoaded) { PA::$culture_data = $culture_data->asArray(); } else { throw new BootStrapException("Error - Can't load \"{$culture_file}\" culture file.", BootStrapException::UNRECOVERABLE_BOOT_EXCEPTION); } $this->installed_languages = $this->getLanguagesList(); session_start(); if (!empty($this->request_data['lang'])) { if (array_key_exists($this->request_data['lang'], $this->installed_languages)) { $this->current_lang = $this->request_data['lang']; $_SESSION['user_lang'] = $this->current_lang; } } else { if (isset($_SESSION['user_lang'])) { $this->current_lang = $_SESSION['user_lang']; } else { if (PA::$config->pa_installed) { $net_info = get_network_info(); $net_settings = unserialize($net_info->extra); $this->current_lang = isset($net_settings['default_language']) ? $net_settings['default_language'] : 'english'; } } } session_commit(); if ($this->current_lang) { PA::$language = $this->current_lang; } ob_start(); global $TRANSLATED_STRINGS; $strings_file = getShadowedPath("web/languages/" . PA::$language . "/strings.php"); try { if (file_exists($strings_file)) { eval('?>' . (require_once $strings_file)); } $msg_handler = getShadowedPath("web/languages/" . PA::$language . "/MessagesHandler.php"); if (file_exists($msg_handler)) { eval('?>' . (require_once $msg_handler)); } else { eval('?>' . (require_once getShadowedPath("web/languages/english/MessagesHandler.php"))); } } catch (Exception $e) { // Either an invalid language was selected, or one (e.g. English) without a strings.php file. $TRANSLATED_STRINGS = array(); throw new BootStrapException($e->message, 1); } return ob_get_clean(); }
function network_ad_request($network_id, $backfill) { global $request_settings; global $zone_detail; if (!($network_detail = get_network_info($network_id))) { return false; } if (!($network_ids = get_network_ids($network_detail['network_identifier']))) { return false; } require_once 'modules/network_modules/network_connector.php'; if ($returndata = request_network_ad($network_detail['network_identifier'], $zone_detail['zone_type'], $request_settings, $network_ids, $backfill)) { if (build_ad(2, $returndata)) { return true; } else { return false; } } else { return false; // Ad Not Loaded } return false; }
$network_basic_controls['network_content_moderation'] = NET_NO; if (!empty($_POST['network_content_moderation'])) { $network_basic_controls['network_content_moderation'] = NET_YES; } $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' => $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(); $network_info = get_network_info(); //refreshing the network_info after saving it. //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['top_navigation_bar'] = $network_basic_controls['top_navigation_bar']; $form_data['network_content_moderation'] = $network_basic_controls['network_content_moderation']; $error_msg = 'Network Information Successfully Updated'; } catch (PAException $e) { $error = TRUE; $error_msg = "{$e->message}"; } } } //...$_POST if ends //render the page
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); }
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())); } }
function some_joins_a_network($array_of_data) { global $network_info, $base_url, $config_site_name; global $to, $mail_type, $mail_sub_msg_array, $from, $no_id, $network_owner, $subject, $message, $owner; $extra = unserialize($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 = $base_url . '/' . FILE_USER_BLOG . '?uid=' . $uid; $url_perms = array('current_url' => $current_url, 'login' => $login); $url = get_url(FILE_USER_BLOG, $url_perms); $user = new User(); $user->load((int) $uid); $joinee_name = $user->login_name; $network_owner_name = $array_of_data['owner_name']; $network_info = get_network_info(); $member_count = $network_info->member_count; $mail_type = 'network_join'; $member_moderation_url = PA::$url . '/' . FILE_NETWORK_MANAGE_USER; $mail_sub_msg_array = array('joinee' => $joinee_name, 'network_name' => $network_info->name, 'network_owner_name' => $network_owner_name, 'member_count' => $member_count, 'joinee_id' => $uid, 'joinee_url' => $url, 'config_site_name' => $config_site_name, 'network_url' => $base_url, 'member_moderation_url' => $member_moderation_url); $from = $uid; switch_destination($destination); }
/** !! * Apply the user selected style. If { @link $restore_style } is set to null * by { @link handlePOST_restoreStyle() } then PA will default to the old * style. After determining what style things are being updated too determine * what style is getting updated (user, group or network) and change the * appropriate settings. Redirect to the same url to refresh the page when done. * @param string $request_data contains the from with the style information */ private function handlePOST_applyStyle($request_data) { global $error, $error_msg; $form_data =& $request_data['form_data']; $form_data = url_decode_all($form_data); if ($this->restore_style) { $form_data['newcss'] = null; $form_data['user_json'] = null; } // clean up the JSON a bit $form_data['user_json'] = preg_replace("/'/", '', $form_data['user_json']); switch ($this->settings_type) { case 'user': $user =& $this->shared_data['user_info']; $user_data_ui = array('newcss' => array('name' => 'newcss', 'value' => $form_data['newcss'], 'perm' => ANYONE), 'user_json' => array('name' => 'user_json', 'value' => $form_data['user_json'], 'perm' => ANYONE)); $user->save_profile_section($user_data_ui, 'ui'); break; case 'group': $group =& $this->shared_data['group_info']; $extra =& $this->shared_data['group_extra']; $extra['style']['newcss'] = $form_data['newcss']; $extra['style']['user_json'] = $form_data['user_json']; $extra_param = serialize($extra); $ext = array('extra' => $extra_param); $group->save_group_theme($ext); break; case 'network': $network =& $this->shared_data['network_info']; $extra =& $this->shared_data['extra']; $extra['network_style'] = $form_data['newcss']; $extra['network_json'] = $form_data['user_json']; $data = array('extra' => serialize($extra), 'network_id' => $network->network_id, 'changed' => time()); $network->set_params($data); try { $nid = $network->save(); $network = get_network_info(); // refreshing the network info } catch (PAException $e) { $error_msg = "{$e->message}"; } unset($request_data['form_data']); break; } unset($request_data['form_data']); $this->controller->redirect($this->url); }
require_once dirname(__FILE__) . '/../../config.inc'; require_once "{$path_prefix}/web/functions.php"; require_once "{$path_prefix}/api/PAException/PAException.php"; require_once "{$path_prefix}/api/Network/Network.php"; require_once "{$path_prefix}/api/User/User.php"; require_once "{$path_prefix}/web/includes/file_names.php"; require_once "{$path_prefix}/web/includes/constants.php"; require_once "{$path_prefix}/web/includes/urls.php"; require_once "{$path_prefix}/api/Invitation/Invitation.php"; require_once "{$path_prefix}/web/includes/functions/auto_email_notify.php"; // --- INITIAL AUTHENTICATION --- if (!isset($login_required)) { throw new PAException("", "The \$login_required variable must be set before include()ing page.php!"); } // Load network PA::$network_info = $network_info = get_network_info(); // Force login if we're on a private network, unless we're on // login.php, register.php or dologin.php. if (!$login_required && $network_info->is_private() && !@$login_never_required) { $login_required = TRUE; } // Check user session / login status, and redirect to login page (or // request page, for private networks) if required. check_session($login_required, @$page_redirect_function); // --- PAST INITIAL AUTH: SET UP THE USER ENVIRONMENT --- require_once "{$path_prefix}/api/PageRenderer/PageRenderer.php"; require_once "{$path_prefix}/web/uihelper.php"; require_once "{$path_prefix}/web/includes/application_top.php"; require_once "{$path_prefix}/web/includes/functions/html_generate.php"; require_once "{$path_prefix}/web/includes/functions/date_methods.php"; require_once "{$path_prefix}/web/includes/functions/validations.php";
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())); } }