mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-04 15:44:07 +01:00
* Improved browser response by minimizing CSS an JS files and joining into one resource per type.
* Added class CssMin for minimizing CSSs. * Cached some config values in session to avoid config file readings. * Improved URL handling. * Minor bug fixes.
This commit is contained in:
@@ -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('<div class="error">' . _('Parámetros incorrectos') . '</DIV>');
|
||||
}
|
||||
|
||||
46
css/css.php
Normal file
46
css/css.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012 Rubén Domínguez nuxsmin@syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php';
|
||||
|
||||
$cssFiles = array(
|
||||
array('href' => 'css/reset.css', 'min' => true),
|
||||
array('href' => 'css/smoothness/jquery-ui.css', 'min' => true),
|
||||
array('href' => 'css/jquery.powertip.css', 'min' => true),
|
||||
array('href' => 'css/jquery.powertip-yellow.min.css', 'min' => true),
|
||||
array('href' => 'css/chosen.css', 'min' => true),
|
||||
array('href' => 'css/alertify.core.css', 'min' => true),
|
||||
array('href' => 'css/alertify.default.css', 'min' => true),
|
||||
array('href' => 'css/jquery.tagsinput.css', 'min' => true),
|
||||
array('href' => 'js/fancybox/jquery.fancybox.css', 'min' => true),
|
||||
array('href' => 'css/styles.css', 'min' => true)
|
||||
);
|
||||
|
||||
if (!SP_Util::resultsCardsIsEnabled()) {
|
||||
array_push($cssFiles, array('href' => 'css/search-grid.css', 'min' => true));
|
||||
}
|
||||
|
||||
SP_Util::getMinified('css', $cssFiles);
|
||||
2
css/smoothness/jquery-ui.css
vendored
2
css/smoothness/jquery-ui.css
vendored
File diff suppressed because one or more lines are too long
4819
inc/ext/cssmin/class.cssmin.php
Normal file
4819
inc/ext/cssmin/class.cssmin.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -98,6 +98,10 @@ class SP_Html
|
||||
// UTF8 Headers
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
|
||||
// Cache Control
|
||||
header("Cache-Control: public, no-cache, max-age=0, must-revalidate");
|
||||
header("Pragma: public; max-age=0");
|
||||
|
||||
if (!is_null($err) && is_array($err) && count($err) > 0) {
|
||||
$data['errors'] = $err;
|
||||
}
|
||||
@@ -169,27 +173,10 @@ class SP_Html
|
||||
*/
|
||||
public static function setCss()
|
||||
{
|
||||
$versionParameter = '?v=' . md5(implode(SP_Util::getVersion()));
|
||||
$visualStyle = SP_Util::resultsCardsIsEnabled();
|
||||
$versionParameter = md5(implode(SP_Util::getVersion()).$visualStyle);
|
||||
|
||||
$cssProp = array(
|
||||
array("href" => "css/reset.css", "media" => ""),
|
||||
array("href" => "css/smoothness/jquery-ui.css", "media" => "screen"),
|
||||
array("href" => "css/jquery.powertip.css", "media" => "screen"),
|
||||
array("href" => "css/jquery.powertip-yellow.min.css", "media" => "screen"),
|
||||
array("href" => "css/chosen.css", "media" => "screen"),
|
||||
array("href" => "css/alertify.core.css", "media" => "screen"),
|
||||
array("href" => "css/alertify.default.css", "media" => "screen"),
|
||||
array("href" => "css/jquery.tagsinput.css", "media" => "screen"),
|
||||
array("href" => "js/fancybox/jquery.fancybox.css", "media" => "screen"),
|
||||
array("href" => "css/styles.css", "media" => ""));
|
||||
|
||||
if ( ! SP_Util::resultsCardsIsEnabled() ){
|
||||
array_push($cssProp,array("href" => "css/search-grid.css", "media" => ""));
|
||||
}
|
||||
|
||||
foreach ($cssProp as $css) {
|
||||
self::$htmlPage[] = '<link rel="stylesheet" href="' . SP_Init::$WEBROOT . "/" . $css["href"] . $versionParameter . '" media="' . $css["media"] . '" />';
|
||||
}
|
||||
self::$htmlPage[] = '<link rel="stylesheet" href="' . SP_Init::$WEBROOT . '/css/css.php?v=' . $versionParameter . '" />';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,36 +187,7 @@ class SP_Html
|
||||
{
|
||||
$versionParameter = md5(implode(SP_Util::getVersion()));
|
||||
|
||||
$js_files = self::getJs();
|
||||
|
||||
foreach ($js_files as $js) {
|
||||
self::$htmlPage[] = '<script type="text/javascript" src="' . SP_Init::$WEBROOT . "/" . $js["src"] . '?v=' . $versionParameter . $js["params"] . '"></script>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Devuelve un array con los archivos JS a incluir
|
||||
* @return array con los archivos js y parámetros
|
||||
*/
|
||||
public static function getJs()
|
||||
{
|
||||
|
||||
$jsProp = array(
|
||||
array("src" => "js/jquery.js", "params" => ""),
|
||||
array("src" => "js/jquery.placeholder.js", "params" => ""),
|
||||
array("src" => "js/jquery-ui.js", "params" => ""),
|
||||
array("src" => "js/fancybox/jquery.fancybox.pack.js", "params" => ""),
|
||||
array("src" => "js/jquery.powertip.min.js", "params" => ""),
|
||||
array("src" => "js/chosen.jquery.min.js", "params" => ""),
|
||||
array("src" => "js/alertify.js", "params" => ""),
|
||||
array("src" => "js/jquery.fileDownload.js", "params" => ""),
|
||||
array("src" => "js/jquery.filedrop.js", "params" => ""),
|
||||
array("src" => "js/jquery.tagsinput.js", "params" => ""),
|
||||
array("src" => "js/ZeroClipboard.min.js", "params" => ""),
|
||||
array("src" => "js/functions.php", "params" => "")
|
||||
);
|
||||
|
||||
return $jsProp;
|
||||
self::$htmlPage[] = '<script type="text/javascript" src="' . SP_Init::$WEBROOT . '/js/js.php?v=' . $versionParameter . '"></script>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
29
inc/init.php
29
inc/init.php
@@ -173,7 +173,7 @@ class SP_Init
|
||||
continue;
|
||||
}
|
||||
|
||||
$params[] = $param . '=' . $value;
|
||||
$params[] = SP_Html::sanitize($param) . '=' . SP_Html::sanitize($value);
|
||||
}
|
||||
|
||||
header("Location: " . self::$WEBROOT . '/index.php?' . implode('&', $params));
|
||||
@@ -231,19 +231,25 @@ class SP_Init
|
||||
self::$SUBURI = str_replace("\\", '/', substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(self::$SERVERROOT)));
|
||||
|
||||
$scriptName = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
|
||||
|
||||
if (substr($scriptName, -1) == '/') {
|
||||
$scriptName .= 'index.php';
|
||||
// Asegurar que suburi sigue las mismas reglas que scriptName
|
||||
if (substr(self::$SUBURI, -9) != 'index.php') {
|
||||
if (substr(self::$SUBURI, -1) != '/') {
|
||||
self::$SUBURI = self::$SUBURI . '/';
|
||||
self::$SUBURI .= '/';
|
||||
}
|
||||
self::$SUBURI = self::$SUBURI . 'index.php';
|
||||
self::$SUBURI .= 'index.php';
|
||||
}
|
||||
}
|
||||
|
||||
//self::$WEBROOT = substr($scriptName, 0, strlen($scriptName) - strlen(self::$SUBURI) + 1);
|
||||
self::$WEBROOT = substr($scriptName, 0, strpos($scriptName, self::$SUBURI));
|
||||
$pos = strpos($scriptName, self::$SUBURI);
|
||||
|
||||
if ($pos === false) {
|
||||
$pos = strpos($scriptName, '?');
|
||||
}
|
||||
|
||||
self::$WEBROOT = substr($scriptName, 0, $pos);
|
||||
|
||||
if (self::$WEBROOT != '' and self::$WEBROOT[0] !== '/') {
|
||||
self::$WEBROOT = '/' . self::$WEBROOT;
|
||||
@@ -292,7 +298,7 @@ class SP_Init
|
||||
private static function checkInitSourceInclude()
|
||||
{
|
||||
$srcScript = pathinfo($_SERVER["SCRIPT_NAME"], PATHINFO_BASENAME);
|
||||
$skipInit = array('functions.php');
|
||||
$skipInit = array('js.php', 'css.php');
|
||||
|
||||
return (in_array($srcScript, $skipInit));
|
||||
}
|
||||
@@ -515,7 +521,13 @@ class SP_Init
|
||||
*/
|
||||
private static function getSessionLifeTime()
|
||||
{
|
||||
return SP_Config::getValue('session_timeout', 60 * 60 * 24);
|
||||
$timeout = SP_Common::parseParams('s', 'session_timeout', 0);
|
||||
|
||||
if ($timeout === 0) {
|
||||
$timeout = $_SESSION['session_timeout'] = SP_Config::getValue('session_timeout', 60 * 5);
|
||||
}
|
||||
|
||||
return $timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -526,9 +538,10 @@ class SP_Init
|
||||
{
|
||||
$inactiveTime = round(((time() - $_SESSION['LAST_ACTIVITY']) / 60), 2);
|
||||
$totalTime = round(((time() - $_SESSION['START_ACTIVITY']) / 60), 2);
|
||||
$ulogin = SP_Common::parseParams('s', 'ulogin');
|
||||
|
||||
$message['action'] = _('Finalizar sesión');
|
||||
$message['text'][] = _('Usuario') . ": " . $_SESSION['ulogin'];
|
||||
$message['text'][] = _('Usuario') . ": " . $ulogin;
|
||||
$message['text'][] = _('Tiempo inactivo') . ": " . $inactiveTime . " min.";
|
||||
$message['text'][] = _('Tiempo total') . ": " . $totalTime . " min.";
|
||||
|
||||
|
||||
@@ -168,22 +168,13 @@ class SP_Util
|
||||
return in_array("ldap", get_loaded_extensions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Comprobar si el módulo CURL está instalado
|
||||
* @return bool
|
||||
*/
|
||||
public static function curlIsAvailable()
|
||||
{
|
||||
return (function_exists('curl_init'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Devuelve la versión de sysPass
|
||||
* @return string con la versión
|
||||
*/
|
||||
public static function getVersionString()
|
||||
{
|
||||
return '1.1b';
|
||||
return '1.1-rc1';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +185,7 @@ class SP_Util
|
||||
*/
|
||||
public static function checkUpdates()
|
||||
{
|
||||
if (! self::curlIsAvailable() || !SP_Config::getValue('checkupdates')) {
|
||||
if (!self::curlIsAvailable() || !SP_Config::getValue('checkupdates')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -257,6 +248,15 @@ class SP_Util
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Comprobar si el módulo CURL está instalado
|
||||
* @return bool
|
||||
*/
|
||||
public static function curlIsAvailable()
|
||||
{
|
||||
return (function_exists('curl_init'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Devuelve la versión de sysPass
|
||||
* @param bool $retBuild devolver el número de compilación
|
||||
@@ -264,7 +264,7 @@ class SP_Util
|
||||
*/
|
||||
public static function getVersion($retBuild = false)
|
||||
{
|
||||
$build = 13;
|
||||
$build = 14;
|
||||
$version = array(1, 1, 2);
|
||||
|
||||
if ($retBuild) {
|
||||
@@ -322,7 +322,14 @@ class SP_Util
|
||||
*/
|
||||
public static function demoIsEnabled()
|
||||
{
|
||||
return SP_Config::getValue('demo_enabled', false);
|
||||
$enabled = SP_Common::parseParams('s', 'demo_enabled', 0);
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($enabled === 0 || $reload === 1) {
|
||||
$enabled = $_SESSION['demo_enabled'] = SP_Config::getValue('demo_enabled', false);
|
||||
}
|
||||
|
||||
return self::boolval($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -331,7 +338,14 @@ class SP_Util
|
||||
*/
|
||||
public static function fileIsEnabled()
|
||||
{
|
||||
return SP_Config::getValue('files_enabled', false);
|
||||
$enabled = SP_Common::parseParams('s', 'files_enabled', 0);
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($enabled === 0 || $reload === 1) {
|
||||
$enabled = $_SESSION['files_enabled'] = SP_Config::getValue('files_enabled', false);
|
||||
}
|
||||
|
||||
return self::boolval($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,7 +354,14 @@ class SP_Util
|
||||
*/
|
||||
public static function mailIsEnabled()
|
||||
{
|
||||
return SP_Config::getValue('mail_enabled', false);
|
||||
$enabled = SP_Common::parseParams('s', 'mail_enabled', 0);
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($enabled === 0 || $reload === 1) {
|
||||
$enabled = $_SESSION['mail_enabled'] = SP_Config::getValue('mail_enabled', false);
|
||||
}
|
||||
|
||||
return self::boolval($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,7 +370,14 @@ class SP_Util
|
||||
*/
|
||||
public static function wikiIsEnabled()
|
||||
{
|
||||
return SP_Config::getValue('wiki_enabled', false);
|
||||
$enabled = SP_Common::parseParams('s', 'wiki_enabled', 0);
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($enabled === 0 || $reload === 1) {
|
||||
$enabled = $_SESSION['wiki_enabled'] = SP_Config::getValue('wiki_enabled', false);
|
||||
}
|
||||
|
||||
return self::boolval($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,7 +386,14 @@ class SP_Util
|
||||
*/
|
||||
public static function mailrequestIsEnabled()
|
||||
{
|
||||
return SP_Config::getValue('mail_requestsenabled', false);
|
||||
$enabled = SP_Common::parseParams('s', 'mail_requestsenabled', 0);
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($enabled === 0 || $reload === 1) {
|
||||
$enabled = $_SESSION['mail_requestsenabled'] = SP_Config::getValue('mail_requestsenabled', false);
|
||||
}
|
||||
|
||||
return self::boolval($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,7 +402,14 @@ class SP_Util
|
||||
*/
|
||||
public static function ldapIsEnabled()
|
||||
{
|
||||
return SP_Config::getValue('ldap_enabled', false);
|
||||
$enabled = SP_Common::parseParams('s', 'ldap_enabled', 0);
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($enabled === 0 || $reload === 1) {
|
||||
$enabled = $_SESSION['ldap_enabled'] = SP_Config::getValue('ldap_enabled', false);
|
||||
}
|
||||
|
||||
return self::boolval($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,7 +418,14 @@ class SP_Util
|
||||
*/
|
||||
public static function logIsEnabled()
|
||||
{
|
||||
return SP_Config::getValue('log_enabled', false);
|
||||
$enabled = SP_Common::parseParams('s', 'log_enabled', 0);
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($enabled === 0 || $reload === 1) {
|
||||
$enabled = $_SESSION['log_enabled'] = SP_Config::getValue('log_enabled', false);
|
||||
}
|
||||
|
||||
return self::boolval($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,7 +434,14 @@ class SP_Util
|
||||
*/
|
||||
public static function resultsCardsIsEnabled()
|
||||
{
|
||||
return SP_Config::getValue('resultsascards', false);
|
||||
$enabled = SP_Common::parseParams('s', 'resultsascards', 0);
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($enabled === 0 || $reload === 1) {
|
||||
$enabled = $_SESSION['resultsascards'] = SP_Config::getValue('resultsascards', false);
|
||||
}
|
||||
|
||||
return self::boolval($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,7 +450,9 @@ class SP_Util
|
||||
*/
|
||||
public static function reload()
|
||||
{
|
||||
if (!isset($_SESSION["reload"]) || $_SESSION["reload"] === 0) {
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($reload === 0) {
|
||||
$_SESSION["reload"] = 1;
|
||||
}
|
||||
}
|
||||
@@ -405,9 +463,174 @@ class SP_Util
|
||||
*/
|
||||
public static function checkReload()
|
||||
{
|
||||
if (isset($_SESSION["reload"]) && $_SESSION["reload"] === 1) {
|
||||
$_SESSION["reload"] = 0;
|
||||
exit("<script>window.location.href = 'index.php';</script>");
|
||||
$reload = SP_Common::parseParams('s', 'reload', 0);
|
||||
|
||||
if ($reload === 1) {
|
||||
$_SESSION['reload'] = 0;
|
||||
//exit("<script>window.location.href = 'index.php';</script>");
|
||||
exit("<script>location.reload();</script>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Devolver al navegador archivos CSS y JS comprimidos
|
||||
* @param string $type tipo de recurso a devolver
|
||||
* @param array $files archivos a parsear
|
||||
* @return none
|
||||
*
|
||||
* Método que devuelve un recurso CSS o JS comprimido. Si coincide el ETAG se
|
||||
* devuelve el código HTTP/304
|
||||
*/
|
||||
public static function getMinified($type, &$files)
|
||||
{
|
||||
$offset = 3600 * 24 * 30;
|
||||
$nextCheck = time() + $offset;
|
||||
$expire = 'Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', $nextCheck);
|
||||
//$etag = md5(implode(SP_Util::getVersion()));
|
||||
$etag = self::getEtag($files);
|
||||
$etagMatch = self::getRequestHeaders('If-None-Match');
|
||||
$cacheControl = self::getRequestHeaders('Cache-Control');
|
||||
$pragma = self::getRequestHeaders('Pragma');
|
||||
|
||||
header('Etag: ' . $etag);
|
||||
header("Cache-Control: public, max-age={$offset}, must-revalidate");
|
||||
header("Pragma: public; maxage={$offset}");
|
||||
header($expire);
|
||||
|
||||
// Devolver código 304 si la versión es la misma y no se solicita refrescar
|
||||
if ($etag == $etagMatch && !($cacheControl == 'no-cache' || $pragma == 'no-cache')) {
|
||||
header($_SERVER["SERVER_PROTOCOL"] . " 304 Not Modified");
|
||||
exit;
|
||||
}
|
||||
|
||||
$path = SP_Init::$SERVERROOT . DIRECTORY_SEPARATOR;
|
||||
|
||||
if ($type == 'js') {
|
||||
header("Content-type: application/x-javascript; charset: UTF-8");
|
||||
} elseif ($type == 'css') {
|
||||
header("Content-type: text/css; charset: UTF-8");
|
||||
}
|
||||
|
||||
flush();
|
||||
ob_start('ob_gzhandler');
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filePath = $path . $file['href'];
|
||||
|
||||
if ($file['min'] === true) {
|
||||
echo '/* MINIFIED FILE: ' . $file['href'] . ' */' . PHP_EOL;
|
||||
if ($type == 'js') {
|
||||
echo self::jsCompress(file_get_contents($filePath));
|
||||
} elseif ($type == 'css') {
|
||||
require_once EXTENSIONS_DIR . DIRECTORY_SEPARATOR . 'cssmin' . DIRECTORY_SEPARATOR . 'class.cssmin.php';
|
||||
echo CssMin::minify(file_get_contents($filePath));
|
||||
}
|
||||
} else {
|
||||
echo '/* FILE: ' . $file['href'] . ' */' . PHP_EOL;
|
||||
echo file_get_contents($filePath);
|
||||
}
|
||||
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calcular el hash MD5 de varios archivos
|
||||
* @param array $files archivos a calcular
|
||||
* @return string
|
||||
*/
|
||||
private static function getEtag(&$files)
|
||||
{
|
||||
$md5Sum = '';
|
||||
$path = SP_Init::$SERVERROOT . DIRECTORY_SEPARATOR;
|
||||
|
||||
foreach ($files as $file) {
|
||||
$md5Sum .= md5_file($path . $file['href']);
|
||||
}
|
||||
|
||||
return md5($md5Sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Devolver las cabeceras enviadas desde el cliente
|
||||
* @param string $header nombre de la cabecera a devolver
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequestHeaders($header = '')
|
||||
{
|
||||
if (!function_exists('apache_request_headers')) {
|
||||
function apache_request_headers()
|
||||
{
|
||||
foreach ($_SERVER as $key => $value) {
|
||||
if (substr($key, 0, 5) == "HTTP_") {
|
||||
$key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
|
||||
$headers[$key] = $value;
|
||||
} else {
|
||||
$headers[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$headers = apache_request_headers();
|
||||
}
|
||||
|
||||
if (!empty($header) && array_key_exists($header, $headers)) {
|
||||
return $headers[$header];
|
||||
} elseif (!empty($header)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Comprimir código javascript
|
||||
* @param string $buffer código a comprimir
|
||||
* @return string
|
||||
*/
|
||||
private static function jsCompress($buffer)
|
||||
{
|
||||
$regexReplace = array(
|
||||
'#/\*[^*]*\*+([^/][^*]*\*+)*/#',
|
||||
'#^[\s\t]*//.*$#m',
|
||||
'#[\s\t]+$#m',
|
||||
'#^[\s\t]+#m',
|
||||
'#\s*//\s.*$#m'
|
||||
);
|
||||
$buffer = preg_replace($regexReplace, '', $buffer);
|
||||
// remove tabs, spaces, newlines, etc.
|
||||
$buffer = str_replace(array("\r\n", "\r", "\n", "\t"), '', $buffer);
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/** Checks a variable to see if it should be considered a boolean true or false.
|
||||
* Also takes into account some text-based representations of true of false,
|
||||
* such as 'false','N','yes','on','off', etc.
|
||||
* @author Samuel Levy <sam+nospam@samuellevy.com>
|
||||
* @param mixed $in The variable to check
|
||||
* @param bool $strict If set to false, consider everything that is not false to
|
||||
* be true.
|
||||
* @return bool The boolean equivalent or null (if strict, and no exact equivalent)
|
||||
*/
|
||||
public static function boolval($in, $strict = false)
|
||||
{
|
||||
$out = null;
|
||||
$in = (is_string($in) ? strtolower($in) : $in);
|
||||
// if not strict, we only have to check if something is false
|
||||
if (in_array($in, array('false', 'no', 'n', '0', 'off', false, 0), true) || !$in) {
|
||||
$out = false;
|
||||
} else if ($strict) {
|
||||
// if strict, check the equivalent true values
|
||||
if (in_array($in, array('true', 'yes', 'y', '1', 'on', true, 1), true)) {
|
||||
$out = true;
|
||||
}
|
||||
} else {
|
||||
// not strict? let the regular php bool check figure it out (will
|
||||
// largely default to true)
|
||||
$out = ($in ? true : false);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
8
js/fancybox/jquery.fancybox.css
vendored
8
js/fancybox/jquery.fancybox.css
vendored
@@ -76,7 +76,7 @@
|
||||
}
|
||||
|
||||
#fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span {
|
||||
background-image: url('fancybox_sprite.png');
|
||||
background-image: url('../js/fancybox/fancybox_sprite.png');
|
||||
}
|
||||
|
||||
#fancybox-loading {
|
||||
@@ -94,7 +94,7 @@
|
||||
#fancybox-loading div {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
background: url('fancybox_loading.gif') center center no-repeat;
|
||||
background: url('../js/fancybox/fancybox_loading.gif') center center no-repeat;
|
||||
}
|
||||
|
||||
.fancybox-close {
|
||||
@@ -114,7 +114,7 @@
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
background: transparent url('blank.gif'); /* helps IE */
|
||||
background: transparent url('../js/fancybox/blank.gif'); /* helps IE */
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
z-index: 8040;
|
||||
}
|
||||
@@ -172,7 +172,7 @@
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
z-index: 8010;
|
||||
background: url('fancybox_overlay.png');
|
||||
background: url('../js/fancybox/fancybox_overlay.png');
|
||||
}
|
||||
|
||||
.fancybox-overlay-fixed {
|
||||
|
||||
240
js/functions.js
240
js/functions.js
@@ -10,7 +10,6 @@ var passToClip = 0;
|
||||
var windowAdjustSize = 350;
|
||||
|
||||
var strPassword;
|
||||
var charPassword;
|
||||
var minPasswordLength = 8;
|
||||
var baseScore = 0, score = 0;
|
||||
|
||||
@@ -39,22 +38,30 @@ jQuery.extend(jQuery.fancybox.defaults, {
|
||||
padding: 0,
|
||||
helpers: {overlay: { css: { 'background': 'rgba(0, 0, 0, 0.1)'}}},
|
||||
afterShow: function () {
|
||||
"use strict";
|
||||
|
||||
$('#fancyContainer').find('input:visible:first').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
"use strict";
|
||||
|
||||
$("[title]").powerTip(powertipOptions);
|
||||
$('input, textarea').placeholder();
|
||||
setContentSize();
|
||||
setWindowAdjustSize();
|
||||
}).ajaxComplete(function () {
|
||||
"use strict";
|
||||
|
||||
$("[title]").powerTip(powertipOptions);
|
||||
$('input, textarea').placeholder();
|
||||
});
|
||||
|
||||
// Función para cargar el contenido de la acción del menú seleccionada
|
||||
function doAction(action, lastAction, id) {
|
||||
"use strict";
|
||||
|
||||
var data = {'action': action, 'lastAction': lastAction, 'id': id, isAjax: 1};
|
||||
|
||||
$('#content').fadeOut(function () {
|
||||
@@ -81,6 +88,8 @@ function doAction(action, lastAction, id) {
|
||||
|
||||
// Función para establecer la altura del contenedor ajax
|
||||
function setContentSize() {
|
||||
"use strict";
|
||||
|
||||
// Calculate total height for full body resize
|
||||
var totalHeight = $("#content").height() + 100;
|
||||
//var totalWidth = $("#wrap").width();
|
||||
@@ -90,9 +99,11 @@ function setContentSize() {
|
||||
|
||||
// Función para establecer la variable de ajuste óptimo de altura
|
||||
function setWindowAdjustSize() {
|
||||
"use strict";
|
||||
|
||||
var browser = getBrowser();
|
||||
|
||||
if ( browser == "MSIE" ){
|
||||
if (browser === "MSIE") {
|
||||
windowAdjustSize = 150;
|
||||
}
|
||||
//console.log(windowAdjustSize);
|
||||
@@ -100,12 +111,16 @@ function setWindowAdjustSize() {
|
||||
|
||||
// Función para retornar el scroll a la posición inicial
|
||||
function scrollUp() {
|
||||
"use strict";
|
||||
|
||||
$('html, body').animate({ scrollTop: 0 }, 'slow');
|
||||
}
|
||||
|
||||
// Función para limpiar un formulario
|
||||
function clearSearch(clearStart) {
|
||||
if ( clearStart === 1 ){
|
||||
"use strict";
|
||||
|
||||
if (clearStart === 1) {
|
||||
$('#frmSearch').find('input[name="start"]').val(0);
|
||||
return;
|
||||
}
|
||||
@@ -123,6 +138,8 @@ function clearSearch(clearStart) {
|
||||
|
||||
// Funcion para crear un desplegable con opciones
|
||||
function mkChosen(options) {
|
||||
"use strict";
|
||||
|
||||
$('#' + options.id).chosen({
|
||||
allow_single_deselect: true,
|
||||
placeholder_text_single: options.placeholder,
|
||||
@@ -133,15 +150,17 @@ function mkChosen(options) {
|
||||
|
||||
// Función para la búsqueda de cuentas mediante filtros
|
||||
function accSearch(continous, event) {
|
||||
"use strict";
|
||||
|
||||
var lenTxtSearch = $('#txtSearch').val().length;
|
||||
|
||||
if ( typeof (event) != 'undefined'
|
||||
&& ((event.keyCode < 48 && event.keyCode != 13) || (event.keyCode > 105 && event.keyCode < 123)) ) return;
|
||||
if (typeof (event) !== 'undefined' && ((event.keyCode < 48 && event.keyCode !== 13) || (event.keyCode > 105 && event.keyCode < 123))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lenTxtSearch < 3
|
||||
&& continous === 1
|
||||
&& lenTxtSearch > window.lastlen
|
||||
&& event.keyCode != 13) return;
|
||||
if (lenTxtSearch < 3 && continous === 1 && lenTxtSearch > window.lastlen && event.keyCode != 13) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.lastlen = lenTxtSearch;
|
||||
|
||||
@@ -150,6 +169,8 @@ function accSearch(continous, event) {
|
||||
|
||||
// Función para la búsqueda de cuentas mediante ordenación
|
||||
function searchSort(skey, start, nav) {
|
||||
"use strict";
|
||||
|
||||
if (typeof(skey) === "undefined" || typeof(start) === "undefined") return false;
|
||||
|
||||
if (order.key > 0 && order.key != skey) {
|
||||
@@ -173,7 +194,9 @@ function searchSort(skey, start, nav) {
|
||||
}
|
||||
|
||||
// Función para la búsqueda de cuentas
|
||||
function doSearch(){
|
||||
function doSearch() {
|
||||
"use strict";
|
||||
|
||||
var frmData = $("#frmSearch").serialize();
|
||||
|
||||
$.fancybox.showLoading();
|
||||
@@ -187,9 +210,9 @@ function doSearch(){
|
||||
$('#resBuscar').html(response);
|
||||
$('#resBuscar').css("max-height", $('html').height() - windowAdjustSize);
|
||||
|
||||
if ( order.key ){
|
||||
if (order.key) {
|
||||
$('#search-sort-' + order.key).addClass('filterOn');
|
||||
if (order.dir == 0) {
|
||||
if (order.dir === 0) {
|
||||
$('#search-sort-' + order.key).append('<img src="imgs/arrow_down.png" style="width:17px;height:12px;" />');
|
||||
} else {
|
||||
$('#search-sort-' + order.key).append('<img src="imgs/arrow_up.png" style="width:17px;height:12px;" />');
|
||||
@@ -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 = '<div id="alert"><p id="alert-text">' + LANG[3] + '</p></div>';
|
||||
var url = '/ajax/ajax_accountSave.php';
|
||||
|
||||
alertify.confirm(atext, function (e) {
|
||||
if (e) {
|
||||
sendAjax(data,url);
|
||||
sendAjax(data, url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Función para enviar una solicitud de modificación de cuenta
|
||||
function sendRequest() {
|
||||
"use strict";
|
||||
|
||||
var url = '/ajax/ajax_sendRequest.php';
|
||||
var data = $('#frmRequestModify').serialize();
|
||||
|
||||
sendAjax(data,url);
|
||||
sendAjax(data, url);
|
||||
}
|
||||
|
||||
// Función para guardar la configuración
|
||||
function configMgmt(action) {
|
||||
"use strict";
|
||||
|
||||
var frm, url;
|
||||
|
||||
switch (action) {
|
||||
case "saveconfig":
|
||||
frm = 'frmConfig';
|
||||
var url = '/ajax/ajax_configSave.php';
|
||||
url = '/ajax/ajax_configSave.php';
|
||||
break;
|
||||
case "savempwd":
|
||||
frm = 'frmCrypt';
|
||||
var url = '/ajax/ajax_configSave.php';
|
||||
url = '/ajax/ajax_configSave.php';
|
||||
break;
|
||||
case "backup":
|
||||
frm = 'frmBackup';
|
||||
@@ -422,7 +467,7 @@ function configMgmt(action) {
|
||||
break;
|
||||
case "migrate":
|
||||
frm = 'frmMigrate';
|
||||
var url = '/ajax/ajax_migrate.php';
|
||||
url = '/ajax/ajax_migrate.php';
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@@ -435,6 +480,8 @@ function configMgmt(action) {
|
||||
|
||||
// Función para descargar/ver archivos de una cuenta
|
||||
function downFile(id, sk, action) {
|
||||
"use strict";
|
||||
|
||||
var data = {'fileId': id, 'sk': sk, 'action': action};
|
||||
|
||||
if (action === 'view') {
|
||||
@@ -468,6 +515,8 @@ function downFile(id, sk, action) {
|
||||
|
||||
// Función para obtener la lista de archivos de una cuenta
|
||||
function getFiles(id, isDel, sk) {
|
||||
"use strict";
|
||||
|
||||
var data = {'id': id, 'del': isDel, 'sk': sk};
|
||||
|
||||
$.ajax({
|
||||
@@ -486,6 +535,8 @@ function getFiles(id, isDel, sk) {
|
||||
|
||||
// Función para eliminar archivos de una cuenta
|
||||
function delFile(id, sk, accid) {
|
||||
"use strict";
|
||||
|
||||
var atext = '<div id="alert"><p id="alert-text">' + LANG[15] + '</p></div>';
|
||||
|
||||
alertify.confirm(atext, function (e) {
|
||||
@@ -507,14 +558,16 @@ function delFile(id, sk, accid) {
|
||||
|
||||
// Función para activar el Drag&Drop de archivos en las cuentas
|
||||
function dropFile(accountId, sk, maxsize) {
|
||||
"use strict";
|
||||
|
||||
var dropfiles = $('#dropzone');
|
||||
var file_exts_ok = dropfiles.attr('data-files-ext').toLowerCase().split(',');
|
||||
|
||||
dropfiles.filedrop({
|
||||
fallback_id: 'inFile',
|
||||
paramname: 'inFile', // $_FILES name
|
||||
paramname: 'inFile',
|
||||
maxfiles: 5,
|
||||
maxfilesize: maxsize, // in mb
|
||||
maxfilesize: maxsize,
|
||||
allowedfileextensions: file_exts_ok,
|
||||
url: APP_ROOT + '/ajax/ajax_files.php',
|
||||
data: {
|
||||
@@ -526,7 +579,7 @@ function dropFile(accountId, sk, maxsize) {
|
||||
uploadFinished: function (i, file, response) {
|
||||
$.fancybox.hideLoading();
|
||||
|
||||
var sk = $('input:[name=sk]').val();
|
||||
var sk = $('input[name="sk"]').val();
|
||||
$("#downFiles").load(APP_ROOT + "/ajax/ajax_getFiles.php?id=" + accountId + "&del=1&isAjax=1&sk=" + sk);
|
||||
|
||||
resMsg("ok", response);
|
||||
@@ -557,14 +610,16 @@ function dropFile(accountId, sk, maxsize) {
|
||||
|
||||
// Función para activar el Drag&Drop de archivos en la importación de cuentas
|
||||
function importFile(sk) {
|
||||
"use strict";
|
||||
|
||||
var dropfiles = $('#dropzone');
|
||||
var file_exts_ok = ['csv','xml'];
|
||||
var file_exts_ok = ['csv', 'xml'];
|
||||
|
||||
dropfiles.filedrop({
|
||||
fallback_id: 'inFile',
|
||||
paramname: 'inFile', // $_FILES name
|
||||
paramname: 'inFile',
|
||||
maxfiles: 1,
|
||||
maxfilesize: 1, // in mb
|
||||
maxfilesize: 1,
|
||||
allowedfileextensions: file_exts_ok,
|
||||
url: APP_ROOT + '/ajax/ajax_import.php',
|
||||
data: {
|
||||
@@ -613,6 +668,8 @@ function importFile(sk) {
|
||||
|
||||
// Función para realizar una petición ajax
|
||||
function sendAjax(data, url) {
|
||||
"use strict";
|
||||
|
||||
$.fancybox.showLoading();
|
||||
|
||||
$.ajax({
|
||||
@@ -660,6 +717,8 @@ function sendAjax(data, url) {
|
||||
|
||||
// Función para mostrar el formulario para cambio de clave de usuario
|
||||
function usrUpdPass(id, usrlogin) {
|
||||
"use strict";
|
||||
|
||||
var data = {'usrid': id, 'usrlogin': usrlogin, 'isAjax': 1};
|
||||
|
||||
$.fancybox.showLoading();
|
||||
@@ -681,6 +740,8 @@ function usrUpdPass(id, usrlogin) {
|
||||
|
||||
// Función para mostrar los datos de un registro
|
||||
function appMgmtData(id, type, sk, active, view) {
|
||||
"use strict";
|
||||
|
||||
var data = {'id': id, 'type': type, 'sk': sk, 'active': active, 'view': view, 'isAjax': 1};
|
||||
var url = APP_ROOT + '/ajax/ajax_appMgmtData.php';
|
||||
|
||||
@@ -706,11 +767,13 @@ function appMgmtData(id, type, sk, active, view) {
|
||||
|
||||
// Función para editar los datos de un registro
|
||||
function appMgmtSave(frmId, isDel, id, type, sk, nextaction) {
|
||||
"use strict";
|
||||
|
||||
var data;
|
||||
var url = '/ajax/ajax_appMgmtSave.php';
|
||||
|
||||
if (isDel === 1) {
|
||||
var data = {'id': id, 'type': type, 'action': 4, 'sk': sk, 'activeTab': frmId, 'onCloseAction': nextaction };
|
||||
data = {'id': id, 'type': type, 'action': 4, 'sk': sk, 'activeTab': frmId, 'onCloseAction': nextaction };
|
||||
var atext = '<div id="alert"><p id="alert-text">' + LANG[12] + '</p></div>';
|
||||
|
||||
alertify.confirm(atext, function (e) {
|
||||
@@ -720,13 +783,14 @@ function appMgmtSave(frmId, isDel, id, type, sk, nextaction) {
|
||||
});
|
||||
} else {
|
||||
data = $("#" + frmId).serialize();
|
||||
|
||||
sendAjax(data, url);
|
||||
}
|
||||
}
|
||||
|
||||
// Función para verificar si existen actualizaciones
|
||||
function checkUpds() {
|
||||
"use strict";
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
dataType: 'html',
|
||||
@@ -743,6 +807,8 @@ function checkUpds() {
|
||||
|
||||
// Función para limpiar el log de eventos
|
||||
function clearEventlog(sk) {
|
||||
"use strict";
|
||||
|
||||
var atext = '<div id="alert"><p id="alert-text">' + LANG[20] + '</p></div>';
|
||||
|
||||
alertify.confirm(atext, function (e) {
|
||||
@@ -750,13 +816,15 @@ function clearEventlog(sk) {
|
||||
var data = { 'clear': 1, 'sk': sk, 'isAjax': 1};
|
||||
var url = '/ajax/ajax_eventlog.php';
|
||||
|
||||
sendAjax(data,url);
|
||||
sendAjax(data, url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Función para mostrar los botones de acción en los resultados de búsqueda
|
||||
function showOptional(me) {
|
||||
"use strict";
|
||||
|
||||
$(me).hide();
|
||||
//$(me).parent().css('width','15em');
|
||||
//var actions = $(me).closest('.account-actions').children('.actions-optional');
|
||||
@@ -766,19 +834,23 @@ function showOptional(me) {
|
||||
|
||||
// Función para obtener el tiempo actual en milisegundos
|
||||
function getTime() {
|
||||
t = new Date();
|
||||
"use strict";
|
||||
|
||||
var t = new Date();
|
||||
return t.getTime();
|
||||
}
|
||||
|
||||
// Función para generar claves aleatorias.
|
||||
// By Uzbekjon from http://jquery-howto.blogspot.com.es
|
||||
function password(length, special, fancy, dstId) {
|
||||
"use strict";
|
||||
|
||||
var iteration = 0;
|
||||
var password = "";
|
||||
var genPassword = '';
|
||||
var randomNumber;
|
||||
|
||||
if (special == undefined) {
|
||||
var special = false;
|
||||
if (typeof special === 'undefined') {
|
||||
special = false;
|
||||
}
|
||||
|
||||
while (iteration < length) {
|
||||
@@ -798,33 +870,34 @@ function password(length, special, fancy, dstId) {
|
||||
}
|
||||
}
|
||||
iteration++;
|
||||
password += String.fromCharCode(randomNumber);
|
||||
genPassword += String.fromCharCode(randomNumber);
|
||||
}
|
||||
|
||||
if (fancy == true) {
|
||||
$("#viewPass").attr("title", password);
|
||||
if (fancy === true) {
|
||||
$("#viewPass").attr("title", genPassword);
|
||||
//alertify.alert('<div id="alert"><p id="alert-text">' + LANG[6] + '</p><p id="alert-pass"> ' + password + '</p>');
|
||||
} else {
|
||||
alertify.alert('<div id="alert"><p id="alert-text">' + LANG[6] + '</p><p id="alert-pass"> ' + password + '</p>');
|
||||
alertify.alert('<div id="alert"><p id="alert-text">' + LANG[6] + '</p><p id="alert-pass"> ' + genPassword + '</p>');
|
||||
}
|
||||
|
||||
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 = '<P CLASS="error round">Oops...<BR />' + LANG[1] + '<BR />' + txt + '</P>';
|
||||
return html;
|
||||
break;
|
||||
default:
|
||||
alertify.set({ beforeCloseAction: action });
|
||||
return alertify.error(txt);
|
||||
@@ -960,12 +1036,16 @@ function resMsg(type, txt, url, action) {
|
||||
$.fancybox(html, {afterLoad: function () {
|
||||
$('.fancybox-skin,.fancybox-outer,.fancybox-inner').css({'border-radius': '25px', '-moz-border-radius': '25px', '-webkit-border-radius': '25px'});
|
||||
}, afterClose: function () {
|
||||
if (typeof(action) !== "undefined") eval(action);
|
||||
if (typeof action !== "undefined") {
|
||||
eval(action);
|
||||
}
|
||||
} });
|
||||
}
|
||||
|
||||
// Función para comprobar la conexión con LDAP
|
||||
function checkLdapConn() {
|
||||
"use strict";
|
||||
|
||||
var ldapServer = $('#frmConfig').find('[name=ldap_server]').val();
|
||||
var ldapBase = $('#frmConfig').find('[name=ldap_base]').val();
|
||||
var ldapGroup = $('#frmConfig').find('[name=ldap_group]').val();
|
||||
@@ -974,25 +1054,29 @@ function checkLdapConn() {
|
||||
var sk = $('#frmConfig').find('[name=sk]').val();
|
||||
var data = {'ldap_server': ldapServer, 'ldap_base': ldapBase, 'ldap_group': ldapGroup, 'ldap_binduser': ldapBindUser, 'ldap_bindpass': ldapBindPass, 'isAjax': 1, 'sk': sk};
|
||||
|
||||
sendAjax(data,'/ajax/ajax_checkLdap.php');
|
||||
sendAjax(data, '/ajax/ajax_checkLdap.php');
|
||||
}
|
||||
|
||||
// Función para volver al login
|
||||
function goLogin() {
|
||||
setTimeout(function () { location.href = "index.php";}, 2000);
|
||||
"use strict";
|
||||
|
||||
setTimeout(function () {
|
||||
location.href = "index.php";
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// Función para obtener el navegador usado
|
||||
function getBrowser()
|
||||
{
|
||||
var version = -1; // Return value assumes failure.
|
||||
function getBrowser() {
|
||||
"use strict";
|
||||
|
||||
var browser;
|
||||
var ua = navigator.userAgent;
|
||||
var re = new RegExp("(MSIE|Firefox)[ /]?([0-9]{1,}[\.0-9]{0,})", "i");
|
||||
if (re.exec(ua) != null) {
|
||||
var browser = RegExp.$1;
|
||||
var re = new RegExp("(MSIE|Firefox)[ /]?([0-9]{1,}[\.0-9]{0,})", "i");
|
||||
if (re.exec(ua) !== null) {
|
||||
browser = RegExp.$1;
|
||||
//version = parseFloat( RegExp.$2 );
|
||||
}
|
||||
|
||||
return browser;
|
||||
//return version;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012 Rubén Domínguez nuxsmin@syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php';
|
||||
|
||||
$offset = 3600 * 24;
|
||||
$expire = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
|
||||
|
||||
header("content-type: application/x-javascript");
|
||||
header($expire);
|
||||
header('Cache-Control: max-age=3600, must-revalidate');
|
||||
|
||||
$arrJsLang = array(_('Error en la consulta'),
|
||||
_('Ha ocurrido un error'),
|
||||
_('Sesión finalizada'),
|
||||
_('Borrar la cuenta?'),
|
||||
_('Borrar el usuario?'),
|
||||
_('Guarde la configuración para que sea efectiva'),
|
||||
_('Clave Generada'),
|
||||
_('Nivel alto'),
|
||||
_('Nivel medio'),
|
||||
_('Nivel bajo'),
|
||||
_('Nivel muy alto'),
|
||||
_('Utilizar al menos 8 caracteres'),
|
||||
_('Borrar elemento?'),
|
||||
_('Página no encontrada'),
|
||||
_('Archivo no soportado para visualizar'),
|
||||
_('Eliminar archivo?'),
|
||||
_('Su navegador no soporta subir archivos con HTML5'),
|
||||
_('Demasiados archivos'),
|
||||
_('No es posible guardar el archivo.<br>Tamaño máximo:'),
|
||||
_('Extensión no permitida'),
|
||||
_('Vaciar el registro de eventos?'));
|
||||
|
||||
echo "// i18n language array from PHP. Detected language: ".SP_Init::$LANG."\n";
|
||||
echo "var LANG = ['".implode("','",$arrJsLang)."']; \n";
|
||||
echo "var APP_ROOT = '".SP_Init::$WEBROOT."';\n\n";
|
||||
include_once 'functions.js';
|
||||
@@ -1,427 +1,434 @@
|
||||
/*
|
||||
* jQuery File Download Plugin v1.4.2
|
||||
*
|
||||
* http://www.johnculviner.com
|
||||
*
|
||||
* Copyright (c) 2013 - John Culviner
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
/*
|
||||
* jQuery File Download Plugin v1.4.2
|
||||
*
|
||||
* http://www.johnculviner.com
|
||||
*
|
||||
* Copyright (c) 2013 - John Culviner
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
(function($, window){
|
||||
// i'll just put them here to get evaluated on script load
|
||||
var htmlSpecialCharsRegEx = /[<>&\r\n"']/gm;
|
||||
var htmlSpecialCharsPlaceHolders = {
|
||||
'<': 'lt;',
|
||||
'>': 'gt;',
|
||||
'&': 'amp;',
|
||||
'\r': "#13;",
|
||||
'\n': "#10;",
|
||||
'"': 'quot;',
|
||||
"'": 'apos;' /*single quotes just to be safe*/
|
||||
};
|
||||
(function ($, window) {
|
||||
// i'll just put them here to get evaluated on script load
|
||||
var htmlSpecialCharsRegEx = /[<>&\r\n"']/gm;
|
||||
var htmlSpecialCharsPlaceHolders = {
|
||||
'<': 'lt;',
|
||||
'>': 'gt;',
|
||||
'&': 'amp;',
|
||||
'\r': "#13;",
|
||||
'\n': "#10;",
|
||||
'"': 'quot;',
|
||||
"'": 'apos;' /*single quotes just to be safe*/
|
||||
};
|
||||
|
||||
$.extend({
|
||||
//
|
||||
//$.fileDownload('/path/to/url/', options)
|
||||
// see directly below for possible 'options'
|
||||
fileDownload: function (fileUrl, options) {
|
||||
$.extend({
|
||||
//
|
||||
//$.fileDownload('/path/to/url/', options)
|
||||
// see directly below for possible 'options'
|
||||
fileDownload: function (fileUrl, options) {
|
||||
|
||||
//provide some reasonable defaults to any unspecified options below
|
||||
var settings = $.extend({
|
||||
//provide some reasonable defaults to any unspecified options below
|
||||
var settings = $.extend({
|
||||
|
||||
//
|
||||
//Requires jQuery UI: provide a message to display to the user when the file download is being prepared before the browser's dialog appears
|
||||
//
|
||||
preparingMessageHtml: null,
|
||||
//
|
||||
//Requires jQuery UI: provide a message to display to the user when the file download is being prepared before the browser's dialog appears
|
||||
//
|
||||
preparingMessageHtml: null,
|
||||
|
||||
//
|
||||
//Requires jQuery UI: provide a message to display to the user when a file download fails
|
||||
//
|
||||
failMessageHtml: null,
|
||||
//
|
||||
//Requires jQuery UI: provide a message to display to the user when a file download fails
|
||||
//
|
||||
failMessageHtml: null,
|
||||
|
||||
//
|
||||
//the stock android browser straight up doesn't support file downloads initiated by a non GET: http://code.google.com/p/android/issues/detail?id=1780
|
||||
//specify a message here to display if a user tries with an android browser
|
||||
//if jQuery UI is installed this will be a dialog, otherwise it will be an alert
|
||||
//
|
||||
androidPostUnsupportedMessageHtml: "Unfortunately your Android browser doesn't support this type of file download. Please try again with a different browser.",
|
||||
//
|
||||
//the stock android browser straight up doesn't support file downloads initiated by a non GET: http://code.google.com/p/android/issues/detail?id=1780
|
||||
//specify a message here to display if a user tries with an android browser
|
||||
//if jQuery UI is installed this will be a dialog, otherwise it will be an alert
|
||||
//
|
||||
androidPostUnsupportedMessageHtml: "Unfortunately your Android browser doesn't support this type of file download. Please try again with a different browser.",
|
||||
|
||||
//
|
||||
//Requires jQuery UI: options to pass into jQuery UI Dialog
|
||||
//
|
||||
dialogOptions: { modal: true },
|
||||
//
|
||||
//Requires jQuery UI: options to pass into jQuery UI Dialog
|
||||
//
|
||||
dialogOptions: { modal: true },
|
||||
|
||||
//
|
||||
//a function to call while the dowload is being prepared before the browser's dialog appears
|
||||
//Args:
|
||||
// url - the original url attempted
|
||||
//
|
||||
prepareCallback: function (url) { },
|
||||
//
|
||||
//a function to call while the dowload is being prepared before the browser's dialog appears
|
||||
//Args:
|
||||
// url - the original url attempted
|
||||
//
|
||||
prepareCallback: function (url) {
|
||||
},
|
||||
|
||||
//
|
||||
//a function to call after a file download dialog/ribbon has appeared
|
||||
//Args:
|
||||
// url - the original url attempted
|
||||
//
|
||||
successCallback: function (url) { },
|
||||
//
|
||||
//a function to call after a file download dialog/ribbon has appeared
|
||||
//Args:
|
||||
// url - the original url attempted
|
||||
//
|
||||
successCallback: function (url) {
|
||||
},
|
||||
|
||||
//
|
||||
//a function to call after a file download dialog/ribbon has appeared
|
||||
//Args:
|
||||
// responseHtml - the html that came back in response to the file download. this won't necessarily come back depending on the browser.
|
||||
// in less than IE9 a cross domain error occurs because 500+ errors cause a cross domain issue due to IE subbing out the
|
||||
// server's error message with a "helpful" IE built in message
|
||||
// url - the original url attempted
|
||||
//
|
||||
failCallback: function (responseHtml, url) { },
|
||||
//
|
||||
//a function to call after a file download dialog/ribbon has appeared
|
||||
//Args:
|
||||
// responseHtml - the html that came back in response to the file download. this won't necessarily come back depending on the browser.
|
||||
// in less than IE9 a cross domain error occurs because 500+ errors cause a cross domain issue due to IE subbing out the
|
||||
// server's error message with a "helpful" IE built in message
|
||||
// url - the original url attempted
|
||||
//
|
||||
failCallback: function (responseHtml, url) {
|
||||
},
|
||||
|
||||
//
|
||||
// the HTTP method to use. Defaults to "GET".
|
||||
//
|
||||
httpMethod: "GET",
|
||||
//
|
||||
// the HTTP method to use. Defaults to "GET".
|
||||
//
|
||||
httpMethod: "GET",
|
||||
|
||||
//
|
||||
// if specified will perform a "httpMethod" request to the specified 'fileUrl' using the specified data.
|
||||
// data must be an object (which will be $.param serialized) or already a key=value param string
|
||||
//
|
||||
data: null,
|
||||
//
|
||||
// if specified will perform a "httpMethod" request to the specified 'fileUrl' using the specified data.
|
||||
// data must be an object (which will be $.param serialized) or already a key=value param string
|
||||
//
|
||||
data: null,
|
||||
|
||||
//
|
||||
//a period in milliseconds to poll to determine if a successful file download has occured or not
|
||||
//
|
||||
checkInterval: 100,
|
||||
//
|
||||
//a period in milliseconds to poll to determine if a successful file download has occured or not
|
||||
//
|
||||
checkInterval: 100,
|
||||
|
||||
//
|
||||
//the cookie name to indicate if a file download has occured
|
||||
//
|
||||
cookieName: "fileDownload",
|
||||
//
|
||||
//the cookie name to indicate if a file download has occured
|
||||
//
|
||||
cookieName: "fileDownload",
|
||||
|
||||
//
|
||||
//the cookie value for the above name to indicate that a file download has occured
|
||||
//
|
||||
cookieValue: "true",
|
||||
//
|
||||
//the cookie value for the above name to indicate that a file download has occured
|
||||
//
|
||||
cookieValue: "true",
|
||||
|
||||
//
|
||||
//the cookie path for above name value pair
|
||||
//
|
||||
cookiePath: "/",
|
||||
//
|
||||
//the cookie path for above name value pair
|
||||
//
|
||||
cookiePath: "/",
|
||||
|
||||
//
|
||||
//the title for the popup second window as a download is processing in the case of a mobile browser
|
||||
//
|
||||
popupWindowTitle: "Initiating file download...",
|
||||
//
|
||||
//the title for the popup second window as a download is processing in the case of a mobile browser
|
||||
//
|
||||
popupWindowTitle: "Initiating file download...",
|
||||
|
||||
//
|
||||
//Functionality to encode HTML entities for a POST, need this if data is an object with properties whose values contains strings with quotation marks.
|
||||
//HTML entity encoding is done by replacing all &,<,>,',",\r,\n characters.
|
||||
//Note that some browsers will POST the string htmlentity-encoded whilst others will decode it before POSTing.
|
||||
//It is recommended that on the server, htmlentity decoding is done irrespective.
|
||||
//
|
||||
encodeHTMLEntities: true
|
||||
|
||||
}, options);
|
||||
//
|
||||
//Functionality to encode HTML entities for a POST, need this if data is an object with properties whose values contains strings with quotation marks.
|
||||
//HTML entity encoding is done by replacing all &,<,>,',",\r,\n characters.
|
||||
//Note that some browsers will POST the string htmlentity-encoded whilst others will decode it before POSTing.
|
||||
//It is recommended that on the server, htmlentity decoding is done irrespective.
|
||||
//
|
||||
encodeHTMLEntities: true
|
||||
|
||||
var deferred = new $.Deferred();
|
||||
}, options);
|
||||
|
||||
//Setup mobile browser detection: Partial credit: http://detectmobilebrowser.com/
|
||||
var userAgent = (navigator.userAgent || navigator.vendor || window.opera).toLowerCase();
|
||||
var deferred = new $.Deferred();
|
||||
|
||||
var isIos; //has full support of features in iOS 4.0+, uses a new window to accomplish this.
|
||||
var isAndroid; //has full support of GET features in 4.0+ by using a new window. Non-GET is completely unsupported by the browser. See above for specifying a message.
|
||||
var isOtherMobileBrowser; //there is no way to reliably guess here so all other mobile devices will GET and POST to the current window.
|
||||
//Setup mobile browser detection: Partial credit: http://detectmobilebrowser.com/
|
||||
var userAgent = (navigator.userAgent || navigator.vendor || window.opera).toLowerCase();
|
||||
|
||||
if (/ip(ad|hone|od)/.test(userAgent)) {
|
||||
//has full support of features in iOS 4.0+, uses a new window to accomplish this.
|
||||
var isIos;
|
||||
//has full support of GET features in 4.0+ by using a new window. Non-GET is completely unsupported by the browser. See above for specifying a message.
|
||||
var isAndroid;
|
||||
//there is no way to reliably guess here so all other mobile devices will GET and POST to the current window.
|
||||
var isOtherMobileBrowser;
|
||||
|
||||
isIos = true;
|
||||
if (/ip(ad|hone|od)/.test(userAgent)) {
|
||||
|
||||
} else if (userAgent.indexOf('android') !== -1) {
|
||||
isIos = true;
|
||||
|
||||
isAndroid = true;
|
||||
} else if (userAgent.indexOf('android') !== -1) {
|
||||
|
||||
} else {
|
||||
isAndroid = true;
|
||||
|
||||
isOtherMobileBrowser = /avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|playbook|silk|iemobile|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4));
|
||||
|
||||
}
|
||||
|
||||
var httpMethodUpper = settings.httpMethod.toUpperCase();
|
||||
|
||||
if (isAndroid && httpMethodUpper !== "GET") {
|
||||
//the stock android browser straight up doesn't support file downloads initiated by non GET requests: http://code.google.com/p/android/issues/detail?id=1780
|
||||
|
||||
if ($().dialog) {
|
||||
$("<div>").html(settings.androidPostUnsupportedMessageHtml).dialog(settings.dialogOptions);
|
||||
} else {
|
||||
alert(settings.androidPostUnsupportedMessageHtml);
|
||||
|
||||
isOtherMobileBrowser = /avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|playbook|silk|iemobile|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4));
|
||||
|
||||
}
|
||||
|
||||
return deferred.reject();
|
||||
}
|
||||
var httpMethodUpper = settings.httpMethod.toUpperCase();
|
||||
|
||||
var $preparingDialog = null;
|
||||
if (isAndroid && httpMethodUpper !== "GET") {
|
||||
//the stock android browser straight up doesn't support file downloads initiated by non GET requests: http://code.google.com/p/android/issues/detail?id=1780
|
||||
|
||||
var internalCallbacks = {
|
||||
|
||||
onPrepare: function (url) {
|
||||
|
||||
//wire up a jquery dialog to display the preparing message if specified
|
||||
if (settings.preparingMessageHtml) {
|
||||
|
||||
$preparingDialog = $("<div>").html(settings.preparingMessageHtml).dialog(settings.dialogOptions);
|
||||
|
||||
} else if (settings.prepareCallback) {
|
||||
|
||||
settings.prepareCallback(url);
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
onSuccess: function (url) {
|
||||
|
||||
//remove the perparing message if it was specified
|
||||
if ($preparingDialog) {
|
||||
$preparingDialog.dialog('close');
|
||||
};
|
||||
|
||||
settings.successCallback(url);
|
||||
|
||||
deferred.resolve(url);
|
||||
},
|
||||
|
||||
onFail: function (responseHtml, url) {
|
||||
|
||||
//remove the perparing message if it was specified
|
||||
if ($preparingDialog) {
|
||||
$preparingDialog.dialog('close');
|
||||
};
|
||||
|
||||
//wire up a jquery dialog to display the fail message if specified
|
||||
if (settings.failMessageHtml) {
|
||||
$("<div>").html(settings.failMessageHtml).dialog(settings.dialogOptions);
|
||||
}
|
||||
|
||||
settings.failCallback(responseHtml, url);
|
||||
|
||||
deferred.reject(responseHtml, url);
|
||||
}
|
||||
};
|
||||
|
||||
internalCallbacks.onPrepare(fileUrl);
|
||||
|
||||
//make settings.data a param string if it exists and isn't already
|
||||
if (settings.data !== null && typeof settings.data !== "string") {
|
||||
settings.data = $.param(settings.data);
|
||||
}
|
||||
|
||||
|
||||
var $iframe,
|
||||
downloadWindow,
|
||||
formDoc,
|
||||
$form;
|
||||
|
||||
if (httpMethodUpper === "GET") {
|
||||
|
||||
if (settings.data !== null) {
|
||||
//need to merge any fileUrl params with the data object
|
||||
|
||||
var qsStart = fileUrl.indexOf('?');
|
||||
|
||||
if (qsStart !== -1) {
|
||||
//we have a querystring in the url
|
||||
|
||||
if (fileUrl.substring(fileUrl.length - 1) !== "&") {
|
||||
fileUrl = fileUrl + "&";
|
||||
}
|
||||
if ($().dialog) {
|
||||
$("<div>").html(settings.androidPostUnsupportedMessageHtml).dialog(settings.dialogOptions);
|
||||
} else {
|
||||
|
||||
fileUrl = fileUrl + "?";
|
||||
alert(settings.androidPostUnsupportedMessageHtml);
|
||||
}
|
||||
|
||||
fileUrl = fileUrl + settings.data;
|
||||
return deferred.reject();
|
||||
}
|
||||
|
||||
if (isIos || isAndroid) {
|
||||
var $preparingDialog = null;
|
||||
|
||||
downloadWindow = window.open(fileUrl);
|
||||
downloadWindow.document.title = settings.popupWindowTitle;
|
||||
window.focus();
|
||||
var internalCallbacks = {
|
||||
|
||||
} else if (isOtherMobileBrowser) {
|
||||
onPrepare: function (url) {
|
||||
|
||||
window.location(fileUrl);
|
||||
//wire up a jquery dialog to display the preparing message if specified
|
||||
if (settings.preparingMessageHtml) {
|
||||
|
||||
} else {
|
||||
$preparingDialog = $("<div>").html(settings.preparingMessageHtml).dialog(settings.dialogOptions);
|
||||
|
||||
//create a temporary iframe that is used to request the fileUrl as a GET request
|
||||
$iframe = $("<iframe>")
|
||||
.hide()
|
||||
.prop("src", fileUrl)
|
||||
.appendTo("body");
|
||||
}
|
||||
} else if (settings.prepareCallback) {
|
||||
|
||||
} else {
|
||||
settings.prepareCallback(url);
|
||||
|
||||
var formInnerHtml = "";
|
||||
|
||||
if (settings.data !== null) {
|
||||
|
||||
$.each(settings.data.replace(/\+/g, ' ').split("&"), function () {
|
||||
|
||||
var kvp = this.split("=");
|
||||
|
||||
var key = settings.encodeHTMLEntities ? htmlSpecialCharsEntityEncode(decodeURIComponent(kvp[0])) : decodeURIComponent(kvp[0]);
|
||||
if (key) {
|
||||
var value = settings.encodeHTMLEntities ? htmlSpecialCharsEntityEncode(decodeURIComponent(kvp[1])) : decodeURIComponent(kvp[1]);
|
||||
formInnerHtml += '<input type="hidden" name="' + key + '" value="' + value + '" />';
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
onSuccess: function (url) {
|
||||
|
||||
//remove the perparing message if it was specified
|
||||
if ($preparingDialog) {
|
||||
$preparingDialog.dialog('close');
|
||||
}
|
||||
|
||||
settings.successCallback(url);
|
||||
|
||||
deferred.resolve(url);
|
||||
},
|
||||
|
||||
onFail: function (responseHtml, url) {
|
||||
|
||||
//remove the perparing message if it was specified
|
||||
if ($preparingDialog) {
|
||||
$preparingDialog.dialog('close');
|
||||
}
|
||||
|
||||
//wire up a jquery dialog to display the fail message if specified
|
||||
if (settings.failMessageHtml) {
|
||||
$("<div>").html(settings.failMessageHtml).dialog(settings.dialogOptions);
|
||||
}
|
||||
|
||||
settings.failCallback(responseHtml, url);
|
||||
|
||||
deferred.reject(responseHtml, url);
|
||||
}
|
||||
};
|
||||
|
||||
internalCallbacks.onPrepare(fileUrl);
|
||||
|
||||
//make settings.data a param string if it exists and isn't already
|
||||
if (settings.data !== null && typeof settings.data !== "string") {
|
||||
settings.data = $.param(settings.data);
|
||||
}
|
||||
|
||||
if (isOtherMobileBrowser) {
|
||||
|
||||
$form = $("<form>").appendTo("body");
|
||||
$form.hide()
|
||||
.prop('method', settings.httpMethod)
|
||||
.prop('action', fileUrl)
|
||||
.html(formInnerHtml);
|
||||
var $iframe,
|
||||
downloadWindow,
|
||||
formDoc,
|
||||
$form;
|
||||
|
||||
} else {
|
||||
if (httpMethodUpper === "GET") {
|
||||
|
||||
if (isIos) {
|
||||
if (settings.data !== null) {
|
||||
//need to merge any fileUrl params with the data object
|
||||
|
||||
downloadWindow = window.open("about:blank");
|
||||
var qsStart = fileUrl.indexOf('?');
|
||||
|
||||
if (qsStart !== -1) {
|
||||
//we have a querystring in the url
|
||||
|
||||
if (fileUrl.substring(fileUrl.length - 1) !== "&") {
|
||||
fileUrl = fileUrl + "&";
|
||||
}
|
||||
} else {
|
||||
|
||||
fileUrl = fileUrl + "?";
|
||||
}
|
||||
|
||||
fileUrl = fileUrl + settings.data;
|
||||
}
|
||||
|
||||
if (isIos || isAndroid) {
|
||||
|
||||
downloadWindow = window.open(fileUrl);
|
||||
downloadWindow.document.title = settings.popupWindowTitle;
|
||||
formDoc = downloadWindow.document;
|
||||
window.focus();
|
||||
|
||||
} else if (isOtherMobileBrowser) {
|
||||
|
||||
window.location(fileUrl);
|
||||
|
||||
} else {
|
||||
|
||||
$iframe = $("<iframe style='display: none' src='about:blank'></iframe>").appendTo("body");
|
||||
formDoc = getiframeDocument($iframe);
|
||||
//create a temporary iframe that is used to request the fileUrl as a GET request
|
||||
$iframe = $("<iframe>")
|
||||
.hide()
|
||||
.prop("src", fileUrl)
|
||||
.appendTo("body");
|
||||
}
|
||||
|
||||
formDoc.write("<html><head></head><body><form method='" + settings.httpMethod + "' action='" + fileUrl + "'>" + formInnerHtml + "</form>" + settings.popupWindowTitle + "</body></html>");
|
||||
$form = $(formDoc).find('form');
|
||||
}
|
||||
} else {
|
||||
|
||||
$form.submit();
|
||||
}
|
||||
var formInnerHtml = "";
|
||||
|
||||
if (settings.data !== null) {
|
||||
|
||||
//check if the file download has completed every checkInterval ms
|
||||
setTimeout(checkFileDownloadComplete, settings.checkInterval);
|
||||
$.each(settings.data.replace(/\+/g, ' ').split("&"), function () {
|
||||
|
||||
var kvp = this.split("=");
|
||||
|
||||
function checkFileDownloadComplete() {
|
||||
|
||||
//has the cookie been written due to a file download occuring?
|
||||
if (document.cookie.indexOf(settings.cookieName + "=" + settings.cookieValue) != -1) {
|
||||
|
||||
//execute specified callback
|
||||
internalCallbacks.onSuccess(fileUrl);
|
||||
|
||||
//remove the cookie and iframe
|
||||
document.cookie = settings.cookieName + "=; expires=" + new Date(1000).toUTCString() + "; path=" + settings.cookiePath;
|
||||
|
||||
cleanUp(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//has an error occured?
|
||||
//if neither containers exist below then the file download is occuring on the current window
|
||||
if (downloadWindow || $iframe) {
|
||||
|
||||
//has an error occured?
|
||||
try {
|
||||
|
||||
var formDoc = downloadWindow ? downloadWindow.document : getiframeDocument($iframe);
|
||||
|
||||
if (formDoc && formDoc.body != null && formDoc.body.innerHTML.length) {
|
||||
|
||||
var isFailure = true;
|
||||
|
||||
if ($form && $form.length) {
|
||||
var $contents = $(formDoc.body).contents().first();
|
||||
|
||||
if ($contents.length && $contents[0] === $form[0]) {
|
||||
isFailure = false;
|
||||
}
|
||||
var key = settings.encodeHTMLEntities ? htmlSpecialCharsEntityEncode(decodeURIComponent(kvp[0])) : decodeURIComponent(kvp[0]);
|
||||
if (key) {
|
||||
var value = settings.encodeHTMLEntities ? htmlSpecialCharsEntityEncode(decodeURIComponent(kvp[1])) : decodeURIComponent(kvp[1]);
|
||||
formInnerHtml += '<input type="hidden" name="' + key + '" value="' + value + '" />';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (isFailure) {
|
||||
internalCallbacks.onFail(formDoc.body.innerHTML, fileUrl);
|
||||
if (isOtherMobileBrowser) {
|
||||
|
||||
cleanUp(true);
|
||||
$form = $("<form>").appendTo("body");
|
||||
$form.hide()
|
||||
.prop('method', settings.httpMethod)
|
||||
.prop('action', fileUrl)
|
||||
.html(formInnerHtml);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (isIos) {
|
||||
|
||||
downloadWindow = window.open("about:blank");
|
||||
downloadWindow.document.title = settings.popupWindowTitle;
|
||||
formDoc = downloadWindow.document;
|
||||
window.focus();
|
||||
|
||||
} else {
|
||||
|
||||
$iframe = $("<iframe style='display: none' src='about:blank'></iframe>").appendTo("body");
|
||||
formDoc = getiframeDocument($iframe);
|
||||
}
|
||||
|
||||
formDoc.write("<html><head></head><body><form method='" + settings.httpMethod + "' action='" + fileUrl + "'>" + formInnerHtml + "</form>" + settings.popupWindowTitle + "</body></html>");
|
||||
$form = $(formDoc).find('form');
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
//500 error less than IE9
|
||||
internalCallbacks.onFail('', fileUrl);
|
||||
$form.submit();
|
||||
}
|
||||
|
||||
cleanUp(true);
|
||||
|
||||
//check if the file download has completed every checkInterval ms
|
||||
setTimeout(checkFileDownloadComplete, settings.checkInterval);
|
||||
|
||||
|
||||
function checkFileDownloadComplete() {
|
||||
|
||||
//has the cookie been written due to a file download occuring?
|
||||
if (document.cookie.indexOf(settings.cookieName + "=" + settings.cookieValue) != -1) {
|
||||
|
||||
//execute specified callback
|
||||
internalCallbacks.onSuccess(fileUrl);
|
||||
|
||||
//remove the cookie and iframe
|
||||
document.cookie = settings.cookieName + "=; expires=" + new Date(1000).toUTCString() + "; path=" + settings.cookiePath;
|
||||
|
||||
cleanUp(false);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//has an error occured?
|
||||
//if neither containers exist below then the file download is occuring on the current window
|
||||
if (downloadWindow || $iframe) {
|
||||
|
||||
//keep checking...
|
||||
setTimeout(checkFileDownloadComplete, settings.checkInterval);
|
||||
}
|
||||
//has an error occured?
|
||||
try {
|
||||
|
||||
//gets an iframes document in a cross browser compatible manner
|
||||
function getiframeDocument($iframe) {
|
||||
var iframeDoc = $iframe[0].contentWindow || $iframe[0].contentDocument;
|
||||
if (iframeDoc.document) {
|
||||
iframeDoc = iframeDoc.document;
|
||||
}
|
||||
return iframeDoc;
|
||||
}
|
||||
var formDoc = downloadWindow ? downloadWindow.document : getiframeDocument($iframe);
|
||||
|
||||
function cleanUp(isFailure) {
|
||||
if (formDoc && formDoc.body != null && formDoc.body.innerHTML.length) {
|
||||
|
||||
setTimeout(function() {
|
||||
var isFailure = true;
|
||||
|
||||
if (downloadWindow) {
|
||||
if ($form && $form.length) {
|
||||
var $contents = $(formDoc.body).contents().first();
|
||||
|
||||
if (isAndroid) {
|
||||
downloadWindow.close();
|
||||
}
|
||||
if ($contents.length && $contents[0] === $form[0]) {
|
||||
isFailure = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isIos) {
|
||||
downloadWindow.focus(); //ios safari bug doesn't allow a window to be closed unless it is focused
|
||||
if (isFailure) {
|
||||
downloadWindow.close();
|
||||
if (isFailure) {
|
||||
internalCallbacks.onFail(formDoc.body.innerHTML, fileUrl);
|
||||
|
||||
cleanUp(true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
//500 error less than IE9
|
||||
internalCallbacks.onFail('', fileUrl);
|
||||
|
||||
cleanUp(true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//iframe cleanup appears to randomly cause the download to fail
|
||||
//not doing it seems better than failure...
|
||||
//if ($iframe) {
|
||||
// $iframe.remove();
|
||||
//}
|
||||
|
||||
}, 0);
|
||||
|
||||
//keep checking...
|
||||
setTimeout(checkFileDownloadComplete, settings.checkInterval);
|
||||
}
|
||||
|
||||
//gets an iframes document in a cross browser compatible manner
|
||||
function getiframeDocument($iframe) {
|
||||
var iframeDoc = $iframe[0].contentWindow || $iframe[0].contentDocument;
|
||||
if (iframeDoc.document) {
|
||||
iframeDoc = iframeDoc.document;
|
||||
}
|
||||
return iframeDoc;
|
||||
}
|
||||
|
||||
function cleanUp(isFailure) {
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
if (downloadWindow) {
|
||||
|
||||
if (isAndroid) {
|
||||
downloadWindow.close();
|
||||
}
|
||||
|
||||
if (isIos) {
|
||||
//ios safari bug doesn't allow a window to be closed unless it is focused
|
||||
downloadWindow.focus();
|
||||
if (isFailure) {
|
||||
downloadWindow.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//iframe cleanup appears to randomly cause the download to fail
|
||||
//not doing it seems better than failure...
|
||||
//if ($iframe) {
|
||||
// $iframe.remove();
|
||||
//}
|
||||
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
function htmlSpecialCharsEntityEncode(str) {
|
||||
return str.replace(htmlSpecialCharsRegEx, function (match) {
|
||||
return '&' + htmlSpecialCharsPlaceHolders[match];
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
|
||||
function htmlSpecialCharsEntityEncode(str) {
|
||||
return str.replace(htmlSpecialCharsRegEx, function(match) {
|
||||
return '&' + htmlSpecialCharsPlaceHolders[match];
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery, this);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -170,7 +170,8 @@
|
||||
$.fn.tagExist = function(val) {
|
||||
var id = $(this).attr('id');
|
||||
var tagslist = $(this).val().split(delimiter[id]);
|
||||
return (jQuery.inArray(val, tagslist) >= 0); //true when tag exists, false when not
|
||||
//true when tag exists, false when not
|
||||
return (jQuery.inArray(val, tagslist) >= 0);
|
||||
};
|
||||
|
||||
// clear all existing tags and import new ones from a string
|
||||
@@ -178,7 +179,7 @@
|
||||
id = $(this).attr('id');
|
||||
$('#' + id + '_tagsinput .tag').remove();
|
||||
$.fn.tagsInput.importTags(this, str);
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.tagsInput = function(options) {
|
||||
var settings = jQuery.extend({
|
||||
@@ -334,7 +335,8 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
} // if settings.interactive
|
||||
}
|
||||
// if settings.interactive
|
||||
$(data.holder).animate({scrollTop: $(data.holder).height()});
|
||||
});
|
||||
|
||||
@@ -362,4 +364,4 @@
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
70
js/js.php
Normal file
70
js/js.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012 Rubén Domínguez nuxsmin@syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php';
|
||||
|
||||
$jsFiles = array(
|
||||
array("href" => "js/jquery.js", "min" => false),
|
||||
array("href" => "js/jquery.placeholder.js", "min" => true),
|
||||
array("href" => "js/jquery-ui.js", "min" => false),
|
||||
array("href" => "js/fancybox/jquery.fancybox.pack.js", "min" => false),
|
||||
array("href" => "js/jquery.powertip.min.js", "min" => false),
|
||||
array("href" => "js/chosen.jquery.min.js", "min" => false),
|
||||
array("href" => "js/alertify.js", "min" => true),
|
||||
array("href" => "js/jquery.fileDownload.js", "min" => true),
|
||||
array("href" => "js/jquery.filedrop.js", "min" => true),
|
||||
array("href" => "js/jquery.tagsinput.js", "min" => true),
|
||||
array("href" => "js/ZeroClipboard.min.js", "min" => false),
|
||||
array("href" => "js/functions.js", "min" => true)
|
||||
);
|
||||
|
||||
$arrJsLang = array(_('Error en la consulta'),
|
||||
_('Ha ocurrido un error'),
|
||||
_('Sesión finalizada'),
|
||||
_('Borrar la cuenta?'),
|
||||
_('Borrar el usuario?'),
|
||||
_('Guarde la configuración para que sea efectiva'),
|
||||
_('Clave Generada'),
|
||||
_('Nivel alto'),
|
||||
_('Nivel medio'),
|
||||
_('Nivel bajo'),
|
||||
_('Nivel muy alto'),
|
||||
_('Utilizar al menos 8 caracteres'),
|
||||
_('Borrar elemento?'),
|
||||
_('Página no encontrada'),
|
||||
_('Archivo no soportado para visualizar'),
|
||||
_('Eliminar archivo?'),
|
||||
_('Su navegador no soporta subir archivos con HTML5'),
|
||||
_('Demasiados archivos'),
|
||||
_('No es posible guardar el archivo.<br>Tamaño máximo:'),
|
||||
_('Extensión no permitida'),
|
||||
_('Vaciar el registro de eventos?'));
|
||||
|
||||
//$js = "// i18n language array from PHP. Detected language: " . SP_Init::$LANG . "\n";
|
||||
echo "var LANG = ['" . implode("','", $arrJsLang) . "'];";
|
||||
echo "var APP_ROOT = '" . SP_Init::$WEBROOT . "';\n";
|
||||
|
||||
SP_Util::getMinified('js', $jsFiles);
|
||||
Reference in New Issue
Block a user