/** * GetLang * Returns the defined language variable based on the name passed in. * * If a default value is NOT specified (or specified to NULL), the function WILL STOP execution * whenever a language definition is NOT found. If it is specified, the function will * return the specified default value instead. * * @param String $langvar Name of the language variable to retrieve. * @param String $default Default value to be returned if language definition does not exists * * @return String Returns the defined string, if it doesn't exist (and default is not specified) the script execution will be halted. */ function GetLang($langvar = false, $default = null) { static $array_to_replace_from = false; static $array_to_replace_to = false; if (!$langvar) { return ''; } if (!defined('LNG_' . $langvar)) { // Language definition is not found, return a default value if it is defined if (!is_null($default)) { return strval($default); } // Make note of where the error occured $message = ''; if (function_exists('debug_backtrace')) { $btrace = debug_backtrace(); $called_from = $btrace[0]; $message = ' (Called from ' . basename($called_from['file']) . ', line ' . $called_from['line'] . ')'; } trigger_error("Langvar '{$langvar}' doesn't exist: " . $message, E_USER_NOTICE); return $langvar; } $var = constant('LNG_' . $langvar); if (!$array_to_replace_from || !$array_to_replace_to) { $agency_edition_info = get_agency_license_variables(); $array_to_replace_from = array('%%WHITELABEL_INFOTIPS%%', '%%IEM_SYSTEM_LICENSE_TRIALUSER_TRIALDAYS%%', '%%IEM_SYSTEM_LICENSE_TRIALUSER_EMAILLIMIT%%'); defined('LNG_NumberFormat_Thousands') or define('LNG_NumberFormat_Thousands', ','); defined('LNG_NumberFormat_Dec') or define('LNG_NumberFormat_Dec', '.'); $array_to_replace_to = array(IEM::enableInfoTipsGet(), $agency_edition_info['trial_days'], number_format((double) $agency_edition_info['trial_email_limit'], 0, LNG_NumberFormat_Dec, LNG_NumberFormat_Thousands)); } return str_replace($array_to_replace_from, $array_to_replace_to, $var); }
/** * Enter description here... * * @return Void Does not return anything * @todo phpdoc */ private function IEM_DefaultVariables() { static $variables = null; if (is_null($variables)) { $IEM = array('User' => GetUser(), 'ApplicationTitle' => GetLang('ApplicationTitle'), 'PageTitle' => GetLang('PageTitle'), 'CurrentPage' => IEM::requestGetGET('Page', IEM::requestGetGET('page', '')), 'ApplicationLogoImage' => APPLICATION_LOGO_IMAGE, 'ApplicationFavicon' => APPLICATION_FAVICON, 'InfoTips' => IEM::enableInfoTipsGet()); list($IEM['LicenseError'], $IEM['LicenseMessage']) = sesion_start(); IEM::sessionSet('LicenseError', $IEM['LicenseError']); if (!$IEM['LicenseError'] && isset($GLOBALS['ProductEdition'])) { $IEM['ApplicationTitle'] .= sprintf(GetLang('ApplicationTitleEdition'), $GLOBALS['ProductEdition']); } list($IEM['MenuLinks'], $IEM['TextLinks']) = $this->IEM_Menu(); $variables = $IEM; } return $variables; }
/** * PrintInterspireRSS * Print the latest info from an rss feed. * This also caches the feed for 24 hours so it's not going to constantly cause a remote hit * and should also mean subsequent views are a little faster. * If a url can't be fetched, the box on the front appears empty. * * @param String $rss_url The RSS URL to read in and process. * @param Int $number_to_display The number of entries to display from the rss feed. * * @return Void Doesn't return anything, just prints the top 5 entries from the feed. */ function PrintRSS($rss_url=false, $number_to_display=5) { if (!$rss_url) { return; } // make sure number_to_display is >= 1. if ((int)$number_to_display < 1) { $number_to_display = 5; } $check_version = false; $cache_file = TEMP_DIRECTORY . '/' . str_replace(array('/', '\\', '.', ';', '"', "'"), '', base64_encode($rss_url)).'.xml'; if (!is_file($cache_file)) { $check_version = true; } if (is_file($cache_file)) { $last_hit = filemtime($cache_file); if ($last_hit === false) { $check_version = true; } if ($last_hit < (time() - 86400)) { $check_version = true; } // if the file is empty.. if (filesize($cache_file) == 0) { $check_version = true; } } if ($check_version) { list($content, $error) = $this->GetPageContents($rss_url); if ($content !== false) { if (is_writable(TEMP_DIRECTORY)) { $fp = fopen($cache_file, 'w'); fputs($fp, $content); fclose($fp); } } } else { $content = file_get_contents($cache_file); } if ($content !== false) { $items = $this->FetchXMLNode('item',$content,true); $i = 0; foreach ($items as $item) { $url = $this->FetchXMLNode('link',$item); $title = $this->FetchXMLNode('title',$item); preg_match('%<\!\[cdata\[(.*?)\]\]>%is', $title, $matches); if (isset($matches[1])) { echo '<li><a href="' . $url . '" target="_blank" title="' . htmlspecialchars($matches[1], ENT_QUOTES, SENDSTUDIO_CHARSET) . '">' . $this->TruncateInMiddle($matches[1]) . '</a></li>'; } else { preg_match('/http:\/\/www\.viewkb\.com\/questions\/(\d*)\//is', $url, $matches); if (count($matches) == 2) { echo '<li><a href="#" onClick="LaunchHelp(\''.IEM::enableInfoTipsGet().'\',\'' . $matches[1] . '\');" title="' . htmlspecialchars($title, ENT_QUOTES, SENDSTUDIO_CHARSET) . '">' . $this->TruncateInMiddle($title) . '</a></li>'; } else { echo '<li><a href="' . $url . '" target="_blank" title="' . htmlspecialchars($title, ENT_QUOTES, SENDSTUDIO_CHARSET) . '">' . $this->TruncateInMiddle($title) . '</a></li>'; } } $i++; if ($i >= $number_to_display) { break; } } } }
/** * GenerateTextMenuLinks * Generates the text links at the top of the page - which include the home, "users" or "my account", logout links. * This is used by the template system when it prints out the header. * * If a license key error occurs, then this only shows the settings, logout and help links at the top. * It will not trigger an event to occur either (which addons will use to add themselves to the text links). * * Link areas are arrays which can be manipulated by addons if they are installed/enabled. * * A menu item can either be singular: * <code> * $links['area_name'] = array ( * array ( * 'text' => 'This is the link to click', * 'link' => 'index.php?Page=MyPage', * 'show' => true, * 'description' => 'This is the long description. It is used for the title tag and only shows when you hover over the link' * ) * ); * </code> * * or contain a dropdown menu: * <code> * $links['area_name'] = array ( * 'menudetails' => array ( * 'width' => 100, // this is the width in pixels for the dropdown menu * 'title' => 'What the dropdown menu is called', * 'description' => 'Long description which shows up when you hover over the dropdown link', * ), * array ( * 'text' => 'This is the first item in the menu', * 'link' => 'index.php?Page=MyPage', * 'show' => true, * 'description' => 'This is the long description. It is used for the title tag and only shows when you hover over the link' * ), * array ( * 'text' => 'This is the second item in the menu', * 'link' => 'index.php?Page=MyPage', * 'show' => true, * 'description' => 'This is the long description. It is used for the title tag and only shows when you hover over the link' * ), * ); * </code> * * The 'menudetails' are used to create the dropdown menu base. * * @see InterspireTemplate::IEM_Menu * * @return String Returns the string to display up the top. * * @uses EventData_IEM_SENDSTUDIOFUNCTIONS_GENERATETEXTMENULINKS */ static function GenerateTextMenuLinks() { $user = IEM::getCurrentUser(); $lke = IEM::sessionGet('LicenseError', false); // if there's an error with the lk, then just show the links to the settings page, logout & help. if ($lke && (!isset($_GET['Page']) || strtolower($_GET['Page']) == 'settings')) { $textlinks = ''; if ($user->HasAccess('Settings')) { $textlinks .= '<a href="index.php?Page=Settings" class="MenuText" title="' . GetLang('Menu_Settings_Description') . '">' . GetLang('Settings') . '</a>|'; } $textlinks .= '<a href="index.php?Page=Logout" class="MenuText" title="' . GetLang('Menu_Logout_Description') . '">' . GetLang('Logout') . '</a>|'; $textlinks .= '<a href="JavaScript:LaunchHelp(\''.IEM::enableInfoTipsGet().'\');" class="MenuText" title="' . GetLang('Menu_Help_Description') . '">' . GetLang('ShowHelp') . '</a>'; return $textlinks; } $links = array(); $links['home'] = array ( array ( 'text' => GetLang('Home'), 'link' => 'index.php', 'show' => true, 'description' => GetLang('Menu_Home_Description'), ) ); $links['templates'] = array ( 'menudetails' => array ( 'width' => '185', 'title' => GetLang('Menu_Templates'), 'description' => GetLang('Menu_Templates_Description'), ), array ( 'text' => GetLang('Menu_Templates_Manage'), 'link' => 'index.php?Page=Templates&Action=Manage', 'show' => $user->HasAccess('Templates', 'Manage'), 'description' => GetLang('Menu_Templates_Description'), 'image' => 'templates_view.gif' ), array ( 'text' => GetLang('Menu_Templates_Create'), 'link' => 'index.php?Page=Templates&Action=Create', 'show' => $user->HasAccess('Templates', 'Create'), 'description' => GetLang('Menu_Templates_Create_Description'), 'image' => 'templates_add.gif' ), array ( 'text' => GetLang('Menu_Templates_Manage_BuiltIn'), 'link' => 'index.php?Page=Templates&Action=BuiltIn', 'show' => $user->HasAccess('Templates', 'BuiltIn'), 'description' => GetLang('Menu_Templates_Manage_Description'), 'image' => 'templates_builtin.gif' ), ); $links['forms'] = array ( 'menudetails' => array( 'width' => '145', 'title' => GetLang('Menu_Forms'), 'show' => $user->HasAccess('Forms'), 'description' => GetLang('Menu_Website_Forms_Description'), ), array ( 'text' => GetLang('Menu_Website_Forms'), 'link' => 'index.php?Page=Forms', 'show' => $user->HasAccess('Forms'), 'description' => GetLang('Menu_Website_Forms_Description'), 'image' => 'forms_view.gif' ), array ( 'text' => GetLang('Menu_Create_Form'), 'link' => 'index.php?Page=Forms&Action=create', 'show' => $user->HasAccess('Forms','Create'), 'description' => GetLang('Menu_Create_Form_Description'), 'image' => 'forms_add.gif' ), ); if (!$user->isAdmin() && $user->EditOwnSettings()) { $links['manageaccount'] = array ( array ( 'text' => GetLang('MyAccount'), 'link' => 'index.php?Page=ManageAccount', 'show' => true, 'description' => GetLang('Menu_Users_Own_Description'), ) ); } if ($user->isUserAdmin()) { $add_user_disabled = false; $temp = get_available_user_count(); if ($temp['normal'] == 0 && $temp['trial'] == 0) { $add_user_disabled = true; } $links['users'] = array ( 'menudetails' => array( 'width' => '140', 'title' => GetLang('Menu_UsersGroups'), 'show' => true, 'description' => GetLang('MenuDescription_UsersGroups'), ), array ( 'text' => GetLang('Menu_UsersGroups_ManageUsers'), 'link' => 'index.php?Page=Users', 'show' => true, ), array ( 'text' => GetLang('Menu_UsersGroups_CreateUser'), 'link' => 'index.php?Page=Users&Action=Add', 'show' => !$add_user_disabled, ), null, array ( 'text' => GetLang('Menu_UsersGroups_ManageGroups'), 'link' => 'index.php?Page=UsersGroups', 'show' => true, ), array ( 'text' => GetLang('Menu_UsersGroups_CreateGroup'), 'link' => 'index.php?Page=UsersGroups&Action=createGroup', 'show' => true, ), ); } if ($user->Admin()) { $links['settings'] = array ( 'menudetails' => array( 'width' => '145', 'title' => GetLang('Settings'), 'show' => true, 'description' => GetLang('Menu_Settings_Description'), ), array ( 'text' => GetLang('ApplicationSettings_Heading'), 'link' => 'index.php?Page=Settings&Tab=1', 'show' => true, ), array ( 'text' => GetLang('EmailSettings_Heading'), 'link' => 'index.php?Page=Settings&Tab=2', 'show' => true, ), array ( 'text' => GetLang('BounceSettings_Heading'), 'link' => 'index.php?Page=Settings&Tab=7', 'show' => true, ), array ( 'text' => GetLang('CreditSettings_Heading'), 'link' => 'index.php?Page=Settings&Tab=3', 'show' => true, ), array ( 'text' => GetLang('CronSettings_Heading'), 'link' => 'index.php?Page=Settings&Tab=4', 'show' => true, ), array ( 'text' => GetLang('PrivateLabelSettings_Heading'), 'link' => 'index.php?Page=Settings&Tab=8', 'show' => (defined('APPLICATION_SHOW_WHITELABEL_MENU')? constant('APPLICATION_SHOW_WHITELABEL_MENU') : true), ), array ( 'text' => GetLang('SecuritySettings_Heading'), 'link' => 'index.php?Page=Settings&Tab=5', 'show' => true, ), array ( 'text' => GetLang('AddonsSettings_Heading'), 'link' => 'index.php?Page=Settings&Tab=6', 'show' => true, ), ); $links['tools'] = array ( 'menudetails' => array ( 'width' => '140', 'title' => GetLang('Menu_Tools'), 'description' => GetLang('Menu_Tools_Description') ), array ( 'text' => GetLang('Menu_Tools_SystemInformation'), 'link' => 'index.php?Page=Settings&Action=SystemInfo', 'show' => true, 'description' => GetLang('Menu_Tools_SystemInformation_Description'), ) ); } $links['logout'] = array ( array ( 'text' => GetLang('Logout'), 'link' => 'index.php?Page=Logout', 'description' => GetLang('Menu_Logout_Description'), ) ); $links['help'] = array ( array ( 'text' => GetLang('ShowHelp'), 'link' => 'JavaScript:LaunchHelp(\''.IEM::enableInfoTipsGet().'\');', 'description' => GetLang('Menu_Help_Description') ) ); /** * Trigger event */ $tempEventData = new EventData_IEM_SENDSTUDIOFUNCTIONS_GENERATETEXTMENULINKS(); $tempEventData->data = &$links; $tempEventData->trigger(); unset($tempEventData); /** * ----- */ $textlinks = ''; /** * Go through the link areas and work out if it's a normal link or whether it should be a menu. * If it has a 'menudetails' section set, then it's going to be a dropdown menu. * The menudetails array must contain: * - title (used as the link name) * - description (used as the link title) * - width of the menu (in px) * * If those details are found, then it's turned into a dropdown menu rather than just a link. */ foreach ($links as $link_area => $sublinks) { $has_submenu = false; if (isset($sublinks['menudetails'])) { $has_submenu = true; } if (isset($sublinks['show']) && $sublinks['show'] == false) { continue; } if (!$has_submenu) { $link_details = array_pop($sublinks); $textlinks .= '<a href="' . $link_details['link'] . '" class="MenuText" title="' . htmlspecialchars($link_details['description'], ENT_QUOTES, SENDSTUDIO_CHARSET) . '">' . htmlspecialchars($link_details['text'], ENT_QUOTES, SENDSTUDIO_CHARSET) . '</a>|'; continue; } $id = ucfirst($link_area); $width = '100'; $width = (int) $sublinks['menudetails']['width']; $sublink = '<a href="#" title="' . htmlspecialchars($links[$link_area]['menudetails']['description'], ENT_QUOTES, SENDSTUDIO_CHARSET) . '" id="' . $id . 'MenuButton" class="PopDownMenu MenuText">' . htmlspecialchars($links[$link_area]['menudetails']['title'], ENT_QUOTES, SENDSTUDIO_CHARSET) . '<img src="images/arrow_down_white.gif" border="0" style="position: relative;" /></a><div id="' . $id . 'Menu" style="display: none; width: ' . $width . 'px;" class="DropDownMenu DropShadow">' . '<ul>'; unset($sublinks['menudetails']); foreach ($sublinks as $link_details) { if (is_null($link_details)) { $sublink .= '<li><hr /></li>'; continue; } if (isset($link_details['show']) && $link_details['show'] == false) { continue; } $sublink .= '<li><a href="' . $link_details['link'] . '">' . $link_details['text'] . '</a></li>'; } $sublink .= '</ul></div>|'; $textlinks .= $sublink; } $textlinks = rtrim($textlinks, '|'); return $textlinks; }
/** * handle * Perform the appropriate action after the Bounce Test popup has completed. * For manual bounce processing, this will redirect to the next step. * For other cases it will either report success and close or display the error. * * @param string $type One of 'next_combo', 'error_report' or 'success'. * @param boolean $in_place Whether the action should take place in the popup (true) or redirect. * * @return void Does not return anything. It prints JavaScript (ugh!). */ private static function handle($type, $in_place) { $bd = self::hold('TestBounceDetails'); $root = 'index.php?Page=Bounce&Action='; $urls = array( 'next_combo' => array('TestBounceSettings', 'window', 150), 'error_report' => array('BounceStep2Warning', 'self.parent.parent', 0), 'success' => array('BounceStep3', 'self.parent.parent', 0) ); if (!$in_place || $type == 'next_combo') { $url = $root . $urls[$type][0]; $url .= $in_place ? '&InPlace=true' : ''; self::setJSRedirect($url, $urls[$type][1], $urls[$type][2]); exit(); } // Replace the progress bar with a message. // TODO: work out some nicer way to do this. echo "<script src=\"includes/js/jquery.js\"></script>\n"; if ($type == 'error_report') { // Alert the appropriate error. $error = self::getRealError(self::hold('ConnectionErrors')); $tpl = GetTemplateSystem(); $GLOBALS['Error'] = "<strong>" . $error['name'] . "</strong>"; $GLOBALS['Error'] .= "<ul style=\"padding-left:2em;\">"; foreach ($error['advice'] as $title => $article) { $GLOBALS['Error'] .= "<li><a href=\"javascript:LaunchHelp('".IEM::enableInfoTipsGet()."',{$article});\">{$title}</a></li>\n"; } $GLOBALS['Error'] .= "</ul>"; $msg = $tpl->ParseTemplate('ErrorMsg', true); } elseif ($type == 'success') { // Set the combo in the UI and disappear. $msg = self::PrintSuccess('BounceLogin_Successful'); } $msg = str_replace("\n", '\n', addslashes($msg)); echo "<script> parent.$('#ProgressReportContainer > div').hide(); parent.$('#ProgressReportMessage').html('{$msg}'); parent.$('#ProgressReportTitle').show(); parent.$('#ProgressReportMessage').show();\n"; if ($type == 'success') { echo "self.parent.parent.$('#bounce_extrasettings').val('{$bd['extra_settings']}');\n"; echo "self.parent.parent.Application.Page.BounceInfo.evaluateCheckboxes();\n"; echo "setTimeout(function() { self.parent.parent.tb_remove(); }, 1500);\n"; } else { echo "parent.$('#ProgressReportWindow_Close').show();\n"; } echo "</script>\n"; exit(); }