AAAAhome/academiac/www/modules/mod_search/helper.php000064400000001305151372117150015755 0ustar00home/academiac/www/modules/mod_finder/helper.php000064400000004370151372530670015772 0ustar00getVar('Itemid'); $fields = array(); $uri = JURI::getInstance(JRoute::_($route)); $uri->delVar('q'); // Create hidden input elements for each part of the URI. foreach ($uri->getQuery(true) as $n => $v) { $fields[] = ''; } // Add a field for Itemid if we need one. if ($needId) { $id = JFactory::getApplication()->input->get('Itemid', '0', 'int'); $fields[] = ''; } return implode('', $fields); } /** * Get Smart Search query object. * * @param JRegistry object containing module parameters. * * @return FinderIndexerQuery object * * @since 2.5 */ public static function getQuery($params) { $app = JFactory::getApplication(); $input = $app->input; $request = $input->request; $filter = JFilterInput::getInstance(); // Get the static taxonomy filters. $options = array(); $options['filter'] = ($request->get('f', 0, 'int') != 0) ? $request->get('f', '', 'int') : $params->get('searchfilter'); $options['filter'] = $filter->clean($options['filter'], 'int'); // Get the dynamic taxonomy filters. $options['filters'] = $request->get('t', '', 'array'); $options['filters'] = $filter->clean($options['filters'], 'array'); JArrayHelper::toInteger($options['filters']); // Instantiate a query object. $query = new FinderIndexerQuery($options); return $query; } } home/academiac/www/modules/mod_wrapper/helper.php000064400000002214151372547760016206 0ustar00def('url', ''); $params->def('scrolling', 'auto'); $params->def('height', '200'); $params->def('height_auto', '0'); $params->def('width', '100%'); $params->def('add', '1'); $params->def('name', 'wrapper'); $url = $params->get('url'); if ($params->get('add')) { // adds 'http://' if none is set if (substr($url, 0, 1) == '/') { // relative url in component. use server http_host. $url = 'http://'.$_SERVER['HTTP_HOST'].$url; } elseif (!strstr($url, 'http') && !strstr($url, 'https')) { $url = 'http://'.$url; } else { $url = $url; } } // auto height control if ($params->def('height_auto')) { $load = 'onload="iFrameHeight()"'; } else { $load = ''; } $params->set('load', $load); $params->set('url', $url); return $params; } } home/academiac/www/libraries/joomla/application/helper.php000064400000024163151372561300017750 0ustar00id = 0; $obj->name = 'site'; $obj->path = JPATH_SITE; self::$_clients[0] = clone $obj; // Administrator Client $obj->id = 1; $obj->name = 'administrator'; $obj->path = JPATH_ADMINISTRATOR; self::$_clients[1] = clone $obj; // Installation Client $obj->id = 2; $obj->name = 'installation'; $obj->path = JPATH_INSTALLATION; self::$_clients[2] = clone $obj; } // If no client id has been passed return the whole array if (is_null($id)) { return self::$_clients; } // Are we looking for client information by id or by name? if (!$byName) { if (isset(self::$_clients[$id])) { return self::$_clients[$id]; } } else { foreach (self::$_clients as $client) { if ($client->name == strtolower($id)) { return $client; } } } return null; } /** * Adds information for a client. * * @param mixed $client A client identifier either an array or object * * @return boolean True if the information is added. False on error * * @since 11.1 */ public static function addClientInfo($client) { if (is_array($client)) { $client = (object) $client; } if (!is_object($client)) { return false; } $info = self::getClientInfo(); if (!isset($client->id)) { $client->id = count($info); } self::$_clients[$client->id] = clone $client; return true; } /** * Get a path * * @param string $varname Identify location or type of xml * @param string $user_option Option (e.g. com_something) used to find path. * * @return string The requested path * * @since 11.1 * @deprecated 12.1 */ public static function getPath($varname, $user_option = null) { // Check needed for handling of custom/new module XML file loading $check = (($varname == 'mod0_xml') || ($varname == 'mod1_xml')); if (!$user_option && !$check) { $user_option = JRequest::getCmd('option'); } else { $user_option = JFilterInput::getInstance()->clean($user_option, 'path'); } $result = null; $name = substr($user_option, 4); switch ($varname) { case 'front': $result = self::_checkPath('/components/' . $user_option . '/' . $name . '.php', 0); break; case 'html': case 'front_html': if (!($result = self::_checkPath('/templates/' . JApplication::getTemplate() . '/components/' . $name . '.html.php', 0))) { $result = self::_checkPath('/components/' . $user_option . '/' . $name . '.html.php', 0); } break; case 'toolbar': $result = self::_checkPath('/components/' . $user_option . '/toolbar.' . $name . '.php', -1); break; case 'toolbar_html': $result = self::_checkPath('/components/' . $user_option . '/toolbar.' . $name . '.html.php', -1); break; case 'toolbar_default': case 'toolbar_front': $result = self::_checkPath('/includes/HTML_toolbar.php', 0); break; case 'admin': $path = '/components/' . $user_option . '/admin.' . $name . '.php'; $result = self::_checkPath($path, -1); if ($result == null) { $path = '/components/' . $user_option . '/' . $name . '.php'; $result = self::_checkPath($path, -1); } break; case 'admin_html': $path = '/components/' . $user_option . '/admin.' . $name . '.html.php'; $result = self::_checkPath($path, -1); break; case 'admin_functions': $path = '/components/' . $user_option . '/' . $name . '.functions.php'; $result = self::_checkPath($path, -1); break; case 'class': if (!($result = self::_checkPath('/components/' . $user_option . '/' . $name . '.class.php'))) { $result = self::_checkPath('/includes/' . $name . '.php'); } break; case 'helper': $path = '/components/' . $user_option . '/' . $name . '.helper.php'; $result = self::_checkPath($path); break; case 'com_xml': $path = '/components/' . $user_option . '/' . $name . '.xml'; $result = self::_checkPath($path, 1); break; case 'mod0_xml': $path = '/modules/' . $user_option . '/' . $user_option . '.xml'; $result = self::_checkPath($path); break; case 'mod1_xml': // Admin modules $path = '/modules/' . $user_option . '/' . $user_option . '.xml'; $result = self::_checkPath($path, -1); break; case 'plg_xml': // Site plugins $j15path = '/plugins/' . $user_option . '.xml'; $parts = explode(DIRECTORY_SEPARATOR, $user_option); $j16path = '/plugins/' . $user_option . '/' . $parts[1] . '.xml'; $j15 = self::_checkPath($j15path, 0); $j16 = self::_checkPath($j16path, 0); // Return 1.6 if working otherwise default to whatever 1.5 gives us $result = $j16 ? $j16 : $j15; break; case 'menu_xml': $path = '/components/com_menus/' . $user_option . '/' . $user_option . '.xml'; $result = self::_checkPath($path, -1); break; } return $result; } /** * Parse a XML install manifest file. * * XML Root tag should be 'install' except for languages which use meta file. * * @param string $path Full path to XML file. * * @return array XML metadata. * * @since 11.1 * @deprecated 13.3 Use JInstaller::parseXMLInstallFile instead. * @note This method must remain as is to allow updates from 2.5.4 and earlier sites to work. */ public static function parseXMLInstallFile($path) { JLog::add('JApplicationHelper::parseXMLInstallFile is deprecated. Use JInstaller::parseXMLInstallFile instead.', JLog::WARNING, 'deprecated'); // Read the file to see if it's a valid component XML file if (!$xml = JFactory::getXML($path)) { return false; } // Check for a valid XML root tag. // Should be 'install', but for backward compatibility we will accept 'extension'. // Languages use 'metafile' instead if ($xml->getName() != 'install' && $xml->getName() != 'extension' && $xml->getName() != 'metafile') { unset($xml); return false; } $data = array(); $data['legacy'] = ($xml->getName() == 'mosinstall' || $xml->getName() == 'install'); $data['name'] = (string) $xml->name; // Check if we're a language. If so use metafile. $data['type'] = $xml->getName() == 'metafile' ? 'language' : (string) $xml->attributes()->type; $data['creationDate'] = ((string) $xml->creationDate) ? (string) $xml->creationDate : JText::_('Unknown'); $data['author'] = ((string) $xml->author) ? (string) $xml->author : JText::_('Unknown'); $data['copyright'] = (string) $xml->copyright; $data['authorEmail'] = (string) $xml->authorEmail; $data['authorUrl'] = (string) $xml->authorUrl; $data['version'] = (string) $xml->version; $data['description'] = (string) $xml->description; $data['group'] = (string) $xml->group; return $data; } /** * Parse a XML language meta file. * * XML Root tag for languages which is meta file. * * @param string $path Full path to XML file. * * @return array XML metadata. */ public static function parseXMLLangMetaFile($path) { // Read the file to see if it's a valid component XML file $xml = JFactory::getXML($path); if (!$xml) { return false; } /* * Check for a valid XML root tag. * * Should be 'langMetaData'. */ if ($xml->getName() != 'metafile') { unset($xml); return false; } $data = array(); $data['name'] = (string) $xml->name; $data['type'] = $xml->attributes()->type; $data['creationDate'] = ((string) $xml->creationDate) ? (string) $xml->creationDate : JText::_('JLIB_UNKNOWN'); $data['author'] = ((string) $xml->author) ? (string) $xml->author : JText::_('JLIB_UNKNOWN'); $data['copyright'] = (string) $xml->copyright; $data['authorEmail'] = (string) $xml->authorEmail; $data['authorUrl'] = (string) $xml->authorUrl; $data['version'] = (string) $xml->version; $data['description'] = (string) $xml->description; $data['group'] = (string) $xml->group; return $data; } /** * Tries to find a file in the administrator or site areas * * @param string $path A file name * @param integer $checkAdmin 0 to check site only, 1 to check site and admin, -1 to check admin only * * @return string File name or null * * @since 11.1 * @deprecated 12.1 */ protected static function _checkPath($path, $checkAdmin = 1) { $file = JPATH_SITE . $path; if ($checkAdmin > -1 && file_exists($file)) { return $file; } elseif ($checkAdmin != 0) { $file = JPATH_ADMINISTRATOR . $path; if (file_exists($file)) { return $file; } } return null; } } home/academiac/www/libraries/joomla/user/helper.php000064400000041065151372565400016430 0ustar00groups)) { // Get the title of the group. $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName('title')); $query->from($db->quoteName('#__usergroups')); $query->where($db->quoteName('id') . ' = ' . (int) $groupId); $db->setQuery($query); $title = $db->loadResult(); // Check for a database error. if ($db->getErrorNum()) { return new Exception($db->getErrorMsg()); } // If the group does not exist, return an exception. if (!$title) { return new Exception(JText::_('JLIB_USER_EXCEPTION_ACCESS_USERGROUP_INVALID')); } // Add the group data to the user object. $user->groups[$title] = $groupId; // Store the user object. if (!$user->save()) { return new Exception($user->getError()); } } // Set the group data for any preloaded user objects. $temp = JFactory::getUser((int) $userId); $temp->groups = $user->groups; // Set the group data for the user object in the session. $temp = JFactory::getUser(); if ($temp->id == $userId) { $temp->groups = $user->groups; } return true; } /** * Method to get a list of groups a user is in. * * @param integer $userId The id of the user. * * @return mixed Array on success, JException on error. * * @since 11.1 */ public static function getUserGroups($userId) { // Get the user object. $user = JUser::getInstance((int) $userId); return isset($user->groups) ? $user->groups : array(); } /** * Method to remove a user from a group. * * @param integer $userId The id of the user. * @param integer $groupId The id of the group. * * @return mixed Boolean true on success, JException on error. * * @since 11.1 */ public static function removeUserFromGroup($userId, $groupId) { // Get the user object. $user = JUser::getInstance((int) $userId); // Remove the user from the group if necessary. $key = array_search($groupId, $user->groups); if ($key !== false) { // Remove the user from the group. unset($user->groups[$key]); // Store the user object. if (!$user->save()) { return new JException($user->getError()); } } // Set the group data for any preloaded user objects. $temp = JFactory::getUser((int) $userId); $temp->groups = $user->groups; // Set the group data for the user object in the session. $temp = JFactory::getUser(); if ($temp->id == $userId) { $temp->groups = $user->groups; } return true; } /** * Method to set the groups for a user. * * @param integer $userId The id of the user. * @param array $groups An array of group ids to put the user in. * * @return mixed Boolean true on success, Exception on error. * * @since 11.1 */ public static function setUserGroups($userId, $groups) { // Get the user object. $user = JUser::getInstance((int) $userId); // Set the group ids. JArrayHelper::toInteger($groups); $user->groups = $groups; // Get the titles for the user groups. $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName('id') . ', ' . $db->quoteName('title')); $query->from($db->quoteName('#__usergroups')); $query->where($db->quoteName('id') . ' = ' . implode(' OR ' . $db->quoteName('id') . ' = ', $user->groups)); $db->setQuery($query); $results = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { return new Exception($db->getErrorMsg()); } // Set the titles for the user groups. for ($i = 0, $n = count($results); $i < $n; $i++) { $user->groups[$results[$i]->id] = $results[$i]->title; } // Store the user object. if (!$user->save()) { return new Exception($user->getError()); } // Set the group data for any preloaded user objects. $temp = JFactory::getUser((int) $userId); $temp->groups = $user->groups; // Set the group data for the user object in the session. $temp = JFactory::getUser(); if ($temp->id == $userId) { $temp->groups = $user->groups; } return true; } /** * Gets the user profile information * * @param integer $userId The id of the user. * * @return object * * @since 11.1 */ public static function getProfile($userId = 0) { if ($userId == 0) { $user = JFactory::getUser(); $userId = $user->id; } // Get the dispatcher and load the user's plugins. $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('user'); $data = new JObject; $data->id = $userId; // Trigger the data preparation event. $dispatcher->trigger('onContentPrepareData', array('com_users.profile', &$data)); return $data; } /** * Method to activate a user * * @param string $activation Activation string * * @return boolean True on success * * @since 11.1 */ public static function activateUser($activation) { // Initialize some variables. $db = JFactory::getDbo(); $query = $db->getQuery(true); // Let's get the id of the user we want to activate $query->select($db->quoteName('id')); $query->from($db->quoteName('#__users')); $query->where($db->quoteName('activation') . ' = ' . $db->quote($activation)); $query->where($db->quoteName('block') . ' = 1'); $query->where($db->quoteName('lastvisitDate') . ' = ' . $db->quote('0000-00-00 00:00:00')); $db->setQuery($query); $id = intval($db->loadResult()); // Is it a valid user to activate? if ($id) { $user = JUser::getInstance((int) $id); $user->set('block', '0'); $user->set('activation', ''); // Time to take care of business.... store the user. if (!$user->save()) { JError::raiseWarning("SOME_ERROR_CODE", $user->getError()); return false; } } else { JError::raiseWarning("SOME_ERROR_CODE", JText::_('JLIB_USER_ERROR_UNABLE_TO_FIND_USER')); return false; } return true; } /** * Returns userid if a user exists * * @param string $username The username to search on. * * @return integer The user id or 0 if not found. * * @since 11.1 */ public static function getUserId($username) { // Initialise some variables $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName('id')); $query->from($db->quoteName('#__users')); $query->where($db->quoteName('username') . ' = ' . $db->quote($username)); $db->setQuery($query, 0, 1); return $db->loadResult(); } /** * Hashes a password using the current encryption. * * @param string $password The plaintext password to encrypt. * * @return string The encrypted password. * * @since 3.2.1 */ public static function hashPassword($password) { // Use PHPass's portable hashes with a cost of 10. $phpass = new PasswordHash(10, true); return $phpass->HashPassword($password); } /** * Formats a password using the current encryption. If the user ID is given * and the hash does not fit the current hashing algorithm, it automatically * updates the hash. * * @param string $password The plaintext password to check. * @param string $hash The hash to verify against. * @param integer $user_id ID of the user if the password hash should be updated * * @return boolean True if the password and hash match, false otherwise * * @since 3.2.1 */ public static function verifyPassword($password, $hash, $user_id = 0) { $rehash = false; $match = false; // If we are using phpass if (strpos($hash, '$P$') === 0) { // Use PHPass's portable hashes with a cost of 10. $phpass = new PasswordHash(10, true); $match = $phpass->CheckPassword($password, $hash); $rehash = false; } else { // Check the password $parts = explode(':', $hash); $crypt = $parts[0]; $salt = @$parts[1]; $rehash = true; $testcrypt = md5($password . $salt) . ($salt ? ':' . $salt : ''); $match = JCrypt::timingSafeCompare($hash, $testcrypt); } // If we have a match and rehash = true, rehash the password with the current algorithm. if ((int) $user_id > 0 && $match && $rehash) { $user = new JUser($user_id); $user->password = self::hashPassword($password); $user->save(); } return $match; } /** * Formats a password using the current encryption. * * @param string $plaintext The plaintext password to encrypt. * @param string $salt The salt to use to encrypt the password. [] * If not present, a new salt will be * generated. * @param string $encryption The kind of password encryption to use. * Defaults to md5-hex. * @param boolean $show_encrypt Some password systems prepend the kind of * encryption to the crypted password ({SHA}, * etc). Defaults to false. * * @return string The encrypted password. * * @since 11.1 * * @deprecated 4.0 */ public static function getCryptedPassword($plaintext, $salt = '', $encryption = 'md5-hex', $show_encrypt = false) { // Get the salt to use. $salt = JUserHelper::getSalt($encryption, $salt, $plaintext); // Encrypt the password. switch ($encryption) { case 'plain': return $plaintext; case 'sha': $encrypted = base64_encode(mhash(MHASH_SHA1, $plaintext)); return ($show_encrypt) ? '{SHA}' . $encrypted : $encrypted; case 'crypt': case 'crypt-des': case 'crypt-md5': case 'crypt-blowfish': return ($show_encrypt ? '{crypt}' : '') . crypt($plaintext, $salt); case 'md5-base64': $encrypted = base64_encode(mhash(MHASH_MD5, $plaintext)); return ($show_encrypt) ? '{MD5}' . $encrypted : $encrypted; case 'ssha': $encrypted = base64_encode(mhash(MHASH_SHA1, $plaintext . $salt) . $salt); return ($show_encrypt) ? '{SSHA}' . $encrypted : $encrypted; case 'smd5': $encrypted = base64_encode(mhash(MHASH_MD5, $plaintext . $salt) . $salt); return ($show_encrypt) ? '{SMD5}' . $encrypted : $encrypted; case 'aprmd5': $length = strlen($plaintext); $context = $plaintext . '$apr1$' . $salt; $binary = JUserHelper::_bin(md5($plaintext . $salt . $plaintext)); for ($i = $length; $i > 0; $i -= 16) { $context .= substr($binary, 0, ($i > 16 ? 16 : $i)); } for ($i = $length; $i > 0; $i >>= 1) { $context .= ($i & 1) ? chr(0) : $plaintext[0]; } $binary = JUserHelper::_bin(md5($context)); for ($i = 0; $i < 1000; $i++) { $new = ($i & 1) ? $plaintext : substr($binary, 0, 16); if ($i % 3) { $new .= $salt; } if ($i % 7) { $new .= $plaintext; } $new .= ($i & 1) ? substr($binary, 0, 16) : $plaintext; $binary = JUserHelper::_bin(md5($new)); } $p = array(); for ($i = 0; $i < 5; $i++) { $k = $i + 6; $j = $i + 12; if ($j == 16) { $j = 5; } $p[] = JUserHelper::_toAPRMD5((ord($binary[$i]) << 16) | (ord($binary[$k]) << 8) | (ord($binary[$j])), 5); } return '$apr1$' . $salt . '$' . implode('', $p) . JUserHelper::_toAPRMD5(ord($binary[11]), 3); case 'md5-hex': default: $encrypted = ($salt) ? md5($plaintext . $salt) : md5($plaintext); return ($show_encrypt) ? '{MD5}' . $encrypted : $encrypted; } } /** * Returns a salt for the appropriate kind of password encryption. * Optionally takes a seed and a plaintext password, to extract the seed * of an existing password, or for encryption types that use the plaintext * in the generation of the salt. * * @param string $encryption The kind of password encryption to use. * Defaults to md5-hex. * @param string $seed The seed to get the salt from (probably a * previously generated password). Defaults to * generating a new seed. * @param string $plaintext The plaintext password that we're generating * a salt for. Defaults to none. * * @return string The generated or extracted salt. * * @since 11.1 */ public static function getSalt($encryption = 'md5-hex', $seed = '', $plaintext = '') { // Encrypt the password. switch ($encryption) { case 'crypt': case 'crypt-des': if ($seed) { return substr(preg_replace('|^{crypt}|i', '', $seed), 0, 2); } else { return substr(md5(mt_rand()), 0, 2); } break; case 'crypt-md5': if ($seed) { return substr(preg_replace('|^{crypt}|i', '', $seed), 0, 12); } else { return '$1$' . substr(md5(mt_rand()), 0, 8) . '$'; } break; case 'crypt-blowfish': if ($seed) { return substr(preg_replace('|^{crypt}|i', '', $seed), 0, 16); } else { return '$2$' . substr(md5(mt_rand()), 0, 12) . '$'; } break; case 'ssha': if ($seed) { return substr(preg_replace('|^{SSHA}|', '', $seed), -20); } else { return mhash_keygen_s2k(MHASH_SHA1, $plaintext, substr(pack('h*', md5(mt_rand())), 0, 8), 4); } break; case 'smd5': if ($seed) { return substr(preg_replace('|^{SMD5}|', '', $seed), -16); } else { return mhash_keygen_s2k(MHASH_MD5, $plaintext, substr(pack('h*', md5(mt_rand())), 0, 8), 4); } break; case 'aprmd5': /* 64 characters that are valid for APRMD5 passwords. */ $APRMD5 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; if ($seed) { return substr(preg_replace('/^\$apr1\$(.{8}).*/', '\\1', $seed), 0, 8); } else { $salt = ''; for ($i = 0; $i < 8; $i++) { $salt .= $APRMD5{rand(0, 63)}; } return $salt; } break; default: $salt = ''; if ($seed) { $salt = $seed; } return $salt; break; } } /** * Generate a random password * * @param integer $length Length of the password to generate * * @return string Random Password * * @since 11.1 */ public static function genRandomPassword($length = 8) { $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $base = strlen($salt); $makepass = ''; /* * Start with a cryptographic strength random string, then convert it to * a string with the numeric base of the salt. * Shift the base conversion on each character so the character * distribution is even, and randomize the start shift so it's not * predictable. */ $random = JCrypt::genRandomBytes($length + 1); $shift = ord($random[0]); for ($i = 1; $i <= $length; ++$i) { $makepass .= $salt[($shift + ord($random[$i])) % $base]; $shift += ord($random[$i]); } return $makepass; } /** * Converts to allowed 64 characters for APRMD5 passwords. * * @param string $value The value to convert. * @param integer $count The number of characters to convert. * * @return string $value converted to the 64 MD5 characters. * * @since 11.1 */ protected static function _toAPRMD5($value, $count) { /* 64 characters that are valid for APRMD5 passwords. */ $APRMD5 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; $aprmd5 = ''; $count = abs($count); while (--$count) { $aprmd5 .= $APRMD5[$value & 0x3f]; $value >>= 6; } return $aprmd5; } /** * Converts hexadecimal string to binary data. * * @param string $hex Hex data. * * @return string Binary data. * * @since 11.1 */ private static function _bin($hex) { $bin = ''; $length = strlen($hex); for ($i = 0; $i < $length; $i += 2) { $tmp = sscanf(substr($hex, $i, 2), '%x'); $bin .= chr(array_shift($tmp)); } return $bin; } } home/academiac/www/libraries/joomla/application/component/helper.php000064400000025666151372623420021765 0ustar00enabled = $strict ? false : true; $result->params = new JRegistry; } } else { $result = self::$components[$option]; } return $result; } /** * Checks if the component is enabled * * @param string $option The component option. * @param boolean $strict If set and the component does not exist, false will be returned. * * @return boolean * * @since 11.1 */ public static function isEnabled($option, $strict = false) { $result = self::getComponent($option, $strict); return ($result->enabled | JFactory::getApplication()->isAdmin()); } /** * Gets the parameter object for the component * * @param string $option The option for the component. * @param boolean $strict If set and the component does not exist, false will be returned * * @return JRegistry A JRegistry object. * * @see JRegistry * @since 11.1 */ public static function getParams($option, $strict = false) { $component = self::getComponent($option, $strict); return $component->params; } /** * Applies the global text filters to arbitrary text as per settings for current user groups * * @param string $text The string to filter * * @return string The filtered string * * @since 11.4 */ public static function filterText($text) { // Filter settings $config = self::getParams('com_config'); $user = JFactory::getUser(); $userGroups = JAccess::getGroupsByUser($user->get('id')); $filters = $config->get('filters'); $blackListTags = array(); $blackListAttributes = array(); $customListTags = array(); $customListAttributes = array(); $whiteListTags = array(); $whiteListAttributes = array(); $noHtml = false; $whiteList = false; $blackList = false; $customList = false; $unfiltered = false; // Cycle through each of the user groups the user is in. // Remember they are included in the Public group as well. foreach ($userGroups as $groupId) { // May have added a group by not saved the filters. if (!isset($filters->$groupId)) { continue; } // Each group the user is in could have different filtering properties. $filterData = $filters->$groupId; $filterType = strtoupper($filterData->filter_type); if ($filterType == 'NH') { // Maximum HTML filtering. $noHtml = true; } elseif ($filterType == 'NONE') { // No HTML filtering. $unfiltered = true; } else { // Black or white list. // Preprocess the tags and attributes. $tags = explode(',', $filterData->filter_tags); $attributes = explode(',', $filterData->filter_attributes); $tempTags = array(); $tempAttributes = array(); foreach ($tags as $tag) { $tag = trim($tag); if ($tag) { $tempTags[] = $tag; } } foreach ($attributes as $attribute) { $attribute = trim($attribute); if ($attribute) { $tempAttributes[] = $attribute; } } // Collect the black or white list tags and attributes. // Each list is cummulative. if ($filterType == 'BL') { $blackList = true; $blackListTags = array_merge($blackListTags, $tempTags); $blackListAttributes = array_merge($blackListAttributes, $tempAttributes); } elseif ($filterType == 'CBL') { // Only set to true if Tags or Attributes were added if ($tempTags || $tempAttributes) { $customList = true; $customListTags = array_merge($customListTags, $tempTags); $customListAttributes = array_merge($customListAttributes, $tempAttributes); } } elseif ($filterType == 'WL') { $whiteList = true; $whiteListTags = array_merge($whiteListTags, $tempTags); $whiteListAttributes = array_merge($whiteListAttributes, $tempAttributes); } } } // Remove duplicates before processing (because the black list uses both sets of arrays). $blackListTags = array_unique($blackListTags); $blackListAttributes = array_unique($blackListAttributes); $customListTags = array_unique($customListTags); $customListAttributes = array_unique($customListAttributes); $whiteListTags = array_unique($whiteListTags); $whiteListAttributes = array_unique($whiteListAttributes); // Unfiltered assumes first priority. if ($unfiltered) { // Dont apply filtering. } else { // Custom blacklist precedes Default blacklist if ($customList) { $filter = JFilterInput::getInstance(array(), array(), 1, 1); // Override filter's default blacklist tags and attributes if ($customListTags) { $filter->tagBlacklist = $customListTags; } if ($customListAttributes) { $filter->attrBlacklist = $customListAttributes; } } // Black lists take second precedence. elseif ($blackList) { // Remove the white-listed tags and attributes from the black-list. $blackListTags = array_diff($blackListTags, $whiteListTags); $blackListAttributes = array_diff($blackListAttributes, $whiteListAttributes); $filter = JFilterInput::getInstance($blackListTags, $blackListAttributes, 1, 1); // Remove white listed tags from filter's default blacklist if ($whiteListTags) { $filter->tagBlacklist = array_diff($filter->tagBlacklist, $whiteListTags); } // Remove white listed attributes from filter's default blacklist if ($whiteListAttributes) { $filter->attrBlacklist = array_diff($filter->attrBlacklist); } } // White lists take third precedence. elseif ($whiteList) { // Turn off xss auto clean $filter = JFilterInput::getInstance($whiteListTags, $whiteListAttributes, 0, 0, 0); } // No HTML takes last place. else { $filter = JFilterInput::getInstance(); } $text = $filter->clean($text, 'html'); } return $text; } /** * Render the component. * * @param string $option The component option. * @param array $params The component parameters * * @return object * * @since 11.1 */ public static function renderComponent($option, $params = array()) { // Initialise variables. $app = JFactory::getApplication(); // Load template language files. $template = $app->getTemplate(true)->template; $lang = JFactory::getLanguage(); $lang->load('tpl_' . $template, JPATH_BASE, null, false, true) || $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", null, false, true); if (empty($option)) { // Throw 404 if no component JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND')); return; } // Record the scope $scope = $app->scope; // Set scope to component name $app->scope = $option; // Build the component path. $option = preg_replace('/[^A-Z0-9_\.-]/i', '', $option); $file = substr($option, 4); // Define component path. define('JPATH_COMPONENT', JPATH_BASE . '/components/' . $option); define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/' . $option); define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/' . $option); // Get component path if ($app->isAdmin() && file_exists(JPATH_COMPONENT . '/admin.' . $file . '.php')) { JLog::add('Files in the format admin.COMPONENTNAME.php are considered deprecated and will not be loaded in Joomla 3.0.', JLog::WARNING, 'deprecated'); $path = JPATH_COMPONENT . '/admin.' . $file . '.php'; } else { $path = JPATH_COMPONENT . '/' . $file . '.php'; } // If component is disabled throw error if (!self::isEnabled($option) || !file_exists($path)) { JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND')); } $task = JRequest::getString('task'); // Load common and local language files. $lang->load($option, JPATH_BASE, null, false, true) || $lang->load($option, JPATH_COMPONENT, null, false, true); // Handle template preview outlining. $contents = null; // Execute the component. $contents = self::executeComponent($path); // Build the component toolbar $path = JApplicationHelper::getPath('toolbar'); if ($path && $app->isAdmin()) { JLog::add('Files in the format toolbar.COMPONENTNAME.php are considered deprecated and will not be loaded in Joomla 3.0.', JLog::WARNING, 'deprecated'); // Get the task again, in case it has changed $task = JRequest::getString('task'); // Make the toolbar include_once $path; } // Revert the scope $app->scope = $scope; return $contents; } /** * Execute the component. * * @param string $path The component path. * * @return string The component output * * @since 11.3 */ protected static function executeComponent($path) { ob_start(); require_once $path; $contents = ob_get_contents(); ob_end_clean(); return $contents; } /** * Load the installed components into the components property. * * @param string $option The element value for the extension * * @return boolean True on success * * @since 11.1 */ protected static function _load($option) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('extension_id AS id, element AS "option", params, enabled'); $query->from('#__extensions'); $query->where($query->qn('type') . ' = ' . $db->quote('component')); $query->where($query->qn('element') . ' = ' . $db->quote($option)); $db->setQuery($query); $cache = JFactory::getCache('_system', 'callback'); self::$components[$option] = $cache->get(array($db, 'loadObject'), null, $option, false); if ($error = $db->getErrorMsg() || empty(self::$components[$option])) { // Fatal error. JError::raiseWarning(500, JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $error)); return false; } // Convert the params to an object. if (is_string(self::$components[$option]->params)) { $temp = new JRegistry; $temp->loadString(self::$components[$option]->params); self::$components[$option]->params = $temp; } return true; } } home/academiac/www/libraries/joomla/application/module/helper.php000064400000033030151372623640021234 0ustar00name == $name || $modules[$i]->module == $name) { // Match the title if we're looking for a specific instance of the module if (!$title || $modules[$i]->title == $title) { // Found it $result = &$modules[$i]; break; // Found it } } } // If we didn't find it, and the name is mod_something, create a dummy object if (is_null($result) && substr($name, 0, 4) == 'mod_') { $result = new stdClass; $result->id = 0; $result->title = ''; $result->module = $name; $result->position = ''; $result->content = ''; $result->showtitle = 0; $result->control = ''; $result->params = ''; $result->user = 0; } return $result; } /** * Get modules by position * * @param string $position The position of the module * * @return array An array of module objects * * @since 11.1 */ public static function &getModules($position) { $position = strtolower($position); $result = array(); $modules =& JModuleHelper::_load(); $total = count($modules); for ($i = 0; $i < $total; $i++) { if ($modules[$i]->position == $position) { $result[] = &$modules[$i]; } } if (count($result) == 0) { if (JRequest::getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display')) { $result[0] = JModuleHelper::getModule('mod_' . $position); $result[0]->title = $position; $result[0]->content = $position; $result[0]->position = $position; } } return $result; } /** * Checks if a module is enabled * * @param string $module The module name * * @return boolean * * @since 11.1 */ public static function isEnabled($module) { $result = JModuleHelper::getModule($module); return !is_null($result); } /** * Render the module. * * @param object $module A module object. * @param array $attribs An array of attributes for the module (probably from the XML). * * @return string The HTML content of the module output. * * @since 11.1 */ public static function renderModule($module, $attribs = array()) { static $chrome; if (constant('JDEBUG')) { JProfiler::getInstance('Application')->mark('beforeRenderModule ' . $module->module . ' (' . $module->title . ')'); } $app = JFactory::getApplication(); // Record the scope. $scope = $app->scope; // Set scope to component name $app->scope = $module->module; // Get module parameters $params = new JRegistry; $params->loadString($module->params); // Get module path $module->module = preg_replace('/[^A-Z0-9_\.-]/i', '', $module->module); $path = JPATH_BASE . '/modules/' . $module->module . '/' . $module->module . '.php'; // Load the module // $module->user is a check for 1.0 custom modules and is deprecated refactoring if (empty($module->user) && file_exists($path)) { $lang = JFactory::getLanguage(); // 1.5 or Core then 1.6 3PD $lang->load($module->module, JPATH_BASE, null, false, true) || $lang->load($module->module, dirname($path), null, false, true); $content = ''; ob_start(); include $path; $module->content = ob_get_contents() . $content; ob_end_clean(); } // Load the module chrome functions if (!$chrome) { $chrome = array(); } include_once JPATH_THEMES . '/system/html/modules.php'; $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/modules.php'; if (!isset($chrome[$chromePath])) { if (file_exists($chromePath)) { include_once $chromePath; } $chrome[$chromePath] = true; } // Make sure a style is set if (!isset($attribs['style'])) { $attribs['style'] = 'none'; } // Dynamically add outline style if (JRequest::getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display')) { $attribs['style'] .= ' outline'; } foreach (explode(' ', $attribs['style']) as $style) { $chromeMethod = 'modChrome_' . $style; // Apply chrome and render module if (function_exists($chromeMethod)) { $module->style = $attribs['style']; ob_start(); $chromeMethod($module, $params, $attribs); $module->content = ob_get_contents(); ob_end_clean(); } } //revert the scope $app->scope = $scope; if (constant('JDEBUG')) { JProfiler::getInstance('Application')->mark('afterRenderModule ' . $module->module . ' (' . $module->title . ')'); } return $module->content; } /** * Get the path to a layout for a module * * @param string $module The name of the module * @param string $layout The name of the module layout. If alternative layout, in the form template:filename. * * @return string The path to the module layout * * @since 11.1 */ public static function getLayoutPath($module, $layout = 'default') { $template = JFactory::getApplication()->getTemplate(); $defaultLayout = $layout; if (strpos($layout, ':') !== false) { // Get the template and file name from the string $temp = explode(':', $layout); $template = ($temp[0] == '_') ? $template : $temp[0]; $layout = $temp[1]; $defaultLayout = ($temp[1]) ? $temp[1] : 'default'; } // Build the template and base path for the layout $tPath = JPATH_THEMES . '/' . $template . '/html/' . $module . '/' . $layout . '.php'; $bPath = JPATH_BASE . '/modules/' . $module . '/tmpl/' . $defaultLayout . '.php'; $dPath = JPATH_BASE . '/modules/' . $module . '/tmpl/default.php'; // If the template has a layout override use it if (file_exists($tPath)) { return $tPath; } elseif (file_exists($bPath)) { return $bPath; } else { return $dPath; } } /** * Load published modules. * * @return array * * @since 11.1 */ protected static function &_load() { static $clean; if (isset($clean)) { return $clean; } $Itemid = JRequest::getInt('Itemid'); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $lang = JFactory::getLanguage()->getTag(); $clientId = (int) $app->getClientId(); $cache = JFactory::getCache('com_modules', ''); $cacheid = md5(serialize(array($Itemid, $groups, $clientId, $lang))); if (!($clean = $cache->get($cacheid))) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params, mm.menuid'); $query->from('#__modules AS m'); $query->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = m.id'); $query->where('m.published = 1'); $query->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id'); $query->where('e.enabled = 1'); $date = JFactory::getDate(); $now = $date->toSql(); $nullDate = $db->getNullDate(); $query->where('(m.publish_up = ' . $db->Quote($nullDate) . ' OR m.publish_up <= ' . $db->Quote($now) . ')'); $query->where('(m.publish_down = ' . $db->Quote($nullDate) . ' OR m.publish_down >= ' . $db->Quote($now) . ')'); $query->where('m.access IN (' . $groups . ')'); $query->where('m.client_id = ' . $clientId); $query->where('(mm.menuid = ' . (int) $Itemid . ' OR mm.menuid <= 0)'); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $query->where('m.language IN (' . $db->Quote($lang) . ',' . $db->Quote('*') . ')'); } $query->order('m.position, m.ordering'); // Set the query $db->setQuery($query); $modules = $db->loadObjectList(); $clean = array(); if ($db->getErrorNum()) { JError::raiseWarning(500, JText::sprintf('JLIB_APPLICATION_ERROR_MODULE_LOAD', $db->getErrorMsg())); return $clean; } // Apply negative selections and eliminate duplicates $negId = $Itemid ? -(int) $Itemid : false; $dupes = array(); for ($i = 0, $n = count($modules); $i < $n; $i++) { $module = &$modules[$i]; // The module is excluded if there is an explicit prohibition $negHit = ($negId === (int) $module->menuid); if (isset($dupes[$module->id])) { // If this item has been excluded, keep the duplicate flag set, // but remove any item from the cleaned array. if ($negHit) { unset($clean[$module->id]); } continue; } $dupes[$module->id] = true; // Only accept modules without explicit exclusions. if (!$negHit) { // Determine if this is a 1.0 style custom module (no mod_ prefix) // This should be eliminated when the class is refactored. // $module->user is deprecated. $file = $module->module; $custom = substr($file, 0, 4) == 'mod_' ? 0 : 1; $module->user = $custom; // 1.0 style custom module name is given by the title field, otherwise strip off "mod_" $module->name = $custom ? $module->module : substr($file, 4); $module->style = null; $module->position = strtolower($module->position); $clean[$module->id] = $module; } } unset($dupes); // Return to simple indexing that matches the query order. $clean = array_values($clean); $cache->store($clean, $cacheid); } return $clean; } /** * Module cache helper * * Caching modes: * To be set in XML: * 'static' One cache file for all pages with the same module parameters * 'oldstatic' 1.5 definition of module caching, one cache file for all pages * with the same module id and user aid, * 'itemid' Changes on itemid change, to be called from inside the module: * 'safeuri' Id created from $cacheparams->modeparams array, * 'id' Module sets own cache id's * * @param object $module Module object * @param object $moduleparams Module parameters * @param object $cacheparams Module cache parameters - id or url parameters, depending on the module cache mode * * @return string * * @since 11.1 * * @link JFilterInput::clean() */ public static function moduleCache($module, $moduleparams, $cacheparams) { if (!isset($cacheparams->modeparams)) { $cacheparams->modeparams = null; } if (!isset($cacheparams->cachegroup)) { $cacheparams->cachegroup = $module->module; } $user = JFactory::getUser(); $cache = JFactory::getCache($cacheparams->cachegroup, 'callback'); $conf = JFactory::getConfig(); // Turn cache off for internal callers if parameters are set to off and for all logged in users if ($moduleparams->get('owncache', null) === '0' || $conf->get('caching') == 0 || $user->get('id')) { $cache->setCaching(false); } // module cache is set in seconds, global cache in minutes, setLifeTime works in minutes $cache->setLifeTime($moduleparams->get('cache_time', $conf->get('cachetime') * 60) / 60); $wrkaroundoptions = array('nopathway' => 1, 'nohead' => 0, 'nomodules' => 1, 'modulemode' => 1, 'mergehead' => 1); $wrkarounds = true; $view_levels = md5(serialize($user->getAuthorisedViewLevels())); switch ($cacheparams->cachemode) { case 'id': $ret = $cache->get( array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $cacheparams->modeparams, $wrkarounds, $wrkaroundoptions ); break; case 'safeuri': $secureid = null; if (is_array($cacheparams->modeparams)) { $uri = JRequest::get(); $safeuri = new stdClass; foreach ($cacheparams->modeparams as $key => $value) { // Use int filter for id/catid to clean out spamy slugs if (isset($uri[$key])) { $safeuri->$key = JRequest::_cleanVar($uri[$key], 0, $value); } } } $secureid = md5(serialize(array($safeuri, $cacheparams->method, $moduleparams))); $ret = $cache->get( array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id . $view_levels . $secureid, $wrkarounds, $wrkaroundoptions ); break; case 'static': $ret = $cache->get( array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->module . md5(serialize($cacheparams->methodparams)), $wrkarounds, $wrkaroundoptions ); break; case 'oldstatic': // provided for backward compatibility, not really usefull $ret = $cache->get( array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id . $view_levels, $wrkarounds, $wrkaroundoptions ); break; case 'itemid': default: $ret = $cache->get( array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id . $view_levels . JRequest::getVar('Itemid', null, 'default', 'INT'), $wrkarounds, $wrkaroundoptions ); break; } return $ret; } } home/academiac/www/modules/mod_menu/helper.php000064400000010040151372627150015456 0ustar00getMenu(); // If no active menu, use default $active = ($menu->getActive()) ? $menu->getActive() : $menu->getDefault(); $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); asort($levels); $key = 'menu_items'.$params.implode(',', $levels).'.'.$active->id; $cache = JFactory::getCache('mod_menu', ''); if (!($items = $cache->get($key))) { // Initialise variables. $list = array(); $db = JFactory::getDbo(); $path = $active->tree; $start = (int) $params->get('startLevel'); $end = (int) $params->get('endLevel'); $showAll = $params->get('showAllChildren'); $items = $menu->getItems('menutype', $params->get('menutype')); $lastitem = 0; if ($items) { foreach($items as $i => $item) { if (($start && $start > $item->level) || ($end && $item->level > $end) || (!$showAll && $item->level > 1 && !in_array($item->parent_id, $path)) || ($start > 1 && !in_array($item->tree[$start-2], $path)) ) { unset($items[$i]); continue; } $item->deeper = false; $item->shallower = false; $item->level_diff = 0; if (isset($items[$lastitem])) { $items[$lastitem]->deeper = ($item->level > $items[$lastitem]->level); $items[$lastitem]->shallower = ($item->level < $items[$lastitem]->level); $items[$lastitem]->level_diff = ($items[$lastitem]->level - $item->level); } $item->parent = (boolean) $menu->getItems('parent_id', (int) $item->id, true); $lastitem = $i; $item->active = false; $item->flink = $item->link; // Reverted back for CMS version 2.5.6 switch ($item->type) { case 'separator': // No further action needed. continue; case 'url': if ((strpos($item->link, 'index.php?') === 0) && (strpos($item->link, 'Itemid=') === false)) { // If this is an internal Joomla link, ensure the Itemid is set. $item->flink = $item->link.'&Itemid='.$item->id; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $item->flink = 'index.php?Itemid='.$item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid='.$item->id; } else { $item->flink .= '&Itemid='.$item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && (strpos($item->flink, 'index.php?') !== false)) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } $item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false); $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false); $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false); $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false) : ''; } if (isset($items[$lastitem])) { $items[$lastitem]->deeper = (($start?$start:1) > $items[$lastitem]->level); $items[$lastitem]->shallower = (($start?$start:1) < $items[$lastitem]->level); $items[$lastitem]->level_diff = ($items[$lastitem]->level - ($start?$start:1)); } } $cache->store($items, $key); } return $items; } } home/academiac/www/modules/mod_feed/helper.php000064400000003160151372627200015416 0ustar00get('rssurl', ''); // get RSS parsed object $cache_time = 0; if ($params->get('cache')) { /* * The cache_time will get fed into JCache to initiate the feed_parser cache group and eventually * JCacheStorage will multiply the value by 60 and use that for its lifetime. The only way to sync * the feed_parser cache (which caches with an empty dataset anyway) with the module cache is to * first divide the module's cache time by 60 then inject that forward, which once stored into the * JCacheStorage object, will be the correct value in minutes. */ $cache_time = $params->get('cache_time', 15) / 60; } $rssDoc = JFactory::getFeedParser($rssurl, $cache_time); $feed = new stdClass; if ($rssDoc != false) { // channel header and link $feed->title = $rssDoc->get_title(); $feed->link = $rssDoc->get_link(); $feed->description = $rssDoc->get_description(); // channel image if exists $feed->image = new stdClass; $feed->image->url = $rssDoc->get_image_url(); $feed->image->title = $rssDoc->get_image_title(); // items $items = $rssDoc->get_items(); // feed elements $feed->items = array_slice($items, 0, $params->get('rssitems', 5)); } else { $feed = false; } return $feed; } } home/academiac/www/libraries/joomla/mail/helper.php000064400000010321151372633300016356 0ustar00 255) { return false; } /* * Check the local address * We're a bit more conservative about what constitutes a "legal" address, that is, a-zA-Z0-9.!#$%&’*+/=?^_`{|}~- * The first and last character in local cannot be a period ('.') * Also, period should not appear 2 or more times consecutively */ $allowed = 'a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-'; $regex = "/^[$allowed][\.$allowed]{0,63}$/"; if (!preg_match($regex, $local) || substr($local, -1) == '.' || $local[0] == '.' || preg_match('/\.\./', $local)) { return false; } // No problem if the domain looks like an IP address, ish $regex = '/^[0-9\.]+$/'; if (preg_match($regex, $domain)) { return true; } // Check Lengths $localLen = strlen($local); if ($localLen < 1 || $localLen > 64) { return false; } // Check the domain $domain_array = explode(".", rtrim($domain, '.')); $regex = '/^[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/'; foreach ($domain_array as $domain) { // Must be something if (!$domain) { return false; } // Check for invalid characters if (!preg_match($regex, $domain)) { return false; } // Check for a dash at the beginning of the domain if (strpos($domain, '-') === 0) { return false; } // Check for a dash at the end of the domain $length = strlen($domain) - 1; if (strpos($domain, '-', $length) === $length) { return false; } } return true; } } home/academiac/www/modules/mod_related_items/helper.php000064400000010211151372635070017333 0ustar00get('id'); $count = intval($params->get('count', 5)); $groups = implode(',', $user->getAuthorisedViewLevels()); $date = JFactory::getDate(); $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $temp = JRequest::getString('id'); $temp = explode(':', $temp); $id = $temp[0]; $showDate = $params->get('showDate', 0); $nullDate = $db->getNullDate(); $now = $date->toSql(); $related = array(); $query = $db->getQuery(true); if ($option == 'com_content' && $view == 'article' && $id) { // select the meta keywords from the item $query->select('metakey'); $query->from('#__content'); $query->where('id = ' . (int) $id); $db->setQuery($query); if ($metakey = trim($db->loadResult())) { // explode the meta keys on a comma $keys = explode(',', $metakey); $likes = array (); // assemble any non-blank word(s) foreach ($keys as $key) { $key = trim($key); if ($key) { $likes[] = $db->escape($key); } } if (count($likes)) { // select other items based on the metakey field 'like' the keys found $query->clear(); $query->select('a.id'); $query->select('a.title'); $query->select('DATE_FORMAT(a.created, "%Y-%m-%d") as created'); $query->select('a.catid'); $query->select('a.language'); $query->select('cc.access AS cat_access'); $query->select('cc.published AS cat_state'); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $query->select($case_when); $case_when = ' CASE WHEN '; $case_when .= $query->charLength('cc.alias'); $case_when .= ' THEN '; $c_id = $query->castAsChar('cc.id'); $case_when .= $query->concatenate(array($c_id, 'cc.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $c_id.' END as catslug'; $query->select($case_when); $query->from('#__content AS a'); $query->leftJoin('#__content_frontpage AS f ON f.content_id = a.id'); $query->leftJoin('#__categories AS cc ON cc.id = a.catid'); $query->where('a.id != ' . (int) $id); $query->where('a.state = 1'); $query->where('a.access IN (' . $groups . ')'); $concat_string = $query->concatenate(array('","', ' REPLACE(a.metakey, ", ", ",")', ' ","')); $query->where('('.$concat_string.' LIKE "%'.implode('%" OR '.$concat_string.' LIKE "%', $likes).'%")'); //remove single space after commas in keywords) $query->where('(a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).')'); $query->where('(a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).')'); // Filter by language if ($app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query); $qstring = $db->getQuery(); $temp = $db->loadObjectList(); if (count($temp)) { foreach ($temp as $row) { if ($row->cat_state == 1) { $row->route = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->language)); $related[] = $row; } } } unset ($temp); } } } return $related; } } home/academiac/www/libraries/joomla/form/helper.php000064400000017642151372645060016422 0ustar00 * paths: * {ENTITY_NAME}: * - /path/1 * - /path/2 * * * @var array * @since 11.1 * */ protected static $paths; /** * Static array of JForm's entity objects for re-use. * Prototypes for all fields and rules are here. * * Array's structure: * * entities: * {ENTITY_NAME}: * {KEY}: {OBJECT} * * * @var array * @since 11.1 */ protected static $entities = array(); /** * Method to load a form field object given a type. * * @param string $type The field type. * @param boolean $new Flag to toggle whether we should get a new instance of the object. * * @return mixed JFormField object on success, false otherwise. * * @since 11.1 */ public static function loadFieldType($type, $new = true) { return self::loadType('field', $type, $new); } /** * Method to load a form rule object given a type. * * @param string $type The rule type. * @param boolean $new Flag to toggle whether we should get a new instance of the object. * * @return mixed JFormRule object on success, false otherwise. * * @since 11.1 */ public static function loadRuleType($type, $new = true) { return self::loadType('rule', $type, $new); } /** * Method to load a form entity object given a type. * Each type is loaded only once and then used as a prototype for other objects of same type. * Please, use this method only with those entities which support types (forms don't support them). * * @param string $entity The entity. * @param string $type The entity type. * @param boolean $new Flag to toggle whether we should get a new instance of the object. * * @return mixed Entity object on success, false otherwise. * * @since 11.1 */ protected static function loadType($entity, $type, $new = true) { // Reference to an array with current entity's type instances $types = &self::$entities[$entity]; // Initialize variables. $key = md5($type); $class = ''; // Return an entity object if it already exists and we don't need a new one. if (isset($types[$key]) && $new === false) { return $types[$key]; } if (($class = self::loadClass($entity, $type)) !== false) { // Instantiate a new type object. $types[$key] = new $class; return $types[$key]; } else { return false; } } /** * Attempt to import the JFormField class file if it isn't already imported. * You can use this method outside of JForm for loading a field for inheritance or composition. * * @param string $type Type of a field whose class should be loaded. * * @return mixed Class name on success or false otherwise. * * @since 11.1 */ public static function loadFieldClass($type) { return self::loadClass('field', $type); } /** * Attempt to import the JFormRule class file if it isn't already imported. * You can use this method outside of JForm for loading a rule for inheritance or composition. * * @param string $type Type of a rule whose class should be loaded. * * @return mixed Class name on success or false otherwise. * * @since 11.1 */ public static function loadRuleClass($type) { return self::loadClass('rule', $type); } /** * Load a class for one of the form's entities of a particular type. * Currently, it makes sense to use this method for the "field" and "rule" entities * (but you can support more entities in your subclass). * * @param string $entity One of the form entities (field or rule). * @param string $type Type of an entity. * * @return mixed Class name on success or false otherwise. * * @since 11.1 */ protected static function loadClass($entity, $type) { if (strpos($type, '.')) { list($prefix, $type) = explode('.', $type); } else { $prefix = 'J'; } $class = JString::ucfirst($prefix, '_') . 'Form' . JString::ucfirst($entity, '_') . JString::ucfirst($type, '_'); if (class_exists($class)) { return $class; } // Get the field search path array. $paths = JFormHelper::addPath($entity); // If the type is complex, add the base type to the paths. if ($pos = strpos($type, '_')) { // Add the complex type prefix to the paths. for ($i = 0, $n = count($paths); $i < $n; $i++) { // Derive the new path. $path = $paths[$i] . '/' . strtolower(substr($type, 0, $pos)); // If the path does not exist, add it. if (!in_array($path, $paths)) { $paths[] = $path; } } // Break off the end of the complex type. $type = substr($type, $pos + 1); } // Try to find the class file. $type = strtolower($type) . '.php'; foreach ($paths as $path) { if ($file = JPath::find($path, $type)) { require_once $file; if (class_exists($class)) { break; } } } // Check for all if the class exists. return class_exists($class) ? $class : false; } /** * Method to add a path to the list of field include paths. * * @param mixed $new A path or array of paths to add. * * @return array The list of paths that have been added. * * @since 11.1 */ public static function addFieldPath($new = null) { return self::addPath('field', $new); } /** * Method to add a path to the list of form include paths. * * @param mixed $new A path or array of paths to add. * * @return array The list of paths that have been added. * * @since 11.1 */ public static function addFormPath($new = null) { return self::addPath('form', $new); } /** * Method to add a path to the list of rule include paths. * * @param mixed $new A path or array of paths to add. * * @return array The list of paths that have been added. * * @since 11.1 */ public static function addRulePath($new = null) { return self::addPath('rule', $new); } /** * Method to add a path to the list of include paths for one of the form's entities. * Currently supported entities: field, rule and form. You are free to support your own in a subclass. * * @param string $entity Form's entity name for which paths will be added. * @param mixed $new A path or array of paths to add. * * @return array The list of paths that have been added. * * @since 11.1 */ protected static function addPath($entity, $new = null) { // Reference to an array with paths for current entity $paths = &self::$paths[$entity]; // Add the default entity's search path if not set. if (empty($paths)) { // While we support limited number of entities (form, field and rule) // we can do this simple pluralisation: $entity_plural = $entity . 's'; // But when someday we would want to support more entities, then we should consider adding // an inflector class to "libraries/joomla/utilities" and use it here (or somebody can use a real inflector in his subclass). // see also: pluralization snippet by Paul Osman in JControllerForm's constructor. $paths[] = dirname(__FILE__) . '/' . $entity_plural; } // Force the new path(s) to an array. settype($new, 'array'); // Add the new paths to the stack if not already there. foreach ($new as $path) { if (!in_array($path, $paths)) { array_unshift($paths, trim($path)); } } return $paths; } } home/academiac/www/modules/mod_articles_latest/helper.php000064400000006165151372657670017723 0ustar00 true)); // Set application parameters in model $app = JFactory::getApplication(); $appParams = $app->getParams(); $model->setState('params', $appParams); // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('count', 5)); $model->setState('filter.published', 1); // Access filter $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $model->setState('filter.access', $access); // Category filter $model->setState('filter.category_id', $params->get('catid', array())); // User filter $userId = JFactory::getUser()->get('id'); switch ($params->get('user_id')) { case 'by_me': $model->setState('filter.author_id', (int) $userId); break; case 'not_me': $model->setState('filter.author_id', $userId); $model->setState('filter.author_id.include', false); break; case '0': break; default: $model->setState('filter.author_id', (int) $params->get('user_id')); break; } // Filter by language $model->setState('filter.language', $app->getLanguageFilter()); // Featured switch switch ($params->get('show_featured')) { case '1': $model->setState('filter.featured', 'only'); break; case '0': $model->setState('filter.featured', 'hide'); break; default: $model->setState('filter.featured', 'show'); break; } // Set ordering $order_map = array( 'm_dsc' => 'a.modified DESC, a.created', 'mc_dsc' => 'CASE WHEN (a.modified = '.$db->quote($db->getNullDate()).') THEN a.created ELSE a.modified END', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up', ); $ordering = JArrayHelper::getValue($order_map, $params->get('ordering'), 'a.publish_up'); $dir = 'DESC'; $model->setState('list.ordering', $ordering); $model->setState('list.direction', $dir); $items = $model->getItems(); foreach ($items as &$item) { $item->slug = $item->id.':'.$item->alias; $item->catslug = $item->catid.':'.$item->category_alias; if ($access || in_array($item->access, $authorised)) { // We know that user has the privilege to view the article $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->language)); } else { $item->link = JRoute::_('index.php?option=com_users&view=login'); } } return $items; } } home/academiac/www/modules/mod_users_latest/helper.php000064400000002201151372672440017231 0ustar00getQuery(true); $query->select('a.id, a.name, a.username, a.registerDate'); $query->order('a.registerDate DESC'); $query->from('#__users AS a'); $user = JFactory::getUser(); if (!$user->authorise('core.admin') && $params->get('filter_groups', 0) == 1) { $groups = $user->getAuthorisedGroups(); if (empty($groups)) { return array(); } $query->leftJoin('#__user_usergroup_map AS m ON m.user_id = a.id'); $query->leftJoin('#__usergroups AS ug ON ug.id = m.group_id'); $query->where('ug.id in (' . implode(',', $groups) . ')'); $query->where('ug.id <> 1'); } $db->setQuery($query, 0, $params->get('shownumber')); $result = $db->loadObjectList(); return (array) $result; } } home/academiac/www/modules/mod_virtuemart_category/helper.php000060400000002273151372674260020622 0ustar00home/academiac/www/libraries/joomla/cache/storage/helpers/helper.php000064400000002137151372677330021626 0ustar00group = $group; } /** * Increase cache items count. * * @param string $size Cached item size * * @return void * * @since 11.1 */ public function updateSize($size) { $this->size = number_format($this->size + $size, 2, '.', ''); $this->count++; } } home/academiac/www/modules/mod_stats/helper.php000064400000005653151372705510015663 0ustar00getQuery(true); $serverinfo = $params->get('serverinfo'); $siteinfo = $params->get('siteinfo'); $counter = $params->get('counter'); $increase = $params->get('increase'); $i = 0; if ($serverinfo) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_OS'); $rows[$i]->data = substr(php_uname(), 0, 7); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_PHP'); $rows[$i]->data = phpversion(); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_MYSQL'); $rows[$i]->data = $db->getVersion(); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JTEXT::_('MOD_STATS_TIME'); $rows[$i]->data = JHtml::_('date', 'now', 'H:i'); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_CACHING'); $rows[$i]->data = $app->getCfg('caching') ? JText::_('JENABLED'):JText::_('JDISABLED'); $i++; $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_GZIP'); $rows[$i]->data = $app->getCfg('gzip') ? JText::_('JENABLED'):JText::_('JDISABLED'); $i++; } if ($siteinfo) { $query->select('COUNT(id) AS count_users'); $query->from('#__users'); $db->setQuery($query); $users = $db->loadResult(); $query->clear(); $query->select('COUNT(id) AS count_items'); $query->from('#__content'); $query->where('state = 1'); $db->setQuery($query); $items = $db->loadResult(); $query->clear(); $query->select('COUNT(id) AS count_links '); $query->from('#__weblinks'); $query->where('state = 1'); $db->setQuery($query); $links = $db->loadResult(); if ($users) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_USERS'); $rows[$i]->data = $users; $i++; } if ($items) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_ARTICLES'); $rows[$i]->data = $items; $i++; } if ($links) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_WEBLINKS'); $rows[$i]->data = $links; $i++; } } if ($counter) { $query->clear(); $query->select('SUM(hits) AS count_hits'); $query->from('#__content'); $query->where('state = 1'); $db->setQuery($query); $hits = $db->loadResult(); if ($hits) { $rows[$i] = new stdClass; $rows[$i]->title = JText::_('MOD_STATS_ARTICLES_VIEW_HITS'); $rows[$i]->data = $hits + $increase; $i++; } } return $rows; } } home/academiac/www/libraries/joomla/client/helper.php000064400000014363151372706500016727 0ustar00 $config->get('ftp_enable'), 'host' => $config->get('ftp_host'), 'port' => $config->get('ftp_port'), 'user' => $config->get('ftp_user'), 'pass' => $config->get('ftp_pass'), 'root' => $config->get('ftp_root')); break; default: $options = array('enabled' => false, 'host' => '', 'port' => '', 'user' => '', 'pass' => '', 'root' => ''); break; } // If user and pass are not set in global config lets see if they are in the session if ($options['enabled'] == true && ($options['user'] == '' || $options['pass'] == '')) { $session = JFactory::getSession(); $options['user'] = $session->get($client . '.user', null, 'JClientHelper'); $options['pass'] = $session->get($client . '.pass', null, 'JClientHelper'); } // If user or pass are missing, disable this client if ($options['user'] == '' || $options['pass'] == '') { $options['enabled'] = false; } // Save the credentials for later use $credentials[$client] = $options; } return $credentials[$client]; } /** * Method to set client login credentials * * @param string $client Client name, currently only 'ftp' is supported * @param string $user Username * @param string $pass Password * * @return boolean True if the given login credentials have been set and are valid * * @since 11.1 */ public static function setCredentials($client, $user, $pass) { $return = false; $client = strtolower($client); // Test if the given credentials are valid switch ($client) { case 'ftp': $config = JFactory::getConfig(); $options = array('enabled' => $config->get('ftp_enable'), 'host' => $config->get('ftp_host'), 'port' => $config->get('ftp_port')); if ($options['enabled']) { jimport('joomla.client.ftp'); $ftp = JFTP::getInstance($options['host'], $options['port']); // Test the connection and try to log in if ($ftp->isConnected()) { if ($ftp->login($user, $pass)) { $return = true; } $ftp->quit(); } } break; default: break; } if ($return) { // Save valid credentials to the session $session = JFactory::getSession(); $session->set($client . '.user', $user, 'JClientHelper'); $session->set($client . '.pass', $pass, 'JClientHelper'); // Force re-creation of the data saved within JClientHelper::getCredentials() JClientHelper::getCredentials($client, true); } return $return; } /** * Method to determine if client login credentials are present * * @param string $client Client name, currently only 'ftp' is supported * * @return boolean True if login credentials are available * * @since 11.1 */ public static function hasCredentials($client) { $return = false; $client = strtolower($client); // Get (unmodified) credentials for this client switch ($client) { case 'ftp': $config = JFactory::getConfig(); $options = array('enabled' => $config->get('ftp_enable'), 'user' => $config->get('ftp_user'), 'pass' => $config->get('ftp_pass')); break; default: $options = array('enabled' => false, 'user' => '', 'pass' => ''); break; } if ($options['enabled'] == false) { // The client is disabled in global config, so let's pretend we are OK $return = true; } elseif ($options['user'] != '' && $options['pass'] != '') { // Login credentials are available in global config $return = true; } else { // Check if login credentials are available in the session $session = JFactory::getSession(); $user = $session->get($client . '.user', null, 'JClientHelper'); $pass = $session->get($client . '.pass', null, 'JClientHelper'); if ($user != '' && $pass != '') { $return = true; } } return $return; } /** * Determine whether input fields for client settings need to be shown * * If valid credentials were passed along with the request, they are saved to the session. * This functions returns an exception if invalid credentials have been given or if the * connection to the server failed for some other reason. * * @param string $client The name of the client. * * @return mixed True, if FTP settings should be shown or an exception * * @since 11.1 */ public static function setCredentialsFromRequest($client) { // Determine whether FTP credentials have been passed along with the current request $user = JRequest::getString('username', null, 'POST', JREQUEST_ALLOWRAW); $pass = JRequest::getString('password', null, 'POST', JREQUEST_ALLOWRAW); if ($user != '' && $pass != '') { // Add credentials to the session if (JClientHelper::setCredentials($client, $user, $pass)) { $return = false; } else { $return = JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_CLIENT_ERROR_HELPER_SETCREDENTIALSFROMREQUEST_FAILED')); } } else { // Just determine if the FTP input fields need to be shown $return = !JClientHelper::hasCredentials('ftp'); } return $return; } } home/academiac/www/modules/mod_languages/helper.php000064400000005070151372756460016476 0ustar00getMenu(); // Get menu home items $homes = array(); foreach($menu->getMenu() as $item) { if ($item->home) { $homes[$item->language] = $item; } } // Load associations $assoc = isset($app->menu_associations) ? $app->menu_associations : 0; if ($assoc) { $active = $menu->getActive(); if ($active) { $associations = MenusHelper::getAssociations($active->id); } } $levels = $user->getAuthorisedViewLevels(); $languages = JLanguageHelper::getLanguages(); // Filter allowed languages foreach($languages as $i => &$language) { // Do not display language without frontend UI if (!JLanguage::exists($language->lang_code)) { unset($languages[$i]); } // Do not display language without specific home menu elseif (!isset($homes[$language->lang_code])) { unset($languages[$i]); } // Do not display language without authorized access level elseif (isset($language->access) && $language->access && !in_array($language->access, $levels)) { unset($languages[$i]); } else { $language->active = $language->lang_code == $lang->getTag(); if ($app->getLanguageFilter()) { if (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) { $itemid = $associations[$language->lang_code]; if ($app->getCfg('sef')=='1') { $language->link = JRoute::_('index.php?lang='.$language->sef.'&Itemid='.$itemid); } else { $language->link = 'index.php?lang='.$language->sef.'&Itemid='.$itemid; } } else { if ($app->getCfg('sef')=='1') { $itemid = isset($homes[$language->lang_code]) ? $homes[$language->lang_code]->id : $homes['*']->id; $language->link = JRoute::_('index.php?lang='.$language->sef.'&Itemid='.$itemid); } else { $language->link = 'index.php?lang='.$language->sef; } } } else { $language->link = JRoute::_('&Itemid='.$homes['*']->id); } } } return $languages; } } home/academiac/www/modules/mod_articles_category/helper.php000064400000027540151372760130020226 0ustar00 true)); // Set application parameters in model $app = JFactory::getApplication(); $appParams = $app->getParams(); $articles->setState('params', $appParams); // Set the filters based on the module params $articles->setState('list.start', 0); $articles->setState('list.limit', (int) $params->get('count', 0)); $articles->setState('filter.published', 1); // Access filter $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $articles->setState('filter.access', $access); // Prep for Normal or Dynamic Modes $mode = $params->get('mode', 'normal'); switch ($mode) { case 'dynamic': $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); if ($option === 'com_content') { switch($view) { case 'category': $catids = array(JRequest::getInt('id')); break; case 'categories': $catids = array(JRequest::getInt('id')); break; case 'article': if ($params->get('show_on_article_page', 1)) { $article_id = JRequest::getInt('id'); $catid = JRequest::getInt('catid'); if (!$catid) { // Get an instance of the generic article model $article = JModelLegacy::getInstance('Article', 'ContentModel', array('ignore_request' => true)); $article->setState('params', $appParams); $article->setState('filter.published', 1); $article->setState('article.id', (int) $article_id); $item = $article->getItem(); $catids = array($item->catid); } else { $catids = array($catid); } } else { // Return right away if show_on_article_page option is off return; } break; case 'featured': default: // Return right away if not on the category or article views return; } } else { // Return right away if not on a com_content page return; } break; case 'normal': default: $catids = $params->get('catid'); $articles->setState('filter.category_id.include', (bool) $params->get('category_filtering_type', 1)); break; } // Category filter if ($catids) { if ($params->get('show_child_category_articles', 0) && (int) $params->get('levels', 0) > 0) { // Get an instance of the generic categories model $categories = JModelLegacy::getInstance('Categories', 'ContentModel', array('ignore_request' => true)); $categories->setState('params', $appParams); $levels = $params->get('levels', 1) ? $params->get('levels', 1) : 9999; $categories->setState('filter.get_children', $levels); $categories->setState('filter.published', 1); $categories->setState('filter.access', $access); $additional_catids = array(); foreach($catids as $catid) { $categories->setState('filter.parentId', $catid); $recursive = true; $items = $categories->getItems($recursive); if ($items) { foreach($items as $category) { $condition = (($category->level - $categories->getParent()->level) <= $levels); if ($condition) { $additional_catids[] = $category->id; } } } } $catids = array_unique(array_merge($catids, $additional_catids)); } $articles->setState('filter.category_id', $catids); } // Ordering $articles->setState('list.ordering', $params->get('article_ordering', 'a.ordering')); $articles->setState('list.direction', $params->get('article_ordering_direction', 'ASC')); // New Parameters $articles->setState('filter.featured', $params->get('show_front', 'show')); $articles->setState('filter.author_id', $params->get('created_by', "")); $articles->setState('filter.author_id.include', $params->get('author_filtering_type', 1)); $articles->setState('filter.author_alias', $params->get('created_by_alias', "")); $articles->setState('filter.author_alias.include', $params->get('author_alias_filtering_type', 1)); $excluded_articles = $params->get('excluded_articles', ''); if ($excluded_articles) { $excluded_articles = explode("\r\n", $excluded_articles); $articles->setState('filter.article_id', $excluded_articles); $articles->setState('filter.article_id.include', false); // Exclude } $date_filtering = $params->get('date_filtering', 'off'); if ($date_filtering !== 'off') { $articles->setState('filter.date_filtering', $date_filtering); $articles->setState('filter.date_field', $params->get('date_field', 'a.created')); $articles->setState('filter.start_date_range', $params->get('start_date_range', '1000-01-01 00:00:00')); $articles->setState('filter.end_date_range', $params->get('end_date_range', '9999-12-31 23:59:59')); $articles->setState('filter.relative_date', $params->get('relative_date', 30)); } // Filter by language $articles->setState('filter.language', $app->getLanguageFilter()); $items = $articles->getItems(); // Display options $show_date = $params->get('show_date', 0); $show_date_field = $params->get('show_date_field', 'created'); $show_date_format = $params->get('show_date_format', 'Y-m-d H:i:s'); $show_category = $params->get('show_category', 0); $show_hits = $params->get('show_hits', 0); $show_author = $params->get('show_author', 0); $show_introtext = $params->get('show_introtext', 0); $introtext_limit = $params->get('introtext_limit', 100); // Find current Article ID if on an article page $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); if ($option === 'com_content' && $view === 'article') { $active_article_id = JRequest::getInt('id'); } else { $active_article_id = 0; } // Prepare data for display using display options foreach ($items as &$item) { $item->slug = $item->id.':'.$item->alias; $item->catslug = $item->catid ? $item->catid .':'.$item->category_alias : $item->catid; if ($access || in_array($item->access, $authorised)) { // We know that user has the privilege to view the article $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->language)); } else { // Angie Fixed Routing $app = JFactory::getApplication(); $menu = $app->getMenu(); $menuitems = $menu->getItems('link', 'index.php?option=com_users&view=login'); if(isset($menuitems[0])) { $Itemid = $menuitems[0]->id; } elseif (JRequest::getInt('Itemid') > 0) { //use Itemid from requesting page only if there is no existing menu $Itemid = JRequest::getInt('Itemid'); } $item->link = JRoute::_('index.php?option=com_users&view=login&Itemid='.$Itemid); } // Used for styling the active article $item->active = $item->id == $active_article_id ? 'active' : ''; $item->displayDate = ''; if ($show_date) { $item->displayDate = JHTML::_('date', $item->$show_date_field, $show_date_format); } if ($item->catid) { $item->displayCategoryLink = JRoute::_(ContentHelperRoute::getCategoryRoute($item->catid)); $item->displayCategoryTitle = $show_category ? ''.$item->category_title.'' : ''; } else { $item->displayCategoryTitle = $show_category ? $item->category_title : ''; } $item->displayHits = $show_hits ? $item->hits : ''; $item->displayAuthorName = $show_author ? $item->author : ''; if ($show_introtext) { $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'mod_articles_category.content'); $item->introtext = self::_cleanIntrotext($item->introtext); } $item->displayIntrotext = $show_introtext ? self::truncate($item->introtext, $introtext_limit) : ''; $item->displayReadmore = $item->alternative_readmore; } return $items; } public static function _cleanIntrotext($introtext) { $introtext = str_replace('

', ' ', $introtext); $introtext = str_replace('

', ' ', $introtext); $introtext = strip_tags($introtext, ''); $introtext = trim($introtext); return $introtext; } /** * Method to truncate introtext * * The goal is to get the proper length plain text string with as much of * the html intact as possible with all tags properly closed. * * @param string $html The content of the introtext to be truncated * @param integer $maxLength The maximum number of charactes to render * * @return string The truncated string */ public static function truncate($html, $maxLength = 0) { $baseLength = strlen($html); $diffLength = 0; // First get the plain text string. This is the rendered text we want to end up with. $ptString = JHtml::_('string.truncate', $html, $maxLength, $noSplit = true, $allowHtml = false); for ($maxLength; $maxLength < $baseLength;) { // Now get the string if we allow html. $htmlString = JHtml::_('string.truncate', $html, $maxLength, $noSplit = true, $allowHtml = true); // Now get the plain text from the html string. $htmlStringToPtString = JHtml::_('string.truncate', $htmlString, $maxLength, $noSplit = true, $allowHtml = false); // If the new plain text string matches the original plain text string we are done. if ($ptString == $htmlStringToPtString) { return $htmlString; } // Get the number of html tag characters in the first $maxlength characters $diffLength = strlen($ptString) - strlen($htmlStringToPtString); // Set new $maxlength that adjusts for the html tags $maxLength += $diffLength; if ($baseLength <= $maxLength || $diffLength <= 0) { return $htmlString; } } return $html; } public static function groupBy($list, $fieldName, $article_grouping_direction, $fieldNameToKeep = null) { $grouped = array(); if (!is_array($list)) { if ($list == '') { return $grouped; } $list = array($list); } foreach($list as $key => $item) { if (!isset($grouped[$item->$fieldName])) { $grouped[$item->$fieldName] = array(); } if (is_null($fieldNameToKeep)) { $grouped[$item->$fieldName][$key] = $item; } else { $grouped[$item->$fieldName][$key] = $item->$fieldNameToKeep; } unset($list[$key]); } $article_grouping_direction($grouped); return $grouped; } public static function groupByDate($list, $type = 'year', $article_grouping_direction, $month_year_format = 'F Y') { $grouped = array(); if (!is_array($list)) { if ($list == '') { return $grouped; } $list = array($list); } foreach($list as $key => $item) { switch($type) { case 'month_year': $month_year = JString::substr($item->created, 0, 7); if (!isset($grouped[$month_year])) { $grouped[$month_year] = array(); } $grouped[$month_year][$key] = $item; break; case 'year': default: $year = JString::substr($item->created, 0, 4); if (!isset($grouped[$year])) { $grouped[$year] = array(); } $grouped[$year][$key] = $item; break; } unset($list[$key]); } $article_grouping_direction($grouped); if ($type === 'month_year') { foreach($grouped as $group => $items) { $date = new JDate($group); $formatted_group = $date->format($month_year_format); $grouped[$formatted_group] = $items; unset($grouped[$group]); } } return $grouped; } } home/academiac/www/modules/mod_articles_categories/helper.php000064400000001531151373033670020531 0ustar00get($params->get('parent', 'root')); if ($category != null) { $items = $category->getChildren(); if($params->get('count', 0) > 0 && count($items) > $params->get('count', 0)) { $items = array_slice($items, 0, $params->get('count', 0)); } return $items; } } } home/academiac/www/administrator/includes/helper.php000064400000001560151373151520016672 0ustar00get('guest')) || !$user->authorise('core.login.admin')) { $option = 'com_login'; } if (empty($option)) { $option = 'com_cpanel'; } JRequest::setVar('option', $option); return $option; } } home/academiac/www/modules/mod_simplefileuploadv1.3/helper.php000060400000123071151373155250020463 0ustar00get( 'upload_maxsize', '100000' ); $upload_filetypes = $params->get( 'upload_filetypes', '' ); $upload_fileexist = $params->get( 'upload_fileexist', '' ); $upload_email = $params->get( 'upload_email', '' ); $upload_emailmsg = $params->get( 'upload_emailmsg', '0' ); $upload_emailhtml = $params->get( 'upload_emailhtml', '1' ); $upload_unzip = $params->get( 'upload_unzip', '0' ); $upload_showerrmsg = $params->get( 'upload_showerrmsg', '1' ); $upload_showdircontent = $params->get( 'upload_showdircontent', '0' ); $upload_popshowpath = $params->get( 'upload_popshowpath', '1' ); $upload_popshowbytes = $params->get( 'upload_popshowbytes', '0' ); $upload_blacklist = $params->get( 'upload_blacklist', '.php .php3 .php4 .php5 .php6 .phtml .pl .py .jsp .asp .htm .shtml .sh .cgi .exe .bat .cmd .htaccess' ); $upload_doubleext = $params->get( 'upload_doubleext', '1' ); $upload_phpext = $params->get( 'upload_phpext', '1' ); $upload_gifcomment = $params->get( 'upload_gifcomment', '1' ); $upload_mailfrom = $params->get( 'upload_mailfrom' , 'noreply@simplefileupload.com' ); $upload_maximgwidth = $params->get( 'upload_maximgwidth', '0' ); $upload_maximgheight = $params->get( 'upload_maximgheight', '0' ); $upload_compressimg = $params->get( 'upload_compressimg', '' ); $upload_disablegdlib = $params->get( 'upload_disablegdlib', '0' ); $upload_disablegdthreshold = $params->get( 'upload_diablegdthreshold', '0' ); $upload_thumbcreate = $params->get( 'upload_thumbcreate', '0' ); $upload_thumbsize = $params->get( 'upload_thumbsize', '40x40' ); $upload_thumbname = $params->get( 'upload_thumbname', 'sfuthumb' ); $upload_debug = $params->get( 'upload_debug', '0' ); $upload_formfields = $params->get( 'upload_formfields', '' ); $upload_useformsfields = $params->get( 'upload_useformsfields', '0' ); if ($upload_useformsfields == 0) $upload_formfields = ""; $upload_formfieldsfile = $params->get( 'upload_formfieldsfile', '' ); $upload_formfieldsdiv = $params->get( 'upload_formfieldsdiv', '|' ); $upload_nohtmlencoding = $params->get( 'upload_nohtmlencoding', '0' ); $upload_replacetag = $params->get( 'upload_replacetag', '0' ); $results = ""; $fileCnt = 0; $fileErr = 0; $written = 0; $filename = ""; $fileList = ""; $fileInfo = ""; $filetypeok = true; $filetype = ""; $blacklist = explode(" ", $upload_blacklist); $formfieldsval = array(); $formfieldsemail = array(); $chkfileexist = ""; $baseurl = ""; $serverurl = ""; $protocol = ""; $protocol = "http://"; if (substr($_SERVER["HTTP_REFERER"], 0, 5) === "https") $protocol = "https://"; $folder = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/")); if ($folder === "//") $folder = ""; // Check if relative path if (substr($upload_location, 0, 1) === ".") { $serverurl .= str_replace(".", $protocol.$_SERVER["HTTP_HOST"].$folder, $upload_location); // Fix Windows path... $baseurl .= str_replace("\\", "", $serverurl); } else { if ((substr($upload_location, 1, 2) === ":\\") || (substr($upload_location, 0, 1) === "/")) { // Server root path $baseurl = "file://".str_replace("\\", "/", $upload_location); } else { $serverurl = str_replace("\\", "/", $_SERVER["DOCUMENT_ROOT"]); $baseurl = str_replace("\\", "/", $upload_location); $baseurl = str_replace($serverurl, "", $baseurl); //$baseurl = dirname($_SERVER["HTTP_REFERER"])."/".$baseurl; $baseurl = $protocol.$_SERVER["HTTP_HOST"].$folder."/".$baseurl; } } //Replace space with %20 for URL $baseurl = str_replace(" ", "%20", $baseurl); // Make sure it ends with front slash if ( substr( $baseurl , strlen($baseurl) - 1) !== "/" ) { $baseurl .= "/"; } if(is_array($_FILES["uploadedfile$mid"]["name"])) { foreach($_FILES["uploadedfile$mid"]["name"] as $value) { /* Not really useful since I need type and size as well... just use $_FILES if(strlen($value) > 0) { //Check that we have a filename $filenames[] = $value; }*/ $fileCnt += 1; } } for ($cnt = 0; $cnt<$fileCnt; $cnt++) { if ((strlen($_FILES["uploadedfile$mid"]["name"][$cnt]) > 0) && ($upload_users === "true")) { // Check blacklist first foreach ($blacklist as $file) { $filename = $_FILES["uploadedfile$mid"]["name"][$cnt]; if (preg_match("/$file\$/i", $filename)) { $filetypeok = false; break; } } // Check double extension if ($upload_doubleext === "1" || $upload_phpext === "1") { $exts = explode('.', $filename); // There is more than one dot! if (count($exts) > 2) { // Any double extension blocked if ($upload_doubleext === "1") $filetypeok = false; if ($upload_phpext === "1") { // Block .php. if (strtolower($exts[count($exts)-2]) === "php") $filetypeok = false; } } else { // Check and block any .php combination if (stripos($filename, ".php") !== false) $filetypeok = false; } } if ($_FILES["uploadedfile$mid"]["error"][$cnt] > 0) { // Check if there was any error $filetypeok = false; } if ($filetypeok) { $fileList .= $_FILES["uploadedfile$mid"]["name"][$cnt] . "|"; $filetype = $_FILES["uploadedfile$mid"]["type"][$cnt]; $fileInfo .= "(" . JText::_('TYPE') . ": " . $filetype . " " . JText::_('SIZE') . ": " . $_FILES["uploadedfile$mid"]["size"][$cnt] . " " . JText::_('BYTES') . ")|"; if ($filetype === "") $filetype = "false"; if (stripos($upload_filetypes, $filetype) === false) { $filetypeok = false; } else { $filetypeok = true; } if ($upload_filetypes === "*") { $filetypeok = true; } //Check if GIF and block GIF Comment if ($upload_gifcomment === "1" && (preg_match("/.gif\$/i", $_FILES["uploadedfile$mid"]["name"][$cnt]))) { $comment = ModSimpleFileUploaderHelperv13::getGIFComment($_FILES["uploadedfile$mid"]["tmp_name"][$cnt], $upload_debug); if(stripos($comment, "getGIFComment:BLOCK") !== false) { $filetypeok = false; } if ($upload_debug == 1) $results .= $comment; } } if (($filetypeok) && ($_FILES["uploadedfile$mid"]["size"][$cnt] < $upload_maxsize)) { $errmsg = ""; $new_filename = ""; if ($_FILES["uploadedfile$mid"]["error"][$cnt] > 0) { if (($_FILES["uploadedfile$mid"]["size"][$cnt] == 0) && ($_FILES["uploadedfile$mid"]["error"][$cnt] == 2)) { $errmsg = "(".$_FILES["uploadedfile$mid"]["name"][$cnt].")".JText::sprintf('ERROR_TOO_BIG', "
[PHP Error: " . $_FILES["uploadedfile$mid"]["error"][$cnt]) . "]
"; } else { $errmsg = "(".$_FILES["uploadedfile$mid"]["name"][$cnt].")".JText::sprintf('ERROR_LABEL', $_FILES["uploadedfile$mid"]["error"][$cnt]) . "
"; } if ($upload_showerrmsg == 1) $results .= $errmsg; else $results .= JText::_('UPLOAD_FAILED'); $fileErr = 1; } else { $bytesfilesize = $_FILES["uploadedfile$mid"]["size"][$cnt]; // Check to see if GD lib functions should be skipped if ($upload_disablegdthreshold > 0) { if ($bytesfilesize >= $upload_disablegdthreshold) $upload_disablegdlib = 1; } $filesize = ModSimpleFileUploaderHelperv13::getFileSizePP($bytesfilesize); if (($upload_popshowbytes == 1) && ($bytesfilesize != $filesize)) $filesize = $filesize . " (" . $bytesfilesize . " " . JText::_('BYTES') . ")"; //$results .= "" . JText::_('FILE_OK_MSG') . "

"; $results .= "".JText::sprintf('FILE_UPLOAD_LABEL', $_FILES["uploadedfile$mid"]["name"][$cnt]) . "
"; $results .= JText::sprintf('FILE_TYPE_LABEL', $_FILES["uploadedfile$mid"]["type"][$cnt]) . "
"; $results .= JText::sprintf('FILE_SIZE_LABEL', $filesize) . "
"; #$results .= "uploaded to: " . $_FILES["uploadedfile$mid"]["tmp_name"][$cnt] . "
"; if (file_exists($upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt])) { if ( $upload_fileexist === "0" ) { // FAIL $results .= "
" . JText::sprintf('FILE_EXISTS_MSG', $_FILES["uploadedfile$mid"]["name"][$cnt]) . "

" . JText::_('FILE_EXISTS_CORR'); $fileErr = 1; } /* // Don't delete until new file has been created! if ( $upload_fileexist === "1" ) { // REPLACE unlink($upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt]); $results .= JText::_('FILE_EXISTS_REPLACE') . "
"; $chkfileexist = "no"; }*/ if ( $upload_fileexist === "2" || $upload_fileexist === "1" ) { // BACKUP $new_filename = $_FILES["uploadedfile$mid"]["name"][$cnt] . microtime(); rename($upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt], $upload_location . $new_filename); if ($upload_fileexist === "1") $results .= JText::_('FILE_EXISTS_REPLACE') . "
"; else $results .= JText::sprintf('FILE_EXISTS_BACKUP', $new_filename) . "
"; $new_filename = $upload_location . $new_filename; $chkfileexist = "no"; } } else { $chkfileexist = "no"; } if ( $chkfileexist === "no" ) { // Resize and/or compress? $image_resize = false; $img_compressimg = 0; $img_maximgheight = 0; $img_maximgwidth = 0; // Check size of images before moving if (ModSimpleFileUploaderHelperv13::gd_get_info() && $upload_disablegdlib == 0) { if (($img = @getimagesize($_FILES["uploadedfile$mid"]["tmp_name"][$cnt])) && (((is_numeric($upload_maximgwidth) && $upload_maximgwidth > 0) || (is_numeric($upload_maximgheight) && $upload_maximgheight > 0)) || ($upload_thumbcreate == 1))) { list($width, $height, $type, $attr) = getimagesize($_FILES["uploadedfile$mid"]["tmp_name"][$cnt]); // Make sure we have a valid compression ratio if (!is_numeric($upload_compressimg) || $upload_compressimg > 100 || $upload_compressimg <= 0) $img_compressimg = 100; else $img_compressimg = $upload_compressimg; if ($upload_maximgheight == 0) $img_maximgheight = $height; else $img_maximgheight = $upload_maximgheight; if ($upload_maximgwidth == 0) $img_maximgwidth = $width; else $img_maximgwidth = $upload_maximgwidth; $ratioh = $img_maximgheight/$height; $ratiow = $img_maximgwidth/$width; $ratio = min($ratioh, $ratiow); // New dimensions $n_width = intval($ratio*$width); $n_height = intval($ratio*$height); $errmsg = ""; switch ($type) { case 1: //'image/gif' if (imagetypes() & IMG_GIF) { // not the same as IMAGETYPE $oim = imageCreateFromGIF($_FILES["uploadedfile$mid"]["tmp_name"][$cnt]) ; } else { $errmsg = "GIF ".JText::_('IMG_TYPE_FAIL')."
"; } break; case 2: //'image/jpeg' if (imagetypes() & IMG_JPG) { $oim = imageCreateFromJPEG($_FILES["uploadedfile$mid"]["tmp_name"][$cnt]) ; } else { $errmsg = "JPEG ".JText::_('IMG_TYPE_FAIL')."
"; } break; case 3: //'image/png' if (imagetypes() & IMG_PNG) { $oim = imageCreateFromPNG($_FILES["uploadedfile$mid"]["tmp_name"][$cnt]) ; $img_compressimg = round($img_compressimg / 10); // Quality is 0-9 for PNG if ($img_compressimg >= 10) $img_compressimg = 9; // If user has set quality to 100 } else { $errmsg = "PNG ".JText::_('IMG_TYPE_FAIL')."
"; } break; case 15: //'image/wbmp' if (imagetypes() & IMG_WBMP) { $oim = imageCreateFromWBMP($_FILES["uploadedfile$mid"]["tmp_name"][$cnt]) ; } else { $errmsg = "WBMP ".JText::_('IMG_TYPE_FAIL')."
"; } break; default: $errmsg = $type." ".JText::_('IMG_TYPE_FAIL')."
"; break; } if ($errmsg === "") { // If thumbnail $thumbfilename = ""; if ($upload_thumbcreate == 1) { $img_thumbsize = strtolower($upload_thumbsize); $img_thumbsize = explode("x", $img_thumbsize); if (is_array($img_thumbsize)) { if (count($img_thumbsize) == 2) { if (is_numeric($img_thumbsize[0]) && is_numeric($img_thumbsize[1])) { $ttim=imagecreatetruecolor($img_thumbsize[0],$img_thumbsize[1]); imagecopyresampled($ttim,$oim,0,0,0,0,$img_thumbsize[0],$img_thumbsize[1],$width,$height); $ext = substr(strrchr($_FILES["uploadedfile$mid"]["name"][$cnt], '.'), 1); $thumbfilename .= substr($_FILES["uploadedfile$mid"]["name"][$cnt], 0, (strlen($_FILES["uploadedfile$mid"]["name"][$cnt])-(strlen($ext) +1))) . "_" . $upload_thumbname . "." . $ext; // Make thumb as a link $results .= JText::_('IMG_THUMB_FILE') . '
'.$thumbfilename.'
'; //$results .= JText::_('IMG THUMB FILE') . " " . $thumbfilename . "
"; // Add path to thumb filename $thumbfilename = $upload_location . $thumbfilename; } } } } // Only thumbnail, no resize if ($upload_maximgheight !== 0 && $upload_maximgwidth !== 0) { $tim=imagecreatetruecolor($n_width,$n_height); imagecopyresampled($tim,$oim,0,0,0,0,$n_width,$n_height,$width,$height); } switch ($type) { case 1: // Only thumbnail, no resize if ($upload_maximgheight !== 0 && $upload_maximgwidth !== 0) imageGIF($tim, $upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt]); if ($thumbfilename !== "") imageGIF($ttim, $thumbfilename); $image_resize = true; break; case 2: // Only thumbnail, no resize if ($upload_maximgheight !== 0 && $upload_maximgwidth !== 0) imageJPEG($tim, $upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt], $img_compressimg); if ($thumbfilename !== "") imageJPEG($ttim, $thumbfilename); $img_compressimg = ""; $image_resize = true; break; case 3: // Only thumbnail, no resize if ($upload_maximgheight !== 0 && $upload_maximgwidth !== 0) imagePNG($tim, $upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt], $img_compressimg); if ($thumbfilename !== "") imagePNG($ttim, $thumbfilename); $img_compressimg = ""; $image_resize = true; break; case 15: // Only thumbnail, no resize if ($upload_maximgheight !== 0 && $upload_maximgwidth !== 0) imageWBMP($tim, $upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt]); if ($thumbfilename !== "") imageWBMP($ttim, $thumbfilename); break; $image_resize = true; default: $image_resize = false; break; } // Only thumbnail, no resize if ($upload_maximgheight !== 0 && $upload_maximgwidth !== 0) { imagedestroy($tim); if ($image_resize) $results .= JText::_('IMG_ORIG_RESIZE')."
"; else $results .= JText::_('IMG_RESIZE_FAIL')."
"; } else { $image_resize = false; } imagedestroy($oim); if ($thumbfilename !== "") imagedestroy($ttim); } else { $fileErr = 1; $results .= JText::_('FAIL_REQUEST') . "
"; $_SESSION["failedfile"] .= $_FILES["uploadedfile$mid"]["name"][$cnt]." (".JText::_('IMG_SAVE_FAIL').", ".$errmsg.")
"; } } if (($img = @getimagesize($_FILES["uploadedfile$mid"]["tmp_name"][$cnt])) && (!$image_resize) && ($upload_compressimg !== "") && is_numeric($upload_compressimg)) { // Compress JPEG? This only happens if no resize! list($width, $height, $type, $attr) = getimagesize($_FILES["uploadedfile$mid"]["tmp_name"][$cnt]); // Make sure we have a valid compression ratio if ($upload_compressimg > 100 || $upload_compressimg <= 0) $img_compressimg = 100; if (($type == 2) && (is_numeric($img_compressimg)) && ($fileErr == 0)) { $oim = imagecreatefromjpeg($_FILES["uploadedfile$mid"]["tmp_name"][$cnt]); if (imagejpeg($oim, $upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt], $img_compressimg)) { $fileErr = 0; $image_resize = true; } else { $fileErr = 1; $results .= JText::_('FAIL_REQUEST') . "
"; $_SESSION["failedfile"] .= $_FILES["uploadedfile$mid"]["name"][$cnt]." (".JText::_('IMG_COMPRESS_FAIL').")
"; } imagedestroy($oim); } // Compress PNG? This only happens if no resize! if (($type == 3) && (is_numeric($upload_compressimg)) && ($fileErr == 0)) { $oim = imagecreatefrompng($_FILES["uploadedfile$mid"]["tmp_name"][$cnt]); $img_compressimg = round($upload_compressimg / 100); // Quality is 0-9 for PNG if ($img_compressimg >= 10) $img_compressimg = 9; // If user has set quality to 100 if (imagepng($oim, $upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt], $img_compressimg)) { $fileErr = 0; $image_resize = true; } else { $fileErr = 1; $results .= JText::_('FAIL_REQUEST') . "
"; $_SESSION["failedfile"] .= $_FILES["uploadedfile$mid"]["name"][$cnt]." (".JText::_('IMG_COMPRESS_FAIL').")
"; } imagedestroy($oim); } if ($image_resize) $results .= JText::_('IMG_ORIG_COMPRESS')."
"; else $results .= JText::_('IMG_COMPRESS_FAIL')."
"; } } // If image has been resized it is already saved if (!$image_resize) { if (move_uploaded_file($_FILES["uploadedfile$mid"]["tmp_name"][$cnt], $upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt])) { $fileErr = 0; } else { $fileErr = 1; $results .= JText::_('FAIL_REQUEST') . "
"; $_FILES["uploadedfile$mid"]["name"][$cnt] = ""; } } // Form Fields if (($upload_useformsfields == 1) && (strlen($upload_formfields) > 0) && ($fileErr == 0)) { $fields = explode(";", $upload_formfields); $valname = ""; $valfile = ""; $ffform = ""; $fffield = ""; $formfieldsemail[$cnt] = ""; if ($upload_nohtmlencoding == 1) $ffform = trim ( $_REQUEST["sfuFormFields$mid"] ); else $ffform = htmlentities ( trim ( $_REQUEST["sfuFormFields$mid"] ) , ENT_NOQUOTES , "utf-8" ); if ($upload_debug == 1) print_r($_REQUEST); if ($upload_replacetag == 1) $ffform = str_replace(">", ">", str_replace("<", "<", $ffform)); if ($upload_debug == 1) $results .= "ffform=$ffform
"; $ffform = explode("[||]", $ffform); // If create a row in the form fileds file... if (strlen($upload_formfieldsfile) > 0) $valfile = $_FILES["uploadedfile$mid"]["name"][$cnt].$upload_formfieldsdiv; for ($iff = 0; $iff < count($ffform); $iff++) { $valname = $ffform[$iff]; $fffield = explode("=", $valname); foreach ($fields as $fld) { $valname = "sfuff".$mid."_".$fld."_".$_FILES["uploadedfile$mid"]["name"][$cnt]; if ($valname === $fffield[0]) { if (strlen($upload_formfieldsfile) > 0) $valfile .= $fffield[1].$upload_formfieldsdiv; else $valfile .= $fld."=".$fffield[1]."\n"; // Store for e-mail, use same counter as file $formfieldsemail[$cnt] .= $fld."=".$fffield[1]."\n"; } } if ($upload_debug == 1) $results .= "valname=$valname
"; } if (strlen($upload_formfieldsfile) > 0) { // Remove last pipe $valfile = substr($valfile, 0, -1); // Check if we got something if ($valfile === $_FILES["uploadedfile$mid"]["name"][$cnt]) $valfile = ""; } if ($upload_debug == 1) $results .= "valfile=$valfile
"; if ((strlen($valfile) > 0) && (strlen($upload_formfieldsfile) == 0)) { // Write the file: $ffFile = $upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt] . ".txt"; if ($upload_debug == 1) $results .= "ffFile=$ffFile
"; $fh = fopen($ffFile, 'w') or $fileErr = 1; if ($fileErr == 1) { $results .= JText::_('FAIL_FORMFIELDS_FILE') . "
"; } else { // For some mysterious reason PHP refuses to write UTF-8 as UTF-8. Some stupid work-around below found at php.net $valfile = mb_convert_encoding( $valfile, 'UTF-8'); fwrite($fh, $valfile); fclose($fh); } } // Store for Form Fields File, use same counter as file $formfieldsval[$cnt] = $valfile; } if (($upload_popshowpath == 1) && ($fileErr == 0)) { $results .= JText::sprintf('FILE_SAVE_AS', ''.$baseurl.$_FILES["uploadedfile$mid"]["name"][$cnt].'').'

'; } if ($upload_fileexist === "1" && file_exists($new_filename)) { if ($fileErr == 0) { // Delete (=replace) of old file unlink($new_filename); } else { // Put original back if something went wrong rename($new_filename, $upload_location . $_FILES["uploadedfile$mid"]["name"][$cnt]); } } //$results .= "
"; } } // UNZIP if (($upload_unzip == 1) && ($fileErr == 0)) { if (($_FILES["uploadedfile$mid"]["type"][$cnt] === "application/x-tar") || ($_FILES["uploadedfile$mid"]["type"][$cnt] === "application/x-tar-compressed") || ($_FILES["uploadedfile$mid"]["type"][$cnt] === "application/tar-compressed")) { //system("tar -zxvf ".$upload_location.$_FILES["uploadedfile$mid"]["name"]); $res = shell_exec("cd ".$upload_location.";tar -xvzf ".$_FILES["uploadedfile$mid"]["name"][$cnt].";"); if ($res === FALSE) { $results .= "

".JText::_('MSG_UNZIP_ERROR')."

"; } else { $results .= "

".JText::_('MSG_UNZIP')."

"; } } if (($_FILES["uploadedfile$mid"]["type"][$cnt] === "application/x-zip") || ($_FILES["uploadedfile$mid"]["type"][$cnt] === "application/x-zip-compressed") || ($_FILES["uploadedfile$mid"]["type"][$cnt] === "application/zip-compressed")) { $zip = new ZipArchive; $res = $zip->open($upload_location.$_FILES["uploadedfile$mid"]["name"][$cnt]); if ($res === TRUE) { $zip->extractTo($upload_location); $zip->close(); $results .= "

".JText::_('MSG_UNZIP')."

"; } else { $results .= "

".JText::_('MSG_UNZIP_ERROR')."

"; } } } $_SESSION["uploaderr$mid"] = $fileErr; } else { $fileErr = 1; $errmsg = "(".$_FILES["uploadedfile$mid"]["name"][$cnt].")
".JText::sprintf('FILE_IN_ERROR', $filetype)."
  [".ModSimpleFileUploaderHelperv13::errCodeToMessage($_FILES["uploadedfile$mid"]["error"][$cnt])."]

"; $_SESSION["uploaderr$mid"] = 1; if ($upload_showerrmsg == 1) $results .= $errmsg; else $results .= JText::_('UPLOAD_FAILED')."

"; if ($written == 0) { $filesize = ModSimpleFileUploaderHelperv13::getFileSizePP($upload_maxsize); $results .= JText::_('ALLOWED_TYPES') . ": " . $upload_filetypes . "
" . JText::_('FILE_MAX_SIZE') . ": " . $filesize . "

"; //$results .= "
"; $written = 1; } } } else { if ($upload_users === "false") { $_SESSION["uploaderr$mid"] = 1; $results .= JText::_('NOT_ALLOWED_USER'); } } } // end for // Create Form Fields file if ((count($formfieldsval) > 0) && (strlen($upload_formfieldsfile) > 0)) { // Write the file but read first if the same file exists from previous set: $valfile = ""; $ffFile = $upload_location . $upload_formfieldsfile; if (file_exists($ffFile)) { //RegExp can't handle pipe, make it escaped // !! Not needed for explode(), only deprecated split() !! //$upload_formfieldsdiv2 = $upload_formfieldsdiv; //if ($upload_formfieldsdiv === "|") $upload_formfieldsdiv2 = "\|"; $fileRows = explode("\n", file_get_contents($ffFile)); for ($cnt = 0; $cnt"; if (strpos($rowdata, $upload_formfieldsdiv) >= 0) { $rowArray = explode($upload_formfieldsdiv, $rowdata); if (strlen($rowArray[0]) > 0) { $found = false; for ($cnt2 = 0; $cnt2"; //echo "replace: [".str_replace($ffArray[0], "", $rowArray[0])."]
"; // Equal on string seems not reliable. Maybe encoding issues but replace does the trick it seems. //if ($ffArray[0] === $rowArray[0]) { if (strlen(str_replace($ffArray[0], "", $rowArray[0])) == 0) { //echo "inside!
"; $valfile .= $formfieldsval[$cnt2]."\n"; $formfieldsval[$cnt2] = ""; $found = true; break; } } if (!$found) $valfile .= $rowdata."\n"; } } } } $fh = fopen($ffFile, 'w') or $fileErr = 1; if ($fileErr == 1) { $results .= JText::_('FAIL_FORMFIELDS_FILE') . "
"; } else { for ($cnt = 0; $cnt 0) $valfile .= $formfieldsval[$cnt]."\n"; } // Don't make the file UTF-8 here as it totally messes up the reading of the file! // For some mysterious reason PHP refuses to write UTF-8 as UTF-8. Some stupid work-around below found at php.net //$valfile = chr(255).chr(254).mb_convert_encoding( $valfile, 'UTF-16LE', 'UTF-8'); //echo "valfile=$valfile
"; fwrite($fh, $valfile); fclose($fh); } } // SHOW DIR CONTENT if (($upload_showdircontent == 1) && ($fileErr == 0)) { $results .= "
"; if($bib = @opendir($upload_location)) { while (false !== ($lfile = readdir($bib))) { //if($lfile != "." && $lfile != ".." && !ereg("^\..+", $lfile) && $lfile != "index.html") { if($lfile !== "." && $lfile !== ".." && !preg_match("/^\..+/", $lfile) && $lfile !== "index.html") { $fil_list[] = "$lfile"; } } closedir($bib); if(is_array($fil_list)) { $liste = "
  • " . join("
  • ", $fil_list) . "
  • "; } else { $liste = "
  • " . JText::_('NO_FILES_FOUND') . " " . $upload_location . "
  • "; } $results .= "

    " . JText::_('FILES_IN_DIR') . " (" . $upload_location . "):

      " . $liste . "
    "; } else { //die("Could not read files in " . $upload_location); $results .= "

    " . JText::_('NO_FILES_FOUND') . "


    "; } $results .= "

    "; } // SEND E-MAIL if ((strlen($upload_email) > 0) && ($fileErr == 0)) { $to = $upload_email; $subject = JText::_('MAIL_SUBJECT'); $infos = explode("|", $fileInfo); $text = ""; $headers = ""; //Replace space with %20 for URL if ($upload_emailhtml == 0) { for ($cnt = 0; $cnt<$fileCnt; $cnt++) { if(strlen($_FILES["uploadedfile$mid"]["name"][$cnt]) > 0) $text .= $upload_location.$_FILES["uploadedfile$mid"]["name"][$cnt]." (".$baseurl.str_replace(" ", "%20", $_FILES["uploadedfile$mid"]["name"][$cnt]).")\r\n"; if (count($formfieldsemail) >= $cnt+1) { if (strlen($formfieldsemail[$cnt]) > 0) $text .= $formfieldsemail[$cnt] . "\r\n\r\n"; } } $body = JText::sprintf('MAIL_BODY', $_SERVER["HTTP_HOST"]); $body .= "\r\n\r\n".$text; $body .= "\r\n\r\n(Find out more about Simple File Upload for Joomla at http://wasen.net/)"; } else { $text = "

    "; for ($cnt = 0; $cnt<$fileCnt; $cnt++) { if(strlen($_FILES["uploadedfile$mid"]["name"][$cnt]) > 0) $text .= ""; if (count($formfieldsemail) >= $cnt+1) { if (strlen($formfieldsemail[$cnt]) > 0) { $fields = explode("\n", $formfieldsemail[$cnt]); foreach ($fields as $f) $text .= ""; } } } $text .= "
    ".$upload_location.$_FILES["uploadedfile$mid"]["name"][$cnt]." (".$baseurl.str_replace(" ", "%20", $_FILES["uploadedfile$mid"]["name"][$cnt]).")".$infos[$cnt]."
    " . $f . "

    "; $body = JText::sprintf('MAIL_BODY', $_SERVER["HTTP_HOST"]); if (strlen($users_name) < 5) $users_name = "Anonymous (@".$_SERVER['REMOTE_ADDR'].")"; $body .= " ".JText::sprintf('BY_USER', $users_name); $body .= $text; $body .= "

    (Find out more about Simple File Upload for Joomla at http://wasen.net/)"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers //$headers .= 'To: ' . $to . "\r\n"; $headers .= 'From: ' . $upload_mailfrom . "\r\n"; } if (mail($to, $subject, $body, $headers)) { if ($upload_emailmsg == 1) $results .= "

    ".JText::_('MSG_SENT')."

    "; } else { if ($upload_emailmsg == 1) $results .= "

    ".JText::_('MSG_FAILED')."(To:".$to.")

    "; } } return $results; } function gd_get_info() { if (extension_loaded('gd') and imagetypes() & IMG_PNG and imagetypes() & IMG_GIF and imagetypes() & IMG_JPG and imagetypes() & IMG_WBMP) { return true; } else { return false; } } function getFileSizePP($filesize) { $kb=1024; $mb=1048576; $gb=1073741824; $tb=1099511627776; if(!$filesize) $filesize = '0 B'; elseif($filesize<$kb) $filesize = $filesize.' B'; elseif($filesize<$mb) $filesize = round($filesize/$kb, 2).' KB'; elseif($filesize<$gb) $filesize = round($filesize/$mb, 2).' MB'; elseif($filesize<$tb) $filesize = round($filesize/$gb, 2).' GB'; else $filesize = round($filesize/$tb, 2).' TB'; return $filesize; } function errCodeToMessage($code) { $message = ""; switch ($code) { case UPLOAD_ERR_INI_SIZE: $message = JText::_('UPLOAD_ERR_INI_SIZE'); //"The uploaded file exceeds the upload_max_filesize directive in php.ini"; break; case UPLOAD_ERR_FORM_SIZE: $message = JText::_('UPLOAD_ERR_FORM_SIZE'); //"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"; break; case UPLOAD_ERR_PARTIAL: $message = JText::_('UPLOAD_ERR_PARTIAL'); //"The uploaded file was only partially uploaded"; break; case UPLOAD_ERR_NO_FILE: $message = JText::_('UPLOAD_ERR_NO_FILE'); //"No file was uploaded"; break; case UPLOAD_ERR_NO_TMP_DIR: $message = JText::_('UPLOAD_ERR_NO_TMP_DIR'); //"Missing a temporary folder"; break; case UPLOAD_ERR_CANT_WRITE: $message = JText::_('UPLOAD_ERR_CANT_WRITE'); //"Failed to write file to disk"; break; case UPLOAD_ERR_EXTENSION: $message = JText::_('UPLOAD_ERR_EXTENSION'); //"File upload stopped by extension"; break; default: $message = JText::_('UPLOAD_ERR_DEFAULT'); //"Unknown upload error"; break; } return $message; } function getGIFComment($filename, $upload_debug) { $retval = ""; $fd = fopen( $filename, 'rb' ); if ( $fd ) { if ($upload_debug == 1) $retval .= "
    getGIFComment: File opened!"; // Read GIF header $data = fread( $fd, 6 ); if ( $data == 'GIF87a' or $data == 'GIF89a' ) { if ($upload_debug == 1) $retval .= "
    getGIFComment: We've found a GIF"; $offset = 6; // Read Logical Screen Descriptor $data = fread( $fd, 7 ); $offset += 7; $width = ( ord( $data[1] ) << 8 ) + ord( $data[0] ); $height = ( ord( $data[3] ) << 8 ) + ord( $data[2] ); if ($upload_debug == 1) $retval .= "
    getGIFComment: GIF width: ".$width; if ($upload_debug == 1) $retval .= "
    getGIFComment: GIF height: ".$height; $done = false; while ( !$done ) { $data = fread( $fd, 1 ); $offset += 1; $blockType = ord( $data[0] ); if ( $blockType == 0x21 ) // Extension Introducer { $data .= fread( $fd, 1 ); $offset += 1; $extensionLabel = ord( $data[1] ); if ( $extensionLabel == 0xfe ) // Comment Extension { $commentBlockDone = false; $comment = false; while ( !$commentBlockDone ) { $data = fread( $fd, 1 ); $offset += 1; $blockBytes = ord( $data[0] ); if ( $blockBytes ) { $data = fread( $fd, $blockBytes ); $comment .= $data; $offset += $blockBytes; } else { $commentBlockDone = true; } } if ( $comment ) { if ($upload_debug == 1) $retval .= "
    getGIFComment: GIF has comment: ".$comment; if(stripos($comment, "php") !== false) { $retval = "getGIFComment:BLOCK".$retval; } else { $retval = "getGIFComment:OK".$retval; } } else { if ($upload_debug == 1) $retval .= "
    getGIFComment: No GIF comment found!"; $retval = "getGIFComment:OK".$retval; } $done = true; } } else if ( $blockType == 0x3b ) // Trailer, end of stream { if ($upload_debug == 1) $retval .= "
    getGIFComment: GIF stream terminated by Trailer block"; $done = true; } if ( feof( $fd ) ) { if ($upload_debug == 1) $retval .= "
    getGIFComment: GIF stream terminated by EOF"; $done = true; } } } } else { if ($upload_debug == 1) $retval .= "
    getGIFComment: File failed!"; } return $retval."
    "; } } class SFUAjaxServlet { function getCaptcha($sfu_version, $bgcolor, $mid, $source) { error_reporting(0); /*ini_set ("session.Save_path", $_SERVER['DOCUMENT_ROOT'] . "/mySessions"); session_start(); if (isset($_SERVER['REMOTE_HOST'])) { session_name($_SERVER['REMOTE_HOST'] . "-captcha"); } else { session_name(uniqid() . "-captcha"); }*/ $myCryptBase = "AB0CDE1FG2HIJ3KL4MNO5PQ6RST7UV8WX9YZ"; $capString = ""; $image = imagecreatetruecolor(150, 60); $white = imagecolorallocate ($image, 255, 255, 255); $rndm = imagecolorallocate ($image, rand($bgcolor[0],$bgcolor[1]), rand($bgcolor[0],$bgcolor[1]), rand($bgcolor[0],$bgcolor[1])); imagefill ($image, 0, 0, $white); $folder_captcha_class = JPATH_SITE.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'mod_simplefileuploadv'.$sfu_version.DIRECTORY_SEPARATOR.'tmpl'; $fontName = $folder_captcha_class."/arial.ttf"; $myX = 15; $myY = 30; $angle = 0; for ($x = 0; $x <=1000; $x++) { $myX = rand(1,148); $myY = rand(1,58); imageline($image, $myX, $myY, $myX + rand(-5,5), $myY + rand(-5,5), $rndm); } for ($x = 0; $x <= 4; $x++) { $dark = imagecolorallocate ($image, rand(5,128),rand(5,128),rand(5,128)); $capChar = substr($myCryptBase, rand(1,35), 1); $capString .= $capChar; $fs = rand (20, 26); $myX = 15 + ($x * 28+ rand(-5,5)); $myY = rand($fs + 2,55); $angle = rand(-30, 30); ImageTTFText ($image,$fs, $angle, $myX, $myY, $dark, $fontName, $capChar); } $_SESSION["capString$mid"] = $capString; ob_start(); header ("Content-type: image/jpeg"); imagejpeg($image,"",95); $result = ob_get_contents(); ob_end_clean(); if ($source === 'site') echo base64_encode($result); else echo $result; imagedestroy($image); error_reporting(E_ALL); } function getContent($action) { $retVal = "false"; if ($action === "sfuuser") { $user = $_GET["val1"]; $pass = $_GET["val2"]; $mid = $_GET["mid"]; $session_username = ""; $session_password = ""; // TODO: Should I fetch this from DB if session has expired before trying to login... Else it will return failed... if (isset($_SESSION["upload_username$mid"])) { $session_username = $_SESSION["upload_username$mid"]; $session_password = $_SESSION["upload_password$mid"]; } if (strlen($session_username) == 0) { // Workaround for missing session user... should be from DB I guess... //$retVal = "Credentials not found. Please refresh your session or contact the Administrator to get the login details."; $retVal = JText::_('FAIL_CREDENTIALS'); } else { $hashedpw = md5($session_password); if ((strcmp($user, $session_username) == 0) && (strcmp($pass, $hashedpw) == 0)) { $_SESSION["upload_username_ok$mid"] = $hashedpw; $retVal = "true"; } else { //$retVal = "Username and/or password does not match"; $retVal = JText::_('USER_PASS_FAILED'); /* debug $retVal .= "\nGiven user = " . $user; $retVal .= "\nGiven pass = " . $pass; $retVal .= "\nStored user = " . $session_username; $retVal .= "\nStored pass = " . $session_password; $retVal .= "\nStored hash = " . md5($session_password); */ } } } if ($action === "sfucaptcha") { $captcha = $_GET["val1"]; $casesense = $_GET["val2"]; $mid = $_GET["mid"]; $captchaStored = ""; if (isset($_SESSION["capString$mid"])) $captchaStored = $_SESSION["capString$mid"]; else $retVal = JText::_('FAIL_REQUEST') . "\n\n[Session time-out]"; if ($casesense === "1") { $captchaStored = strtoupper($captchaStored); $captcha = strtoupper($captcha); } if (strlen($captchaStored) > 0) { if ($captchaStored === $captcha) $retVal = "true"; else $retVal = JText::_('FAULTY_CAPTCHA'); } else { $retVal = JText::_('FAIL_REQUEST'); } } if ($action === "sfukillsession") { $ses = session_destroy(); if ($ses) $retVal = "Session destroyed"; else $retVal = "Session still alive"; } //global $mainframe; $app = JFactory::getApplication(); echo $retVal; //$mainframe->close(); $app->close(); } } ?>home/academiac/www/modules/mod_random_image/helper.php000064400000004552151373263160017145 0ustar00get('width'); $height = $params->get('height'); $i = count($images); $random = mt_rand(0, $i - 1); $image = $images[$random]; $size = getimagesize (JPATH_BASE . '/' . $image->folder . '/' . $image->name); if ($width == '') { $width = 100; } if ($size[0] < $width) { $width = $size[0]; } $coeff = $size[0]/$size[1]; if ($height == '') { $height = (int) ($width/$coeff); } else { $newheight = min ($height, (int) ($width/$coeff)); if ($newheight < $height) { $height = $newheight; } else { $width = $height * $coeff; } } $image->width = $width; $image->height = $height; $image->folder = str_replace('\\', '/', $image->folder); return $image; } static function getImages(&$params, $folder) { $type = $params->get('type', 'jpg'); $files = array(); $images = array(); $dir = JPATH_BASE . '/' . $folder; // check if directory exists if (is_dir($dir)) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'index.html') { $files[] = $file; } } } closedir($handle); $i = 0; foreach ($files as $img) { if (!is_dir($dir . '/' . $img)) { if (preg_match('/'.$type.'/', $img)) { $images[$i] = new stdClass; $images[$i]->name = $img; $images[$i]->folder = $folder; $i++; } } } } return $images; } static function getFolder(&$params) { $folder = $params->get('folder'); $LiveSite = JURI::base(); // if folder includes livesite info, remove if (JString::strpos($folder, $LiveSite) === 0) { $folder = str_replace($LiveSite, '', $folder); } // if folder includes absolute path, remove if (JString::strpos($folder, JPATH_SITE) === 0) { $folder= str_replace(JPATH_BASE, '', $folder); } $folder = str_replace('\\', DIRECTORY_SEPARATOR, $folder); $folder = str_replace('/', DIRECTORY_SEPARATOR, $folder); return $folder; } } home/academiac/www/libraries/joomla/installer/helper.php000064400000016460151373370470017452 0ustar00getUserAgent('Installer')); $http = JHttpFactory::getHttp(); // load installer plugins, and allow url and headers modification $headers = array(); JPluginHelper::importPlugin('installer'); $dispatcher = JDispatcher::getInstance(); $results = $dispatcher->trigger('onInstallerBeforePackageDownload', array(&$url, &$headers)); try { $response = $http->get($url, $headers); } catch (Exception $exc) { $response = null; } if (is_null($response)) { JError::raiseWarning(42, JText::_('JLIB_INSTALLER_ERROR_DOWNLOAD_SERVER_CONNECT')); return false; } if (302 == $response->code && isset($response->headers['Location'])) { return self::downloadPackage($response->headers['Location']); } elseif (200 != $response->code) { if ($response->body === '') { $response->body = $php_errormsg; } JError::raiseWarning(42, JText::sprintf('JLIB_INSTALLER_ERROR_DOWNLOAD_SERVER_CONNECT', $response->body)); return false; } // Parse the Content-Disposition header to get the file name if (isset($response->headers['Content-Disposition']) && preg_match("/\s*filename\s?=\s?(.*)/", $response->headers['Content-Disposition'], $parts)) { $target = trim(rtrim($parts[1], ";"), '"'); } // Set the target path if not given if (!$target) { $target = $config->get('tmp_path') . '/' . self::getFilenameFromURL($url); } else { $target = $config->get('tmp_path') . '/' . basename($target); } // Write buffer to file JFile::write($target, $response->body); // Restore error tracking to what it was before ini_set('track_errors', $track_errors); // bump the max execution time because not using built in php zip libs are slow @set_time_limit(ini_get('max_execution_time')); // Return the name of the downloaded package return basename($target); } /** * Unpacks a file and verifies it as a Joomla element package * Supports .gz .tar .tar.gz and .zip * * @param string $p_filename The uploaded package filename or install directory * * @return array Two elements: extractdir and packagefile * * @since 11.1 */ public static function unpack($p_filename) { // Path to the archive $archivename = $p_filename; // Temporary folder to extract the archive into $tmpdir = uniqid('install_'); // Clean the paths to use for archive extraction $extractdir = JPath::clean(dirname($p_filename) . '/' . $tmpdir); $archivename = JPath::clean($archivename); // Do the unpacking of the archive $result = JArchive::extract($archivename, $extractdir); if ($result === false) { return false; } /* * Let's set the extraction directory and package file in the result array so we can * cleanup everything properly later on. */ $retval['extractdir'] = $extractdir; $retval['packagefile'] = $archivename; /* * Try to find the correct install directory. In case the package is inside a * subdirectory detect this and set the install directory to the correct path. * * List all the items in the installation directory. If there is only one, and * it is a folder, then we will set that folder to be the installation folder. */ $dirList = array_merge(JFolder::files($extractdir, ''), JFolder::folders($extractdir, '')); if (count($dirList) == 1) { if (JFolder::exists($extractdir . '/' . $dirList[0])) { $extractdir = JPath::clean($extractdir . '/' . $dirList[0]); } } /* * We have found the install directory so lets set it and then move on * to detecting the extension type. */ $retval['dir'] = $extractdir; /* * Get the extension type and return the directory/type array on success or * false on fail. */ if ($retval['type'] = self::detectType($extractdir)) { return $retval; } else { return false; } } /** * Method to detect the extension type from a package directory * * @param string $p_dir Path to package directory * * @return mixed Extension type string or boolean false on fail * * @since 11.1 */ public static function detectType($p_dir) { // Search the install dir for an XML file $files = JFolder::files($p_dir, '\.xml$', 1, true); if (!count($files)) { JError::raiseWarning(1, JText::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE')); return false; } foreach ($files as $file) { if (!$xml = JFactory::getXML($file)) { continue; } if ($xml->getName() != 'install' && $xml->getName() != 'extension') { unset($xml); continue; } $type = (string) $xml->attributes()->type; // Free up memory unset($xml); return $type; } JError::raiseWarning(1, JText::_('JLIB_INSTALLER_ERROR_NOTFINDJOOMLAXMLSETUPFILE')); // Free up memory. unset($xml); return false; } /** * Gets a file name out of a url * * @param string $url URL to get name from * * @return mixed String filename or boolean false if failed * * @since 11.1 */ public static function getFilenameFromURL($url) { if (is_string($url)) { $parts = explode('/', $url); return $parts[count($parts) - 1]; } return false; } /** * Clean up temporary uploaded package and unpacked extension * * @param string $package Path to the uploaded package file * @param string $resultdir Path to the unpacked extension * * @return boolean True on success * * @since 11.1 */ public static function cleanupInstall($package, $resultdir) { $config = JFactory::getConfig(); // Does the unpacked extension directory exist? if (is_dir($resultdir)) { JFolder::delete($resultdir); } // Is the package file a valid file? if (is_file($package)) { JFile::delete($package); } elseif (is_file(JPath::clean($config->get('tmp_path') . '/' . $package))) { // It might also be just a base filename JFile::delete(JPath::clean($config->get('tmp_path') . '/' . $package)); } } /** * Splits contents of a sql file into array of discreet queries. * Queries need to be delimited with end of statement marker ';' * * @param string $sql The SQL statement. * * @return array Array of queries * * @since 11.1 */ public static function splitSql($sql) { $db = JFactory::getDbo(); return $db->splitSql($sql); } } home/academiac/www/modules/mod_syndicate/helper.php000064400000001110151373521450016470 0ustar00_links as $link => $value) { $value = JArrayHelper::toString($value); if (strpos($value, 'application/'.$params->get('format').'+xml')) { return $link; } } } } home/academiac/www/modules/mod_whosonline/helper.php000064400000003664151373535550016720 0ustar00getQuery(true); $query->select('guest, usertype, client_id'); $query->from('#__session'); $query->where('client_id = 0'); $db->setQuery($query); $sessions = (array) $db->loadObjectList(); if (count($sessions)) { foreach ($sessions as $session) { // if guest increase guest count by 1 if ($session->guest == 1 && !$session->usertype) { $guest_array ++; } // if member increase member count by 1 if ($session->guest == 0) { $user_array ++; } } } $result['user'] = $user_array; $result['guest'] = $guest_array; return $result; } // show online member names static function getOnlineUserNames($params) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.username, a.time, a.userid, a.usertype, a.client_id'); $query->from('#__session AS a'); $query->where('a.userid != 0'); $query->where('a.client_id = 0'); $query->group('a.userid'); $user = JFactory::getUser(); if (!$user->authorise('core.admin') && $params->get('filter_groups', 0) == 1) { $groups = $user->getAuthorisedGroups(); if (empty($groups)) { return array(); } $query->leftJoin('#__user_usergroup_map AS m ON m.user_id = a.userid'); $query->leftJoin('#__usergroups AS ug ON ug.id = m.group_id'); $query->where('ug.id in (' . implode(',', $groups) . ')'); $query->where('ug.id <> 1'); } $db->setQuery($query); return (array) $db->loadObjectList(); } } home/academiac/www/modules/mod_weblinks/helper.php000064400000006345151373556210016344 0ustar00 true)); // Set application parameters in model $app = JFactory::getApplication(); $appParams = $app->getParams(); $model->setState('params', $appParams); // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('count', 5)); $model->setState('filter.state', 1); $model->setState('filter.publish_date', true); $model->setState('filter.archived', 0); $model->setState('filter.approved', 1); // Access filter $access = !JComponentHelper::getParams('com_weblinks')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $model->setState('filter.access', $access); $ordering = $params->get('ordering', 'ordering'); $model->setState('list.ordering', $ordering == 'order' ? 'ordering' : $ordering); $model->setState('list.direction', $params->get('direction', 'asc')); $catid = (int) $params->get('catid', 0); $model->setState('category.id', $catid); // Create query object $db = JFactory::getDbo(); $query = $db->getQuery(true); $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('a.alias'); $case_when1 .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when1 .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $a_id.' END as slug'; $case_when2 = ' CASE WHEN '; $case_when2 .= $query->charLength('c.alias'); $case_when2 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when2 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when2 .= ' ELSE '; $case_when2 .= $c_id.' END as catslug'; $model->setState('list.select', 'a.*, c.published AS c_published,'.$case_when1.','.$case_when2.','. 'DATE_FORMAT(a.date, "%Y-%m-%d") AS created'); $model->setState('filter.c.published', 1); // Filter by language $model->setState('filter.language', $app->getLanguageFilter()); $items = $model->getItems(); /* * This was in the previous code before we changed over to using the * weblinkscategory model but I don't see any models using checked_out filters * in their getListQuery() methods so I believe we should not be adding this now */ /* $query->where('(a.checked_out = 0 OR a.checked_out = '.$user->id.')'); */ for ($i =0, $count = count($items); $i < $count; $i++) { $item = &$items[$i]; if ($item->params->get('count_clicks', $params->get('count_clicks')) == 1) { $item->link = JRoute::_('index.php?option=com_weblinks&task=weblink.go&catid='.$item->catslug.'&id='. $item->slug); } else { $item->link = $item->url; } } return $items; } } home/academiac/www/modules/mod_banners/helper.php000064400000002312151373573030016143 0ustar00getMetaData('keywords')); $model = JModelLegacy::getInstance('Banners', 'BannersModel', array('ignore_request'=>true)); $model->setState('filter.client_id', (int) $params->get('cid')); $model->setState('filter.category_id', $params->get('catid', array())); $model->setState('list.limit', (int) $params->get('count', 1)); $model->setState('list.start', 0); $model->setState('filter.ordering', $params->get('ordering')); $model->setState('filter.tag_search', $params->get('tag_search')); $model->setState('filter.keywords', $keywords); $model->setState('filter.language', $app->getLanguageFilter()); $banners = $model->getItems(); $model->impress(); return $banners; } } home/academiac/www/modules/mod_login/helper.php000064400000003437151373574240015640 0ustar00getRouter(); $url = null; if ($itemid = $params->get($type)) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName('link')); $query->from($db->quoteName('#__menu')); $query->where($db->quoteName('published') . '=1'); $query->where($db->quoteName('id') . '=' . $db->quote($itemid)); $db->setQuery($query); if ($link = $db->loadResult()) { if ($router->getMode() == JROUTER_MODE_SEF) { $url = 'index.php?Itemid='.$itemid; } else { $url = $link.'&Itemid='.$itemid; } } } if (!$url) { // stay on the same page $uri = clone JFactory::getURI(); $vars = $router->parse($uri); unset($vars['lang']); if ($router->getMode() == JROUTER_MODE_SEF) { if (isset($vars['Itemid'])) { $itemid = $vars['Itemid']; $menu = $app->getMenu(); $item = $menu->getItem($itemid); unset($vars['Itemid']); if (isset($item) && $vars == $item->query) { $url = 'index.php?Itemid='.$itemid; } else { $url = 'index.php?'.JURI::buildQuery($vars).'&Itemid='.$itemid; } } else { $url = 'index.php?'.JURI::buildQuery($vars); } } else { $url = 'index.php?'.JURI::buildQuery($vars); } } return base64_encode($url); } static function getType() { $user = JFactory::getUser(); return (!$user->get('guest')) ? 'logout' : 'login'; } } home/academiac/www/modules/mod_articles_news/helper.php000064400000006472151374251010017360 0ustar00 true)); // Set application parameters in model $appParams = JFactory::getApplication()->getParams(); $model->setState('params', $appParams); // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('count', 5)); $model->setState('filter.published', 1); $model->setState('list.select', 'a.fulltext, a.id, a.title, a.alias, a.title_alias, a.introtext, a.state, a.catid, a.created, a.created_by, a.created_by_alias,' . ' a.modified, a.modified_by, a.publish_up, a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access,' . ' a.hits, a.featured, a.language' ); // Access filter $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $model->setState('filter.access', $access); // Category filter $model->setState('filter.category_id', $params->get('catid', array())); // Filter by language $model->setState('filter.language', $app->getLanguageFilter()); // Set ordering $ordering = $params->get('ordering', 'a.publish_up'); $model->setState('list.ordering', $ordering); if (trim($ordering) == 'rand()') { $model->setState('list.direction', ''); } else { $model->setState('list.direction', 'DESC'); } // Retrieve Content $items = $model->getItems(); foreach ($items as &$item) { $item->readmore = strlen(trim($item->fulltext)); $item->slug = $item->id.':'.$item->alias; $item->catslug = $item->catid.':'.$item->category_alias; if ($access || in_array($item->access, $authorised)) { // We know that user has the privilege to view the article $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language)); $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE'); } else { $item->link = JRoute::_('index.php?option=com_users&view=login'); $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE_REGISTER'); } $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'mod_articles_news.content'); //new if (!$params->get('image')) { $item->introtext = preg_replace('/]*>/', '', $item->introtext); } $results = $app->triggerEvent('onContentAfterDisplay', array('com_content.article', &$item, &$params, 1)); $item->afterDisplayTitle = trim(implode("\n", $results)); $results = $app->triggerEvent('onContentBeforeDisplay', array('com_content.article', &$item, &$params, 1)); $item->beforeDisplayContent = trim(implode("\n", $results)); } return $items; } } home/academiac/www/modules/mod_breadcrumbs/helper.php000064400000003633151374257550017022 0ustar00getPathway(); $items = $pathway->getPathWay(); $count = count($items); // don't use $items here as it references JPathway properties directly $crumbs = array(); for ($i = 0; $i < $count; $i ++) { $crumbs[$i] = new stdClass(); $crumbs[$i]->name = stripslashes(htmlspecialchars($items[$i]->name, ENT_COMPAT, 'UTF-8')); $crumbs[$i]->link = JRoute::_($items[$i]->link); } if ($params->get('showHome', 1)) { $item = new stdClass(); $item->name = htmlspecialchars($params->get('homeText', JText::_('MOD_BREADCRUMBS_HOME'))); $item->link = JRoute::_('index.php?Itemid='.$app->getMenu()->getDefault()->id); array_unshift($crumbs, $item); } return $crumbs; } /** * Set the breadcrumbs separator for the breadcrumbs display. * * @param string $custom Custom xhtml complient string to separate the * items of the breadcrumbs * @return string Separator string * @since 1.5 */ public static function setSeparator($custom = null) { $lang = JFactory::getLanguage(); // If a custom separator has not been provided we try to load a template // specific one first, and if that is not present we load the default separator if ($custom == null) { if ($lang->isRTL()){ $_separator = JHtml::_('image', 'system/arrow_rtl.png', NULL, NULL, true); } else{ $_separator = JHtml::_('image', 'system/arrow.png', NULL, NULL, true); } } else { $_separator = htmlspecialchars($custom); } return $_separator; } } home/academiac/www/modules/mod_avatar_slide_galleria/helper.php000060400000005754151375024050021015 0ustar00get('Source');} public static function getflickrSearchBy($params){return $params->get('flickrSearchBy');} public static function getpicasaSearchBy($params){return $params->get('picasaSearchBy');} public static function getstringFlickr($params){return $params->get('stringFlickr');} public static function getstringPicasa($params){return $params->get('stringPicasa');} public static function getTheme($params){return $params->get('theme');} public static function getresponsive($params){return $params->get('responsive');} public static function getlightBox($params){return $params->get('lightBox');} public static function getflickrSort($params){return $params->get('flickrSort');} public static function getimageQuality($params){return $params->get('imageQuality');} public static function gettransitionSpeed($params){return $params->get('transitionSpeed');} public static function getimgCrop($params){return $params->get('imgCrop');} public static function getimgPan($params){return $params->get('imgPan');} public static function getimgPanSmoothness($params){return $params->get('imgPanSmoothness');} public static function getshowCounter($params){return $params->get('showCounter');} public static function getshowImageNav($params){return $params->get('showImageNav');} public static function getswipe($params){return $params->get('swipe');} public static function getthumbnails($params){return $params->get('thumbnails');} public static function gettitle($params){return $params->get('title');} public static function getbgColor($params){return $params->get('bgColor');} public static function getbgoption($params){return $params->get('background');} public static function getshowInfo($params){return $params->get('showInfo');} public static function getshowFileName($params){return $params->get('showFileName');} public static function getfullscreenCrop($params){return $params->get('fullsreenCrop');} public static function getdataSort($params){return $params->get('dataSort');} public static function getfullscreenTransition($params){return $params->get('fullscreenTransition');} public static function getfullscreenBtn($params){return $params->get('fullscreenBtn');} public static function getprogress($params){return $params->get('progress');} public static function getinfoColor($params){return $params->get('infoColor');} public static function gettitleColor($params){return $params->get('titleColor');} public static function getdesColor($params){return $params->get('desColor');} //function get($params){return $params->get('responsive');} } ?>home/academiac/www/modules/mod_googlesearch_cse/helper.php000060400000002055151375025030020001 0ustar00get('id'); $db = JFactory::getDBO(); $db->setQuery("SELECT * FROM #__googleSearch_cse_conf LIMIT 1"); $rows = $db->loadObjectList(); $r = $rows[0]; return $r; } static function getItemid(&$params) { global $mainframe; $db = JFactory::getDBO(); $user = JFactory::getUser(); $userId = (int) $user->get('id'); $db = JFactory::getDBO(); $db->setQuery("SELECT id FROM #__menu where link LIKE 'index.php?option=com_googlesearchcse&view=googleSearch%' LIMIT 1"); $Itemid = $db->loadResult(); return $Itemid; } } home/academiac/www/modules/mod_articles_popular/helper.php000064400000004141151375025120020057 0ustar00 true)); // Set application parameters in model $app = JFactory::getApplication(); $appParams = $app->getParams(); $model->setState('params', $appParams); // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('count', 5)); $model->setState('filter.published', 1); $model->setState('filter.featured', $params->get('show_front', 1) == 1 ? 'show' : 'hide'); // Access filter $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $model->setState('filter.access', $access); // Category filter $model->setState('filter.category_id', $params->get('catid', array())); // Filter by language $model->setState('filter.language', $app->getLanguageFilter()); // Ordering $model->setState('list.ordering', 'a.hits'); $model->setState('list.direction', 'DESC'); $items = $model->getItems(); foreach ($items as &$item) { $item->slug = $item->id.':'.$item->alias; $item->catslug = $item->catid.':'.$item->category_alias; if ($access || in_array($item->access, $authorised)) { // We know that user has the privilege to view the article $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->language)); } else { $item->link = JRoute::_('index.php?option=com_users&view=login'); } } return $items; } } home/academiac/www/modules/mod_articles_archive/helper.php000064400000003406151375035570020033 0ustar00getQuery(true); $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year'); $query->from('#__content'); $query->where('state = 2 AND checked_out = 0'); $query->group('created_year DESC, created_month DESC'); // Filter by language if (JFactory::getApplication()->getLanguageFilter()) { $query->where('language in ('.$db->quote(JFactory::getLanguage()->getTag()).','.$db->quote('*').')'); } $db->setQuery($query, 0, intval($params->get('count'))); $rows = (array) $db->loadObjectList(); $app = JFactory::getApplication(); $menu = $app->getMenu(); $item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true); $itemid = (isset($item) && !empty($item->id) ) ? '&Itemid='.$item->id : ''; $i = 0; $lists = array(); foreach ($rows as $row) { $date = JFactory::getDate($row->created); $created_month = $date->format('n'); $created_year = $date->format('Y'); $created_year_cal = JHTML::_('date', $row->created, 'Y'); $month_name_cal = JHTML::_('date', $row->created, 'F'); $lists[$i] = new stdClass; $lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year='.$created_year.'&month='.$created_month.$itemid); $lists[$i]->text = JText::sprintf('MOD_ARTICLES_ARCHIVE_DATE', $month_name_cal, $created_year_cal); $i++; } return $lists; } } home/academiac/www/modules/mod_virtuemart_product/helper.php000060400000011707151375070250020457 0ustar00load ('com_virtuemart'); if (!class_exists ('calculationHelper')) { require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'calculationh.php'); } if (!class_exists ('CurrencyDisplay')) { require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php'); } if (!class_exists ('VirtueMartModelVendor')) { require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' . DS . 'vendor.php'); } if (!class_exists ('VmImage')) { require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'image.php'); } if (!class_exists ('shopFunctionsF')) { require(JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'shopfunctionsf.php'); } if (!class_exists ('calculationHelper')) { require(JPATH_COMPONENT_SITE . DS . 'helpers' . DS . 'cart.php'); } if (!class_exists ('VirtueMartModelProduct')) { JLoader::import ('product', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models'); } class mod_virtuemart_product { static function addtocart ($product) { if (!VmConfig::get ('use_as_catalog', 0)) { $stockhandle = VmConfig::get ('stockhandle', 'none'); if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($product->product_in_stock - $product->product_ordered) < 1) { $button_lbl = JText::_ ('COM_VIRTUEMART_CART_NOTIFY'); $button_cls = 'notify-button'; $button_name = 'notifycustomer'; ?>
    customfieldsCart)) { ?>
    customfieldsCart as $field) { ?>
    show_title == 1) { ?> custom_title ?> custom_tip, $field->custom_title, 'tooltip.png'); ?> display ?> custom_field_desc ?>
    orderable); ?>
    type == $type) { $result[] = $p; } } } else { foreach ($plugins as $p) { // Is this plugin in the right group? if ($p->type == $type && $p->name == $plugin) { $result = $p; break; } } } return $result; } /** * Checks if a plugin is enabled. * * @param string $type The plugin type, relates to the sub-directory in the plugins directory. * @param string $plugin The plugin name. * * @return boolean * * @since 11.1 */ public static function isEnabled($type, $plugin = null) { $result = self::getPlugin($type, $plugin); return (!empty($result)); } /** * Loads all the plugin files for a particular type if no specific plugin is specified * otherwise only the specific plugin is loaded. * * @param string $type The plugin type, relates to the sub-directory in the plugins directory. * @param string $plugin The plugin name. * @param boolean $autocreate Autocreate the plugin. * @param JDispatcher $dispatcher Optionally allows the plugin to use a different dispatcher. * * @return boolean True on success. * * @since 11.1 */ public static function importPlugin($type, $plugin = null, $autocreate = true, $dispatcher = null) { static $loaded = array(); // check for the default args, if so we can optimise cheaply $defaults = false; if (is_null($plugin) && $autocreate == true && is_null($dispatcher)) { $defaults = true; } if (!isset($loaded[$type]) || !$defaults) { $results = null; // Load the plugins from the database. $plugins = self::_load(); // Get the specified plugin(s). for ($i = 0, $t = count($plugins); $i < $t; $i++) { if ($plugins[$i]->type == $type && ($plugin === null || $plugins[$i]->name == $plugin)) { self::_import($plugins[$i], $autocreate, $dispatcher); $results = true; } } // Bail out early if we're not using default args if (!$defaults) { return $results; } $loaded[$type] = $results; } return $loaded[$type]; } /** * Loads the plugin file. * * @param JPlugin &$plugin The plugin. * @param boolean $autocreate True to autocreate. * @param JDispatcher $dispatcher Optionally allows the plugin to use a different dispatcher. * * @return boolean True on success. * * @since 11.1 */ protected static function _import(&$plugin, $autocreate = true, $dispatcher = null) { static $paths = array(); $plugin->type = preg_replace('/[^A-Z0-9_\.-]/i', '', $plugin->type); $plugin->name = preg_replace('/[^A-Z0-9_\.-]/i', '', $plugin->name); $legacypath = JPATH_PLUGINS . '/' . $plugin->type . '/' . $plugin->name . '.php'; $path = JPATH_PLUGINS . '/' . $plugin->type . '/' . $plugin->name . '/' . $plugin->name . '.php'; if (!isset($paths[$path]) || !isset($paths[$legacypath])) { $pathExists = file_exists($path); if ($pathExists || file_exists($legacypath)) { $path = $pathExists ? $path : $legacypath; if (!isset($paths[$path])) { require_once $path; } $paths[$path] = true; if ($autocreate) { // Makes sure we have an event dispatcher if (!is_object($dispatcher)) { $dispatcher = JDispatcher::getInstance(); } $className = 'plg' . $plugin->type . $plugin->name; if (class_exists($className)) { // Load the plugin from the database. if (!isset($plugin->params)) { // Seems like this could just go bye bye completely $plugin = self::getPlugin($plugin->type, $plugin->name); } // Instantiate and register the plugin. new $className($dispatcher, (array) ($plugin)); } } } else { $paths[$path] = false; } } } /** * Loads the published plugins. * * @return array An array of published plugins * * @since 11.1 */ protected static function _load() { if (self::$plugins !== null) { return self::$plugins; } $user = JFactory::getUser(); $cache = JFactory::getCache('com_plugins', ''); $levels = implode(',', $user->getAuthorisedViewLevels()); if (!(self::$plugins = $cache->get($levels))) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('folder AS type, element AS name, params') ->from('#__extensions') ->where('enabled >= 1') ->where('type =' . $db->Quote('plugin')) ->where('state >= 0') ->where('access IN (' . $levels . ')') ->order('ordering'); self::$plugins = $db->setQuery($query)->loadObjectList(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } $cache->store(self::$plugins, $levels); } return self::$plugins; } } home/academiac/www/administrator/modules/mod_version/helper.php000064400000002025151375334500021060 0ustar00get('format', 'short'); $product = $params->get('product', 0); $method = 'get' . ucfirst($format) . "Version"; // Get the joomla version $instance = new JVersion(); $version = call_user_func(array($instance, $method));//$instance->{$method}; if ($format=='short' && !empty($product)) { //add the product name to short format only (in long format it's included) $version = $instance->PRODUCT . ' ' . $version; } return $version; } } home/academiac/www/modules/mod_sociallogin/classes/helper.php000060400000004633151375340470020461 0ustar00setQuery ($sql); $rows = $db->LoadAssocList (); if (is_array ($rows)) { foreach ($rows AS $key => $data) { if ($data['setting'] == 'providers') { $tmp = @unserialize ($data ['value']); if (is_array ($tmp)) { $settings [$data['setting']] = $tmp; } else { $settings [$data['setting']] = array(); } } else { $settings [$data['setting']] = $data ['value']; } } } return $settings; } }home/academiac/www/administrator/modules/mod_latest/helper.php000064400000006070151375455540020703 0ustar00 true)); // Set List SELECT $model->setState('list.select', 'a.id, a.title, a.checked_out, a.checked_out_time, ' . ' a.access, a.created, a.created_by, a.created_by_alias, a.featured, a.state'); // Set Ordering filter switch ($params->get('ordering')) { case 'm_dsc': $model->setState('list.ordering', 'modified DESC, created'); $model->setState('list.direction', 'DESC'); break; case 'c_dsc': default: $model->setState('list.ordering', 'created'); $model->setState('list.direction', 'DESC'); break; } // Set Category Filter $categoryId = $params->get('catid'); if (is_numeric($categoryId)){ $model->setState('filter.category_id', $categoryId); } // Set User Filter. $userId = $user->get('id'); switch ($params->get('user_id')) { case 'by_me': $model->setState('filter.author_id', $userId); break; case 'not_me': $model->setState('filter.author_id', $userId); $model->setState('filter.author_id.include', false); break; } // Set the Start and Limit $model->setState('list.start', 0); $model->setState('list.limit', $params->get('count', 5)); $items = $model->getItems(); if ($error = $model->getError()) { JError::raiseError(500, $error); return false; } // Set the links foreach ($items as &$item) { if ($user->authorise('core.edit', 'com_content.article.'.$item->id)){ $item->link = JRoute::_('index.php?option=com_content&task=article.edit&id='.$item->id); } else { $item->link = ''; } } return $items; } /** * Get the alternate title for the module * * @param JObject The module parameters. * @return string The alternate title for the module. */ public static function getTitle($params) { $who = $params->get('user_id'); $catid = (int)$params->get('catid'); $type = $params->get('ordering') == 'c_dsc' ? '_CREATED' : '_MODIFIED'; if ($catid) { $category = JCategories::getInstance('Content')->get($catid); if ($category) { $title = $category->title; } else { $title = JText::_('MOD_POPULAR_UNEXISTING'); } } else { $title = ''; } return JText::plural('MOD_LATEST_TITLE'.$type.($catid ? "_CATEGORY" : '').($who!='0' ? "_$who" : ''), (int)$params->get('count'), $title); } } home/academiac/www/libraries/joomla/language/helper.php000064400000010770151375621520017233 0ustar00getQuery(true); $query->select('element'); $query->from('#__extensions'); $query->where('type=' . $db->quote('language')); $query->where('state=0'); $query->where('enabled=1'); $query->where('client_id=' . ($basePath == JPATH_ADMINISTRATOR ? 1 : 0)); $db->setQuery($query); $installed_languages = $db->loadObjectList('element'); } foreach ($langs as $lang => $metadata) { if (!$installed || array_key_exists($lang, $installed_languages)) { $option = array(); $option['text'] = $metadata['name']; $option['value'] = $lang; if ($lang == $actualLanguage) { $option['selected'] = 'selected="selected"'; } $list[] = $option; } } return $list; } /** * Tries to detect the language. * * @return string locale or null if not found * * @since 11.1 */ public static function detectLanguage() { if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $browserLangs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $systemLangs = self::getLanguages(); foreach ($browserLangs as $browserLang) { // Slice out the part before ; on first step, the part before - on second, place into array $browserLang = substr($browserLang, 0, strcspn($browserLang, ';')); $primary_browserLang = substr($browserLang, 0, 2); foreach ($systemLangs as $systemLang) { // Take off 3 letters iso code languages as they can't match browsers' languages and default them to en $Jinstall_lang = $systemLang->lang_code; if (strlen($Jinstall_lang) < 6) { if (strtolower($browserLang) == strtolower(substr($systemLang->lang_code, 0, strlen($browserLang)))) { return $systemLang->lang_code; } elseif ($primary_browserLang == substr($systemLang->lang_code, 0, 2)) { $primaryDetectedLang = $systemLang->lang_code; } } } if (isset($primaryDetectedLang)) { return $primaryDetectedLang; } } } return null; } /** * Get available languages * * @param string $key Array key * * @return array An array of published languages * * @since 11.1 */ public static function getLanguages($key = 'default') { static $languages; if (empty($languages)) { // Installation uses available languages if (JFactory::getApplication()->getClientId() == 2) { $languages[$key] = array(); $knownLangs = JLanguage::getKnownLanguages(JPATH_BASE); foreach ($knownLangs as $metadata) { // Take off 3 letters iso code languages as they can't match browsers' languages and default them to en $languages[$key][] = new JObject(array('lang_code' => $metadata['tag'])); } } else { $cache = JFactory::getCache('com_languages', ''); if (!$languages = $cache->get('languages')) { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('*') ->from('#__languages') ->where('published=1') ->order('ordering ASC'); $db->setQuery($query); $languages['default'] = $db->loadObjectList(); $languages['sef'] = array(); $languages['lang_code'] = array(); if (isset($languages['default'][0])) { foreach ($languages['default'] as $lang) { $languages['sef'][$lang->sef] = $lang; $languages['lang_code'][$lang->lang_code] = $lang; } } $cache->store($languages, 'languages'); } } } return $languages[$key]; } } home/academiac/www/administrator/modules/mod_quickicon/helper.php000064400000012245151375733460021375 0ustar00get('context', 'mod_quickicon'); if ($context == 'mod_quickicon') { // Load mod_quickicon language file in case this method is called before rendering the module JFactory::getLanguage()->load('mod_quickicon'); self::$buttons[$key] = array( array( 'link' => JRoute::_('index.php?option=com_content&task=article.add'), 'image' => 'header/icon-48-article-add.png', 'text' => JText::_('MOD_QUICKICON_ADD_NEW_ARTICLE'), 'access' => array('core.manage', 'com_content', 'core.create', 'com_content', ) ), array( 'link' => JRoute::_('index.php?option=com_content'), 'image' => 'header/icon-48-article.png', 'text' => JText::_('MOD_QUICKICON_ARTICLE_MANAGER'), 'access' => array('core.manage', 'com_content') ), array( 'link' => JRoute::_('index.php?option=com_categories&extension=com_content'), 'image' => 'header/icon-48-category.png', 'text' => JText::_('MOD_QUICKICON_CATEGORY_MANAGER'), 'access' => array('core.manage', 'com_content') ), array( 'link' => JRoute::_('index.php?option=com_media'), 'image' => 'header/icon-48-media.png', 'text' => JText::_('MOD_QUICKICON_MEDIA_MANAGER'), 'access' => array('core.manage', 'com_media') ), array( 'link' => JRoute::_('index.php?option=com_menus'), 'image' => 'header/icon-48-menumgr.png', 'text' => JText::_('MOD_QUICKICON_MENU_MANAGER'), 'access' => array('core.manage', 'com_menus') ), array( 'link' => JRoute::_('index.php?option=com_users'), 'image' => 'header/icon-48-user.png', 'text' => JText::_('MOD_QUICKICON_USER_MANAGER'), 'access' => array('core.manage', 'com_users') ), array( 'link' => JRoute::_('index.php?option=com_modules'), 'image' => 'header/icon-48-module.png', 'text' => JText::_('MOD_QUICKICON_MODULE_MANAGER'), 'access' => array('core.manage', 'com_modules') ), array( 'link' => JRoute::_('index.php?option=com_installer'), 'image' => 'header/icon-48-extension.png', 'text' => JText::_('MOD_QUICKICON_EXTENSION_MANAGER'), 'access' => array('core.manage', 'com_installer') ), array( 'link' => JRoute::_('index.php?option=com_languages'), 'image' => 'header/icon-48-language.png', 'text' => JText::_('MOD_QUICKICON_LANGUAGE_MANAGER'), 'access' => array('core.manage', 'com_languages') ), array( 'link' => JRoute::_('index.php?option=com_config'), 'image' => 'header/icon-48-config.png', 'text' => JText::_('MOD_QUICKICON_GLOBAL_CONFIGURATION'), 'access' => array('core.manage', 'com_config', 'core.admin', 'com_config') ), array( 'link' => JRoute::_('index.php?option=com_templates'), 'image' => 'header/icon-48-themes.png', 'text' => JText::_('MOD_QUICKICON_TEMPLATE_MANAGER'), 'access' => array('core.manage', 'com_templates') ), array( 'link' => JRoute::_('index.php?option=com_admin&task=profile.edit&id='.JFactory::getUser()->id), 'image' => 'header/icon-48-user-profile.png', 'text' => JText::_('MOD_QUICKICON_PROFILE'), 'access' => true ), ); } else { self::$buttons[$key] = array(); } // Include buttons defined by published quickicon plugins JPluginHelper::importPlugin('quickicon'); $app = JFactory::getApplication(); $arrays = (array) $app->triggerEvent('onGetIcons', array($context)); foreach ($arrays as $response) { foreach ($response as $icon) { $default = array( 'link' => null, 'image' => 'header/icon-48-config.png', 'text' => null, 'access' => true ); $icon = array_merge($default, $icon); if (!is_null($icon['link']) && !is_null($icon['text'])) { self::$buttons[$key][] = $icon; } } } } return self::$buttons[$key]; } /** * Get the alternate title for the module * * @param JRegistry The module parameters. * @param object The module. * * @return string The alternate title for the module. */ public static function getTitle($params, $module) { $key = $params->get('context', 'mod_quickicon') . '_title'; if (JFactory::getLanguage()->hasKey($key)) { return JText::_($key); } else { return $module->title; } } }