public function __construct($_err_no, $_friendly_err_message, $_technical_err_message = null, $_level = IIRS_MESSAGE_USER_INFORMATION, $_user_action = null, $_args = null) { global $IIRS_is_live_domain, $IIRS_user_agent, $IIRS_host_domain, $IIRS_user_ip; $this->err_no = $_err_no; $this->friendly_err_message = $_friendly_err_message; $this->technical_err_message = $_technical_err_message; $this->level = $_level; $this->user_action = $_user_action; $this->args = $_args; if ($this->level > IIRS_MESSAGE_USER_INFORMATION && function_exists('IIRS_0_error_log')) { IIRS_0_error_log($this); } if (($IIRS_is_live_domain || IIRS_0_debug()) && IIRS_ADMIN_ERROR_EMAILS && $this->level > IIRS_MESSAGE_USER_WARNING) { $body = "<h1>IIRS_Error</h1>"; $body .= "<ul>"; // -------------------------- basic info $body .= "<li>{$this->err_no}</li>"; $body .= "<li>{$this->friendly_err_message}</li>"; $body .= "<li>{$this->technical_err_message}</li>"; $body .= "<li>{$this->level}</li>"; $body .= "<li>{$this->user_action}</li>"; // -------------------------- context info $body .= "<li>User Agent: {$IIRS_user_agent}</li>"; $body .= "<li>Host Domain: {$IIRS_host_domain}</li>"; $body .= "<li>CLient IP: {$IIRS_user_ip}</li>"; if (IIRS_0_debug()) { $body .= "<li>WP_DEBUG is on so this email goes to annesley_newholm@yahoo.it</li>"; } $body .= "</ul>"; // -------------------------- extensible args if ($this->args && is_array($this->args)) { $body .= "<ul>"; foreach ($this->args as $arg) { ob_start(); // PHP 4,5 var_dump($arg); $body .= "<li>" . ob_get_contents() . "</li>"; ob_end_clean(); } $body .= "</ul>"; } // -------------------------- send emails to admin(s) // $subject = $this->__toString() if (function_exists('IIRS_0_send_email')) { //email to developer team at TN if (IIRS_0_debug()) { $email_address = '*****@*****.**'; } else { $email_address = IIRS_EMAIL_TEAM_EMAIL; } IIRS_0_send_email($email_address, $this, $body); //additional email to local plugin administrator if ($email_address = IIRS_0_setting('additional_error_notification_email')) { IIRS_0_send_email($email_address, $this, $body); } } } }
<?php /* Copyright 2015, 2016 Transition Network ltd * This program is distributed under the terms of the GNU General Public License * as detailed in the COPYING file included in the root of this plugin */ ?> <?php global $location_array_not_specified; // -------------------------------------------------------------------- configuration $accept_website_address = IIRS_0_setting('accept_website_address'); $offer_buy_domains = IIRS_0_setting('offer_buy_domains'); $add_projects = IIRS_0_setting('add_projects'); $advanced_settings = IIRS_0_setting('advanced_settings'); // -------------------------------------------------------------------- TI // SECURITY: IIRS_RAW_USER_INPUT indicates that the dangerous USER INPUT will not have slashes added before single quotes // pay attention to appropriately escape when outputting these values into the HTML stream $town_name = IIRS_0_input('town_name', IIRS_RAW_USER_INPUT); $initiative_name = IIRS_0_input('initiative_name', IIRS_RAW_USER_INPUT); $native_ti_ID = IIRS_0_input('native_ti_ID'); $town_name_base = IIRS_0_input('town_name_base'); $summary = IIRS_0_input('summary'); $domain = IIRS_0_input('domain'); $domain_other = IIRS_0_input('domain_other'); if (!isset($domain) || empty($domain)) { $domain = $domain_other; } if ($location_value_serialised = IIRS_0_input('place')) { $location_array = unserialize(urldecode($location_value_serialised)); if ($location_array == $location_array_not_specified) {
?> <form method="POST" id="IIRS_0_form_popup_summary_projects" action="finished" class="IIRS_0_clear IIRS_0_formPopupNavigate"><div> <?php IIRS_0_printEncodedPostParameters(); ?> <h3 class="IIRS_0_horizontal_section"><?php IIRS_0_print_HTML_text($summary_from_website); ?> :</h3> <?php IIRS_0_HTML_editor($summaryFromDomain, 'summary'); ?> <?php if (IIRS_0_setting('image_entry')) { ?> <h3 class="IIRS_0_horizontal_section"><?php IIRS_0_print_translated_HTML_text(IGNORE_TRANSLATION, 'image'); ?> :</h3> <div id="IIRS_0_searchcontrol"><?php IIRS_0_print_translated_HTML_text(IGNORE_TRANSLATION, 'Loading Google images for'); IIRS_0_print_HTML_text(" {$town_name}"); ?> </div> <div id="IIRS_0_searchForm"><?php IIRS_0_print_HTML_text("{$town_name} town"); ?> </div> <?php
} } } //------- 2) users laptop language preferences if (empty($lang_code)) { if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $lang_code = IIRS_0_getBestMatchingLangcode($_SERVER['HTTP_ACCEPT_LANGUAGE'], $available_languages); if (!empty($lang_code)) { $debug_environment .= "2) users laptop language preferences: [{$lang_code}]\n"; } } } //------- 3) explicit host web-server language setting (plugin mode only) if (empty($lang_code)) { if ($IIRS_plugin_mode) { $lang_code = IIRS_0_setting('lang_code'); if (!in_array($lang_code, $available_languages)) { $lang_code_warning = "the language you requested [{$lang_code}] is not available (3)"; $lang_code = ''; } if (!empty($lang_code)) { $debug_environment .= "3) explicit host web-server language setting: [{$lang_code}]\n"; } } } //------- 4) host domain whois record if (empty($lang_code)) { $language_domain = $IIRS_host_domain; if ($IIRS_widget_mode) { $IIRS_HTTP_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL; $language_domain = preg_replace('/^(https?:\\/\\/)?(www\\.)?([^\\/?]*).*/i', '$3', $IIRS_HTTP_referer);
<?php /* Copyright 2015, 2016 Transition Network ltd * This program is distributed under the terms of the GNU General Public License * as detailed in the COPYING file included in the root of this plugin */ ?> <div id="IIRS_0_debug"><pre> debug output: <?php require_once IIRS__COMMON_DIR . 'utility.php'; require_once IIRS__COMMON_DIR . 'framework_abstraction_layer.php'; require_once IIRS__COMMON_DIR . 'environment.php'; require_once IIRS__COMMON_DIR . 'registration/inputs.php'; //------------------------------------- values IIRS_0_TI_update_TI(array('summary' => $summary)); $url = IIRS_0_setting('thankyou_for_registering_url'); if (empty($url)) { $url = IIRS_0_URL_view_TI(); } if ($url) { IIRS_0_redirect($url); } IIRS_0_debug_print("thankyou_for_registering_url: [{$url}]"); ?> </pre></div>
function IIRS_0_print_language_selector() { global $lang_list, $lang_code, $available_languages; if (IIRS_0_setting('language_selector')) { $html = '<select id="IIRS_0_language_control">'; foreach ($available_languages as $code) { if (isset($lang_list[$code])) { $details = $lang_list[$code]; $selected = $code == $lang_code ? 'selected' : ''; $html .= "<option {$selected} value=\"{$code}\">{$details['1']}</option>"; } } $html .= '</select>'; IIRS_0_print($html); } }
function IIRS_0_geocode($town_name, $format = 'xml') { global $location_is_example, $IIRS_host_TLD, $IIRS_common_dir; $location_arrays = array(); // http://open.mapquestapi.com/geocoding/ // see also http://en.wikipedia.org/wiki/Country_code_top-level_domain // for region bias codes // NOTE: the country bias DOES NOT work for MapQuest. we are using a calculated bounding box instead // boundingBox=61.06,-14.02,49.67,2.09 $bounds_param = ''; $region_bias = IIRS_0_setting('region_bias'); if (!$region_bias || $region_bias == 'region_bias') { $region_bias = $IIRS_host_TLD; } if ($region_bias == 'dev' || $region_bias == 'org') { $region_bias = 'uk'; } if ($bounds_details = IIRS_0_tld_bounds($region_bias)) { $bounds_min = $bounds_details['min']; $bounds_max = $bounds_details['max']; $bounds_min_lng = $bounds_min['lng']; $bounds_min_lat = $bounds_min['lat']; $bounds_max_lng = $bounds_max['lng']; $bounds_max_lat = $bounds_max['lat']; $bounds_param = 'boundingBox=' . $bounds_max_lat . ',' . $bounds_min_lng . ',' . $bounds_min_lat . ',' . $bounds_max_lng; IIRS_0_debug_print("located the country bounds for [{$IIRS_host_TLD} / {$region_bias}] => [{$bounds_param}]"); } else { IIRS_0_debug_print("failed to locate the country bounds for [{$IIRS_host_TLD} / {$region_bias}]"); } $town_name_encoded = urlencode($town_name); $url_request = "http://open.mapquestapi.com/geocoding/v1/address?key=Fmjtd%7Cluu829uan1%2C8n%3Do5-9w1a9r&location={$town_name_encoded}&callback=renderGeocode&outFormat={$format}&{$bounds_param}"; IIRS_0_debug_print("region_bias:[" . IIRS_0_setting('region_bias') . "] => {$region_bias}"); IIRS_0_debug_print($url_request); // http://wiki.openstreetmap.org/wiki/Nominatim#Parameters if ($location_is_example) { IIRS_0_debug_print("loading example file..."); $xml = file_get_contents("{$IIRS_common_dir}/location_providers/example_data/mapquest.{$format}"); } else { $xml = IIRS_0_http_request($url_request); } IIRS_0_debug_print($xml); if (IIRS_is_error($xml)) { $location_arrays = $xml; } else { $doc = new DOMDocument(); $doc->loadXML($xml); $oXPath = new DOMXpath($doc); // translate the results in to a standardised array if (!$doc->documentElement || !$doc->documentElement->childNodes) { $location_arrays = new IIRS_Error(IIRS_LOCATION_XML_INVALID, 'Oops, it seems that the our servers are not responding! The manager has been informed and is trying to solve the problem. Please come back here tomorrow :)', 'Invalid XML returned', IIRS_MESSAGE_EXTERNAL_SYSTEM_ERROR, IIRS_MESSAGE_NO_USER_ACTION); } else { // handle no results (not an error as such!) if ($doc->documentElement->childNodes->length == 0) { IIRS_0_debug_print("no results from lookup"); } else { // get places info into an associative array $placeNodes = $oXPath->query('/response/results/result/locations/location'); IIRS_0_debug_print("{$placeNodes->length} results from lookup"); foreach ($placeNodes as $placeNode) { if ($placeNode->nodeType == XML_ELEMENT_NODE) { /* <street></street> <adminArea5 type="City"></adminArea5> <adminArea3 type="State">England</adminArea3> <adminArea4 type="County">Bedford</adminArea4> <postalCode></postalCode> <adminArea1 type="Country">GB</adminArea1> <geocodeQuality>COUNTY</geocodeQuality> <geocodeQualityCode>A4XAX</geocodeQualityCode> <dragPoint>false</dragPoint> <sideOfStreet>N</sideOfStreet> <displayLatLng><latLng><lat>52.136381</lat><lng>-0.467504</lng></latLng></displayLatLng> <linkId>0</linkId> <type>s</type> <latLng><lat>52.136381</lat><lng>-0.467504</lng></latLng> <mapUrl> */ $location_array = array(); // assemble place description $description = ''; foreach ($placeNode->childNodes as $placeValueNode) { $sPlaceKey = $placeValueNode->nodeName; if ($sPlaceKey != 'geocodeQuality' && $sPlaceKey != 'geocodeQualityCode' && $sPlaceKey != 'dragPoint' && $sPlaceKey != 'sideOfStreet' && $sPlaceKey != 'displayLatLng' && $sPlaceKey != 'linkId' && $sPlaceKey != 'type' && $sPlaceKey != 'latLng' && $sPlaceKey != 'mapUrl') { $sPlaceValue = trim($placeValueNode->nodeValue); if ($sPlaceValue) { $description .= "{$sPlaceValue}, "; } } } if ($description) { $description = substr($description, 0, -2); } // entry and add in to the array $location_array['description'] = $description; $location_array['latitude'] = IIRS_0_get_DOM_value($placeNode, 'latLng/lat'); $location_array['longitude'] = IIRS_0_get_DOM_value($placeNode, 'latLng/lng'); $location_array['granuality'] = IIRS_0_get_DOM_value($placeNode, 'geocodeQuality'); $location_array['country'] = IIRS_0_get_DOM_value($placeNode, "adminArea1[@type='Country']"); $location_array['full_address'] = $description; $location_array['bounds'] = ''; $location_arrays[] = $location_array; } } } } } return $location_arrays; }
function IIRS_0_geocode($town_name, $format = 'xml') { global $location_is_example, $IIRS_host_TLD, $IIRS_common_dir; $location_arrays = array(); // http://maps.google.com/maps/api/geocode/xml?sensor=false&address=bedford // see also http://en.wikipedia.org/wiki/Country_code_top-level_domain // for region bias codes $region_bias = IIRS_0_setting('region_bias'); if (!$region_bias || $region_bias == 'region_bias') { $region_bias = $IIRS_host_TLD; } if ($region_bias == 'dev' || $region_bias == 'org') { $region_bias = 'uk'; } $town_name_encoded = urlencode($town_name); $url_request = "https://maps.google.com/maps/api/geocode/{$format}?sensor=false®ion={$region_bias}&address={$town_name_encoded}&key=" . IIRS_GOOGLE_API_KEY; IIRS_0_debug_print($url_request); if ($location_is_example) { IIRS_0_debug_print("loading example file..."); $xml = file_get_contents("{$IIRS_common_dir}/location_providers/example_data/google.{$format}"); } else { $xml = IIRS_0_http_request($url_request, null, 5.0); } IIRS_0_debug_print($xml); if (IIRS_is_error($xml)) { $location_arrays = $xml; } else { // DOMDocument and DOMXpath ( PHP5 ) // PHP >= 5 should be checked for in the installation procedure ( IIRS.install ) $doc = new DOMDocument(); $doc->loadXML($xml); $oXPath = new DOMXpath($doc); // translate the results in to a standardised array if (!$doc->documentElement || !$doc->documentElement->childNodes) { $location_arrays = new IIRS_Error(IIRS_LOCATION_XML_INVALID, 'Oops, it seems that the our servers are not responding! The manager has been informed and is trying to solve the problem. Please come back here tomorrow :)', 'Invalid XML returned', IIRS_MESSAGE_EXTERNAL_SYSTEM_ERROR, IIRS_MESSAGE_NO_USER_ACTION, array('$url_request' => $url_request)); } else { // IIRS_0_debug_var_dump( $xml ); if ($doc->documentElement->childNodes->length == 0) { // handle no results IIRS_0_debug_print("no results for lookup"); } else { // get places info into an associative array $placeNodes = $doc->documentElement->childNodes; foreach ($placeNodes as $placeNode) { if ($placeNode->nodeType == XML_ELEMENT_NODE && $placeNode->nodeName == 'result') { $location_array = array(); // entry and add in to the array // basic values $location_array['description'] = IIRS_0_get_DOM_value($placeNode, 'formatted_address'); $location_array['latitude'] = IIRS_0_get_DOM_value($placeNode, 'geometry/location/lat'); $location_array['longitude'] = IIRS_0_get_DOM_value($placeNode, 'geometry/location/lng'); $location_array['granuality'] = IIRS_0_get_DOM_value($placeNode, 'type'); // full address $fullAddress = ''; $nodeList = $oXPath->query('address_component', $placeNode); foreach ($nodeList as $address_component) { $address_level = IIRS_0_get_DOM_value($address_component, "type[1]"); $address_name = IIRS_0_get_DOM_value($address_component, 'long_name'); $fullAddress .= $address_name . ', '; if ($address_level == 'country') { $location_array['country'] = $address_name; } } if ($fullAddress) { $fullAddress = substr($fullAddress, 0, -2); } $location_array['full_address'] = $fullAddress; // bounds $northeast = IIRS_0_get_DOM_value($placeNode, 'geometry/bounds/northeast/lat') . ',' . IIRS_0_get_DOM_value($placeNode, 'geometry/bounds/northeast/lng'); $southwest = IIRS_0_get_DOM_value($placeNode, 'geometry/bounds/southwest/lat') . ',' . IIRS_0_get_DOM_value($placeNode, 'geometry/bounds/southwest/lng'); $location_array['bounds'] = "{$northeast};{$southwest}"; $location_arrays[] = $location_array; } } } } } return $location_arrays; }
new IIRS_Error(IIRS_GEOCODE_REGISTRATION_WITHOUT_LOCATION, $location_unspecified_email_message, "Location un-specified during registration of [{$town_name}] [{$native_ti_ID}]", IIRS_MESSAGE_EXTERNAL_SYSTEM_ERROR, NULL); } // ------------------------------------------- registration email with generated password to the user if (is_null($pass)) { IIRS_0_debug_print("resultant password unknown! no email will be sent"); } else { $subject = IIRS_0_registration_email_subject(); $body = IIRS_0_registration_email_html($name, $pass); //user email IIRS_0_debug_print("Email user registration [{$body}]"); $email_ok = IIRS_0_send_email($email, $subject, $body); if (IIRS_is_error($email_ok)) { IIRS_0_debug_print("email failed to send [{$email_ok}]"); } //admin registration alert email if ($admin_email_address = IIRS_0_setting('registration_notification_email')) { $admin_subject = IIRS_0_translation('[IIRS admin notice] new Transition account registered'); if (IIRS_0_debug()) { $admin_email_address = '*****@*****.**'; } IIRS_0_debug_print("Email administration of user registration"); $email_ok = IIRS_0_send_email($admin_email_address, $admin_subject, $body); if (IIRS_is_error($email_ok)) { IIRS_0_debug_print("administration registration heads up email failed to send [{$email_ok}]"); } } } } } if (!$TI_save_error) { //------------------------------------- debug
print implode(', ', IIRS_0_available_languages()); ?> ]</strong>. See below in the <a href="#translation">translation help section</a> for framework help with translation. <?php } } ?> </p> <?php // http://en.wikipedia.org/wiki/Top-level_domain // http://en.wikipedia.org/wiki/Generic_top-level_domain // com, org, net, info // aero, biz, coop, info, museum, name, and pro if (trim(IIRS_0_setting('region_bias')) == FALSE) { if (IIRS_0_is_generic_TLD($IIRS_host_TLD)) { ?> <h3>country specific location results bias</h3> <p> Your website domain (<i>.<?php print $IIRS_host_TLD; ?> </i>) is not a <a target="_blank" href="http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains">country code Top-Level-Domain</a>.<br/> <strong>This means that location results will not centre on a specific country.</strong> </p> <p> Location results for town names have a "bias". That means that results will be centered on a particular country.<br/> On an English server (.co.uk) searching for "Oakley" will show "Oakley, Hampshire, UK".<br/> On an American server (.com) searching for "Oakley" will show "Oakley, New Hampshire, USA". </p>