diff --git a/ajax/ajax_getContent.php b/ajax/ajax_getContent.php index 1e07974e..70e2250d 100644 --- a/ajax/ajax_getContent.php +++ b/ajax/ajax_getContent.php @@ -37,7 +37,7 @@ SP_Util::checkReload(); if (SP_Common::parseParams('p', 'action', '', true)) { $action = $tplvars['action'] = SP_Common::parseParams('p', 'action'); $itemId = $tplvars['id'] = SP_Common::parseParams('p', 'id', 0); - $tplvars['lastaction'] = SP_Common::parseParams('p', 'lastAction', 'accsearch'); + $tplvars['lastaction'] = filter_var(SP_Common::parseParams('p', 'lastAction', 'accsearch', false, false, false), FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH); } else { die('
+ * @variables
+ * {
+ * defaultColor: black;
+ * }
+ * color: var(defaultColor);
+ *
+ *
+ * Will get converted to:
+ *
+ * color:black;
+ *
+ *
+ * @package CssMin/Minifier/Plugins
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla " . $variable . " in media types " . implode(", ", $mediaTypes) . "", (string)$token));
+ $token = new CssNullToken();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Implements {@link aMinifierPlugin::getTriggerTokens()}
+ *
+ * @return array
+ */
+ public function getTriggerTokens()
+ {
+ return array
+ (
+ "CssAtFontFaceDeclarationToken",
+ "CssAtPageDeclarationToken",
+ "CssRulesetDeclarationToken"
+ );
+ }
+}
+
+/**
+ * This {@link aCssMinifierFilter minifier filter} will parse the variable declarations out of @variables at-rule
+ * blocks. The variables will get store in the {@link CssVariablesMinifierPlugin} that will apply the variables to
+ * declaration.
+ *
+ * @package CssMin/Minifier/Filters
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla CssVariablesMinifierPlugin was not found but is required for " . __CLASS__ . ""));
+ } else {
+ $plugin->setVariables($variables);
+ }
+ return count($remove);
+ }
+}
+
+/**
+ * {@link aCssParserPlugin Parser plugin} for preserve parsing url() values.
+ *
+ * This plugin return no {@link aCssToken CssToken} but ensures that url() values will get parsed properly.
+ *
+ * @package CssMin/Parser/Plugins
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla " . $name . " with the class name " . $class . " was not found"));
+ }
+ }
+ }
+ if (!is_null($source)) {
+ $this->parse($source);
+ }
+ }
+
+ /**
+ * Parse the CSS source and return a array with parsed tokens.
+ *
+ * @param string $source CSS source
+ * @return array Array with tokens
+ */
+ public function parse($source)
+ {
+ // Reset
+ $this->source = "";
+ $this->tokens = array();
+ // Create a global and plugin lookup table for trigger chars; set array of plugins as local variable and create
+ // several helper variables for plugin handling
+ $globalTriggerChars = "";
+ $plugins = $this->plugins;
+ $pluginCount = count($plugins);
+ $pluginIndex = array();
+ $pluginTriggerStates = array();
+ $pluginTriggerChars = array();
+ for ($i = 0, $l = count($plugins); $i < $l; $i++) {
+ $tPluginClassName = get_class($plugins[$i]);
+ $pluginTriggerChars[$i] = implode("", $plugins[$i]->getTriggerChars());
+ $tPluginTriggerStates = $plugins[$i]->getTriggerStates();
+ $pluginTriggerStates[$i] = $tPluginTriggerStates === false ? false : "|" . implode("|", $tPluginTriggerStates) . "|";
+ $pluginIndex[$tPluginClassName] = $i;
+ for ($ii = 0, $ll = strlen($pluginTriggerChars[$i]); $ii < $ll; $ii++) {
+ $c = substr($pluginTriggerChars[$i], $ii, 1);
+ if (strpos($globalTriggerChars, $c) === false) {
+ $globalTriggerChars .= $c;
+ }
+ }
+ }
+ // Normalise line endings
+ $source = str_replace("\r\n", "\n", $source); // Windows to Unix line endings
+ $source = str_replace("\r", "\n", $source); // Mac to Unix line endings
+ $this->source = $source;
+ // Variables
+ $buffer = & $this->buffer;
+ $exclusive = & $this->stateExclusive;
+ $state = & $this->state;
+ $c = $p = null;
+ // --
+ for ($i = 0, $l = strlen($source); $i < $l; $i++) {
+ // Set the current Char
+ $c = $source[$i]; // Is faster than: $c = substr($source, $i, 1);
+ // Normalize and filter double whitespace characters
+ if ($exclusive === false) {
+ if ($c === "\n" || $c === "\t") {
+ $c = " ";
+ }
+ if ($c === " " && $p === " ") {
+ continue;
+ }
+ }
+ $buffer .= $c;
+ // Extended processing only if the current char is a global trigger char
+ if (strpos($globalTriggerChars, $c) !== false) {
+ // Exclusive state is set; process with the exclusive plugin
+ if ($exclusive) {
+ $tPluginIndex = $pluginIndex[$exclusive];
+ if (strpos($pluginTriggerChars[$tPluginIndex], $c) !== false && ($pluginTriggerStates[$tPluginIndex] === false || strpos($pluginTriggerStates[$tPluginIndex], $state) !== false)) {
+ $r = $plugins[$tPluginIndex]->parse($i, $c, $p, $state);
+ // Return value is TRUE => continue with next char
+ if ($r === true) {
+ continue;
+ } // Return value is numeric => set new index and continue with next char
+ elseif ($r !== false && $r != $i) {
+ $i = $r;
+ continue;
+ }
+ }
+ } // Else iterate through the plugins
+ else {
+ $triggerState = "|" . $state . "|";
+ for ($ii = 0, $ll = $pluginCount; $ii < $ll; $ii++) {
+ // Only process if the current char is one of the plugin trigger chars
+ if (strpos($pluginTriggerChars[$ii], $c) !== false && ($pluginTriggerStates[$ii] === false || strpos($pluginTriggerStates[$ii], $triggerState) !== false)) {
+ // Process with the plugin
+ $r = $plugins[$ii]->parse($i, $c, $p, $state);
+ // Return value is TRUE => break the plugin loop and and continue with next char
+ if ($r === true) {
+ break;
+ } // Return value is numeric => set new index, break the plugin loop and and continue with next char
+ elseif ($r !== false && $r != $i) {
+ $i = $r;
+ break;
+ }
+ }
+ }
+ }
+ }
+ $p = $c; // Set the parent char
+ }
+ return $this->tokens;
+ }
+
+ /**
+ * Append a token to the array of tokens.
+ *
+ * @param aCssToken $token Token to append
+ * @return void
+ */
+ public function appendToken(aCssToken $token)
+ {
+ $this->tokens[] = $token;
+ }
+
+ /**
+ * Clears the current buffer.
+ *
+ * @return void
+ */
+ public function clearBuffer()
+ {
+ $this->buffer = "";
+ }
+
+ /**
+ * Returns and clear the current buffer.
+ *
+ * @param string $trim Chars to use to trim the returned buffer
+ * @param boolean $tolower if TRUE the returned buffer will get converted to lower case
+ * @return string
+ */
+ public function getAndClearBuffer($trim = "", $tolower = false)
+ {
+ $r = $this->getBuffer($trim, $tolower);
+ $this->buffer = "";
+ return $r;
+ }
+
+ /**
+ * Returns the current buffer.
+ *
+ * @param string $trim Chars to use to trim the returned buffer
+ * @param boolean $tolower if TRUE the returned buffer will get converted to lower case
+ * @return string
+ */
+ public function getBuffer($trim = "", $tolower = false)
+ {
+ $r = $this->buffer;
+ if ($trim) {
+ $r = trim($r, " \t\n\r\0\x0B" . $trim);
+ }
+ if ($tolower) {
+ $r = strtolower($r);
+ }
+ return $r;
+ }
+
+ /**
+ * Sets/restores the buffer.
+ *
+ * @param string $buffer Buffer to set
+ * @return void
+ */
+ public function setBuffer($buffer)
+ {
+ $this->buffer = $buffer;
+ }
+
+ /**
+ * Returns the current media types state.
+ *
+ * @return array
+ */
+ public function getMediaTypes()
+ {
+ return $this->stateMediaTypes;
+ }
+
+ /**
+ * Returns the CSS source.
+ *
+ * @return string
+ */
+ public function getSource()
+ {
+ return $this->source;
+ }
+
+ /**
+ * Returns the current state.
+ *
+ * @return integer The current state
+ */
+ public function getState()
+ {
+ return $this->state;
+ }
+
+ /**
+ * Sets the current state in the state stack; equals to {@link CssParser::popState()} + {@link CssParser::pushState()}.
+ *
+ * @param integer $state State to set
+ * @return integer
+ */
+ public function setState($state)
+ {
+ $r = array_pop($this->states);
+ array_push($this->states, $state);
+ $this->state = $this->states[count($this->states) - 1];
+ return $r;
+ }
+
+ /**
+ * Returns a plugin by class name.
+ *
+ * @param string $name Class name of the plugin
+ * @return aCssParserPlugin
+ */
+ public function getPlugin($class)
+ {
+ static $index = null;
+ if (is_null($index)) {
+ $index = array();
+ for ($i = 0, $l = count($this->plugins); $i < $l; $i++) {
+ $index[get_class($this->plugins[$i])] = $i;
+ }
+ }
+ return isset($index[$class]) ? $this->plugins[$index[$class]] : false;
+ }
+
+ /**
+ * Returns the parsed tokens.
+ *
+ * @return array
+ */
+ public function getTokens()
+ {
+ return $this->tokens;
+ }
+
+ /**
+ * Returns if the current state equals the passed state.
+ *
+ * @param integer $state State to compare with the current state
+ * @return boolean TRUE is the state equals to the passed state; FALSE if not
+ */
+ public function isState($state)
+ {
+ return ($this->state == $state);
+ }
+
+ /**
+ * Remove the last state of the state stack and return the removed stack value.
+ *
+ * @return integer Removed state value
+ */
+ public function popState()
+ {
+ $r = array_pop($this->states);
+ $this->state = $this->states[count($this->states) - 1];
+ return $r;
+ }
+
+ /**
+ * Adds a new state onto the state stack.
+ *
+ * @param integer $state State to add onto the state stack.
+ * @return integer The index of the added state in the state stacks
+ */
+ public function pushState($state)
+ {
+ $r = array_push($this->states, $state);
+ $this->state = $this->states[count($this->states) - 1];
+ return $r;
+ }
+
+ /**
+ * Set the exclusive state.
+ *
+ * @param string $exclusive Exclusive state
+ * @return void
+ */
+ public function setExclusive($exclusive)
+ {
+ $this->stateExclusive = $exclusive;
+ }
+
+ /**
+ * Set the media types state.
+ *
+ * @param array $mediaTypes Media types state
+ * @return void
+ */
+ public function setMediaTypes(array $mediaTypes)
+ {
+ $this->stateMediaTypes = $mediaTypes;
+ }
+
+ /**
+ * Removes the exclusive state.
+ *
+ * @return void
+ */
+ public function unsetExclusive()
+ {
+ $this->stateExclusive = false;
+ }
+
+ /**
+ * Removes the media types state.
+ *
+ * @return void
+ */
+ public function unsetMediaTypes()
+ {
+ $this->stateMediaTypes = false;
+ }
+}
+
+/**
+ * {@link aCssFromatter Formatter} returning the CSS source in {@link http://goo.gl/j4XdU OTBS indent style} (The One True Brace Style).
+ *
+ * @package CssMin/Formatter
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla " . $name . " with the class name " . $class . " was not found"));
+ }
+ }
+ }
+ // Plugins
+ foreach ($plugins as $name => $config) {
+ if ($config !== false) {
+ $class = "Css" . $name . "MinifierPlugin";
+ $config = is_array($config) ? $config : array();
+ if (class_exists($class)) {
+ $this->plugins[] = new $class($this, $config);
+ } else {
+ CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin " . $name . " with the class name " . $class . " was not found"));
+ }
+ }
+ }
+ // --
+ if (!is_null($source)) {
+ $this->minify($source);
+ }
+ }
+
+ /**
+ * Minifies the CSS source.
+ *
+ * @param string $source CSS source
+ * @return string
+ */
+ public function minify($source)
+ {
+ // Variables
+ $r = "";
+ $parser = new CssParser($source);
+ $tokens = $parser->getTokens();
+ $filters = $this->filters;
+ $filterCount = count($this->filters);
+ $plugins = $this->plugins;
+ $pluginCount = count($plugins);
+ $pluginIndex = array();
+ $pluginTriggerTokens = array();
+ $globalTriggerTokens = array();
+ for ($i = 0, $l = count($plugins); $i < $l; $i++) {
+ $tPluginClassName = get_class($plugins[$i]);
+ $pluginTriggerTokens[$i] = $plugins[$i]->getTriggerTokens();
+ foreach ($pluginTriggerTokens[$i] as $v) {
+ if (!in_array($v, $globalTriggerTokens)) {
+ $globalTriggerTokens[] = $v;
+ }
+ }
+ $pluginTriggerTokens[$i] = "|" . implode("|", $pluginTriggerTokens[$i]) . "|";
+ $pluginIndex[$tPluginClassName] = $i;
+ }
+ $globalTriggerTokens = "|" . implode("|", $globalTriggerTokens) . "|";
+ /*
+ * Apply filters
+ */
+ for ($i = 0; $i < $filterCount; $i++) {
+ // Apply the filter; if the return value is larger than 0...
+ if ($filters[$i]->apply($tokens) > 0) {
+ // ...then filter null values and rebuild the token array
+ $tokens = array_values(array_filter($tokens));
+ }
+ }
+ $tokenCount = count($tokens);
+ /*
+ * Apply plugins
+ */
+ for ($i = 0; $i < $tokenCount; $i++) {
+ $triggerToken = "|" . get_class($tokens[$i]) . "|";
+ if (strpos($globalTriggerTokens, $triggerToken) !== false) {
+ for ($ii = 0; $ii < $pluginCount; $ii++) {
+ if (strpos($pluginTriggerTokens[$ii], $triggerToken) !== false || $pluginTriggerTokens[$ii] === false) {
+ // Apply the plugin; if the return value is TRUE continue to the next token
+ if ($plugins[$ii]->apply($tokens[$i]) === true) {
+ continue 2;
+ }
+ }
+ }
+ }
+ }
+ // Stringify the tokens
+ for ($i = 0; $i < $tokenCount; $i++) {
+ $r .= (string)$tokens[$i];
+ }
+ $this->minified = $r;
+ return $r;
+ }
+
+ /**
+ * Returns the minified Source.
+ *
+ * @return string
+ */
+ public function getMinified()
+ {
+ return $this->minified;
+ }
+
+ /**
+ * Returns a plugin by class name.
+ *
+ * @param string $name Class name of the plugin
+ * @return aCssMinifierPlugin
+ */
+ public function getPlugin($class)
+ {
+ static $index = null;
+ if (is_null($index)) {
+ $index = array();
+ for ($i = 0, $l = count($this->plugins); $i < $l; $i++) {
+ $index[get_class($this->plugins[$i])] = $i;
+ }
+ }
+ return isset($index[$class]) ? $this->plugins[$index[$class]] : false;
+ }
+}
+
+/**
+ * CssMin - A (simple) css minifier with benefits
+ *
+ * --
+ * Copyright (c) 2011 Joe Scylla " . ($this->configuration["BasePath"] ? $this->configuration["BasePath"] : "null") . " is not a directory"));
+ return 0;
+ }
+ for ($i = 0, $l = count($tokens); $i < $l; $i++) {
+ if (get_class($tokens[$i]) === "CssAtImportToken") {
+ $import = $this->configuration["BasePath"] . "/" . $tokens[$i]->Import;
+ // Import file was not found/is not a file
+ if (!is_file($import)) {
+ CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file " . $import . " was not found.", (string)$tokens[$i]));
+ } // Import file already imported; remove this @import at-rule to prevent recursions
+ elseif (in_array($import, $this->imported)) {
+ CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file " . $import . " was already imported.", (string)$tokens[$i]));
+ $tokens[$i] = null;
+ } else {
+ $this->imported[] = $import;
+ $parser = new CssParser(file_get_contents($import));
+ $import = $parser->getTokens();
+ // The @import at-rule has media types defined requiring special handling
+ if (count($tokens[$i]->MediaTypes) > 0 && !(count($tokens[$i]->MediaTypes) == 1 && $tokens[$i]->MediaTypes[0] == "all")) {
+ $blocks = array();
+ /*
+ * Filter or set media types of @import at-rule or remove the @import at-rule if no media type is matching the parent @import at-rule
+ */
+ for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) {
+ if (get_class($import[$ii]) === "CssAtImportToken") {
+ // @import at-rule defines no media type or only the "all" media type; set the media types to the one defined in the parent @import at-rule
+ if (count($import[$ii]->MediaTypes) == 0 || (count($import[$ii]->MediaTypes) == 1 && $import[$ii]->MediaTypes[0] == "all")) {
+ $import[$ii]->MediaTypes = $tokens[$i]->MediaTypes;
+ } // @import at-rule defineds one or more media types; filter out media types not matching with the parent @import at-rule
+ elseif (count($import[$ii]->MediaTypes > 0)) {
+ foreach ($import[$ii]->MediaTypes as $index => $mediaType) {
+ if (!in_array($mediaType, $tokens[$i]->MediaTypes)) {
+ unset($import[$ii]->MediaTypes[$index]);
+ }
+ }
+ $import[$ii]->MediaTypes = array_values($import[$ii]->MediaTypes);
+ // If there are no media types left in the @import at-rule remove the @import at-rule
+ if (count($import[$ii]->MediaTypes) == 0) {
+ $import[$ii] = null;
+ }
+ }
+ }
+ }
+ /*
+ * Remove media types of @media at-rule block not defined in the @import at-rule
+ */
+ for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) {
+ if (get_class($import[$ii]) === "CssAtMediaStartToken") {
+ foreach ($import[$ii]->MediaTypes as $index => $mediaType) {
+ if (!in_array($mediaType, $tokens[$i]->MediaTypes)) {
+ unset($import[$ii]->MediaTypes[$index]);
+ }
+ $import[$ii]->MediaTypes = array_values($import[$ii]->MediaTypes);
+ }
+ }
+ }
+ /*
+ * If no media types left of the @media at-rule block remove the complete block
+ */
+ for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) {
+ if (get_class($import[$ii]) === "CssAtMediaStartToken") {
+ if (count($import[$ii]->MediaTypes) === 0) {
+ for ($iii = $ii; $iii < $ll; $iii++) {
+ if (get_class($import[$iii]) === "CssAtMediaEndToken") {
+ break;
+ }
+ }
+ if (get_class($import[$iii]) === "CssAtMediaEndToken") {
+ array_splice($import, $ii, $iii - $ii + 1, array());
+ $ll = count($import);
+ }
+ }
+ }
+ }
+ /*
+ * If the media types of the @media at-rule equals the media types defined in the @import
+ * at-rule remove the CssAtMediaStartToken and CssAtMediaEndToken token
+ */
+ for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) {
+ if (get_class($import[$ii]) === "CssAtMediaStartToken" && count(array_diff($tokens[$i]->MediaTypes, $import[$ii]->MediaTypes)) === 0) {
+ for ($iii = $ii; $iii < $ll; $iii++) {
+ if (get_class($import[$iii]) == "CssAtMediaEndToken") {
+ break;
+ }
+ }
+ if (get_class($import[$iii]) == "CssAtMediaEndToken") {
+ unset($import[$ii]);
+ unset($import[$iii]);
+ $import = array_values($import);
+ $ll = count($import);
+ }
+ }
+ }
+ /**
+ * Extract CssAtImportToken and CssAtCharsetToken tokens
+ */
+ for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) {
+ $class = get_class($import[$ii]);
+ if ($class === "CssAtImportToken" || $class === "CssAtCharsetToken") {
+ $blocks = array_merge($blocks, array_splice($import, $ii, 1, array()));
+ $ll = count($import);
+ }
+ }
+ /*
+ * Extract the @font-face, @media and @page at-rule block
+ */
+ for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) {
+ $class = get_class($import[$ii]);
+ if ($class === "CssAtFontFaceStartToken" || $class === "CssAtMediaStartToken" || $class === "CssAtPageStartToken" || $class === "CssAtVariablesStartToken") {
+ for ($iii = $ii; $iii < $ll; $iii++) {
+ $class = get_class($import[$iii]);
+ if ($class === "CssAtFontFaceEndToken" || $class === "CssAtMediaEndToken" || $class === "CssAtPageEndToken" || $class === "CssAtVariablesEndToken") {
+ break;
+ }
+ }
+ $class = get_class($import[$iii]);
+ if (isset($import[$iii]) && ($class === "CssAtFontFaceEndToken" || $class === "CssAtMediaEndToken" || $class === "CssAtPageEndToken" || $class === "CssAtVariablesEndToken")) {
+ $blocks = array_merge($blocks, array_splice($import, $ii, $iii - $ii + 1, array()));
+ $ll = count($import);
+ }
+ }
+ }
+ // Create the import array with extracted tokens and the rulesets wrapped into a @media at-rule block
+ $import = array_merge($blocks, array(new CssAtMediaStartToken($tokens[$i]->MediaTypes)), $import, array(new CssAtMediaEndToken()));
+ }
+ // Insert the imported tokens
+ array_splice($tokens, $i, 1, $import);
+ // Modify parameters of the for-loop
+ $i--;
+ $l = count($tokens);
+ }
+ }
+ }
+ }
+}
+
+/**
+ * {@link aCssParserPlugin Parser plugin} for preserve parsing expression() declaration values.
+ *
+ * This plugin return no {@link aCssToken CssToken} but ensures that expression() declaration values will get parsed
+ * properly.
+ *
+ * @package CssMin/Parser/Plugins
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla " . $this->Source . "" : "") . "
+ * color: rgb(200,60%,5);
+ *
+ *
+ * Will get converted to:
+ *
+ * color:#c89905;
+ *
+ *
+ * @package CssMin/Minifier/Plugins
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla
+ * color: black;
+ * border: 1px solid indigo;
+ *
+ *
+ * Will get converted to:
+ *
+ * color:#000;
+ * border:1px solid #4b0082;
+ *
+ *
+ * @package CssMin/Minifier/Plugins
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla
+ * color: hsl(232,36%,48%);
+ *
+ *
+ * Will get converted to:
+ *
+ * color:#4e5aa7;
+ *
+ *
+ * @package CssMin/Minifier/Plugins
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla
+ * font-weight: normal;
+ * font: bold 11px monospace;
+ *
+ *
+ * Will get converted to:
+ *
+ * font-weight:400;
+ * font:700 11px monospace;
+ *
+ *
+ * @package CssMin/Minifier/Pluginsn
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla
+ * padding: 0.5em;
+ * border: 0px;
+ * margin: 0 0 0 0;
+ *
+ *
+ * Will get compressed to:
+ *
+ *
+ * padding:.5px;
+ * border:0;
+ * margin:0;
+ *
+ *
+ * --
+ *
+ * @package CssMin/Minifier/Plugins
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla
+ * color: #aabbcc;
+ *
+ *
+ * Will get converted to:
+ *
+ * color:#abc;
+ *
+ *
+ * @package CssMin/Minifier/Plugins
+ * @link http://code.google.com/p/cssmin/
+ * @author Joe Scylla
');
} else {
$('#search-sort-' + order.key).append('
');
@@ -208,6 +231,8 @@ function doSearch(){
// Función para navegar por el log de eventos
function navLog(start, current) {
+ "use strict";
+
if (typeof(start) === "undefined") return false;
$.fancybox.showLoading();
@@ -233,8 +258,10 @@ function navLog(start, current) {
// Función para ver la clave de una cuenta
function viewPass(id, full, history) {
+ "use strict";
+
// Comprobamos si la clave ha sido ya obtenida para copiar
- if ( passToClip === 1 && full === 0){
+ if (passToClip === 1 && full === 0) {
return;
}
@@ -243,11 +270,11 @@ function viewPass(id, full, history) {
url: APP_ROOT + '/ajax/ajax_viewpass.php',
async: false,
data: {'accountid': id, 'full': full, 'isHistory': history, 'isAjax': 1},
- success: function(data){
- if (data == "-1") {
+ success: function (data) {
+ if (data === "-1") {
doLogout();
} else {
- if ( full === 0 ){
+ if (full === 0) {
// Copiamos la clave en el objeto que tiene acceso al portapapeles
$('#clip_pass_text').html(data);
passToClip = 1;
@@ -261,6 +288,8 @@ function viewPass(id, full, history) {
// Función para obtener las variables de la URL y parsearlas a un array.
function getUrlVars() {
+ "use strict";
+
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
@@ -273,6 +302,8 @@ function getUrlVars() {
// Función para autentificar usuarios
function doLogin() {
+ "use strict";
+
$.fancybox.showLoading();
var data = $('#frmLogin').serialize();
@@ -318,6 +349,8 @@ function doLogin() {
// Función para salir de la sesión
function doLogout() {
+ "use strict";
+
var url = window.location.search;
if (url.length > 0) {
@@ -329,15 +362,19 @@ function doLogout() {
// Función para comprobar si se ha salido de la sesión
function checkLogout() {
+ "use strict";
+
var session = getUrlVars()["session"];
- if (session == 0) {
+ if (session === 0) {
resMsg("warn", LANG[2], '', "location.search = ''");
}
}
// Función para añadir/editar una cuenta
function saveAccount(frm) {
+ "use strict";
+
var data = $("#" + frm).serialize();
var id = $('input[name="accountid"]').val();
var savetyp = $('input[name="savetyp"]').val();
@@ -358,7 +395,7 @@ function saveAccount(frm) {
if (status === 0) {
resMsg("ok", description);
- if (savetyp == 1) {
+ if (savetyp === 1) {
$('#btnSave').hide();
} else {
$('#btnSave').attr('disabled', true);
@@ -386,35 +423,43 @@ function saveAccount(frm) {
// Función para eliminar una cuenta
function delAccount(id, action, sk) {
+ "use strict";
+
var data = {accountid: id, savetyp: action, sk: sk};
var atext = '' + LANG[3] + '
' + LANG[15] + '
' + LANG[12] + '
' + LANG[20] + '
' + LANG[6] + '
' + password + '
'); } else { - alertify.alert('' + LANG[6] + '
' + password + '
'); + alertify.alert('' + LANG[6] + '
' + genPassword + '
'); } if (dstId) { - checkPassLevel(password); - $('#' + dstId + ' input:password').val(password); + checkPassLevel(genPassword); + $('#' + dstId + ' input:password').val(genPassword); $('#' + dstId + ' #passLevel').show(500); } else { - checkPassLevel(password); - $('input:password').val(password); + checkPassLevel(genPassword); + $('input:password').val(genPassword); $('#passLevel').show(500); } //return password; } -// Funciónes para analizar al fortaleza de una clave +// Funciones para analizar al fortaleza de una clave // From http://net.tutsplus.com/tutorials/javascript-ajax/build-a-simple-password-strength-checker/ function checkPassLevel(password, dstId) { + "use strict"; + strPassword = password; - charPassword = strPassword.split(""); num.Excess = 0; num.Upper = 0; @@ -836,7 +909,7 @@ function checkPassLevel(password, dstId) { baseScore = 0; score = 0; - if (charPassword.length >= minPasswordLength) { + if (password.length >= minPasswordLength) { baseScore = 50; analyzeString(); calcComplexity(); @@ -852,20 +925,23 @@ function checkPassLevel(password, dstId) { } function analyzeString() { - for (i = 0; i < charPassword.length; i++) { - if (charPassword[i].match(/[A-Z]/g)) { + "use strict"; + + var chars = strPassword.split(''); + + for (var i = 0; i < strPassword.length; i++) { + if (chars[i].match(/[A-Z]/g)) { num.Upper++; } - if (charPassword[i].match(/[0-9]/g)) { + if (chars[i].match(/[0-9]/g)) { num.Numbers++; } - //if (charPassword[i].match(/(.*[!,@,#,$,%,^,&,*,?,_,~])/)) { - if (charPassword[i].match(/(.*[!,@,#,$,%,&,*,?,%,_])/)) { + if (chars[i].match(/(.*[!,@,#,$,%,&,*,?,%,_])/)) { num.Symbols++; } } - num.Excess = charPassword.length - minPasswordLength; + num.Excess = strPassword.length - minPasswordLength; if (num.Upper && num.Numbers && num.Symbols) { bonus.Combo = 25; @@ -885,10 +961,14 @@ function analyzeString() { } function calcComplexity() { + "use strict"; + score = baseScore + (num.Excess * bonus.Excess) + (num.Upper * bonus.Upper) + (num.Numbers * bonus.Numbers) + (num.Symbols * bonus.Symbols) + bonus.Combo + bonus.FlatLower + bonus.FlatNumber; } function outputResult(dstId) { + "use strict"; + var complexity, selector = '.passLevel'; if (dstId) { @@ -898,23 +978,18 @@ function outputResult(dstId) { complexity = $(selector); complexity.removeClass("weak good strong strongest"); - if (charPassword.length == 0) { - complexity.attr('title','').empty(); - } else if (charPassword.length < minPasswordLength) { - //complexity.html(LANG[11]).removeClass("good strong strongest").addClass("weak"); - complexity.attr('title',LANG[11]).addClass("weak"); + if (strPassword.length === 0) { + complexity.attr('title', '').empty(); + } else if (strPassword.length < minPasswordLength) { + complexity.attr('title', LANG[11]).addClass("weak"); } else if (score < 50) { - //complexity.html(LANG[9]).removeClass("good strong strongest").addClass("weak"); - complexity.attr('title',LANG[9]).addClass("weak"); + complexity.attr('title', LANG[9]).addClass("weak"); } else if (score >= 50 && score < 75) { - //complexity.html(LANG[8]).removeClass("weak strong strongest").addClass("good"); - complexity.attr('title',LANG[8]).addClass("good"); + complexity.attr('title', LANG[8]).addClass("good"); } else if (score >= 75 && score < 100) { - //complexity.html(LANG[7]).removeClass("weak good strongest").addClass("strong"); - complexity.attr('title',LANG[7]).addClass("strong"); + complexity.attr('title', LANG[7]).addClass("strong"); } else if (score >= 100) { - //complexity.html(LANG[10]).removeClass("weak good strong").addClass("strongest"); - complexity.attr('title',LANG[10]).addClass("strongest"); + complexity.attr('title', LANG[10]).addClass("strongest"); } $('.passLevel').powerTip(powertipOptions); @@ -922,7 +997,9 @@ function outputResult(dstId) { // Función para mostrar mensaje con alertify function resMsg(type, txt, url, action) { - if (typeof(url) !== "undefined") { + "use strict"; + + if (typeof url !== "undefined") { $.ajax({ url: url, type: 'get', dataType: 'html', async: false, success: function (data) { txt = data; }}); @@ -951,7 +1028,6 @@ function resMsg(type, txt, url, action) { case "nofancyerror": html = 'Oops...
' + LANG[1] + '
' + txt + '