diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..2c28fec5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +amp_conf/htdocs/admin/assets/js/pbxlib.js merge=ours +module.xml merge=ours +*.po merge=merge-gettext-po +*.pot merge=merge-gettext-po +*.mo merge=ours diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d6095d44 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +templates/freepbx/compiled/* diff --git a/ENDPOINTMAN_LICENSE.txt b/ENDPOINTMAN_LICENSE.txt deleted file mode 100755 index e6614539..00000000 --- a/ENDPOINTMAN_LICENSE.txt +++ /dev/null @@ -1,41 +0,0 @@ -***** BEGIN LICENSE BLOCK ***** -Version: MPL 1.1/GPL 2.0/LGPL 2.1 - -The contents of this file are subject to the Mozilla Public License Version -1.1 (the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" basis, -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -for the specific language governing rights and limitations under the -License. - -The Original Code is Endpoint Manager for FreePBX. - -The Initial Developer of the Original Code is Ed Macri and John Mullinix. -Portions created by the Initial Developer are Copyright (C) 2010 -the Initial Developer. All Rights Reserved. - -Contributor(s): - Ed Macri - John Mullinix - Tony Shiffer - Andrew Nagy - Darren Schreiber - Philippe Lindheimer - Andrew Miffleton - -Alternatively, the contents of this file may be used under the terms of -either the GNU General Public License Version 2 or later (the "GPL"), or -the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -in which case the provisions of the GPL or the LGPL are applicable instead -of those above. If you wish to allow use of your version of this file only -under the terms of either the GPL or the LGPL, and not to allow others to -use your version of this file under the terms of the MPL, indicate your -decision by deleting the provisions above and replace them with the notice -and other provisions required by the GPL or the LGPL. If you do not delete -the provisions above, a recipient may use your version of this file under -the terms of any one of the MPL, the GPL or the LGPL. - -***** END LICENSE BLOCK ***** \ No newline at end of file diff --git a/Endpointman.class.php b/Endpointman.class.php new file mode 100644 index 00000000..19cb9ad3 --- /dev/null +++ b/Endpointman.class.php @@ -0,0 +1,2184 @@ + 0) + { + foreach ($remplace_txt as $clave => $valor) { + $texto = str_replace($clave, $valor, $texto); + } + } + return '

'.$texto.'

'; +} + +function generate_xml_from_array ($array, $node_name, &$tab = -1) +{ + $tab++; + $xml =""; + if (is_array($array) || is_object($array)) { + foreach ($array as $key=>$value) { + if (is_numeric($key)) { + $key = $node_name; + } + + $xml .= str_repeat(" ", $tab). '<' . $key . '>' . "\n"; + $xml .= generate_xml_from_array($value, $node_name, $tab); + $xml .= str_repeat(" ", $tab). '' . "\n"; + + } + } else { + $xml = str_repeat(" ", $tab) . htmlspecialchars($array, ENT_QUOTES) . "\n"; + } + $tab--; + return $xml; +} + + +class Endpointman implements \BMO { + + //public $epm_config; + + + public $db; //Database from FreePBX + public $eda; //endpoint data abstraction layer + public $tpl; //Template System Object (RAIN TPL) + //public $system; + + public $error; //error construct + public $message; //message construct + + public $UPDATE_PATH; + public $MODULES_PATH; + public $LOCAL_PATH; + public $PHONE_MODULES_PATH; + public $PROVISIONER_BASE; + + + public function __construct($freepbx = null) { + if ($freepbx == null) { + throw new \Exception("Not given a FreePBX Object"); + } + require_once('lib/json.class.php'); + require_once('lib/Config.class.php'); + require_once('lib/epm_system.class.php'); + require_once('lib/datetimezone.class.php'); + require_once('lib/epm_data_abstraction.class.php'); + //require_once("lib/RainTPL.class.php"); + + $this->freepbx = $freepbx; + $this->db = $freepbx->Database; + $this->config = $freepbx->Config; + $this->configmod = new Endpointman\Config(); + $this->system = new epm_system(); + $this->eda = new epm_data_abstraction($this->config, $this->configmod); + + + $this->configmod->set('disable_epm', FALSE); + $this->eda->global_cfg = $this->configmod->getall(); + + //Generate empty array + $this->error = array(); + $this->message = array(); + + + $this->configmod->set('tz', $this->config->get('PHPTIMEZONE')); + date_default_timezone_set($this->configmod->get('tz')); + + $this->UPDATE_PATH = $this->configmod->get('update_server'); + $this->MODULES_PATH = $this->config->get('AMPWEBROOT') . '/admin/modules/'; + +define("UPDATE_PATH", $this->UPDATE_PATH); +define("MODULES_PATH", $this->MODULES_PATH); + + + //Determine if local path is correct! + if (file_exists($this->MODULES_PATH . "endpointman/")) { + $this->LOCAL_PATH = $this->MODULES_PATH . "endpointman/"; +define("LOCAL_PATH", $this->LOCAL_PATH); + } else { + die("Can't Load Local Endpoint Manager Directory!"); + } + + //Define the location of phone modules, keeping it outside of the module directory so that when the user updates endpointmanager they don't lose all of their phones + if (file_exists($this->MODULES_PATH . "_ep_phone_modules/")) { + $this->PHONE_MODULES_PATH = $this->MODULES_PATH . "_ep_phone_modules/"; + } else { + $this->PHONE_MODULES_PATH = $this->MODULES_PATH . "_ep_phone_modules/"; + if (!file_exists($this->PHONE_MODULES_PATH)) { + mkdir($this->PHONE_MODULES_PATH, 0775); + } + if (file_exists($this->PHONE_MODULES_PATH . "setup.php")) { + unlink($this->PHONE_MODULES_PATH . "setup.php"); + } + if (!file_exists($this->MODULES_PATH . "_ep_phone_modules/")) { + die('Endpoint Manager can not create the modules folder!'); + } + } +define("PHONE_MODULES_PATH", $this->PHONE_MODULES_PATH); + + //Define error reporting + if (($this->configmod->get('debug')) AND (!isset($_REQUEST['quietmode']))) { + error_reporting(E_ALL); + ini_set('display_errors', 1); + } else { + ini_set('display_errors', 0); + } + + //Check if config location is writable and/or exists! + if ($this->configmod->isExiste('config_location')) { + $config_location = $this->configmod->get('config_location'); + if (is_dir($config_location)) { + if (!is_writeable($config_location)) { + $user = exec('whoami'); + $group = exec("groups"); + $this->error['config_location'] = _("Configuration Directory is not writable!") . "
" . + _("Please change the location:") . "" . _("Here") . "
" . + _("Or run this command on SSH:") . "
" . + "'chown -hR root: " . $group . " " . $config_location . "'
" . + "'chmod g+w " . $config_location . "'"; + $this->configmod->set('disable_epm', TRUE); + } + } else { + $this->error['config_location'] = _("Configuration Directory is not a directory or does not exist! Please change the location here:") . "" . _("Here") . ""; + $this->configmod->set('disable_epm', TRUE); + } + } + + //$this->tpl = new RainTPL(LOCAL_PATH . '_old/templates/freepbx', LOCAL_PATH . '_old/templates/freepbx/compiled', '/admin/assets/endpointman/images'); + //$this->tpl = new RainTPL('/admin/assets/endpointman/images'); + + + require_once('Endpointman_Config.class.php'); + $this->epm_config = new Endpointman_Config($freepbx, $this->configmod, $this->system); + + require_once('Endpointman_Advanced.class.php'); + $this->epm_advanced = new Endpointman_Advanced($freepbx, $this->configmod, $this->epm_config); + + require_once('Endpointman_Templates.class.php'); + $this->epm_templates = new Endpointman_Templates($freepbx, $this->configmod, $this->epm_config, $this->eda); + + require_once('Endpointman_Devices.class.php'); + $this->epm_devices = new Endpointman_Devices($freepbx, $this->configmod); + + require_once('Endpointman_Devices.class.php'); + $this->epm_oss = new Endpointman_Devices($freepbx, $this->configmod); + + //require_once('Endpointman_Devices.class.php'); + $this->epm_placeholders = new Endpointman_Devices($freepbx, $this->configmod); + + } + + public function chownFreepbx() { + $webroot = $this->config->get('AMPWEBROOT'); + $modulesdir = $webroot . '/admin/modules/'; + $files = array(); + $files[] = array('type' => 'dir', + 'path' => $modulesdir . '/_ep_phone_modules/', + 'perms' => 0755); + $files[] = array('type' => 'file', + 'path' => $modulesdir . '/_ep_phone_modules/setup.php', + 'perms' => 0755); + $files[] = array('type' => 'dir', + 'path' => '/tftpboot', + 'perms' => 0755); + return $files; + } + + public function ajaxRequest($req, &$setting) { + //AVISO!!!!!!!!!!!!!!!!!!!!!!!!!! + //PERMITE TODO!!!!!!!!!!!!!!!!!!! + $setting['authenticate'] = true; + $setting['allowremote'] = true; + return true; + + $module_sec = isset($_REQUEST['module_sec'])? trim($_REQUEST['module_sec']) : ''; + if ($module_sec == "") { return false; } + + switch($module_sec) + { + case "epm_devices": + return $this->epm_devices->ajaxRequest(trim($req), $setting); + break; + + case "epm_oss": + return $this->epm_oss->ajaxRequest(trim($req), $setting); + break; + + case "epm_placeholders": + return $this->epm_placeholders->ajaxRequest(trim($req), $setting); + break; + + case "epm_config": + return $this->epm_config->ajaxRequest(trim($req), $setting); + break; + + case "epm_advanced": + return $this->epm_advanced->ajaxRequest(trim($req), $setting); + break; + + case "epm_templates": + return $this->epm_templates->ajaxRequest(trim($req), $setting); + break; + } + return false; + } + + public function ajaxHandler() { + + $module_sec = isset($_REQUEST['module_sec'])? trim($_REQUEST['module_sec']) : ''; + $module_tab = isset($_REQUEST['module_tab'])? trim($_REQUEST['module_tab']) : ''; + $command = isset($_REQUEST['command'])? trim($_REQUEST['command']) : ''; + + if ($command == "") { + return array("status" => false, "message" => _("No command was sent!")); + } + + $arrVal['mod_sec'] = array("epm_devices", "epm_oss", "epm_placeholders", "epm_templates", "epm_config", "epm_advanced"); + if (! in_array($module_sec, $arrVal['mod_sec'])) { + return array("status" => false, "message" => _("Invalid section module!")); + } + + switch ($module_sec) + { + case "epm_devices": + return $this->epm_devices->ajaxHandler($module_tab, $command); + break; + + case "epm_oss": + return $this->epm_oss->ajaxHandler($module_tab, $command); + break; + case "epm_placeholders": + return $this->epm_placeholders->ajaxHandler($module_tab, $command); + break; + + case "epm_templates": + return $this->epm_templates->ajaxHandler($module_tab, $command); + break; + + case "epm_config": + return $this->epm_config->ajaxHandler($module_tab, $command); + break; + + case "epm_advanced": + return $this->epm_advanced->ajaxHandler($module_tab, $command); + break; + } + return false; + } + + public static function myDialplanHooks() { + return true; + } + + public function doConfigPageInit($page) { + //TODO: Pendiente revisar y eliminar moule_tab. + $module_tab = isset($_REQUEST['module_tab'])? trim($_REQUEST['module_tab']) : ''; + if ($module_tab == "") { + $module_tab = isset($_REQUEST['subpage'])? trim($_REQUEST['subpage']) : ''; + } + $command = isset($_REQUEST['command'])? trim($_REQUEST['command']) : ''; + + + $arrVal['mod_sec'] = array("epm_devices","epm_oss", "epm_placeholders", "epm_templates", "epm_config", "epm_advanced"); + if (! in_array($page, $arrVal['mod_sec'])) { + die(_("Invalid section module!")); + } + + switch ($page) + { + case "epm_devices": + $this->epm_devices->doConfigPageInit($module_tab, $command); + break; + case "epm_oss": + $this->epm_oss->doConfigPageInit($module_tab, $command); + break; + case "epm_placeholders": + $this->epm_placeholders->doConfigPageInit($module_tab, $command); + break; + case "epm_templates": + $this->epm_templates->doConfigPageInit($module_tab, $command); + break; + + case "epm_config": + $this->epm_config->doConfigPageInit($module_tab, $command); + break; + + case "epm_advanced": + $this->epm_advanced->doConfigPageInit($module_tab, $command); + break; + } + } + + public function doGeneralPost() { + if (!isset($_REQUEST['Submit'])) { return; } + if (!isset($_REQUEST['display'])) { return; } + + needreload(); + } + + public function myShowPage() { + if (! isset($_REQUEST['display'])) + return $this->pagedata; + + switch ($_REQUEST['display']) + { + case "epm_devices": + $this->epm_devices->myShowPage($this->pagedata); + break; + case "epm_oss": + return $this->epm_oss->myShowPage($this->pagedata); + break; + case "epm_placeholders": + return $this->epm_placeholders->myShowPage($this->pagedata); + break; + case "epm_templates": + $this->epm_templates->myShowPage($this->pagedata); + return $this->pagedata; + break; + + case "epm_config": + $this->epm_config->myShowPage($this->pagedata); + break; + + case "epm_advanced": + $this->epm_advanced->myShowPage($this->pagedata); + break; + } + + if(! empty($this->pagedata)) { + foreach($this->pagedata as &$page) { + ob_start(); + include($page['page']); + $page['content'] = ob_get_contents(); + ob_end_clean(); + } + return $this->pagedata; + } + } + + public function getActiveModules() { + + } + + //http://wiki.freepbx.org/display/FOP/Adding+Floating+Right+Nav+to+Your+Module + public function getRightNav($request) { + if (! isset($_REQUEST['display'])) + return ''; + else { + //return load_view(dirname(__FILE__).'/views/rnav.php',array()); + return load_view(dirname(__FILE__) . '/views/rnav.php', $var); + } + switch($_REQUEST['display']) + { + case "epm_devices": + return load_view(dirname(__FILE__) . '/views/rnav.php', $var); + break; + case "epm_oss": + return load_view(dirname(__FILE__) . '/views/rnav.php', $var); + break; + case "epm_placeholders": + return load_view(dirname(__FILE__) . '/views/rnav.php', $var); + break; + + case "epm_config": + return load_view(dirname(__FILE__) . '/views/rnav.php', $var); + break; + + case "epm_advanced": + return load_view(dirname(__FILE__) . '/views/rnav.php', $var); + break; + + case "epm_templates": + return load_view(dirname(__FILE__) . '/views/rnav.php', $var); + break; + + default: + return ''; + + } + } + + //http://wiki.freepbx.org/pages/viewpage.action?pageId=29753755 + public function getActionBar($request) { + if (! isset($_REQUEST['display'])) + return ''; + + switch($_REQUEST['display']) + { + case "epm_devices": + return $this->epm_devices->getActionBar($request); + break; + + case "epm_oss": + return $this->epm_oss->getActionBar($request); + break; + case "epm_placeholders": + return $this->epm_placeholders->getActionBar($request); + break; + case "epm_config": + return $this->epm_config->getActionBar($request); + break; + + case "epm_advanced": + return $this->epm_advanced->getActionBar($request); + break; + + case "epm_templates": + return $this->epm_templates->getActionBar($request); + break; + + default: + return ''; + + } + } + + public function install() { + + } + + public function uninstall() { + if(file_exists($this->PHONE_MODULES_PATH)) { + out(_("Removing Phone Modules Directory")); + $this->system->rmrf($this->PHONE_MODULES_PATH); + @exec("rm -R ". $this->PHONE_MODULES_PATH); + } + + $provisioning_path = $this->config->get('AMPWEBROOT')."/provisioning"; + if(file_exists($provisioning_path) && is_link($provisioning_path)) { + out(_('Removing symlink to web provisioner')); + unlink($provisioning_path); + } + + if(!is_link($this->config->get('AMPWEBROOT').'/admin/assets/endpointman')) { + $this->system->rmrf($this->config->get('AMPWEBROOT').'/admin/assets/endpointman'); + } + return true; + } + + public function backup() { + } + + public function restore($backup) { + } + + + private function epm_config_manual_install($install_type = "", $package ="") + { + if ($install_type == "") { + throw new \Exception("Not send install_type!"); + } + + switch($install_type) { + case "export_brand": + + break; + + case "upload_master_xml": + if (file_exists($this->PHONE_MODULES_PATH."temp/master.xml")) { + $handle = fopen($this->PHONE_MODULES_PATH."temp/master.xml", "rb"); + $contents = stream_get_contents($handle); + fclose($handle); + @$a = simplexml_load_string($contents); + if($a===FALSE) { + echo "Not a valid xml file"; + break; + } else { + rename($this->PHONE_MODULES_PATH."temp/master.xml", $this->PHONE_MODULES_PATH."master.xml"); + echo "Move Successful
"; + $this->update_check(); + echo "Updating Brands
"; + } + } else { + } + break; + + case "upload_provisioner": + + break; + + case "upload_brand": + + break; + } + } + + + + + + + /***************************************** + ****** CODIGO ANTIGUO -- REVISADO ******** + *****************************************/ + + + + + + //TODO: DUPLICADO AQUI Y EN epm_advandec + /** + * This function takes a string and tries to determine if it's a valid mac addess, return FALSE if invalid + * @param string $mac The full mac address + * @return mixed The cleaned up MAC is it was a MAC or False if not a mac + + function mac_check_clean($mac) { + if ((strlen($mac) == "17") OR (strlen($mac) == "12")) { + //It might be better to use switch here instead of these IF statements... + //Is the mac separated by colons(:) or dashes(-)? + if (preg_match("/[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f]/i", $mac)) { + return(strtoupper(str_replace(":", "", str_replace("-", "", $mac)))); + //Is the string exactly 12 characters? + } elseif (strlen($mac) == "12") { + //Now is the string a valid HEX mac address? + if (preg_match("/[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]/i", $mac)) { + return(strtoupper($mac)); + } else { + return(FALSE); + } + //Is the mac separated by whitespaces? + } elseif (preg_match("/[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f]/i", $mac)) { + return(strtoupper(str_replace(" ", "", $mac))); + } else { + return(FALSE); + } + } else { + return(FALSE); + } + } + + + */ + + + + + + + + + + + + + + /** + * Returns list of Brands that are installed and not hidden and that have at least one model enabled under them + * @param integer $selected ID Number of the brand that is supposed to be selected in a drop-down list box + * @return array Number array used to generate a select box + */ + function brands_available($selected = NULL, $show_blank=TRUE) { + $data = $this->eda->all_active_brands(); + if ($show_blank) { + $temp[0]['value'] = ""; + $temp[0]['text'] = ""; + $i = 1; + } else { + $i = 0; + } + foreach ($data as $row) { + $temp[$i]['value'] = $row['id']; + $temp[$i]['text'] = $row['name']; + if ($row['id'] == $selected) { + $temp[$i]['selected'] = TRUE; + } else { + $temp[$i]['selected'] = NULL; + } + $i++; + } + return($temp); + } + + function listTZ($selected) { + require_once('lib/datetimezone.class.php'); + $data = \DateTimeZone::listIdentifiers(); + $i = 0; + foreach ($data as $key => $row) { + $temp[$i]['value'] = $row; + $temp[$i]['text'] = $row; + if (strtoupper ($temp[$i]['value']) == strtoupper($selected)) { + $temp[$i]['selected'] = 1; + } else { + $temp[$i]['selected'] = 0; + } + $i++; + } + + return($temp); + } + + function has_git() { + exec('which git', $output); + + $git = file_exists($line = trim(current($output))) ? $line : 'git'; + + unset($output); + + exec($git . ' --version', $output); + + preg_match('#^(git version)#', current($output), $matches); + + return!empty($matches[0]) ? $git : false; + echo!empty($matches[0]) ? 'installed' : 'nope'; + } + + function tftp_check() { + //create a simple block here incase people have strange issues going on as we will kill http + //by running this if the server isn't really running! + $sql = 'SELECT value FROM endpointman_global_vars WHERE var_name = \'tftp_check\''; + if (sql($sql, 'getOne') != 1) { + $sql = 'UPDATE endpointman_global_vars SET value = \'1\' WHERE var_name = \'tftp_check\''; + sql($sql); + $subject = shell_exec("netstat -luan --numeric-ports"); + if (preg_match('/:69\s/i', $subject)) { + $rand = md5(rand(10, 2000)); + if (file_put_contents($this->configmod->get('config_location') . 'TEST', $rand)) { + if ($this->system->tftp_fetch('127.0.0.1', 'TEST') != $rand) { + $this->error['tftp_check'] = 'Local TFTP Server is not correctly configured'; +echo 'Local TFTP Server is not correctly configured'; + } + unlink($this->configmod->get('config_location') . 'TEST'); + } else { + $this->error['tftp_check'] = 'Unable to write to ' . $this->configmod->get('config_location'); +echo 'Unable to write to ' . $this->configmod->get('config_location'); + } + } else { + $dis = FALSE; + if (file_exists('/etc/xinetd.d/tftp')) { + $contents = file_get_contents('/etc/xinetd.d/tftp'); + if (preg_match('/disable.*=.*yes/i', $contents)) { + $this->error['tftp_check'] = 'Disabled is set to "yes" in /etc/xinetd.d/tftp. Please fix
Then restart your TFTP service'; +echo 'Disabled is set to "yes" in /etc/xinetd.d/tftp. Please fix
Then restart your TFTP service'; + $dis = TRUE; + } + } + if (!$dis) { + $this->error['tftp_check'] = 'TFTP Server is not running.
See here for instructions on how to install one: http://wiki.provisioner.net/index.php/Tftp'; +echo 'TFTP Server is not running.
See here for instructions on how to install one: http://wiki.provisioner.net/index.php/Tftp'; + } + } + $sql = 'UPDATE endpointman_global_vars SET value = \'0\' WHERE var_name = \'tftp_check\''; + sql($sql); + } else { + $this->error['tftp_check'] = 'TFTP Server check failed on last past. Skipping'; +echo 'TFTP Server check failed on last past. Skipping'; + } + } + + + /** + * Used to send sample configurations to provisioner.net + * NOTE: The user has to explicitly click a link that states they are sending the configuration to the project + * We don't take configs on our own accord!! + * @param $brand Brand Directory + * @param $product Product Directory + * @param $orig_name The file's original name we are sending + * @param $data The config file's data +*/ + function submit_config($brand, $product, $orig_name, $data) { + $posturl = 'http://www.provisioner.net/submit_config.php'; + + $fp = fopen($this->LOCAL_PATH . 'data.txt', 'w'); + fwrite($fp, $data); + fclose($fp); + $file_name_with_full_path = $this->LOCAL_PATH . "data.txt"; + + $postvars = array('brand' => $brand, 'product' => $product, 'origname' => htmlentities(addslashes($orig_name)), 'file_contents' => '@' . $file_name_with_full_path); + + $ch = curl_init($posturl); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); // DO NOT RETURN HTTP HEADERS + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // RETURN THE CONTENTS OF THE CALL, probably not needed + $Rec_Data = curl_exec($ch); + + ob_start(); + header("Content-Type: text/html"); + $Final_Out = ob_get_clean(); + curl_close($ch); + unlink($file_name_with_full_path); + + return($Final_Out); + } + + + + /** + + + function add_device($mac, $model, $ext, $template=NULL, $line=NULL, $displayname=NULL) { + $mac = $this->mac_check_clean($mac); + if ($mac) { + if (empty($model)) { +//$this->error['add_device'] = + out(_("You Must Select A Model From the Drop Down") . "!"); + return(FALSE); + } elseif (empty($ext)) { +//$this->error['add_device'] = + out(_("You Must Select an Extension/Device From the Drop Down") . "!"); + return(FALSE); + } else { + if ($this->epm_config->sync_model($model)) { + $sql = "SELECT id,template_id FROM endpointman_mac_list WHERE mac = '" . $mac . "'"; + $dup = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + if ($dup) { + if (!isset($template)) { + $template = $dup['template_id']; + } + + $sql = "UPDATE endpointman_mac_list SET model = " . $model . ", template_id = " . $template . " WHERE id = " . $dup['id']; + sql($sql); + $return = $this->add_line($dup['id'], $line, $ext); + if ($return) { + return($return); + } else { + return(FALSE); + } + } else { + if (!isset($template)) { + $template = 0; + } + + $sql = "SELECT mac_id FROM endpointman_line_list WHERE ext = " . $ext; + $used = sql($sql, 'getOne'); + + if (($used) AND (! $this->configmod->get('show_all_registrations'))) { +//$this->error['add_device'] = + out(_("You can't assign the same user to multiple devices") . "!"); + return(FALSE); + } + + if (!isset($displayname)) { + $sql = 'SELECT description FROM devices WHERE id = ' . $ext; + $name = sql($sql, 'getOne'); + $name = "123"; + $displayname = "123"; + } else { + $name = $displayname; + } + + $sql = 'SELECT endpointman_product_list. * , endpointman_model_list.template_data, endpointman_brand_list.directory FROM endpointman_model_list, endpointman_brand_list, endpointman_product_list WHERE endpointman_model_list.id = \'' . $model . '\' AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id'; + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $sql = "INSERT INTO `endpointman_mac_list` (`mac`, `model`, `template_id`) VALUES ('" . $mac . "', '" . $model . "', '" . $template . "')"; + sql($sql); + + $sql = 'SELECT last_insert_id()'; + $ext_id = sql($sql, 'getOne'); + + if (empty($line)) { + $line = 1; + } + + $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('" . $ext_id . "', '" . $ext . "', '" . $line . "', '" . addslashes($name) . "')"; + sql($sql); + +//$this->message['add_device'][] = + out(_("Added ") . $name . _(" to line ") . $line); + return($ext_id); + } + } else { +//$this->error['Sync_Model'] = + out(_("Invalid Model Selected, Can't Sync System") . "!"); + return(FALSE); + } + } + } else { +//$this->error['add_device'] = + out(_("Invalid MAC Address") . "!"); + return(FALSE); + } + } + + + function add_line($mac_id, $line=NULL, $ext=NULL, $displayname=NULL) { + if ((!isset($line)) AND (!isset($ext))) { + if ($this->linesAvailable(NULL, $mac_id)) { + if ($this->eda->all_unused_registrations()) { + $sql = 'SELECT * FROM endpointman_line_list WHERE mac_id = ' . $mac_id; + $lines_list = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + + foreach ($lines_list as $row) { + $sql = "SELECT description FROM devices WHERE id = " . $row['ext']; + $name = sql($sql, 'getOne'); + + $sql = "UPDATE endpointman_line_list SET line = '" . $row['line'] . "', ext = '" . $row['ext'] . "', description = '" . $this->eda->escapeSimple($name) . "' WHERE luid = " . $row['luid']; + sql($sql); + } + + $reg = array_values($this->display_registration_list()); + $lines = array_values($this->linesAvailable(NULL, $mac_id)); + + $sql = "SELECT description FROM devices WHERE id = " . $reg[0]['value']; + $name = sql($sql, 'getOne'); + + $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('" . $mac_id . "', '" . $reg[0]['value'] . "', '" . $lines[0]['value'] . "', '" . addslashes($name) . "')"; + sql($sql); + +//$this->message['add_line'] = + out(_("Added '") . $name . _("' to line '") . $lines[0]['value'] . _("' on device '") . $reg[0]['value'] . _("'
Configuration Files will not be Generated until you click Save!")); + return($mac_id); + } else { +//$this->error['add_line'] = + out(_("No Devices/Extensions Left to Add") . "!"); + return(FALSE); + } + } else { +//$this->error['add_line'] = + out(_("No Lines Left to Add") . "!"); + return(FALSE); + } + } elseif ((!isset($line)) AND (isset($ext))) { + if ($this->linesAvailable(NULL, $mac_id)) { + if ($this->eda->all_unused_registrations()) { + $lines = array_values($this->linesAvailable(NULL, $mac_id)); + + $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('" . $mac_id . "', '" . $ext . "', '" . $lines[0]['value'] . "', '" . addslashes($displayname) . "')"; + sql($sql); + +//$this->message['add_line'] = + out(_("Added '") . $name . _("' to line '") . $lines[0]['value'] . _("' on device '") . $reg[0]['value'] . _("'
Configuration Files will not be Generated until you click Save!")); + return($mac_id); + } else { +//$this->error['add_line'] = + out(_("No Devices/Extensions Left to Add") . "!"); + return(FALSE); + } + } else { +//$this->error['add_line'] = + out(_("No Lines Left to Add") . "!"); + return(FALSE); + } + } elseif ((isset($line)) AND (isset($ext))) { + $sql = "SELECT luid FROM endpointman_line_list WHERE line = '" . $line . "' AND mac_id = " . $mac_id; + $luid = sql($sql, 'getOne'); + if ($luid) { +//$this->error['add_line'] = + out(_("This line has already been assigned!")); + return(FALSE); + } else { + if (!isset($displayname)) { + $sql = 'SELECT description FROM devices WHERE id = ' . $ext; + $name = sql($sql, 'getOne'); + } else { + $name = $displayname; + } + + $sql = "INSERT INTO `endpointman_line_list` (`mac_id`, `ext`, `line`, `description`) VALUES ('" . $mac_id . "', '" . $ext . "', '" . $line . "', '" . addslashes($name) . "')"; + sql($sql); +//$this->message['add_line'] = + out(_("Added ") . $name . _(" to line ") . $line . "
"); + return($mac_id); + } + } + } + + + function linesAvailable($lineid=NULL, $macid=NULL) { + if (isset($lineid)) { + $sql = "SELECT max_lines FROM endpointman_model_list WHERE id = (SELECT endpointman_mac_list.model FROM endpointman_mac_list, endpointman_line_list WHERE endpointman_line_list.luid = " . $lineid . " AND endpointman_line_list.mac_id = endpointman_mac_list.id)"; + + $sql_l = "SELECT line, mac_id FROM `endpointman_line_list` WHERE luid = " . $lineid; + $line = sql($sql_l, 'getRow', DB_FETCHMODE_ASSOC); + + $sql_lu = "SELECT line FROM endpointman_line_list WHERE mac_id = " . $line['mac_id']; + } elseif (isset($macid)) { + $sql = "SELECT max_lines FROM endpointman_model_list WHERE id = (SELECT model FROM endpointman_mac_list WHERE id =" . $macid . ")"; + $sql_lu = "SELECT line FROM endpointman_line_list WHERE mac_id = " . $macid; + + $line['line'] = 0; + } + + $max_lines = sql($sql, 'getOne'); + $lines_used = sql($sql_lu, 'getAll'); + + for ($i = 1; $i <= $max_lines; $i++) { + if ($i == $line['line']) { + $temp[$i]['value'] = $i; + $temp[$i]['text'] = $i; + $temp[$i]['selected'] = "selected"; + } else { + if (!$this->in_array_recursive($i, $lines_used)) { + $temp[$i]['value'] = $i; + $temp[$i]['text'] = $i; + } + } + } + if (isset($temp)) { + return($temp); + } else { + return FALSE; + } + } + + + + + * Display all unused registrations from whatever manager we are using! + * @return + */ + /** + function display_registration_list($line_id=NULL) { + + if (isset($line_id)) { + $result = $this->eda->all_unused_registrations(); + $line_data = $this->eda->get_line_information($line_id); + } else { + $result = $this->eda->all_unused_registrations(); + $line_data = NULL; + } + + $i = 1; + $temp = array(); + foreach ($result as $row) { + $temp[$i]['value'] = $row['id']; + $temp[$i]['text'] = $row['id'] . " --- " . $row['description']; + $i++; + } + + if (isset($line_data)) { + $temp[$i]['value'] = $line_data['ext']; + $temp[$i]['text'] = $line_data['ext'] . " --- " . $line_data['description']; + $temp[$i]['selected'] = "selected"; + } + + return($temp); + } + + + + * Send this function an ID from the mac devices list table and you'll get all the information we have on that particular phone + * @param integer $mac_id ID number reference from the MySQL database referencing the table endpointman_mac_list + * @return array + * @example + * Final Output will look something similar to this + * Array + * ( + * [config_files_override] => + * [global_user_cfg_data] => N; + * [model_id] => 213 + * [brand_id] => 2 + * [name] => Grandstream + * [directory] => grandstream + * [model] => GXP2000 + * [mac] => 000B820D0050 + * [template_id] => 0 + * [global_custom_cfg_data] => Serialized Data (Changed Template Values) + * [long_name] => GXP Enterprise IP series [280,1200,2000,2010,2020] + * [product_id] => 21 + * [cfg_dir] => gxp + * [cfg_ver] => 1.5 + * [template_data] => Serialized Data (The default Template Values) + * [enabled] => 1 + * [line] => Array + * ( + * [1] => Array + * ( + * [luid] => 2 + * [mac_id] => 2 + * [line] => 1 + * [ext] => 1000 + * [description] => Description + * [custom_cfg_data] => + * [user_cfg_data] => + * [secret] => secret + * [id] => 1000 + * [tech] => sip + * [dial] => SIP/1000 + * [devicetype] => fixed + * [user] => 1000 + * [emergency_cid] => + * ) + * ) + * ) + + function get_phone_info($mac_id=NULL) { + //You could screw up a phone if the mac_id is blank + if (!isset($mac_id)) { +//$this->error['get_phone_info'] = + out(_("Mac ID is not set")); + return(FALSE); + } + $sql = "SELECT id FROM endpointman_mac_list WHERE model > 0 AND id =" . $mac_id; + + //$res = sql($sql); + $res = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + if (count($res)) { + //Returns Brand Name, Brand Directory, Model Name, Mac Address, Extension (FreePBX), Custom Configuration Template, Custom Configuration Data, Product Name, Product ID, Product Configuration Directory, Product Configuration Version, Product XML name, + $sql = "SELECT endpointman_mac_list.specific_settings, endpointman_mac_list.config_files_override, endpointman_mac_list.global_user_cfg_data, endpointman_model_list.id as model_id, endpointman_brand_list.id as brand_id, endpointman_brand_list.name, endpointman_brand_list.directory, endpointman_model_list.model, endpointman_mac_list.mac, endpointman_mac_list.template_id, endpointman_mac_list.global_custom_cfg_data, endpointman_product_list.long_name, endpointman_product_list.id as product_id, endpointman_product_list.cfg_dir, endpointman_product_list.cfg_ver, endpointman_model_list.template_data, endpointman_model_list.enabled, endpointman_mac_list.global_settings_override FROM endpointman_line_list, endpointman_mac_list, endpointman_model_list, endpointman_brand_list, endpointman_product_list WHERE endpointman_mac_list.model = endpointman_model_list.id AND endpointman_brand_list.id = endpointman_model_list.brand AND endpointman_product_list.id = endpointman_model_list.product_id AND endpointman_mac_list.id = endpointman_line_list.mac_id AND endpointman_mac_list.id = " . $mac_id; + $phone_info = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + if (!$phone_info) { +//$this->error['get_phone_info'] = + out(_("Error with SQL Statement")); + } + + //If there is a template associated with this phone then pull that information and put it into the array + if ($phone_info['template_id'] > 0) { + $sql = "SELECT name, global_custom_cfg_data, config_files_override, global_settings_override FROM endpointman_template_list WHERE id = " . $phone_info['template_id']; + $phone_info['template_data_info'] = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + } + + $sql = "SELECT endpointman_line_list.*, sip.data as secret, devices.*, endpointman_line_list.description AS epm_description FROM endpointman_line_list, sip, devices WHERE endpointman_line_list.ext = devices.id AND endpointman_line_list.ext = sip.id AND sip.keyword = 'secret' AND mac_id = " . $mac_id . " ORDER BY endpointman_line_list.line ASC"; + $lines_info = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach ($lines_info as $line) { + $phone_info['line'][$line['line']] = $line; + $phone_info['line'][$line['line']]['description'] = $line['epm_description']; + $phone_info['line'][$line['line']]['user_extension'] = $line['user']; + } + } else { + $sql = "SELECT id, mac FROM endpointman_mac_list WHERE id =" . $mac_id; + //Phone is unknown, we need to display this to the end user so that they can make corrections + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $brand = $this->get_brand_from_mac($row['mac']); + if ($brand) { + $phone_info['brand_id'] = $brand['id']; + $phone_info['name'] = $brand['name']; + } else { + $phone_info['brand_id'] = 0; + $phone_info['name'] = 'Unknown'; + } + + $phone_info['id'] = $mac_id; + $phone_info['model_id'] = 0; + $phone_info['product_id'] = 0; + $phone_info['custom_cfg_template'] = 0; + $phone_info['mac'] = $row['mac']; + $sql = "SELECT endpointman_line_list.*, sip.data as secret, devices.* FROM endpointman_line_list, sip, devices WHERE endpointman_line_list.ext = devices.id AND endpointman_line_list.ext = sip.id AND sip.keyword = 'secret' AND mac_id = " . $mac_id; + $lines_info = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach ($lines_info as $line) { + $phone_info['line'][$line['line']] = $line; + } + } + $phone_info = "test"; + return $phone_info; + } +*/ + /** + * Get the brand from any mac sent to this function + * @param string $mac + * @return array + + function get_brand_from_mac($mac) { + //Check for valid mac address first + if (!$this->mac_check_clean($mac)) { + return(FALSE); + } + + //Get the OUI only + $oui = substr($this->mac_check_clean($mac), 0, 6); + //Find the matching brand model to the oui + $oui_sql = "SELECT endpointman_brand_list.name, endpointman_brand_list.id FROM endpointman_oui_list, endpointman_brand_list WHERE oui LIKE '%" . $oui . "%' AND endpointman_brand_list.id = endpointman_oui_list.brand AND endpointman_brand_list.installed = 1 LIMIT 1"; + $brand = sql($oui_sql, 'getRow', DB_FETCHMODE_ASSOC); + + $res = sql($oui_sql); + $brand_count = count($res); + + if (!$brand_count) { + //oui doesn't have a matching mysql reference, probably a PC/router/wap/printer of some sort. + $phone_info['id'] = 0; + $phone_info['name'] = _("Unknown"); + } else { + $phone_info['id'] = $brand['id']; + $phone_info['name'] = $brand['name']; + } + + return($phone_info); + } + +*/ + + /** + * Prepare and then send the data that Provisioner expects, then take what provisioner gives us and do what it says + * @param array $phone_info Everything from get_phone_info + * @param bool $reboot Reboot the Phone after write + * @param bool $write Write out Directory structure. + + function prepare_configs($phone_info, $reboot=TRUE, $write=TRUE) + { + $this->PROVISIONER_BASE = $this->PHONE_MODULES_PATH; + define('PROVISIONER_BASE', $this->PROVISIONER_BASE); + if (file_exists($this->PHONE_MODULES_PATH . 'autoload.php')) { + if (!class_exists('ProvisionerConfig')) { + require($this->PHONE_MODULES_PATH . 'autoload.php'); + } + + //Load Provisioner + $class = "endpoint_" . $phone_info['directory'] . "_" . $phone_info['cfg_dir'] . '_phone'; + $base_class = "endpoint_" . $phone_info['directory'] . '_base'; + $master_class = "endpoint_base"; + if (!class_exists($master_class)) { + ProvisionerConfig::endpointsAutoload($master_class); + } + if (!class_exists($base_class)) { + ProvisionerConfig::endpointsAutoload($base_class); + } + if (!class_exists($class)) { + ProvisionerConfig::endpointsAutoload($class); + } + + if (class_exists($class)) { + $provisioner_lib = new $class(); + + //Determine if global settings have been overridden + if ($phone_info['template_id'] > 0) { + if (isset($phone_info['template_data_info']['global_settings_override'])) { + $settings = unserialize($phone_info['template_data_info']['global_settings_override']); + } else { + $settings['srvip'] = $this->configmod->get('srvip'); + $settings['ntp'] = $this->configmod->get('ntp'); + $settings['config_location'] = $this->configmod->get('config_location'); + $settings['tz'] = $this->configmod->get('tz'); + } + } else { + if (isset($phone_info['global_settings_override'])) { + $settings = unserialize($phone_info['global_settings_override']); + } else { + $settings['srvip'] = $this->configmod->get('srvip'); + $settings['ntp'] = $this->configmod->get('ntp'); + $settings['config_location'] = $this->configmod->get('config_location'); + $settings['tz'] = $this->configmod->get('tz'); + } + } + + + + //Tell the system who we are and were to find the data. + $provisioner_lib->root_dir = $this->PHONE_MODULES_PATH; + $provisioner_lib->engine = 'asterisk'; + $provisioner_lib->engine_location = $this->configmod->get('asterisk_location','asterisk'); + $provisioner_lib->system = 'unix'; + + //have to because of versions less than php5.3 + $provisioner_lib->brand_name = $phone_info['directory']; + $provisioner_lib->family_line = $phone_info['cfg_dir']; + + + + //Phone Model (Please reference family_data.xml in the family directory for a list of recognized models) + //This has to match word for word. I really need to fix this.... + $provisioner_lib->model = $phone_info['model']; + + //Timezone + try { + $provisioner_lib->DateTimeZone = new \DateTimeZone($settings['tz']); + } catch (Exception $e) { +$this->error['parse_configs'] = 'Error Returned From Timezone Library: ' . $e->getMessage(); + return(FALSE); + } + + $temp = ""; + $template_data = unserialize($phone_info['template_data']); + $global_user_cfg_data = unserialize($phone_info['global_user_cfg_data']); + if ($phone_info['template_id'] > 0) { + $global_custom_cfg_data = unserialize($phone_info['template_data_info']['global_custom_cfg_data']); + //Provide alternate Configuration file instead of the one from the hard drive + if (!empty($phone_info['template_data_info']['config_files_override'])) { + $temp = unserialize($phone_info['template_data_info']['config_files_override']); + foreach ($temp as $list) { + $sql = "SELECT original_name,data FROM endpointman_custom_configs WHERE id = " . $list; + //$res = sql($sql); + $res = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + if (count($res)) { + $data = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + $provisioner_lib->config_files_override[$data['original_name']] = $data['data']; + } + } + } + } else { + $global_custom_cfg_data = unserialize($phone_info['global_custom_cfg_data']); + //Provide alternate Configuration file instead of the one from the hard drive + if (!empty($phone_info['config_files_override'])) { + $temp = unserialize($phone_info['config_files_override']); + foreach ($temp as $list) { + $sql = "SELECT original_name,data FROM endpointman_custom_configs WHERE id = " . $list; + //$res = sql($sql); + $res = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + if (count($res)) { + $data = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + $provisioner_lib->config_files_override[$data['original_name']] = $data['data']; + } + } + } + } + + if (!empty($global_custom_cfg_data)) { + if (array_key_exists('data', $global_custom_cfg_data)) { + $global_custom_cfg_ari = $global_custom_cfg_data['ari']; + $global_custom_cfg_data = $global_custom_cfg_data['data']; + } else { + $global_custom_cfg_data = array(); + $global_custom_cfg_ari = array(); + } + } + + $new_template_data = array(); + $line_ops = array(); + if (is_array($global_custom_cfg_data)) { + foreach ($global_custom_cfg_data as $key => $data) { + //TODO: clean up with reg-exp + $full_key = $key; + $key = explode('|', $key); + $count = count($key); + switch ($count) { + case 1: + if (($this->configmod->get('enable_ari') == 1) AND (isset($global_custom_cfg_ari[$full_key])) AND (isset($global_user_cfg_data[$full_key]))) { + $new_template_data[$full_key] = $global_user_cfg_data[$full_key]; + } else { + $new_template_data[$full_key] = $global_custom_cfg_data[$full_key]; + } + break; + case 2: + $breaks = explode('_', $key[1]); + if (($this->configmod->get('enable_ari') == 1) AND (isset($global_custom_cfg_ari[$full_key])) AND (isset($global_user_cfg_data[$full_key]))) { + $new_template_data['loops'][$breaks[0]][$breaks[2]][$breaks[1]] = $global_user_cfg_data[$full_key]; + } else { + $new_template_data['loops'][$breaks[0]][$breaks[2]][$breaks[1]] = $global_custom_cfg_data[$full_key]; + } + break; + case 3: + if (($this->configmod->get('enable_ari') == 1) AND (isset($global_custom_cfg_ari[$full_key])) AND (isset($global_user_cfg_data[$full_key]))) { + $line_ops[$key[1]][$key[2]] = $global_user_cfg_data[$full_key]; + } else { + $line_ops[$key[1]][$key[2]] = $global_custom_cfg_data[$full_key]; + } + break; + } + } + } + + if (!$write) { + $new_template_data['provision']['type'] = 'dynamic'; + $new_template_data['provision']['protocol'] = 'http'; + $new_template_data['provision']['path'] = rtrim($settings['srvip'] . dirname($_SERVER['REQUEST_URI']) . '/', '/'); + $new_template_data['provision']['encryption'] = FALSE; + } else { + $new_template_data['provision']['type'] = 'file'; + $new_template_data['provision']['protocol'] = 'tftp'; + $new_template_data['provision']['path'] = $settings['srvip']; + $new_template_data['provision']['encryption'] = FALSE; + } + + $new_template_data['ntp'] = $settings['ntp']; + + //Overwrite all specific settings variables now + if (!empty($phone_info['specific_settings'])) { + $specific_settings = unserialize($phone_info['specific_settings']); + $specific_settings = is_array($specific_settings) ? $specific_settings : array(); + } else { + $specific_settings = array(); + } + + //Set Variables according to the template_data files included. We can include different template.xml files within family_data.xml also one can create + //template_data_custom.xml which will get included or template_data__custom.xml which will also get included + //line 'global' will set variables that aren't line dependant + + + $provisioner_lib->settings = $new_template_data; + + //Loop through Lines! + $li = 0; + foreach ($phone_info['line'] as $line) { + $line_options = is_array($line_ops[$line['line']]) ? $line_ops[$line['line']] : array(); + $line_statics = array('line' => $line['line'], 'username' => $line['ext'], 'authname' => $line['ext'], 'secret' => $line['secret'], 'displayname' => $line['description'], 'server_host' => $this->configmod->get('srvip'), 'server_port' => '5060', 'user_extension' => $line['user_extension']); + $provisioner_lib->settings['line'][$li] = array_merge($line_options, $line_statics); + $li++; + } + + if (array_key_exists('data', $specific_settings)) { + foreach ($specific_settings['data'] as $key => $data) { + $default_exp = preg_split("/\|/i", $key); + if (isset($default_exp[2])) { + //lineloop + $var = $default_exp[2]; + $line = $default_exp[1]; + $loc = $this->system->arraysearchrecursive($line, $provisioner_lib->settings['line'], 'line'); + if ($loc !== FALSE) { + $k = $loc[0]; + $provisioner_lib->settings['line'][$k][$var] = $data; + } else { + //Adding a new line-ish type options + if (isset($specific_settings['data']['line|' . $line . '|line_enabled'])) { + $lastkey = array_pop(array_keys($provisioner_lib->settings['line'])); + $lastkey++; + $provisioner_lib->settings['line'][$lastkey]['line'] = $line; + $provisioner_lib->settings['line'][$lastkey][$var] = $data; + } + } + } else { + switch ($key) { + case "connection_type": + $provisioner_lib->settings['network'][$key] = $data; + break; + case "ip4_address": + $provisioner_lib->settings['network']['ipv4'] = $data; + break; + case "ip6_address": + $provisioner_lib->settings['network']['ipv6'] = $data; + break; + case "subnet_mask": + $provisioner_lib->settings['network']['subnet'] = $data; + break; + case "gateway_address": + $provisioner_lib->settings['network']['gateway'] = $data; + break; + case "primary_dns": + $provisioner_lib->settings['network'][$key] = $data; + break; + default: + $provisioner_lib->settings[$key] = $data; + break; + } + } + } + } + + $provisioner_lib->settings['mac'] = $phone_info['mac']; + $provisioner_lib->mac = $phone_info['mac']; + + //Setting a line variable here...these aren't defined in the template_data.xml file yet. however they will still be parsed + //and if they have defaults assigned in a future template_data.xml or in the config file using pipes (|) those will be used, pipes take precedence + $provisioner_lib->processor_info = "EndPoint Manager Version " . $this->configmod->get('version'); + + // Because every brand is an extension (eventually) of endpoint, you know this function will exist regardless of who it is + //Start timer + $time_start = microtime(true); + + $provisioner_lib->debug = TRUE; + + try { + $returned_data = $provisioner_lib->generate_all_files(); + } catch (Exception $e) { +$this->error['prepare_configs'] = 'Error Returned From Provisioner Library: ' . $e->getMessage(); + return(FALSE); + } + //print_r($provisioner_lib->debug_return); + //End timer + $time_end = microtime(true); + $time = $time_end - $time_start; + if ($time > 360) { +$this->error['generate_time'] = "It took an awfully long time to generate configs...(" . round($time, 2) . " seconds)"; + } + if ($write) { + $this->write_configs($provisioner_lib, $reboot, $settings['config_location'], $phone_info, $returned_data); + } else { + return ($returned_data); + } + return(TRUE); + } else { +$this->error['parse_configs'] = "Can't Load \"" . $class . "\" Class!"; + return(FALSE); + } + } else { +$this->error['parse_configs'] = "Can't Load the Autoloader!"; + return(FALSE); + } + } + + function write_configs($provisioner_lib, $reboot, $write_path, $phone_info, $returned_data) { + + //Create Directory Structure (If needed) + if (isset($provisioner_lib->directory_structure)) { + foreach ($provisioner_lib->directory_structure as $data) { + if (file_exists($this->PHONE_MODULES_PATH . "endpoint/" . $phone_info['directory'] . "/" . $phone_info['cfg_dir'] . "/" . $data)) { + $dir_iterator = new \RecursiveDirectoryIterator($this->PHONE_MODULES_PATH . "endpoint/" . $phone_info['directory'] . "/" . $phone_info['cfg_dir'] . "/" . $data . "/"); + $iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::SELF_FIRST); + // could use CHILD_FIRST if you so wish + foreach ($iterator as $file) { + $dir = $write_path . str_replace($this->PHONE_MODULES_PATH . "endpoint/" . $phone_info['directory'] . "/" . $phone_info['cfg_dir'] . "/", "", dirname($file)); + if (!file_exists($dir)) { + if (!@mkdir($dir, 0775, TRUE)) { +$this->error['parse_configs'] = "Could Not Create Directory: " . $data; + return(FALSE); + } + } + } + } else { + $dir = $write_path . $data; + if (!file_exists($dir)) { + if (!@mkdir($dir, 0775)) { +$this->error['parse_configs'] = "Could Not Create Directory: " . $data; + return(FALSE); + } + } + } + } + } + + //Copy Files (If needed) + if (isset($provisioner_lib->copy_files)) { + foreach ($provisioner_lib->copy_files as $data) { + if (file_exists($this->PHONE_MODULES_PATH . "endpoint/" . $phone_info['directory'] . "/" . $phone_info['cfg_dir'] . "/" . $data)) { + $file = $write_path . $data; + $orig = $this->PHONE_MODULES_PATH . "endpoint/" . $phone_info['directory'] . "/" . $phone_info['cfg_dir'] . "/" . $data; + if (!file_exists($file)) { + if (!@copy($orig, $file)) { +$this->error['parse_configs'] = "Could Not Create File: " . $data; + return(FALSE); + } + } else { + if (file_exists($this->PHONE_MODULES_PATH . "endpoint/" . $phone_info['directory'] . "/" . $phone_info['cfg_dir'] . "/" . $data)) { + if (!file_exists(dirname($write_path . $data))) { + !@mkdir(dirname($write_path . $data), 0775); + } + copy($this->PHONE_MODULES_PATH . "endpoint/" . $phone_info['directory'] . "/" . $phone_info['cfg_dir'] . "/" . $data, $write_path . $data); + chmod($write_path . $data, 0775); + } + } + } + } + } + + foreach ($returned_data as $file => $data) { + if (((file_exists($write_path . $file)) AND (is_writable($write_path . $file)) AND (!in_array($file, $provisioner_lib->protected_files))) OR (!file_exists($write_path . $file))) { + //Move old file to backup + if (!$this->eda->global_cfg['backup_check']) { + if (!file_exists($write_path . 'config_bkup')) { + if (!@mkdir($write_path . 'config_bkup', 0775)) { +$this->error['parse_configs'] = "Could Not Create Backup Directory"; + return(FALSE); + } + } + if (file_exists($write_path . $file)) { + copy($write_path . $file, $write_path . 'config_bkup/' . $file . '.' . time()); + } + } + file_put_contents($write_path . $file, $data); + chmod($write_path . $file, 0775); + if (!file_exists($write_path . $file)) { +$this->error['parse_configs'] = "File (" . $file . ") not written to hard drive!"; + return(FALSE); + } + } elseif (!in_array($file, $provisioner_lib->protected_files)) { +$this->error['parse_configs'] = "File not written to hard drive!"; + return(FALSE); + } + } + + if ($reboot) { + $provisioner_lib->reboot(); + } + } +*/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /********************************************* + ****** CODIGO ANTIGUO -- SIN REVISADO ******** + *********************************************/ + + + + + + + + + +/* + + function download_json($location, $directory=NULL) { + $temp_directory = $this->sys_get_temp_dir() . "/epm_temp/"; + if (!isset($directory)) { + $destination_file = $this->PHONE_MODULES_PATH . 'endpoint/master.json'; + $directory = "master"; + } else { + if (!file_exists($this->PHONE_MODULES_PATH . '/' . $directory)) { + mkdir($this->PHONE_MODULES_PATH . '/' . $directory, 0775, TRUE); + } + $destination_file = $this->PHONE_MODULES_PATH . '/' . $directory . '/brand_data.json'; + } + $temp_file = $temp_directory . $directory . '.json'; + file_exists(dirname($temp_file)) ? '' : mkdir(dirname($temp_file)); + + if ($this->system->download_file($location, $temp_file)) { + $handle = fopen($temp_file, "rb"); + $contents = fread($handle, filesize($temp_file)); + fclose($handle); + + $a = $this->validate_json($contents); + if ($a === FALSE) { + //Error with the internet....ABORRRTTTT THEEEEE DOWNLOAAAAADDDDDDDD! SCOTTYYYY!; + unlink($temp_file); + return(FALSE); + } else { + rename($temp_file, $destination_file); + chmod($destination_file, 0775); + return(TRUE); + } + } else { + return(FALSE); + } + } + + +*/ + + + /** + * Send process to run in background + * @version 2.11 + * @param string $command the command to run + * @param integer $Priority the Priority of the command to run + * @return int $PID process id + * @package epm_system + + function run_in_background($Command, $Priority = 0) { + return($Priority ? shell_exec("nohup nice -n $Priority $Command 2> /dev/null & echo $!") : shell_exec("nohup $Command > /dev/null 2> /dev/null & echo $!")); + } + + /** + * Check if process is running in background + * @version 2.11 + * @param string $PID proccess ID + * @return bool true or false + * @package epm_system + + function is_process_running($PID) { + exec("ps $PID", $ProcessState); + return(count($ProcessState) >= 2); + } + + + + /** + * Uses which to find executables that asterisk can run/use + * @version 2.11 + * @param string $exec Executable to find + * @package epm_system + + + function find_exec($exec) { + $o = exec('which '.$exec); + if($o) { + if(file_exists($o) && is_executable($o)) { + return($o); + } else { + return(''); + } + } else { + return(''); + } + } + + */ + /** + * Only used once in all of Endpoint Manager to determine if a table exists + * @param string $table Table to look for + * @return bool + + function table_exists($table) { + $sql = "SHOW TABLES FROM " . $this->config->get('AMPDBNAME'); + $result = $this->eda->sql($sql, 'getAll'); + foreach ($result as $row) { + if ($row[0] == $table) { + return TRUE; + } + } + return FALSE; + } + */ + + + + + /** + * Check for valid netmast to avoid security issues + * @param string $mask the complete netmask, eg [1.1.1.1/24] + * @return boolean True if valid, False if not + * @version 2.11 + + function validate_netmask($mask) { + return preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/", $mask) ? TRUE : FALSE; + } + + /** + * Discover New Device/Hardware + * nmap will actually discover 'unseen' devices that the VoIP server hasn't heard from + * If the user just wishes to use the local arp cache they can tell the function to not use nmap + * This results in a speed increase from 60 seconds to less than one second. + * + * This is the original function that started it all + * http://www.pbxinaflash.com/community/index.php?threads/end-point-configuration-manager-module-for-freepbx-part-1.4514/page-4#post-37671 + * + * @version 2.11 + * @param mixed $netmask The netmask, eg [1.1.1.1/24] + * @param boolean $use_nmap True use nmap, false don't use it + * @return array List of devices found on the network + + function discover_new($netmask, $use_nmap=TRUE) { + if (($use_nmap) AND (file_exists($this->eda->global_cfg['nmap_location'])) AND ($this->validate_netmask($netmask))) { + shell_exec($this->eda->global_cfg['nmap_location'] . ' -v -sP ' . $netmask); + } elseif (!$this->validate_netmask($netmask)) { + $this->error['discover_new'] = "Invalid Netmask"; + return(FALSE); + } elseif (!file_exists($this->eda->global_cfg['nmap_location'])) { + $this->error['discover_new'] = "Could Not Find NMAP, Using ARP Only"; + //return(FALSE); + } + + //Get arp list + $arp_list = shell_exec($this->eda->global_cfg['arp_location'] . " -an"); + + //Throw arp list into an array, break by new lines + $arp_array = explode("\n", $arp_list); + + //Find all references to active computers by searching out mac addresses. + $temp = array_values(array_unique(preg_grep("/[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f]/i", $arp_array))); + + //Go through each row of valid arp entries and pull out the information and add it into a nice array! + $z = 0; + foreach ($temp as $key => &$value) { + + //Pull out the IP address from row. It's always the first entry in the row and it can only be a max of 15 characters with the delimiters + preg_match_all("/\((.*?)\)/", $value, $matches); + $ip = $matches[1]; + $ip = $ip[0]; + + //Pull out the mac address by looking for the delimiter + $mac = substr($value, (strpos($value, ":") - 2), 17); + + //Get rid of the delimiter + $mac_strip = strtoupper(str_replace(":", "", $mac)); + + //arp -n will return a MAC address of 000000000000 if no hardware was found, so we need to ignore it + if ($mac_strip != "000000000000") { + //only use the first 6 characters for the oui: http://en.wikipedia.org/wiki/Organizationally_Unique_Identifier + $oui = substr($mac_strip, 0, 6); + + //Find the matching brand model to the oui + $oui_sql = "SELECT endpointman_brand_list.name, endpointman_brand_list.id FROM endpointman_oui_list, endpointman_brand_list WHERE oui LIKE '%" . $oui . "%' AND endpointman_brand_list.id = endpointman_oui_list.brand AND endpointman_brand_list.installed = 1 LIMIT 1"; + + $brand = $this->eda->sql($oui_sql, 'getRow', DB_FETCHMODE_ASSOC); + + $res = $this->eda->sql($oui_sql); + $brand_count = count($res); + + if (!$brand_count) { + //oui doesn't have a matching mysql reference, probably a PC/router/wap/printer of some sort. + $brand['name'] = FALSE; + $brand['id'] = NULL; + } + + //Find out if endpoint has already been configured for this mac address + $epm_sql = "SELECT * FROM endpointman_mac_list WHERE mac LIKE '%" . $mac_strip . "%'"; + $epm_row = $this->eda->sql($epm_sql, 'getRow', DB_FETCHMODE_ASSOC); + + $res = $this->eda->sql($epm_sql); + + $epm = count($res) ? TRUE : FALSE; + + //Add into a final array + $final[$z] = array("ip" => $ip, "mac" => $mac, "mac_strip" => $mac_strip, "oui" => $oui, "brand" => $brand['name'], "brand_id" => $brand['id'], "endpoint_managed" => $epm); + $z++; + } + } + return !is_array($final) ? FALSE : $final; + } + + + + function in_array_recursive($needle, $haystack) { + + $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($haystack)); + + foreach ($it AS $element) { + if ($element == $needle) { + return TRUE; + } + } + return FALSE; + } + + + + + + + function display_templates($product_id, $temp_select = NULL) { + $i = 0; + $sql = "SELECT id FROM endpointman_product_list WHERE endpointman_product_list.id ='" . $product_id . "'"; + $id = sql($sql, 'getOne'); + + $sql = "SELECT * FROM endpointman_template_list WHERE product_id = '" . $id . "'"; + $data = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + + foreach ($data as $row) { + $temp[$i]['value'] = $row['id']; + $temp[$i]['text'] = $row['name']; + if ($row['id'] == $temp_select) { + $temp[$i]['selected'] = "selected"; + } + $i++; + } + $temp[$i]['value'] = 0; + if ($temp_select == 0) { + $temp[$i]['text'] = "Custom..."; + $temp[$i]['selected'] = "selected"; + } else { + $temp[$i]['text'] = "Custom..."; + } + + return($temp); + } + + function validate_json($json) { + return(TRUE); + } + + + + + + + + + + + + + + + + + + /** + + function update_device($macid, $model, $template, $luid=NULL, $name=NULL, $line=NULL, $update_lines=TRUE) { + $sql = "UPDATE endpointman_mac_list SET model = " . $model . ", template_id = " . $template . " WHERE id = " . $macid; + sql($sql); + + if ($update_lines) { + if (isset($luid)) { + $this->update_line($luid, NULL, $name, $line); + return(TRUE); + } else { + $this->update_line(NULL, $macid); + return(TRUE); + } + } + } + + function update_line($luid=NULL, $macid=NULL, $name=NULL, $line=NULL) { + if (isset($luid)) { + $sql = "SELECT * FROM endpointman_line_list WHERE luid = " . $luid; + $row = $this->eda->sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + if (!isset($name)) { + $sql = "SELECT description FROM devices WHERE id = " . $row['ext']; + $name = sql($sql, 'getOne'); + } + + if (!isset($line)) { + $line = $row['line']; + } + $sql = "UPDATE endpointman_line_list SET line = '" . $line . "', ext = '" . $row['ext'] . "', description = '" . $this->eda->escapeSimple($name) . "' WHERE luid = " . $row['luid']; + sql($sql); + return(TRUE); + } else { + $sql = "SELECT * FROM endpointman_line_list WHERE mac_id = " . $macid; + $lines_info = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach ($lines_info as $row) { + $sql = "SELECT description FROM devices WHERE id = " . $row['ext']; + $name = sql($sql, 'getOne'); + + $sql = "UPDATE endpointman_line_list SET line = '" . $row['line'] . "', ext = '" . $row['ext'] . "', description = '" . $this->eda->escapeSimple($name) . "' WHERE luid = " . $row['luid']; + sql($sql); + } + return(TRUE); + } + } + + + * This will either a. delete said line or b. delete said device from line + * @param $line + * @return + + function delete_line($lineid, $allow_device_remove=FALSE) { + $sql = 'SELECT mac_id FROM endpointman_line_list WHERE luid = ' . $lineid; + $mac_id = sql($sql, 'getOne'); + $row = $this->get_phone_info($mac_id); + + $sql = 'SELECT COUNT(*) FROM endpointman_line_list WHERE mac_id = ' . $mac_id; + $num_lines = sql($sql, 'getOne'); + if ($num_lines > 1) { + $sql = "DELETE FROM endpointman_line_list WHERE luid=" . $lineid; + sql($sql); + $this->message['delete_line'] = "Deleted!"; + return(TRUE); + } else { + if ($allow_device_remove) { + $sql = "DELETE FROM endpointman_line_list WHERE luid=" . $lineid; + sql($sql); + + $sql = "DELETE FROM endpointman_mac_list WHERE id=" . $mac_id; + sql($sql); + $this->message['delete_line'] = "Deleted!"; + return(TRUE); + } else { + $this->error['delete_line'] = _("You can't remove the only line left") . "!"; + return(FALSE); + } + } + } + + function delete_device($mac_id) { + $sql = "DELETE FROM endpointman_mac_list WHERE id=" . $mac_id; + sql($sql); + + $sql = "DELETE FROM endpointman_line_list WHERE mac_id=" . $mac_id; + sql($sql); + $this->message['delete_device'] = "Deleted!"; + return(TRUE); + } +*/ + /* function get_message($function_name) { + if (isset($this->message[$function_name])) { + return($this->message[$function_name]); + } else { + return("Unknown Message"); + } + } + + + + + + + + + /** + * Save template from the template view pain + * @param int $id Either the MAC ID or Template ID + * @param int $custom Either 0 or 1, it determines if $id is MAC ID or Template ID + * @param array $variables The variables sent from the form. usually everything in $_REQUEST[] + * @return string Location of area to return to in Endpoint Manager + */ + function save_template($id, $custom, $variables) { + //Custom Means specific to that MAC + //This function is reversed. Not sure why + + if ($custom != "0") { + $sql = "SELECT endpointman_model_list.max_lines, endpointman_product_list.config_files, endpointman_mac_list.*, endpointman_product_list.id as product_id, endpointman_product_list.long_name, endpointman_model_list.template_data, endpointman_product_list.cfg_dir, endpointman_brand_list.directory FROM endpointman_brand_list, endpointman_mac_list, endpointman_model_list, endpointman_product_list WHERE endpointman_mac_list.id=" . $id . " AND endpointman_mac_list.model = endpointman_model_list.id AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id"; + } else { + $sql = "SELECT endpointman_model_list.max_lines, endpointman_brand_list.directory, endpointman_product_list.cfg_dir, endpointman_product_list.config_files, endpointman_product_list.long_name, endpointman_model_list.template_data, endpointman_model_list.id as model_id, endpointman_template_list.* FROM endpointman_brand_list, endpointman_product_list, endpointman_model_list, endpointman_template_list WHERE endpointman_product_list.id = endpointman_template_list.product_id AND endpointman_brand_list.id = endpointman_product_list.brand AND endpointman_template_list.model_id = endpointman_model_list.id AND endpointman_template_list.id = " . $id; + } + + //Load template data + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $cfg_data = unserialize($row['template_data']); + $count = count($cfg_data); + + $custom_cfg_data_ari = array(); + + foreach ($cfg_data['data'] as $cats) { + foreach ($cats as $items) { + foreach ($items as $key_name => $config_options) { + if (preg_match('/(.*)\|(.*)/i', $key_name, $matches)) { + $type = $matches[1]; + $key = $matches[2]; + } else { + die('invalid'); + } + switch ($type) { + case "loop": + $stuffing = explode("_", $key); + $key2 = $stuffing[0]; + foreach ($config_options as $item_key => $item_data) { + $lc = isset($item_data['loop_count']) ? $item_data['loop_count'] : ''; + $key = 'loop|' . $key2 . '_' . $item_key . '_' . $lc; + if ((isset($item_data['loop_count'])) AND (isset($variables[$key]))) { + $custom_cfg_data[$key] = $variables[$key]; + $ari_key = "ari_" . $key; + if (isset($variables[$ari_key])) { + if ($variables[$ari_key] == "on") { + $custom_cfg_data_ari[$key] = 1; + } + } + } + } + break; + case "lineloop": + foreach ($config_options as $item_key => $item_data) { + $lc = isset($item_data['line_count']) ? $item_data['line_count'] : ''; + $key = 'line|' . $lc . '|' . $item_key; + if ((isset($item_data['line_count'])) AND (isset($variables[$key]))) { + $custom_cfg_data[$key] = $variables[$key]; + $ari_key = "ari_" . $key; + if (isset($variables[$ari_key])) { + if ($variables[$ari_key] == "on") { + $custom_cfg_data_ari[$key] = 1; + } + } + } + } + break; + case "option": + if (isset($variables[$key])) { + $custom_cfg_data[$key] = $variables[$key]; + $ari_key = "ari_" . $key; + if (isset($variables[$ari_key])) { + if ($variables[$ari_key] == "on") { + $custom_cfg_data_ari[$key] = 1; + } + } + } + break; + default: + break; + } + } + } + } + + $config_files = explode(",", $row['config_files']); + + $i = 0; + while ($i < count($config_files)) { + $config_files[$i] = str_replace(".", "_", $config_files[$i]); + + if (isset($variables[config_files][$i])) { + + $variables[$config_files[$i]] = explode("_", $variables[config_files][$i], 2); + + $variables[$config_files[$i]] = $variables[$config_files[$i]][0]; + if ($variables[$config_files[$i]] > 0) { + $config_files_selected[$config_files[$i]] = $variables[$config_files[$i]]; + + + } + } + $i++; + } + if (!isset($config_files_selected)) { + $config_files_selected = ""; + } else { + $config_files_selected = serialize($config_files_selected); + } + $custom_cfg_data_temp['data'] = $custom_cfg_data; + $custom_cfg_data_temp['ari'] = $custom_cfg_data_ari; + + $save = serialize($custom_cfg_data_temp); + if ($custom == "0") { + $sql = 'UPDATE endpointman_template_list SET config_files_override = \'' . addslashes($config_files_selected) . '\', global_custom_cfg_data = \'' . addslashes($save) . '\' WHERE id =' . $id; + $location = "template_manager"; + //print_r($sql); + } else { + $sql = 'UPDATE endpointman_mac_list SET config_files_override = \'' . addslashes($config_files_selected) . '\', template_id = 0, global_custom_cfg_data = \'' . addslashes($save) . '\' WHERE id =' . $id; + $location = "devices_manager"; + } + sql($sql); + + $phone_info = array(); +/* + if ($custom != 0) { + $phone_info = $this->get_phone_info($id); + if (isset($variables['epm_reboot'])) { + $this->prepare_configs($phone_info); + } else { + $this->prepare_configs($phone_info, FALSE); + } + } else { + $sql = 'SELECT id FROM endpointman_mac_list WHERE template_id = ' . $id; + $phones = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach ($phones as $data) { + $phone_info = $this->get_phone_info($data['id']); + if (isset($variables['epm_reboot'])) { + $this->prepare_configs($phone_info); + } else { + $this->prepare_configs($phone_info, FALSE); + } + } + } +*/ + + if (isset($variables['silent_mode'])) { + echo ''; + } else { + return($location); + } + } + + + + function display_configs() { + + } + + + + + + + + + + + + + //BORRAR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + //OBSOLETO, ANTIGUAMENTE VENTANAS EMERGENTES, AHORA SON DIALOGOS JQUERY. + /* function prepare_message_box() { + $error_message = NULL; + foreach ($this->error as $key => $error) { + $error_message .= $error; + if ($this->eda->global_cfg['debug']) { + $error_message .= " Function: [" . $key . "]"; + } + $error_message .= "
"; + } + $message = NULL; + foreach ($this->message as $key => $error) { + if (is_array($error)) { + foreach ($error as $sub_error) { + $message .= $sub_error; + if ($this->eda->global_cfg['debug']) { + $message .= " Function: [" . $key . "]"; + } + $message .= "
"; + } + } else { + $message .= $error; + if ($this->eda->global_cfg['debug']) { + $message .= " Function: [" . $key . "]"; + } + $message .= "
"; + } + } + + if (isset($message)) { + $this->display_message_box($message, 0); + } + + if (isset($error_message)) { + $this->display_message_box($error_message, 1); + } + } +*/ + + + + +} diff --git a/Endpointman_Advanced.class.php b/Endpointman_Advanced.class.php new file mode 100644 index 00000000..f8dae74e --- /dev/null +++ b/Endpointman_Advanced.class.php @@ -0,0 +1,1375 @@ +freepbx = $freepbx; + $this->db = $freepbx->Database; + $this->config = $freepbx->Config; + $this->configmod = $cfgmod; + $this->epm_config = $epm_config; + + $this->MODULES_PATH = $this->config->get('AMPWEBROOT') . '/admin/modules/'; + if (file_exists($this->MODULES_PATH . "endpointman/")) { + $this->LOCAL_PATH = $this->MODULES_PATH . "endpointman/"; + } else { + die("Can't Load Local Endpoint Manager Directory!"); + } + if (file_exists($this->MODULES_PATH . "_ep_phone_modules/")) { + $this->PHONE_MODULES_PATH = $this->MODULES_PATH . "_ep_phone_modules/"; + } else { + $this->PHONE_MODULES_PATH = $this->MODULES_PATH . "_ep_phone_modules/"; + if (!file_exists($this->PHONE_MODULES_PATH)) { + mkdir($this->PHONE_MODULES_PATH, 0775); + } + if (file_exists($this->PHONE_MODULES_PATH . "setup.php")) { + unlink($this->PHONE_MODULES_PATH . "setup.php"); + } + if (!file_exists($this->MODULES_PATH . "_ep_phone_modules/")) { + die('Endpoint Manager can not create the modules folder!'); + } + } + } + + public function myShowPage(&$pagedata) { + if(empty($pagedata)) + { + $pagedata['settings'] = array( + "name" => _("Settings"), + "page" => 'views/epm_advanced_settings.page.php' + ); + $pagedata['oui_manager'] = array( + "name" => _("OUI Manager"), + "page" => 'views/epm_advanced_oui_manager.page.php' + ); + $pagedata['poce'] = array( + "name" => _("Product Configuration Editor"), + "page" => 'views/epm_advanced_poce.page.php' + ); + $pagedata['iedl'] = array( + "name" => _("Import/Export My Devices List"), + "page" => 'views/epm_advanced_iedl.page.php' + ); + $pagedata['manual_upload'] = array( + "name" => _("Package Import/Export"), + "page" => 'views/epm_advanced_manual_upload.page.php' + ); + } + } + + public function ajaxRequest($req, &$setting) { + $arrVal = array("oui", "oui_add", "oui_del", "poce_list_brands","poce_select", "poce_select_file", "poce_save_file", "poce_save_as_file", "poce_sendid", "poce_delete_config_custom", "list_files_brands_export", "saveconfig"); + if (in_array($req, $arrVal)) { + $setting['authenticate'] = true; + $setting['allowremote'] = false; + return true; + } + return false; + } + + public function ajaxHandler($module_tab = "", $command = "") + { + $txt = array(); + $txt['settings'] = array( + 'error' => _("Error!"), + 'save_changes' => _("Saving Changes..."), + 'save_changes_ok' => _("Saving Changes... Ok!"), + 'opt_invalid' => _("Invalid Option!") + ); + + if ($module_tab == "settings") + { + switch ($command) + { + case "saveconfig": + $retarr = $this->epm_advanced_settings_saveconfig(); + break; + + default: + $retarr = array("status" => false, "message" => _("Command not found!") . " [" .$command. "]"); + break; + } + $retarr['txt'] = $txt['settings']; + } + elseif ($module_tab == "oui_manager") { + switch ($command) + { + case "oui": + //$sql = 'SELECT endpointman_oui_list.id, endpointman_oui_list.oui , endpointman_brand_list.name, endpointman_oui_list.custom FROM endpointman_oui_list , endpointman_brand_list WHERE endpointman_oui_list.brand = endpointman_brand_list.id ORDER BY endpointman_oui_list.oui ASC'; + $sql = 'SELECT T1.id, T1.oui, T2.name, T1.custom FROM endpointman_oui_list as T1 , endpointman_brand_list as T2 WHERE T1.brand = T2.id ORDER BY T1.oui ASC'; + $data = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + $ret = array(); + foreach ($data as $item) { + $ret[] = array('id' => $item['id'], 'oui' => $item['oui'], 'brand' => $item['name'], 'custom' => $item['custom']); + } + return $ret; + break; + + case "oui_add": + $retarr = $this->epm_advanced_oui_add(); + break; + + case "oui_del": + $retarr = $this->epm_advanced_oui_remove(); + break; + + default: + $retarr = array("status" => false, "message" => _("Command not found!") . " [" .$command. "]"); + break; + } + //$retarr['txt'] = $txt['settings']; + } + elseif ($module_tab == "iedl") { + switch ($command) + { + default: + $retarr = array("status" => false, "message" => _("Command not found!") . " [" .$command. "]"); + break; + } + //$retarr['txt'] = $txt['settings']; + } + elseif ($module_tab == "poce") { + switch ($command) + { + case "poce_list_brands": + $retarr = $this->epm_advanced_poce_list_brands(); + break; + + case "poce_select": + $retarr = $this->epm_advanced_poce_select(); + break; + + case "poce_select_file": + $retarr = $this->epm_advanced_poce_select_file(); + break; + + case "poce_save_file": + case "poce_save_as_file": + $retarr = $this->epm_advanced_poce_save_file(); + break; + + case "poce_sendid": + $retarr = $this->epm_advanced_poce_sendid(); + break; + + case "poce_delete_config_custom": + $retarr = $this->epm_advanced_poce_delete_config_custom(); + break; + + default: + $retarr = array("status" => false, "message" => _("Command not found!") . " [" .$command. "]"); + break; + } + //$retarr['txt'] = $txt['settings']; + } + elseif ($module_tab == "manual_upload") { + switch ($command) + { + case "list_files_brands_export": + $retarr = $this->epm_advanced_manual_upload_list_files_brans_export(); + break; + + default: + $retarr = array("status" => false, "message" => _("Command not found!") . " [" .$command. "]"); + break; + } + } + else { + $retarr = array("status" => false, "message" => _("Tab is not valid!") . " [" .$module_tab. "]"); + } + return $retarr; + } + + public function doConfigPageInit($module_tab = "", $command = "") { + switch ($module_tab) + { + case "oui_manager": + break; + + case "iedl": + switch ($command) { + case "export": + $this->epm_advanced_iedl_export(); + break; + + case "import": + $this->epm_advanced_iedl_import(); + echo "


"; + exit; + break; + } + break; + + case "manual_upload": + switch ($command) { + case "export_brands_availables": + $this->epm_advanced_manual_upload_export_brans_available(); + echo "


"; + exit; + break; + + case "export_brands_availables_file": + $this->epm_advanced_manual_upload_export_brans_available_file(); + exit; + break; + + case "upload_brand": + $this->epm_advanced_manual_upload_brand(); + echo "


"; + exit; + break; + + case "upload_provisioner": + $this->epm_advanced_manual_upload_provisioner(); + echo "


"; + exit; + break; + } + break; + } + } + + public function getRightNav($request) { + return ""; + } + + public function getActionBar($request) { + return ""; + } + + + /**** FUNCIONES SEC MODULO "epm_advanced\settings" ****/ + public function epm_advanced_config_loc_is_writable() + { + $config_loc = $this->configmod->get("config_loc"); + $tftp_writable = FALSE; + if ((isset($config_loc)) AND ($config_loc != "")) { + if ((file_exists($config_loc)) AND (is_dir($config_loc))) { + if (is_writable($config_loc)) { + $tftp_writable = TRUE; + } + } + } + return $tftp_writable; + } + + private function epm_advanced_settings_saveconfig () + { + $arrVal['VAR_REQUEST'] = array("name", "value"); + foreach ($arrVal['VAR_REQUEST'] as $valor) { + if (! array_key_exists($valor, $_REQUEST)) { + return array("status" => false, "message" => _("No send value!")." [".$valor."]"); + } + } + + $dget['name'] = strtolower($_REQUEST['name']); + $dget['value'] = $_REQUEST['value']; + + switch($dget['name']) { + case "enable_ari": + $dget['value'] = strtolower($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . ($dget['value'] == "yes" ? "1": "0") . "' WHERE var_name='enable_ari'"; + break; + + case "enable_debug": + $dget['value'] = strtolower($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . ($dget['value'] == "yes" ? "1": "0") . "' WHERE var_name='debug'"; + break; + + case "disable_help": + $dget['value'] = strtolower($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . ($dget['value'] == "yes" ? "1": "0") . "' WHERE var_name='disable_help'"; + break; + + case "disable_endpoint_warning": + $dget['value'] = strtolower($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . ($dget['value'] == "yes" ? "1": "0") . "' WHERE var_name='disable_endpoint_warning'"; + break; + + case "allow_dupext": + $dget['value'] = strtolower($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . ($dget['value'] == "yes" ? "1": "0") . "' WHERE var_name='show_all_registrations'"; + break; + + case "allow_hdfiles": + $dget['value'] = strtolower($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . ($dget['value'] == "yes" ? "1": "0") . "' WHERE var_name='allow_hdfiles'"; + break; + + case "tftp_check": + $dget['value'] = strtolower($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . ($dget['value'] == "yes" ? "1": "0") . "' WHERE var_name='tftp_check'"; + break; + + case "backup_check": + $dget['value'] = strtolower($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . ($dget['value'] == "yes" ? "1": "0") . "' WHERE var_name='backup_check'"; + break; + + case "use_repo": + $dget['value'] = strtolower($dget['value']); + if (($dget['value'] == "yes") and (! $this->has_git())) { + $retarr = array("status" => false, "message" => _("Git not installed!")); + } + else { + $sql = "UPDATE endpointman_global_vars SET value='" . ($dget['value'] == "yes" ? "1": "0") . "' WHERE var_name='use_repo'"; + } + break; + + case "config_loc": + $dget['value'] = trim($dget['value']); + //No trailing slash. Help the user out and add one :-) + if ($dget['value'][strlen($dget['value']) - 1] != "/") { + $dget['value'] = $dget['value'] . "/"; + } + if ($dget['value'] != "") { + if ((file_exists($dget['value'] = $dget['value'])) AND (is_dir($dget['value'] = $dget['value']))) { + if (is_writable($dget['value'] = $dget['value'])) { + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='config_location'"; + } else { + $retarr = array("status" => false, "message" => _("Directory Not Writable!")); + } + } else { + $retarr = array("status" => false, "message" => _("Not a Vaild Directory.
Try to run 'mkdir " . $_POST['config_loc'] . "' as root.")); + } + } else { + $retarr = array("status" => false, "message" => _("No Configuration Location Defined!")); + } + break; + + case "srvip": + $dget['value'] = trim($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='srvip'"; + break; + case "intsrvip": + $dget['value'] = trim($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='intsrvip'"; + break; + case "tz": + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='tz'"; + break; + + case "adminpass": + $dget['value'] = trim($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='adminpass'"; + break; + case "userpass": + $dget['value'] = trim($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='userpass'"; + break; + + case "ntp_server": + $dget['value'] = trim($dget['value']); + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='ntp'"; + break; + + case "nmap_loc": + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='nmap_location'"; + break; + + case "arp_loc": + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='arp_location'"; + break; + + case "asterisk_loc": + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='asterisk_location'"; + break; + + case "package_server": + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='update_server'"; + break; + + case "cfg_type": + if ($dget['value'] == 'http' or $dget['value'] == 'https' ) { + $symlink = $this->config->get('AMPWEBROOT') . "/provisioning"; + $reallink = $this->LOCAL_PATH . "provisioning"; + if ((!is_link($symlink)) OR (!readlink($symlink) == $reallink)) { + if (!symlink($reallink, $symlink)) { + $retarr = array("status" => false, "message" => _("Your permissions are wrong on " . $this->config->get('AMPWEBROOT') . ", web provisioning link not created!")); + //$dget['value'] = 'file'; + break; + } //else { + //$dget['value'] = 'http'; + //} + }// else { + //$dget['value'] = 'http'; + //} + } else { + $dget['value'] = 'file'; + } + $sql = "UPDATE endpointman_global_vars SET value='" . $dget['value'] . "' WHERE var_name='server_type'"; + break; + + default: + $retarr = array("status" => false, "message" => _("Name invalid: ") . $dget['name'] ); + } + + if (isset($sql)) { + sql($sql); + $retarr = array("status" => true, "message" => "OK", "name" => $dget['name'], "value" => $dget['value']); + unset($sql); + } + + unset($dget); + return $retarr; + } + + + /**** FUNCIONES SEC MODULO "epm_advanced\poce" ****/ + public function epm_advanced_poce_list_brands() + { + //$sql = 'SELECT * FROM endpointman_product_list WHERE hidden = 0 AND id > 0 ORDER BY long_name ASC'; + //$sql = 'SELECT * FROM endpointman_product_list WHERE hidden = 0 AND id > 0 AND brand IN (SELECT id FROM asterisk.endpointman_brand_list where hidden = 0) ORDER BY long_name ASC'; + $sql = 'SELECT * FROM endpointman_product_list WHERE hidden = 0 AND id IN (SELECT DISTINCT product_id FROM asterisk.endpointman_model_list where enabled = 1) AND brand IN (SELECT id FROM asterisk.endpointman_brand_list where hidden = 0) ORDER BY long_name ASC'; + $product_list = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + $i = 0; + $temp = array(); + foreach ($product_list as $srow) + { + $temp[$i]['id'] = $srow['id']; + $temp[$i]['name'] = $srow['long_name']; + $temp[$i]['name_mini'] = substr($srow['long_name'], 0, 40).(strlen($srow['long_name']) > 40 ? "..." : ""); + $i++; + } + return array("status" => true, "message" => _("Ok!"), "ldatos" => $temp); + } + + public function epm_advanced_poce_select() + { + if (! isset($_REQUEST['product_select'])) { + $retarr = array("status" => false, "message" => _("No send Product Select!")); + } + elseif (! is_numeric($_REQUEST['product_select'])) { + $retarr = array("status" => false, "message" => _("Product Select send is not number!")); + } + elseif ($_REQUEST['product_select'] < 0) { + $retarr = array("status" => false, "message" => _("Product Select send is number not valid!")); + } + else + { + $dget['product_select'] = $_REQUEST['product_select']; + + $sql = 'SELECT * FROM `endpointman_product_list` WHERE `hidden` = 0 AND `id` = '.$dget['product_select']; + $product_select_info = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $sql = "SELECT cfg_dir,directory,config_files FROM endpointman_product_list,endpointman_brand_list WHERE endpointman_product_list.brand = endpointman_brand_list.id AND endpointman_product_list.id ='" . $dget['product_select'] . "'"; + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + $config_files = explode(",", $row['config_files']); + $i = 0; + if (count($config_files)) { + foreach ($config_files as $config_files_data) { + //$file_list[$i]['value'] = $i; + $file_list[$i]['value'] = $dget['product_select']; + $file_list[$i]['text'] = $config_files_data; + $i++; + } + } else { $file_list = NULL; } + + $sql = "SELECT * FROM endpointman_custom_configs WHERE product_id = '" . $dget['product_select'] . "'"; + $data = sql($sql,'getAll', DB_FETCHMODE_ASSOC); + $i = 0; + if (count($data)) { + //$data = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach ($data as $row2) { + $sql_file_list[$i]['value'] = $row2['id']; + $sql_file_list[$i]['text'] = $row2['name']; + $sql_file_list[$i]['ref'] = $row2['original_name']; + $i++; + } + } else { $sql_file_list = NULL; } + + + require_once($this->PHONE_MODULES_PATH . 'setup.php'); + $class = "endpoint_" . $row['directory'] . "_" . $row['cfg_dir'] . '_phone'; + $base_class = "endpoint_" . $row['directory'] . '_base'; + $master_class = "endpoint_base"; + + /********************************************************************************* + *** Quick Fix for FreePBX Distro + *** I seriously want to figure out why ONLY the FreePBX Distro can't do autoloads. + **********************************************************************************/ + if (!class_exists($master_class)) { + ProvisionerConfig::endpointsAutoload($master_class); + } + if (!class_exists($base_class)) { + ProvisionerConfig::endpointsAutoload($base_class); + } + if (!class_exists($class)) { + ProvisionerConfig::endpointsAutoload($class); + } + //end quick fix + $phone_config = new $class(); + + //TODO: remove + $template_file_list[0]['value'] = "template_data_custom.xml"; + $template_file_list[0]['text'] = "template_data_custom.xml"; + + $sql = "SELECT id, model FROM endpointman_model_list WHERE product_id = '" . $dget['product_select'] . "' AND enabled = 1 AND hidden = 0"; + $data = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + $i = 1; + foreach ($data as $list) { + //$template_file_list[$i]['value'] = "template_data_" . $list['model'] . "_custom.xml"; + $template_file_list[$i]['value'] = $list['id']; + $template_file_list[$i]['text'] = "template_data_" . $list['model'] . "_custom.xml"; + } + + $retarr = array("status" => true, + "message" => "OK", + "product_select" => $dget['product_select'], + "product_select_info" => $product_select_info, + "file_list" => $file_list, + "template_file_list" => $template_file_list, + "sql_file_list" => $sql_file_list); + unset($dget); + } + return $retarr; + } + + public function epm_advanced_poce_select_file() + { + $arrVal['VAR_REQUEST'] = array("product_select", "file_id", "file_name", "type_file"); + foreach ($arrVal['VAR_REQUEST'] as $valor) { + if (! array_key_exists($valor, $_REQUEST)) { + return array("status" => false, "message" => _("No send value!")." [".$valor."]"); + } + } + if (! is_numeric($_REQUEST['product_select'])) { + return array("status" => false, "message" => _("Product Select send is not number!")); + } + elseif ($_REQUEST['product_select'] < 0) { + return array("status" => false, "message" => _("Product Select send is number not valid!")); + } + + $dget['product_select'] = $_REQUEST['product_select']; + $dget['file_name'] = $_REQUEST['file_name']; + $dget['file_id'] = $_REQUEST['file_id']; + $dget['type_file'] = $_REQUEST['type_file']; + + if ($dget['type_file'] == "sql") { + $sql = 'SELECT * FROM endpointman_custom_configs WHERE id =' . $dget['file_id']; + $row = sql($sql, 'getrow', DB_FETCHMODE_ASSOC); + + $type = $dget['type_file']; + $sendidt = $row['id']; + $product_select = $row['product_id']; + $save_as_name_value = $row['name']; + $original_name = $row['original_name']; + $filename = $row['name']; + $location = "SQL: ". $row['name']; + $config_data = $this->display_htmlspecialchars($row['data']); + + } + elseif ($dget['type_file'] == "file") { + $sql = "SELECT cfg_dir,directory,config_files FROM endpointman_product_list,endpointman_brand_list WHERE endpointman_product_list.brand = endpointman_brand_list.id AND endpointman_product_list.id = '" . $dget['product_select'] . "'"; + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $config_files = explode(",", $row['config_files']); + //TODO: Añadir validacion para ver si $dget['file_name'] esta en el array $config_files + + $filename = $dget['file_name']; + $pathfile = $this->PHONE_MODULES_PATH . 'endpoint/' . $row['directory'] . "/" . $row['cfg_dir'] . "/" . $filename; + + + if (is_readable($pathfile)) { + if(filesize($pathfile)>0) { + $handle = fopen($pathfile, "rb"); + $contents = fread($handle, filesize($pathfile)); + fclose($handle); + $contents = $this->display_htmlspecialchars($contents); + } + else { + $contents = ""; + } + + $type = $dget['type_file']; + $sendidt = $dget['file_id']; + $product_select = $dget['product_select']; + $save_as_name_value = $filename; + $original_name = $filename; + $filename = $filename; + $location = $pathfile; + $config_data = $contents; + } + else { + $retarr = array("status" => false, "message" => _("File not readable, check the permission! ").$filename); + } + } + elseif ($dget['type_file'] == "tfile") + { + if ($dget['file_id'] == "template_data_custom.xml") + { + $sendidt = ""; + $original_name = $dget['file_name']; + $config_data = ""; + } + else { + + $sql = "SELECT * FROM endpointman_model_list WHERE id = '" . $dget['file_id'] . "'"; + $data = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $sendidt = $data['id']; + $original_name = $dget['file_name']; + $config_data = unserialize($data['template_data']); + $config_data = generate_xml_from_array ($config_data, 'node'); + } + + $type = $dget['type_file']; + $product_select = $dget['product_select']; + $save_as_name_value = $dget['file_name']; + $filename = $dget['file_name']; + $location = $dget['file_name']; + } + + $retarr = array("status" => true, + "message" => "OK", + "type" => $type, + "sendidt" => $sendidt, + "product_select" => $product_select, + "save_as_name_value" => $save_as_name_value, + "original_name" => $original_name, + "filename" => $filename, + "location" => $location, + "config_data" => $config_data); + + unset($dget); + return $retarr; + } + + + + + + + + //TODO: PENDIENTE REVISAR + function epm_advanced_poce_sendid() + { + if (! isset($_REQUEST['product_select'])) { + $retarr = array("status" => false, "message" => _("No send Product Select!")); + } + elseif (! isset($_REQUEST['type_file'])) { + $retarr = array("status" => false, "message" => _("No send Type File!")); + } + elseif (! isset($_REQUEST['sendid'])) { + $retarr = array("status" => false, "message" => _("No send SendID!")); + } + else { + $dget['product_select'] = $_REQUEST['product_select']; + $dget['type_file'] = $_REQUEST['type_file']; + $dget['sendid'] = $_REQUEST['sendid']; + $dget['original_name'] = $_REQUEST['original_name']; + $dget['config_text'] = $_REQUEST['config_text']; + + + + //DEBUGGGGGGGGGGGGG + return; + if ($dget['type_file'] == "sql") { + $sql = "SELECT cfg_dir,directory,config_files FROM endpointman_product_list,endpointman_brand_list WHERE endpointman_product_list.brand = endpointman_brand_list.id AND endpointman_product_list.id = '" . $dget['product_select'] . "'"; + $row = sql($sql, 'getrow', DB_FETCHMODE_ASSOC); + $this->submit_config($row['directory'], $row['cfg_dir'], $dget['original_name'], $dget['config_text']); + $retarr = array("status" => true, "message" => "Sent! Thanks :-)"); + } + elseif ($dget['type_file'] == "file") { + $sql = "SELECT cfg_dir,directory,config_files FROM endpointman_product_list,endpointman_brand_list WHERE endpointman_product_list.brand = endpointman_brand_list.id AND endpointman_product_list.id = '" . $dget['product_select'] . "'"; + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + $error = $this->submit_config($row['directory'], $row['cfg_dir'], $dget['original_name'], $dget['config_text']); + $retarr = array("status" => true, "message" => "Sent! Thanks :-)"); + } + else { + $retarr = array("status" => false, "message" => "Type not valid!"); + } + unset ($dget); + } + return $retarr; + } + + + + + + + + function epm_advanced_poce_save_file() + { + $arrVal['VAR_REQUEST'] = array("product_select", "sendid", "type_file", "config_text", "save_as_name", "file_name", "original_name"); + foreach ($arrVal['VAR_REQUEST'] as $valor) { + if (! array_key_exists($valor, $_REQUEST)) { + return array("status" => false, "message" => _("No send value!")." [".$valor."]"); + } + } + + $dget['command'] = $_REQUEST['command']; + $dget['type_file'] = $_REQUEST['type_file']; + $dget['sendid'] = $_REQUEST['sendid']; + $dget['product_select'] = $_REQUEST['product_select']; + $dget['save_as_name'] = $_REQUEST['save_as_name']; + $dget['original_name'] = $_REQUEST['original_name']; + $dget['file_name'] = $_REQUEST['file_name']; + $dget['config_text'] = $_REQUEST['config_text']; + + if ($dget['type_file'] == "file") { + if ($dget['command'] == "poce_save_file") + { + $sql = "SELECT cfg_dir,directory,config_files FROM endpointman_product_list,endpointman_brand_list WHERE endpointman_product_list.brand = endpointman_brand_list.id AND endpointman_product_list.id = '" . $dget['product_select'] . "'"; + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + $config_files = explode(",", $row['config_files']); + + if ((is_array($config_files)) AND (in_array($dget['file_name'], $config_files))) + { + $pathdir = $this->PHONE_MODULES_PATH . 'endpoint/' . $row['directory'] . "/" . $row['cfg_dir'] . "/"; + $pathfile = $pathdir . $dget['file_name']; + if ((! file_exists($pathfile)) AND (! is_writable($pathdir))) { + $retarr = array("status" => false, "message" => "Directory is not Writable (".$pathdir.")!"); + } + elseif (! is_writable($pathfile)) { + $retarr = array("status" => false, "message" => "File is not Writable (".$pathfile.")!"); + } + else + { + $wfh = fopen($pathfile, 'w'); + fwrite($wfh, $dget['config_text']); + fclose($wfh); + $retarr = array("status" => true, "message" => "Saved to Hard Drive!"); + } + } + else { + $retarr = array("status" => false, "message" => "The File no existe in the DataBase!"); + } + } + elseif ($dget['command'] == "poce_save_as_file") + { + $db = $this->db; + $sql = 'INSERT INTO endpointman_custom_configs (name, original_name, product_id, data) VALUES (?,?,?,?)'; + $q = $db->prepare($sql); + $ob = $q->execute(array(addslashes($dget['save_as_name']), addslashes($dget['original_name']), $dget['product_select'], addslashes($dget['config_text']))); + $newidinsert = $db->lastInsertId(); + $retarr = array("status" => true, "message" => "Saved to Database!"); + + $retarr['type_file'] = "sql"; + $retarr['location'] = "SQL: ". $dget['save_as_name']; + $retarr['sendidt'] = $newidinsert; + } + else { + $retarr = array("status" => false, "message" => "Command not valid!"); + } + } + elseif ($dget['type_file'] == "sql") + { + if ($dget['command'] == "poce_save_file") + { + $sql = "UPDATE endpointman_custom_configs SET data = '" . addslashes($dget['config_text']) . "' WHERE id = " . $dget['sendid']; + sql($sql); + $retarr = array("status" => true, "message" => "Saved to Database!"); + } + elseif ($dget['command'] == "poce_save_as_file") + { + $db = $this->db; + $sql = 'INSERT INTO endpointman_custom_configs (name, original_name, product_id, data) VALUES (?,?,?,?)'; + $q = $db->prepare($sql); + $ob = $q->execute(array(addslashes($dget['save_as_name']), addslashes($dget['original_name']), $dget['product_select'], addslashes($dget['config_text']))); + $newidinsert = $db->lastInsertId(); + $retarr = array("status" => true, "message" => "Saved to Database!"); + + $retarr['type_file'] = "sql"; + $retarr['location'] = "SQL: ". $dget['save_as_name']; + $retarr['sendidt'] = $newidinsert; + } + else { + $retarr = array("status" => false, "message" => "Command not valid!"); + } + } + elseif ($dget['type_file'] == "tfile") + { + /* + + $db = $this->db; + $sql = 'INSERT INTO endpointman_custom_configs (name, original_name, product_id, data) VALUES (?,?,?,?)'; + $q = $db->prepare($sql); +@ -790,7 +790,7 @@ class Endpointman_Advanced + $retarr['type_file'] = "sql"; + $retarr['location'] = "SQL: ". $dget['save_as_name']; + $retarr['sendidt'] = $newidinsert; + */ + } + else { + $retarr = array("status" => false, "message" => "Type not valid!"); + } + + $retarr['original_name'] = $dget['original_name']; + $retarr['file_name'] = $dget['file_name']; + $retarr['save_as_name'] = $dget['save_as_name']; + + unset($dget); + return $retarr; + } + + function epm_advanced_poce_delete_config_custom() + { + $arrVal['VAR_REQUEST'] = array("product_select", "type_file", "sql_select"); + foreach ($arrVal['VAR_REQUEST'] as $valor) { + if (! array_key_exists($valor, $_REQUEST)) { + return array("status" => false, "message" => _("No send value!")." [".$valor."]"); + } + } + + $dget['type_file'] = $_REQUEST['type_file']; + $dget['product_select'] = $_REQUEST['product_select']; + $dget['sql_select'] = $_REQUEST['sql_select']; + + if ($dget['type_file'] == "sql") { + $sql = "DELETE FROM endpointman_custom_configs WHERE id =" . $dget['sql_select']; + sql($sql); + unset ($sql); + $retarr = array("status" => true, "message" => "File delete ok!"); + } + else { $retarr = array("status" => false, "message" => _("Type File not valid!")); } + + unset($dget); + return $retarr; + } + + + /**** FUNCIONES SEC MODULO "epm_advanced\manual_upload" ****/ + public function epm_advanced_manual_upload_list_files_brans_export() + { + $path_tmp_dir = $this->PHONE_MODULES_PATH."temp/export/"; + $array_list_files = array(); + $array_count_brand = array(); + + + $array_list_exception= array(".", "..", ".htaccess"); + if(file_exists($path_tmp_dir)) + { + if(is_dir($path_tmp_dir)) + { + $l_files = scandir($path_tmp_dir, 1); + $i = 0; + foreach ($l_files as $archivo) { + if (in_array($archivo, $array_list_exception)) { continue; } + + $pathandfile = $path_tmp_dir.$archivo; + $brand = substr(pathinfo($archivo, PATHINFO_FILENAME), 0, -11); + $ftime = substr(pathinfo($archivo, PATHINFO_FILENAME), -10); + + $array_count_brand[] = $brand; + $array_list_files[$i] = array("brand" => $brand, + "pathall" => $pathandfile, + "path" => $path_tmp_dir, + "file" => $archivo, + "filename" => pathinfo($archivo, PATHINFO_FILENAME), + "extension" => pathinfo($archivo, PATHINFO_EXTENSION), + "timer" => $ftime, + "timestamp" => strftime("[%Y-%m-%d %H:%M:%S]", $ftime), + "mime_type" => mime_content_type($pathandfile), + "is_dir" => is_dir($pathandfile), + "is_file" => is_file($pathandfile), + "is_link" => is_link($pathandfile), + "readlink" => (is_link($pathandfile) == true ? readlink ($pathandfile) : NULL)); + + $i++; + } + unset ($l_files); + + $array_count_brand = array_count_values($array_count_brand); + ksort ($array_count_brand); + $array_count_brand_end = array(); + + foreach($array_count_brand as $key => $value) { + $array_count_brand_end[] = array('name' => $key , 'num' => $value); + } + + $retarr = array("status" => true, "message" => _("List Done!"), "countlist" => count($array_list_files), "list_files" => $array_list_files, "list_brands" => $array_count_brand_end ); + unset ($array_count_brand_end); + unset ($array_count_brand); + unset ($array_list_files); + } + else { + $retarr = array("status" => false, "message" => _("Not is directory: ") . $path_tmp_dir); + } + } else { + $retarr = array("status" => false, "message" => _("Directory no exists: ") . $path_tmp_dir); + } + return $retarr; + } + + public function epm_advanced_manual_upload_brand() + { + if (count($_FILES["files"]["error"]) == 0) { + out(_("Error: Can Not Find Uploaded Files!")); + } + else { + foreach ($_FILES["files"]["error"] as $key => $error) { + out(sprintf(_("Importing brand file %s..."), $_FILES["files"]["name"][$key])); + + if ($error != UPLOAD_ERR_OK) { + out(sprintf(_("Error: %s"), $this->file_upload_error_message($error))); + } + else { + $uploads_dir = $this->PHONE_MODULES_PATH . "temp"; + $name = $_FILES["files"]["name"][$key]; + $extension = pathinfo($name, PATHINFO_EXTENSION); + if ($extension == "tgz") { + $tmp_name = $_FILES["files"]["tmp_name"][$key]; + $uploads_dir_file = $uploads_dir."/".$name; + move_uploaded_file($tmp_name, $uploads_dir_file); + + if (file_exists($uploads_dir_file)) + { + $temp_directory = sys_get_temp_dir() . "/epm_temp/"; + if (!file_exists($temp_directory)) { + outn(_("Creating EPM temp directory...")); + if (mkdir($temp_directory) == true) { + out(_("Done!")); + } + else { + out(_("Error!")); + } + } + if (file_exists($temp_directory)) + { + if ($this->configmod->get('debug')) { + outn(sprintf(_("Extracting Tarball %s to %s... "), $uploads_dir_file, $temp_directory)); + } else { + outn(_("Extracting Tarball... ")); + } + //TODO: PENDIENTE VALIDAR SI EL EXEC NO DA ERROR!!!!! + exec("tar -xvf ".$uploads_dir_file." -C ".$temp_directory); + out(_("Done!")); + + $package = basename($name, ".tgz"); + $package = explode("-",$package); + + if ($this->configmod->get('debug')) { + out(sprintf(_("Looking for file %s to pass on to update_brand() ... "), $temp_directory.$package[0])); + } else { + out(_("Looking file and update brand's ... ")); + } + if(file_exists($temp_directory.$package[0])) { + $this->epm_config->update_brand($package[0],FALSE); + //Note: no need to delete/unlink/rmdir as this is handled in update_brand() + } else { + out(_("Please name the Package the same name as your brand!")); + } + } + } + else { + out(_("Error: No File Provided!")); + //echo "File ".$this->PHONE_MODULES_PATH."temp/".$_REQUEST['package']." not found.
"; + } + } + else { + out(_("Error: Invalid File Extension!")); + } + } + } + } + } + + public function epm_advanced_manual_upload_provisioner () + { + if (count($_FILES["files"]["error"]) == 0) { + out(_("Error: Can Not Find Uploaded Files!")); + } + else + { + foreach ($_FILES["files"]["error"] as $key => $error) { + out(sprintf(_("Importing Provisioner file %s..."), $_FILES["files"]["name"][$key])); + + if ($error != UPLOAD_ERR_OK) { + out(sprintf(_("Error: %s"), $this->file_upload_error_message($error))); + } + else { + $uploads_dir = $this->PHONE_MODULES_PATH . "temp/export"; + $name = $_FILES["files"]["name"][$key]; + $extension = pathinfo($name, PATHINFO_EXTENSION); + if ($extension == "tgz") + { + $tmp_name = $_FILES["files"]["tmp_name"][$key]; + $uploads_dir_file = $uploads_dir."/".$name; + move_uploaded_file($tmp_name, $uploads_dir_file); + + if (file_exists($uploads_dir_file)) { + outn(_("Extracting Provisioner Package... ")); + //TODO: Pendiente añadir validacion si exec no da error!!!! + exec("tar -xvf ".$uploads_dir_file." -C ".$uploads_dir."/"); + out(_("Done!")); + + if(!file_exists($this->PHONE_MODULES_PATH."endpoint")) { + outn(_("Creating Provisioner Directory... ")); + if (mkdir($this->PHONE_MODULES_PATH."endpoint") == true) { + out(_("Done!")); + } + else { + out(_("Error!")); + } + } + + if(file_exists($this->PHONE_MODULES_PATH."endpoint")) + { + $endpoint_last_mod = filemtime($this->PHONE_MODULES_PATH."temp/endpoint/base.php"); + rename($this->PHONE_MODULES_PATH."temp/endpoint/base.php", $this->PHONE_MODULES_PATH."endpoint/base.php"); + + outn(_("Updating Last Modified... ")); + $sql = "UPDATE endpointman_global_vars SET value = '".$endpoint_last_mod."' WHERE var_name = 'endpoint_vers'"; + sql($sql); + out(_("Done!")); + } + + } else { + out(_("Error: File Temp no Exists!")); + } + } else { + out(_("Error: Invalid File Extension!")); + } + } + } + } + } + + public function epm_advanced_manual_upload_export_brans_available_file() + { + if ((! isset($_REQUEST['file_package'])) OR ($_REQUEST['file_package'] == "")) { + header('HTTP/1.0 404 Not Found', true, 404); + echo "

Error 404 Not Found

"; + echo "No send name file!"; + die(); + } + else { + $dget['file_package'] = $_REQUEST['file_package']; + $path_tmp_file = $this->PHONE_MODULES_PATH."/temp/export/".$_REQUEST['file_package']; + + if (! file_exists($path_tmp_file)) { + header('HTTP/1.0 404 Not Found', true, 404); + echo "

Error 404 Not Found

"; + echo "File no exist!"; + die(); + } + else { + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="'.basename($dget['file_package']).'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($path_tmp_file)); + readfile($path_tmp_file); + exit; + } + unset ($path_tmp_file); + unset ($dget); + } + exit; + } + + public function epm_advanced_manual_upload_export_brans_available() + { + if ((! isset($_REQUEST['package'])) OR ($_REQUEST['package'] == "")) { + out(_("Error: No package set!")); + } + elseif ((! is_numeric($_REQUEST['package'])) OR ($_REQUEST['package'] < 0)) { + out(_("Error: Package not valid!")); + } + else { + $dget['package'] = $_REQUEST['package']; + + $sql = 'SELECT `name`, `directory` FROM `endpointman_brand_list` WHERE `id` = '.$dget['package'].''; + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + if ($row == "") { + out(_("Error: ID Package send not valid, brand not exist!")); + } + else { + outn(sprintf(_("Exporting %s ... "), $row['name'])); + + //TODO:Añadir validacion de si se ha creado el dire correctamente!!!! + if(!file_exists($this->PHONE_MODULES_PATH."/temp/export/")) { + mkdir($this->PHONE_MODULES_PATH."/temp/export/"); + } + $time = time(); + //TODO: Pendiente validar si exec no retorna error!!!!! + exec("tar zcf ".$this->PHONE_MODULES_PATH."temp/export/".$row['directory']."-".$time.".tgz --exclude .svn --exclude firmware -C ".$this->PHONE_MODULES_PATH."/endpoint ".$row['directory']); + out(_("Done!") . "
"); + + + out(_("Click this link to download:"). "
"); + out("" . _("Here").""); + //echo "Done! Click this link to download:Here"; + } + unset ($dget); + } + } + + + /**** FUNCIONES SEC MODULO "epm_advanced\iedl" ****/ + public function epm_advanced_iedl_export($sFileName = "devices_list.csv") + { + header("Content-type: text/csv"); + header('Content-Disposition: attachment; filename="'.$sFileName.'"'); + $outstream = fopen("php://output",'w'); + $sql = 'SELECT endpointman_mac_list.mac, endpointman_line_list.ipei, endpointman_brand_list.name, endpointman_model_list.model, endpointman_line_list.ext,endpointman_line_list.line FROM endpointman_mac_list, endpointman_model_list, endpointman_brand_list, endpointman_line_list WHERE endpointman_line_list.mac_id = endpointman_mac_list.id AND endpointman_model_list.id = endpointman_mac_list.model AND endpointman_model_list.brand = endpointman_brand_list.id'; + $result = sql($sql,'getAll',DB_FETCHMODE_ASSOC); + foreach($result as $row) { + fputcsv($outstream, $row); + } + fclose($outstream); + exit; + } + + //Dave B's Q&D file upload security code (http://us2.php.net/manual/en/features.file-upload.php) + public function epm_advanced_iedl_import() + { + if (count($_FILES["files"]["error"]) == 0) { + out(_("Error: Can Not Find Uploaded Files!")); + } + else + { + //$allowedExtensions = array("application/csv", "text/plain", "text/csv", "application/vnd.ms-excel"); + $allowedExtensions = array("csv", "txt"); + foreach ($_FILES["files"]["error"] as $key => $error) { + outn(sprintf(_("Importing CSV file %s ...
"), $_FILES["files"]["name"][$key])); + + if ($error != UPLOAD_ERR_OK) { + out(sprintf(_("Error: %s"), $this->file_upload_error_message($error))); + } + else + { + //if (!in_array($_FILES["files"]["type"][$key], $allowedExtensions)) { + if (!in_array(substr(strrchr($_FILES["files"]["name"][$key], "."), 1), $allowedExtensions)) { + out(sprintf(_("Error: We support only CSV and TXT files, type file %s no support!"), $_FILES["files"]["name"][$key])); + } + elseif ($_FILES["files"]["size"][$key] == 0) { + out(sprintf(_("Error: File %s size is 0!"), $_FILES["files"]["name"][$key])); + } + else { + $uploadfile = $this->LOCAL_PATH . basename($_FILES["files"]["name"][$key]); + $uploadtemp = $_FILES["files"]["tmp_name"][$key]; + + if (move_uploaded_file($uploadtemp, $uploadfile)) { + //Parse the uploaded file + $handle = fopen($uploadfile, "r"); + $i = 1; + while (($device = fgetcsv($handle, filesize($uploadfile))) !== FALSE) { + if ($device[0] != "") { + if ($mac = $this->mac_check_clean($device[0])) { + $sql = "SELECT id FROM endpointman_brand_list WHERE name LIKE '%" . $device[1] . "%' LIMIT 1"; + //$res = sql($sql); + $res = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + + if (count($res) > 0) { + $brand_id = sql($sql, 'getOne'); + // $brand_id = $brand_id[0]; + + $sql_model = "SELECT id FROM endpointman_model_list WHERE brand = " . $brand_id . " AND model LIKE '%" . $device[2] . "%' LIMIT 1"; + $sql_ext = "SELECT extension, name FROM users WHERE extension LIKE '%" . $device[3] . "%' LIMIT 1"; + + $line_id = isset($device[4]) ? $device[4] : 1; + + $res_model = sql($sql_model); + if (count($res_model)) { + $model_id = sql($sql_model, 'getRow', DB_FETCHMODE_ASSOC); + $model_id = $model_id['id']; + + $res_ext = sql($sql_ext); + if (count($res_ext)) { + $ext = sql($sql_ext, 'getRow', DB_FETCHMODE_ASSOC); + $description = $ext['name']; + $ext = $ext['extension']; +//TODO: PENDIENTE ASIGNAR OBJ +FreePBX::Endpointman()->add_device($mac, $model_id, $ext, 0, $line_id, $description); + + //out(_("Done!")); + } else { + out(sprintf(_("Error: Invalid Extension Specified on line %d!"), $i)); + } + } else { + out(sprintf(_("Error: Invalid Model Specified on line %d!"), $i)); + } + } else { + out(sprintf(_("Error: Invalid Brand Specified on line %d!"), $i)); + } + } else { + out(sprintf(_("Error: Invalid Mac on line %d!"), $i)); + } + } + $i++; + + } + fclose($handle); + unlink($uploadfile); + out(_("Please reboot & rebuild all imported phones")); + } else { + out(_("Error: Possible file upload attack!")); + } + } + } + } + } + } + + + /**** FUNCIONES SEC MODULO "epm_advanced\oui_manager" ****/ + private function epm_advanced_oui_remove() + { + //TODO: Añadir validacion de si es custom o no + if ((! isset($_REQUEST['id_del'])) OR ($_REQUEST['id_del'] == "")) { + $retarr = array("status" => false, "message" => _("No ID set!")); + } + elseif ((! is_numeric($_REQUEST['id_del'])) OR ($_REQUEST['id_del'] < 0)) { + $retarr = array("status" => false, "message" => _("ID not valid!"), "id" => $_REQUEST['id']); + } + else + { + $dget['id'] = $_REQUEST['id_del']; + + $sql = "DELETE FROM endpointman_oui_list WHERE id = " . $dget['id']; + sql($sql); + + $retarr = array("status" => true, "message" => "OK", "id" => $dget['id']); + unset($dget); + } + return $retarr; + } + + private function epm_advanced_oui_add() + { + //TODO: Pendiente añadir isExiste datos. + if ((! isset($_REQUEST['number_new_oui'])) OR ($_REQUEST['number_new_oui'] == "")) { + $retarr = array("status" => false, "message" => _("No OUI set!")); + } + elseif ((! isset($_REQUEST['brand_new_oui'])) OR ($_REQUEST['brand_new_oui'] == "")) { + $retarr = array("status" => false, "message" => _("No Brand set!")); + } + else { + $dget['oui'] = $_REQUEST['number_new_oui']; + $dget['brand'] = $_REQUEST['brand_new_oui']; + + $sql = "INSERT INTO endpointman_oui_list (oui, brand, custom) VALUES ('" . $dget['oui'] . "', '" . $dget['brand'] . "', '1')"; + sql($sql); + + $retarr = array("status" => true, "message" => "OK", "oui" => $dget['oui'], "brand" => $dget['brand']); + unset($dget); + } + return $retarr; + } + + + + + + + + + + + + + + + + + + + /** + * Fixes the display are special strings so we can visible see them instead of them being transformed + * @param string $contents a string of course + * @return string fixed string + */ + function display_htmlspecialchars($contents) { + $contents = str_replace("&", "&amp;", $contents); + $contents = str_replace("<", "&lt;", $contents); + $contents = str_replace(">", "&gt;", $contents); + $contents = str_replace(""", "&quot;", $contents); + $contents = str_replace("'", "&#039;", $contents); + return($contents); + } + + /** + * Taken from PHP.net. A list of errors returned when uploading files. + * @param $error_code + * @return string + */ + function file_upload_error_message($error_code) { + switch ($error_code) { + case UPLOAD_ERR_INI_SIZE: + return _('The uploaded file exceeds the upload_max_filesize directive in php.ini'); + case UPLOAD_ERR_FORM_SIZE: + return _('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'); + case UPLOAD_ERR_PARTIAL: + return _('The uploaded file was only partially uploaded'); + case UPLOAD_ERR_NO_FILE: + return _('No file was uploaded'); + case UPLOAD_ERR_NO_TMP_DIR: + return _('Missing a temporary folder'); + case UPLOAD_ERR_CANT_WRITE: + return _('Failed to write file to disk'); + case UPLOAD_ERR_EXTENSION: + return _('File upload stopped by extension'); + default: + return _('Unknown upload error'); + } + } + + /** + * This function takes a string and tries to determine if it's a valid mac addess, return FALSE if invalid + * @param string $mac The full mac address + * @return mixed The cleaned up MAC is it was a MAC or False if not a mac + */ + function mac_check_clean($mac) { + if ((strlen($mac) == "17") OR (strlen($mac) == "12")) { + //It might be better to use switch here instead of these IF statements... + //Is the mac separated by colons(:) or dashes(-)? + if (preg_match("/[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f][:-]" . + "[0-9a-f][0-9a-f]/i", $mac)) { + return(strtoupper(str_replace(":", "", str_replace("-", "", $mac)))); + //Is the string exactly 12 characters? + } elseif (strlen($mac) == "12") { + //Now is the string a valid HEX mac address? + if (preg_match("/[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]" . + "[0-9a-f][0-9a-f]/i", $mac)) { + return(strtoupper($mac)); + } else { + return(FALSE); + } + //Is the mac separated by whitespaces? + } elseif (preg_match("/[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f][\s]" . + "[0-9a-f][0-9a-f]/i", $mac)) { + return(strtoupper(str_replace(" ", "", $mac))); + } else { + return(FALSE); + } + } else { + return(FALSE); + } + } + + + +} diff --git a/Endpointman_Config.class.php b/Endpointman_Config.class.php new file mode 100644 index 00000000..c6379b32 --- /dev/null +++ b/Endpointman_Config.class.php @@ -0,0 +1,1709 @@ +freepbx = $freepbx; + $this->db = $freepbx->Database; + $this->config = $freepbx->Config; + $this->configmod = $cfgmod; + $this->system = $system; + + + $this->UPDATE_PATH = $this->configmod->get('update_server'); + $this->MODULES_PATH = $this->config->get('AMPWEBROOT') . '/admin/modules/'; + if (file_exists($this->MODULES_PATH . "endpointman/")) { + $this->LOCAL_PATH = $this->MODULES_PATH . "endpointman/"; + } else { + die("Can't Load Local Endpoint Manager Directory!"); + } + if (file_exists($this->MODULES_PATH . "_ep_phone_modules/")) { + $this->PHONE_MODULES_PATH = $this->MODULES_PATH . "_ep_phone_modules/"; + } else { + $this->PHONE_MODULES_PATH = $this->MODULES_PATH . "_ep_phone_modules/"; + if (!file_exists($this->PHONE_MODULES_PATH)) { + mkdir($this->PHONE_MODULES_PATH, 0775); + } + if (file_exists($this->PHONE_MODULES_PATH . "setup.php")) { + unlink($this->PHONE_MODULES_PATH . "setup.php"); + } + if (!file_exists($this->MODULES_PATH . "_ep_phone_modules/")) { + die('Endpoint Manager can not create the modules folder!'); + } + } + + } + + public function myShowPage(&$pagedata) { + } + + public function ajaxRequest($req, &$setting) { + $arrVal = array("saveconfig", "list_all_brand", "list_brand_model_hide"); + if (in_array($req, $arrVal)) { + $setting['authenticate'] = true; + $setting['allowremote'] = false; + return true; + } + return false; + } + + public function ajaxHandler($module_tab = "", $command = "") + { + $txt = array( + 'ayuda_model' => _("If we can activate the model set terminals of the models.
If this model is disabled will not appear in the list of models that can be configured for PBX."), + 'ayuda_producto' => _('The button "Install Firmware" installs the necessary files to the server for the terminal alone are updated via TFTP or HTTP.
The button "Remove frimware" delete files server products.
The button "Update frimware" appears if a newer frimware detected on the server and asks if you want to update.
The "Update" button appears when a new version of this model pack is detected.'), + 'ayuda_marca' => _('The "Install" button installs the configuration package brand models we selected.
The "Uninstall" button removes the package configuration models of the brand selected.
The "Update" button appears if a new version of the package that is already installed to upgrade to the latest version is detected.'), + 'new_pack_mod' => _("New Package Modified"), + 'pack_last_mod' => _("Package Last Modified"), + 'check_update' => _("Check for Update "), + 'check_online' => _("Check Online "), + 'install' => _("Install"), + 'uninstall' => _("Uninstall"), + 'update' => _("Update"), + 'fw_install' => _('FW Install'), + 'fw_uninstall' => _('FW Delete'), + 'fw_update' => _('FW Update'), + 'enable' => _('Enable'), + 'disable' => _('Disable'), + 'show' => _("Show"), + 'hide' => _("Hide"), + 'ready' => _("Ready!"), + 'error' => _("Error!"), + 'title_update' => _("Update!"), + 'save_changes' => _("Saving Changes..."), + 'save_changes_ok' => _("Saving Changes... Ok!"), + 'err_upload_content' => _("Upload Content!"), + 'check' => _("Check for Updates..."), + 'check_ok' => _("Check for Updates... Ok!"), + 'update_content' => _("Update Content..."), + 'opt_invalid' => _("Invalid Option!") + ); + + switch ($command) + { + case "saveconfig": + $retarr = $this->epm_config_manager_saveconfig(); + break; + + case "list_all_brand": + $retarr = array("status" => true, "message" => "OK", "datlist" => $this->epm_config_manager_hardware_get_list_all()); + break; + + case "list_brand_model_hide": + $retarr = array("status" => true, "message" => "OK", "datlist" => $this->epm_config_manager_hardware_get_list_all_hide_show()); + break; + + default: + $retarr = array("status" => false, "message" => _("Command not found!") . " [" .$command. "]"); + break; + } + $retarr['txt'] = $txt; + return $retarr; + } + + public function doConfigPageInit($module_tab = "", $command = "") { + switch ($command) { + case "check_for_updates": + $this->epm_config_manager_check_for_updates(); + echo "


"; + exit; + break; + + case "manual_install": + $this->epm_config_manual_install(); + echo "


"; + exit; + break; + + case "firmware": + $this->epm_config_manager_firmware(); + echo "


"; + exit; + break; + + case "brand": + $this->epm_config_manager_brand(); + echo "


"; + exit; + break; + } + } + + public function getRightNav($request) { + return ""; + } + + public function getActionBar($request) { + return ""; + } + + + /** + * Get info models by product id selected. + * @param int $id_product product ID + * @param bool $show_all True return all, False return hidden = 0 + * @return array + */ + public function epm_config_hardware_get_list_models($id_product=NULL, $show_all = true, $byorder = "model") + { + if(! is_numeric($id_product)) { throw new \Exception( _("ID Producto not is number")." (".$id_product.")"); } + if($show_all == true) { $sql = 'SELECT * FROM endpointman_model_list WHERE product_id = '.$id_product.' ORDER BY '.$byorder.' ASC'; } + else { $sql = 'SELECT * FROM endpointman_model_list WHERE hidden = 0 AND product_id = '.$id_product.' ORDER BY '.$byorder.' ASC'; } + $result = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + return $result; + } + + /** + * Get info product by brand id selected. + * @param int $id_brand brand ID + * @param bool $show_all True return all, FAlse return hidde = 0 + * @return array + */ + public function epm_config_hardware_get_list_product($id_brand=NULL, $show_all = true, $byorder = "long_name") + { + if(! is_numeric($id_brand)) { throw new \Exception(_("ID Brand not is numbre")." (".$id_brand.")"); } + if ($show_all == true) { $sql = 'SELECT * FROM endpointman_product_list WHERE brand = '.$id_brand.' ORDER BY '.$byorder.' ASC'; } + else { $sql = 'SELECT * FROM endpointman_product_list WHERE hidden = 0 AND brand = '.$id_brand.' ORDER BY '.$byorder.' ASC'; } + $result = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + return $result; + } + + /** + * Get info all brands. + * @param bool $show_all True return all, False return hidde = 0 + * @return array + */ + public function epm_config_hardware_get_list_brand($show_all = true, $byorder = "id") { + if ($show_all == true) { $sql = "SELECT * from endpointman_brand_list WHERE id > 0 ORDER BY " . $byorder . " ASC "; } + else { $sql = "SELECT * from endpointman_brand_list WHERE id > 0 AND hidden = 0 ORDER BY " . $byorder . " ASC "; } + $result = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + return $result; + } + + + /**** FUNCIONES SEC MODULO "epm_config\editor" ****/ + /** + * Get info all brdans, prodics, models. + * @return array + */ + /* + SE DESACTIVA A VERS SI NO SE USA EN NINGUN SITIO. + public function epm_config_editor_hardware_get_list_all () + { + $row_out = array(); + $i = 0; + foreach ($this->epm_config_hardware_get_list_brand(true, "name") as $row) + { + $row_out[$i] = $row; + $row_out[$i]['count'] = $i; + if ($row['installed']) + { + $j = 0; + foreach ($this->epm_config_hardware_get_list_product($row['id'], true) as $row2) + { + $row_out[$i]['products'][$j] = $row2; + $k = 0; + foreach ($this->epm_config_hardware_get_list_models($row2['id'], true) as $row3) { + $row_out[$i]['products'][$j]['models'][$k] = $row3; + $k++; + } + $j++; + } + } + $i++; + } + return $row_out; + } + */ + /*** END SEC FUNCTIONS ***/ + + + + + + + /**** FUNCIONES SEC MODULO "epm_config\manager" ****/ + private function epm_config_manager_check_for_updates () + { + out("

Update data...

"); + $this->update_check(true); + out ("All Done!"); + } + + private function epm_config_manager_brand() + { + $arrVal['VAR_REQUEST'] = array("command_sub", "idfw"); + foreach ($arrVal['VAR_REQUEST'] as $valor) { + if (! array_key_exists($valor, $_REQUEST)) { + out (_("Error: No send value!")." [".$valor."]"); + return false; + } + } + + $arrVal['VAR_IS_NUM'] = array("idfw"); + foreach ($arrVal['VAR_IS_NUM'] as $valor) { + if (! is_numeric($_REQUEST[$valor])) { + out (_("Error: Value send is not number!")." [".$valor."]"); + return false; + } + } + + $dget['command'] = strtolower($_REQUEST['command_sub']); + $dget['id'] = $_REQUEST['idfw']; + + switch($dget['command']) { + case "brand_install": + case "brand_update": + $this->download_brand($dget['id']); + break; + + case "brand_uninstall": + $this->remove_brand($dget['id']); + break; + + default: + out (_("Error: Command not found!")." [" . $dget['command'] . "]"); + } + $this->update_check(); + unset ($dget); + + return true; + } + + private function epm_config_manager_firmware() + { + $arrVal['VAR_REQUEST'] = array("command_sub", "idfw"); + foreach ($arrVal['VAR_REQUEST'] as $valor) { + if (! array_key_exists($valor, $_REQUEST)) { + out (_("Error: No send value!")." [".$valor."]"); + return false; + } + } + + $arrVal['VAR_IS_NUM'] = array("idfw"); + foreach ($arrVal['VAR_IS_NUM'] as $valor) { + if (! is_numeric($_REQUEST[$valor])) { + out (_("Error: Value send is not number!")." [".$valor."]"); + return false; + } + } + + $dget['command'] = strtolower($_REQUEST['command_sub']); + $dget['id'] = $_REQUEST['idfw']; + + switch($dget['command']) { + case "fw_install": + case "fw_update": + $this->install_firmware($dget['id']); + break; + + case "fw_uninstall": + $this->remove_firmware($dget['id']); + break; + + default: + out (_("Error: Command not found!")." [" . $dget['command'] . "]"); + } + + unset ($dget); + return true; + } + + private function epm_config_manager_saveconfig() + { + $arrVal['VAR_REQUEST'] = array("typesavecfg", "value", "idtype", "idbt"); + foreach ($arrVal['VAR_REQUEST'] as $valor) { + if (! array_key_exists($valor, $_REQUEST)) { + return array("status" => false, "message" => _("No send value!")." [".$valor."]"); + } + } + + $arrVal['VAR_IS_NUM'] = array("value", "idbt"); + foreach ($arrVal['VAR_IS_NUM'] as $valor) { + if (! is_numeric($_REQUEST[$valor])) { + return array("status" => false, "message" => _("Value send is not number!")." [".$valor."]"); + } + } + + $dget['typesavecfg'] = strtolower($_REQUEST['typesavecfg']); + $dget['value'] = strtolower($_REQUEST['value']); + $dget['idtype'] = strtolower($_REQUEST['idtype']); + $dget['id'] = $_REQUEST['idbt']; + + if (! in_array($dget['typesavecfg'], array("hidden", "enabled"))) { + return array("status" => false, "message" => _("Type Save Config is not valid!")." [".$dget['typesavecfg']."]"); + } + + if (($dget['value'] > 1 ) and ($dget['value'] < 0)) { + return array("status" => false, "message" => _("Invalid Value!")); + } + + + if ($dget['typesavecfg'] == "enabled") { + if (($dget['idtype']) == "modelo") { + $sql = "UPDATE endpointman_model_list SET enabled = " .$dget['value']. " WHERE id = '".$dget['id']."'"; + } + else { + $retarr = array("status" => false, "message" => _("IdType not valid to typesavecfg!")); + } + } + else { + switch($dget['idtype']) { + case "marca": + $sql = "UPDATE endpointman_brand_list SET hidden = '".$dget['value'] ."' WHERE id = '".$dget['id']."'"; + break; + + case "producto": + $sql = "UPDATE endpointman_product_list SET hidden = '". $dget['value'] ."' WHERE id = '".$dget['id']."'"; + break; + + case "modelo": + $sql = "UPDATE endpointman_model_list SET hidden = '". $dget['value'] ."' WHERE id = '".$dget['id']."'"; + break; + + default: + $retarr = array("status" => false, "message" => _("IDType invalid: ") . $dget['idtype'] ); + } + } + if (isset($sql)) { + sql($sql); + $retarr = array("status" => true, "message" => "OK", "typesavecfg" => $dget['typesavecfg'], "value" => $dget['value'], "idtype" => $dget['idtype'], "id" => $dget['id']); + unset($sql); + } + + unset($dget); + return $retarr; + } + + public function epm_config_manager_hardware_get_list_all_hide_show() + { + $row_out = array(); + + $i = 0; + $brand_list = $this->epm_config_hardware_get_list_brand(true, "name"); + foreach ($brand_list as $row) + { + //$row_out[$i] = $row; + $row_out[$i]['id'] = $row['id']; + $row_out[$i]['name'] = $row['name']; + $row_out[$i]['directory'] = $row['directory']; + $row_out[$i]['installed'] = $row['installed']; + $row_out[$i]['hidden'] = $row['hidden']; + $row_out[$i]['count'] = $i; + $row_out[$i]['products'] = ""; + if ($row['hidden'] == 1) + { + $i++; + continue; + } + + $j = 0; + $product_list = $this->epm_config_hardware_get_list_product($row['id'], true); + foreach($product_list as $row2) { + //$row_out[$i]['products'][$j] = $row2; + $row_out[$i]['products'][$j]['id'] = $row2['id']; + $row_out[$i]['products'][$j]['brand'] = $row2['brand']; + $row_out[$i]['products'][$j]['long_name'] = $row2['long_name']; + $row_out[$i]['products'][$j]['short_name'] = $row2['short_name']; + $row_out[$i]['products'][$j]['hidden'] = $row2['hidden']; + $row_out[$i]['products'][$j]['count'] = $j; + $row_out[$i]['products'][$j]['models'] = ""; + if ($row2['hidden'] == 1) + { + $j++; + continue; + } + + $k = 0; + $model_list = $this->epm_config_hardware_get_list_models($row2['id'], true); + foreach($model_list as $row3) + { + //$row_out[$i]['products'][$j]['models'][$k] = $row3; + $row_out[$i]['products'][$j]['models'][$k]['id'] = $row3['id']; + $row_out[$i]['products'][$j]['models'][$k]['brand'] = $row3['brand']; + $row_out[$i]['products'][$j]['models'][$k]['model'] = $row3['model']; + $row_out[$i]['products'][$j]['models'][$k]['product_id'] = $row3['product_id']; + $row_out[$i]['products'][$j]['models'][$k]['enabled'] = $row3['enabled']; + $row_out[$i]['products'][$j]['models'][$k]['hidden'] = $row3['hidden']; + $row_out[$i]['products'][$j]['models'][$k]['count'] = $k; + $k++; + } + $j++; + } + $i++; + } + //echo ""; + return $row_out; + } + + + //TODO: PENDIENTE ACTUALIZAR Y ELIMINAR DATOS NO NECESARIOS (TEMPLATES) + //http://pbx.cerebelum.lan/admin/ajax.php?module=endpointman&module_sec=epm_config&module_tab=manager&command=list_all_brand + public function epm_config_manager_hardware_get_list_all() + { + $row_out = array(); + $i = 0; + $brand_list = $this->epm_config_hardware_get_list_brand(true, "name"); + //FIX: https://github.com/FreePBX-ContributedModules/endpointman/commit/2ad929d0b38f05c9da1b847426a4094c3314be3b + + foreach ($brand_list as $row) + { + $row_out[$i] = $row; + $row_out[$i]['count'] = $i; + $row_out[$i]['cfg_ver_datetime'] = $row['cfg_ver']; + $row_out[$i]['cfg_ver_datetime_txt'] = date("c",$row['cfg_ver']); + + $row_mod = $this->brand_update_check($row['directory']); + $row_out[$i]['update'] = $row_mod['update']; + if(isset($row_mod['update_vers'])) { + $row_out[$i]['update_vers'] = $row_mod['update_vers']; + $row_out[$i]['update_vers_txt'] = date("c",$row_mod['update_vers']); + } + + if (! isset($row_out[$i]['update'])) { $row_out[$i]['update'] = ""; } + if (! isset($row_out[$i]['update_vers'])) { $row_out[$i]['update_vers'] = $row_out[$i]['cfg_ver_datetime']; } + if (! isset($row_out[$i]['update_vers_txt'])) { $row_out[$i]['update_vers_txt'] = $row_out[$i]['cfg_ver_datetime_txt']; } + + if ($row['hidden'] == 1) + { + $i++; + continue; + } + + + $j = 0; + $product_list = $this->epm_config_hardware_get_list_product($row['id'], true); + foreach($product_list as $row2) { + $row_out[$i]['products'][$j] = $row2; + if((array_key_exists('firmware_vers', $row2)) AND ($row2['firmware_vers'] > 0)) { + $temp = $this->firmware_update_check($row2['id']); + $row_out[$i]['products'][$j]['update_fw'] = 1; + $row_out[$i]['products'][$j]['update_vers_fw'] = $temp['data']['firmware_ver']; + } else { + $row_out[$i]['products'][$j]['update_fw'] = 0; + $row_out[$i]['products'][$j]['update_vers_fw'] = ""; + } + if (! isset($row_out[$i]['products'][$j]['update_fw'])) { $row_out[$i]['products'][$j]['update_fw'] = 0; } + if (! isset($row_out[$i]['products'][$j]['update_vers_fw'])) { $row_out[$i]['products'][$j]['update_vers_fw'] = ""; } + + + $row_out[$i]['products'][$j]['fw_type'] = $this->firmware_local_check($row2['id']); + $row_out[$i]['products'][$j]['count'] = $j; + if ($row2['hidden'] == 1) + { + $j++; + continue; + } + + $k = 0; + $model_list = $this->epm_config_hardware_get_list_models($row2['id'], true); + foreach($model_list as $row3) + { + $row_out[$i]['products'][$j]['models'][$k] = $row3; + + unset ($row_out[$i]['products'][$j]['models'][$k]['template_list']); + unset ($row_out[$i]['products'][$j]['models'][$k]['template_data']); + + if($row_out[$i]['products'][$j]['models'][$k]['enabled']){ + $row_out[$i]['products'][$j]['models'][$k]['enabled_checked'] = 'checked'; + } + $row_out[$i]['products'][$j]['models'][$k]['count'] = $k; + $k++; + } + $j++; + } + + + $i++; + } + //echo ""; + return $row_out; + } + /*** END SEC FUNCTIONS ***/ + + + + + function brand_update_check($brand_name_find = NULL) + { + if ($brand_name_find == NULL) { return $this->brand_update_check_all(); } + + $sql = "SELECT * FROM endpointman_brand_list WHERE directory = '" . $brand_name_find . "'"; + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $out = array(); + if (! isset($row['directory'])) + { + $out['update'] = -2; + } + else + { + if (file_exists($this->PHONE_MODULES_PATH . "endpoint/" . $row['directory'] . "/brand_data.json")) + { + $temp = $this->file2json($this->PHONE_MODULES_PATH . "endpoint/" . $row['directory'] . "/brand_data.json"); + $temp = $temp['data']['brands']; + + $version = $temp['last_modified']; + $last_mod = ""; + foreach ($temp['family_list'] as $list) { + $last_mod = max($last_mod, $list['last_modified']); + } + $last_mod = max($last_mod, $version); + $version = $last_mod; + + if ($row['cfg_ver'] < $version) { + $out['update'] = 1; + $out['update_vers'] = $version; + } else { + $out['update'] = NULL; + $out['update_vers'] = $version; + } + } + else { + $out['update'] = -1; + } + } + return $out; + } + + + + function brand_update_check_all() + { + $temp = $this->file2json($this->PHONE_MODULES_PATH . 'endpoint/master.json'); + $endpoint_package = $temp['data']['package']; + $endpoint_last_mod = $temp['data']['last_modified']; + + $version = array(); + $out = $temp['data']['brands']; + foreach ($out as $data) { + if (file_exists($this->PHONE_MODULES_PATH . "endpoint/" . $data['directory'] . "/brand_data.json")) { + $temp = $this->file2json($this->PHONE_MODULES_PATH . "endpoint/" . $data['directory'] . "/brand_data.json"); + $temp = $temp['data']['brands']; + + $brand_name = $temp['directory']; + $version[$brand_name] = $temp['last_modified']; + $last_mod = ""; + foreach ($temp['family_list'] as $list) { + $last_mod = max($last_mod, $list['last_modified']); + } + $last_mod = max($last_mod, $version[$brand_name]); + $version[$brand_name] = $last_mod; + } + } + + $sql = 'SELECT * FROM endpointman_brand_list WHERE id > 0'; + $row = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach ($row as $ava_brands) { + $key = $this->system->arraysearchrecursive($ava_brands['directory'], $out, 'directory'); + + if ($key === FALSE) { + $tmp = $ava_brands; + $tmp['update'] = -1; + $out[] = $tmp; + } + else { + $key = $key[0]; + $brand_name = $ava_brands['directory']; + if (! isset($version[$brand_name])) { $version[$brand_name] = 0; } + if ($ava_brands['cfg_ver'] < $version[$brand_name]) { + $out[$key]['update'] = 1; + $out[$key]['update_vers'] = $version[$brand_name]; + } else { + $out[$key]['update'] = NULL; + } + } + } + return $out; + } + + + + /** + * Check for new packges for brands. These packages will include phone models and such which the user can remove if they want + * This function will alos auto-update the provisioner.net library incase anything has changed + * @return array An array of all the brands/products/models and information about what's enabled, installed or otherwise + */ + function update_check($echomsg = false, &$error=array()) { + //$temp_location = $this->system->sys_get_temp_dir() . "/epm_temp/"; + $temp_location = $this->PHONE_MODULES_PATH . "temp/provisioner/"; + if (!$this->configmod->get('use_repo')) { + if ($echomsg == true) { + $master_result = $this->system->download_file_with_progress_bar($this->UPDATE_PATH . "master.json", $this->PHONE_MODULES_PATH . "endpoint/master.json"); + } else { + $master_result = $this->system->download_file($this->UPDATE_PATH . "master.json", $this->PHONE_MODULES_PATH . "endpoint/master.json"); + } + + + if (!$master_result || !file_exists($this->PHONE_MODULES_PATH . "endpoint/master.json")) { + $error['brand_update_check_master'] = _("Error: Not able to connect to repository. Using local master file instead."); + if ($echomsg == true ) { + out($error['brand_update_check_master']); + } + } + + $temp = $this->file2json($this->PHONE_MODULES_PATH . 'endpoint/master.json'); + $endpoint_package = $temp['data']['package']; + $endpoint_last_mod = $temp['data']['last_modified']; + + $sql = "SELECT value FROM endpointman_global_vars WHERE var_name LIKE 'endpoint_vers'"; + $data = sql($sql, 'getOne'); + + $contents = file_get_contents($this->UPDATE_PATH . "/update_status"); + + if ($contents != '1') { + if (($data == "") OR ($data <= $endpoint_last_mod)) { + if ((!$master_result) OR (!$this->system->download_file($this->UPDATE_PATH . '/' . $endpoint_package, $temp_location . $endpoint_package))) + { + $error['brand_update_check_json'] = _("Not able to connect to repository. Using local Provisioner.net Package"); + if ($echomsg == true ) { + out($error['brand_update_check_json']); + } + } else { + exec("tar -xvf " . $temp_location . $endpoint_package . " -C " . $temp_location); + if (!file_exists($this->PHONE_MODULES_PATH . "endpoint")) { + mkdir($this->PHONE_MODULES_PATH . "endpoint"); + } + + //TODO: Automate this somehow... + rename($temp_location . "setup.php", $this->PHONE_MODULES_PATH . "setup.php"); + rename($temp_location . "autoload.php", $this->PHONE_MODULES_PATH . "autoload.php"); + rename($temp_location . "endpoint/base.php", $this->PHONE_MODULES_PATH . "endpoint/base.php"); + rename($temp_location . "endpoint/global_template_data.json", $this->PHONE_MODULES_PATH . "endpoint/global_template_data.json"); + $sql = "UPDATE endpointman_global_vars SET value = '" . $endpoint_last_mod . "' WHERE var_name = 'endpoint_vers'"; + sql($sql); + } + } + + $out = $temp['data']['brands']; + //Assume that if we can't connect and find the master.xml file then why should we try to find every other file. + if ($master_result) { + $sql = 'SELECT * FROM endpointman_brand_list WHERE id > 0'; + $row = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach ($out as $data) { + + $local = sql("SELECT local FROM endpointman_brand_list WHERE directory = '" . $data['directory'] . "'", 'getOne'); + if (!$local) { + if ($echomsg == true) { + out(sprintf(_("Update Brand (%s):"), $data['name'])); + $result = $this->system->download_file_with_progress_bar($this->UPDATE_PATH . $data['directory'] . "/" . $data['directory'] . ".json", $this->PHONE_MODULES_PATH . "endpoint/" . $data['directory'] . "/brand_data.json"); + } else { + $result = $this->system->download_file($this->UPDATE_PATH . $data['directory'] . "/" . $data['directory'] . ".json", $this->PHONE_MODULES_PATH . "endpoint/" . $data['directory'] . "/brand_data.json"); + } + if (!$result) { + $error['brand_update_check'] = sprintf(_("Not able to connect to repository. Using local brand [%s] file instead."), $data['name']); + if ($echomsg == true ) { + out($error['brand_update_check']); + } + } + } + + if (file_exists($this->PHONE_MODULES_PATH . "endpoint/" . $data['directory'] . "/brand_data.json")) { + $temp = $this->file2json($this->PHONE_MODULES_PATH . "endpoint/" . $data['directory'] . "/brand_data.json"); + $temp = $temp['data']['brands']; + if (array_key_exists('oui_list', $temp)) { + foreach ($temp['oui_list'] as $oui) { + $sql = "REPLACE INTO endpointman_oui_list (`oui`, `brand`, `custom`) VALUES ('" . $oui . "', '" . $temp['brand_id'] . "', '0')"; + sql($sql); + } + } + $brand_name = $temp['directory']; + $version[$brand_name] = $temp['last_modified']; + $last_mod = ""; + foreach ($temp['family_list'] as $list) { + $last_mod = max($last_mod, $list['last_modified']); + } + $last_mod = max($last_mod, $version[$brand_name]); + $version[$brand_name] = $last_mod; + + if (!($this->system->arraysearchrecursive($brand_name, $row, 'directory'))) + { + $sql = 'SELECT directory FROM endpointman_brand_list where id = "'.$temp['brand_id'].'"'; + $datoif = sql($sql, 'getOne'); + if ($datoif != "") { + $error['brand_update_id_exist_other_brand'] = sprintf(_("You can not add the mark (%s) as the ID (%d) already exists in the database!"), $temp['name'], $temp['brand_id']); + if ($echomsg == true ) { + out($error['brand_update_id_exist_other_brand']); + } + } + else { + $sql = "INSERT INTO endpointman_brand_list (id, name, directory, cfg_ver) VALUES ('" . $temp['brand_id'] . "', '" . $temp['name'] . "', '" . $temp['directory'] . "', '" . $version[$brand_name] . "')"; + sql($sql); + } + } else { + //in database already! + } + } else { + $error['brand_update_check_local_file'] = sprintf(_("Error: No Local File for %s !"), $data['name'])."
"._("Learn how to manually upload packages here (it's easy!):").""._("Click Here!").""; + if ($echomsg == true ) { + out($error['brand_update_check_local_file']); + } + } + } + + foreach ($row as $ava_brands) { + $key = $this->system->arraysearchrecursive($ava_brands['directory'], $out, 'directory'); + if ($key === FALSE) { + $this->remove_brand($ava_brands['id']); + } else { + $key = $key[0]; + $brand_name = $ava_brands['directory']; + //TODO: This seems old + if ($ava_brands['cfg_ver'] < $version[$brand_name]) { + $out[$key]['update'] = 1; + $out[$key]['update_vers'] = $version[$brand_name]; + } else { + $out[$key]['update'] = NULL; + } + } + } + } else { + $error['brand_update_check_master_file'] = _("Error: Aborting Brand Downloads. Can't Get Master File, Assuming Timeout Issues!")."
"._("Learn how to manually upload packages here (it's easy!):").""._("Click Here!").""; + if ($echomsg == true ) { + out($error['brand_update_check_local_file']); + } + } + return $out; + } else { + $error['remote_server'] = _("Error: The Remote Server Is Currently Syncing With the Master Server, Please try again later"); + if ($echomsg == true ) { + out($error['remote_server']); + } + } + } else { + $o = getcwd(); + chdir(dirname($this->PHONE_MODULES_PATH)); + $path = $this->has_git(); + exec($path . ' git pull', $output); + //exec($path . ' git checkout master', $output); //Why am I doing this? + chdir($o); + $temp = $this->file2json($this->PHONE_MODULES_PATH . 'endpoint/master.json'); + $endpoint_package = $temp['data']['package']; + $endpoint_last_mod = $temp['data']['last_modified']; + + $sql = "UPDATE endpointman_global_vars SET value = '" . $endpoint_last_mod . "' WHERE var_name = 'endpoint_vers'"; + sql($sql); + + $out = $temp['data']['brands']; + $row = sql('SELECT * FROM endpointman_brand_list WHERE id > 0', 'getAll', DB_FETCHMODE_ASSOC); + + foreach ($out as $data) { + $temp = $this->file2json($this->PHONE_MODULES_PATH . 'endpoint/' . $data['directory'] . '/brand_data.json'); + if (key_exists('directory', $temp['data']['brands'])) { + + //Pull in all variables + $directory = $temp['data']['brands']['directory']; + $brand_name = $temp['data']['brands']['name']; + $brand_id = $temp['data']['brands']['brand_id']; + $brand_version = $temp['data']['brands']['last_modified']; + + $b_data = sql("SELECT id FROM endpointman_brand_list WHERE id = '" . $brand_id . "'", 'getOne'); + if ($b_data) { + $sql = "UPDATE endpointman_brand_list SET local = '1', name = '" . $brand_name . "', cfg_ver = '" . $brand_version . "', installed = 1, hidden = 0 WHERE id = " . $brand_id; + sql($sql); + } else { + $sql = "INSERT INTO endpointman_brand_list (id, name, directory, cfg_ver, local, installed) VALUES ('" . $brand_id . "', '" . $brand_name . "', '" . $directory . "', '" . $brand_version . "', '1', '1')"; + sql($sql); + } + + $last_mod = ""; + foreach ($temp['data']['brands']['family_list'] as $family_list) { + $last_mod = max($last_mod, $family_list['last_modified']); + + $family_line_xml = $this->file2json($this->PHONE_MODULES_PATH . '/endpoint/' . $directory . '/' . $family_list['directory'] . '/family_data.json'); + $family_line_xml['data']['last_modified'] = isset($family_line_xml['data']['last_modified']) ? $family_line_xml['data']['last_modified'] : ''; + + /* DONT DO THIS YET + $require_firmware = NULL; + if ((key_exists('require_firmware', $family_line_xml['data'])) && ($remote) && ($family_line_xml['data']['require_firmware'] == "TRUE")) { + echo "Firmware Requirment Detected!..........
"; + $this->install_firmware($family_line_xml['data']['id']); + } + * + */ + + $data = sql("SELECT id FROM endpointman_product_list WHERE id='" . $brand_id . $family_line_xml['data']['id'] . "'", 'getOne'); + $short_name = preg_replace("/\[(.*?)\]/si", "", $family_line_xml['data']['name']); + if ($data) { + $sql = "UPDATE endpointman_product_list SET short_name = '" . $short_name . "', long_name = '" . $family_line_xml['data']['name'] . "', cfg_ver = '" . $family_line_xml['data']['version'] . "', config_files='" . $family_line_xml['data']['configuration_files'] . "' WHERE id = '" . $brand_id . $family_line_xml['data']['id'] . "'"; + } else { + $sql = "INSERT INTO endpointman_product_list (`id`, `brand`, `short_name`, `long_name`, `cfg_dir`, `cfg_ver`, `config_files`, `hidden`) VALUES ('" . $brand_id . $family_line_xml['data']['id'] . "', '" . $brand_id . "', '" . $short_name . "', '" . $family_line_xml['data']['name'] . "', '" . $family_line_xml['data']['directory'] . "', '" . $family_line_xml['data']['last_modified'] . "','" . $family_line_xml['data']['configuration_files'] . "', '0')"; + } + sql($sql); + + foreach ($family_line_xml['data']['model_list'] as $model_list) { + $template_list = implode(",", $model_list['template_data']); + + $m_data = sql("SELECT id FROM endpointman_model_list WHERE id='" . $brand_id . $family_line_xml['data']['id'] . $model_list['id'] . "'", 'getOne'); + if ($m_data) { + $sql = "UPDATE endpointman_model_list SET max_lines = '" . $model_list['lines'] . "', model = '" . $model_list['model'] . "', template_list = '" . $template_list . "' WHERE id = '" . $brand_id . $family_line_xml['data']['id'] . $model_list['id'] . "'"; + } else { + $sql = "INSERT INTO endpointman_model_list (`id`, `brand`, `model`, `max_lines`, `product_id`, `template_list`, `enabled`, `hidden`) VALUES ('" . $brand_id . $family_line_xml['data']['id'] . $model_list['id'] . "', '" . $brand_id . "', '" . $model_list['model'] . "', '" . $model_list['lines'] . "', '" . $brand_id . $family_line_xml['data']['id'] . "', '" . $template_list . "', '0', '0')"; + } + sql($sql); + + if (!$this->sync_model($brand_id . $family_line_xml['data']['id'] . $model_list['id'], $errsync_modal)) { + $error['sync_module_error'] = sprintf(_("Error: System Error in Sync Model [%s] Function, Load Failure!"), $model_list['model']); + if ($echomsg == true ) { + out($error['sync_module_error']); + foreach ($errsync_modal as $v) { + out($v); + } + } + } + unset($errsync_modal); + } + //Phone Models Move Here + $family_id = $brand_id . $family_line_xml['data']['id']; + $sql = "SELECT * FROM endpointman_model_list WHERE product_id = " . $family_id; + $products = sql($sql, 'getall', DB_FETCHMODE_ASSOC); + foreach ($products as $data) { + if (!$this->system->arraysearchrecursive($data['model'], $family_line_xml['data']['model_list'], 'model')) { + if ($echomsg == true ) { + outn(sprintf(_("Moving/Removing Model '%s' not present in JSON file......"), $data['model'])); + } + + $model_name = $data['model']; + $sql = 'DELETE FROM endpointman_model_list WHERE id = ' . $data['id']; + sql($sql); + $sql = "SELECT id FROM endpointman_model_list WHERE model LIKE '" . $model_name . "'"; + $new_model_id = sql($sql, 'getOne'); + if ($new_model_id) { + $sql = "UPDATE endpointman_mac_list SET model = '" . $new_model_id . "' WHERE model = '" . $data['id'] . "'"; + } else { + $sql = "UPDATE endpointman_mac_list SET model = '0' WHERE model = '" . $data['id'] . "'"; + } + sql($sql); + out (_("Done!")); + } + } + } + foreach ($temp['data']['brands']['oui_list'] as $oui) { + $sql = "REPLACE INTO endpointman_oui_list (`oui`, `brand`, `custom`) VALUES ('" . $oui . "', '" . $brand_id . "', '0')"; + sql($sql); + } + } + } + } + } + + /** + * Sync the XML files (incuding all template files) from the hard drive with the database + * @param int $model Model ID + * @return boolean True on sync completed. False on sync failed + */ + function sync_model($model, &$error = array()) { + if ((!empty($model)) OR ($model > 0)) { + $sql = "SELECT * FROM endpointman_model_list WHERE id='" . $model . "'"; + $model_row = sql($sql, 'getrow', DB_FETCHMODE_ASSOC); + + $sql = "SELECT * FROM endpointman_product_list WHERE id='" . $model_row['product_id'] . "'"; + $product_row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $sql = "SELECT * FROM endpointman_brand_list WHERE id=" . $model_row['brand']; + $brand_row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + + $path_brand_dir = $this->PHONE_MODULES_PATH . '/endpoint/' . $brand_row['directory']; + $path_brand_dir_cfg = $path_brand_dir . '/' . $product_row['cfg_dir']; + $path_brand_dir_cfg_json = $path_brand_dir_cfg . '/family_data.json'; + + if (!file_exists($path_brand_dir)) { + $error['sync_model'] = sprintf(_("Brand Directory '%s' Doesn't Exist! (%s)"), $brand_row['directory'], $path_brand_dir); + return(FALSE); + } + if (!file_exists($path_brand_dir_cfg)) { + $error['sync_model'] = sprintf(_("Product Directory '%s' Doesn't Exist! (%s)"), $product_row['cfg_dir'], $path_brand_dir_cfg); + return(FALSE); + } + if (!file_exists($path_brand_dir_cfg_json)) { + $error['sync_model'] = sprintf(_("File 'family_data.json' Doesn't exist in directory: %s"), $path_brand_dir_cfg); + return(FALSE); + } + $family_line_json = $this->file2json($path_brand_dir_cfg_json); + + + //TODO: Add local file checks to avoid slow reloading on PHP < 5.3 + $key = $this->system->arraysearchrecursive($model_row['model'], $family_line_json['data']['model_list'], 'model'); + if ($key === FALSE) { + $error['sync_model'] = "Can't locate model in family JSON file"; + return(FALSE); + } else { + $template_list = implode(",", $family_line_json['data']['model_list'][$key[0]]['template_data']); + $template_list_array = $family_line_json['data']['model_list'][$key[0]]['template_data']; + } + $maxlines = $family_line_json['data']['model_list'][$key[0]]['lines']; + + $sql = "UPDATE endpointman_model_list SET max_lines = '" . $maxlines . "', template_list = '" . $template_list . "' WHERE id = '" . $model . "'"; + sql($sql); + + $version = isset($family_line_json['data']['last_modified']) ? $family_line_json['data']['last_modified'] : ''; + $long_name = $family_line_json['data']['name']; + $short_name = preg_replace("/\[(.*?)\]/si", "", $family_line_json['data']['name']); + $configuration_files = $family_line_json['data']['configuration_files']; + + $sql = "UPDATE endpointman_product_list SET long_name = '" . str_replace("'", "''", $long_name) . "', short_name = '" . str_replace("'", "''", $short_name) . "' , cfg_ver = '" . $version . "' WHERE id = '" . $product_row['id'] . "'"; + sql($sql); + + $template_data_array = array(); + $template_data_array = $this->merge_data($this->PHONE_MODULES_PATH . '/endpoint/' . $brand_row['directory'] . '/' . $product_row['cfg_dir'] . '/', $template_list_array); + + $sql = "UPDATE endpointman_model_list SET template_data = '" . serialize($template_data_array) . "' WHERE id = '" . $model . "'"; + sql($sql); + return(TRUE); + } else { + return(FALSE); + } + } + + /** + * This will download the xml & brand package remotely + * @param integer $id Brand ID + */ + function download_brand($id) { + out(_("Install/Update Brand...")); + if (!$this->configmod->get('use_repo')) { + $temp_directory = $this->system->sys_get_temp_dir() . "/epm_temp/"; + + if (!file_exists($temp_directory)) { + out(_("Creating EPM temp directory")); + if (! mkdir($temp_directory)) { + out(sprintf(_("Error: Failed to create the directory '%s', please Check Permissions!"), $temp_directory)); + return false; + } + } + + outn(_("Downloading Brand JSON..... ")); + $row = sql('SELECT * FROM endpointman_brand_list WHERE id =' . $id, 'getAll', DB_FETCHMODE_ASSOC); + $result = $this->system->download_file($this->UPDATE_PATH . $row[0]['directory'] . "/" . $row[0]['directory'] . ".json", $this->PHONE_MODULES_PATH . "endpoint/" . $row[0]['directory'] . "/brand_data.json"); + if ($result) { + out(_("Done!")); + + $temp = $this->file2json($this->PHONE_MODULES_PATH . 'endpoint/' . $row[0]['directory'] . '/brand_data.json'); + $package = $temp['data']['brands']['package']; + + out(_("Downloading Brand Package...")); + if ($this->system->download_file_with_progress_bar($this->UPDATE_PATH . $row[0]['directory'] . '/' . $package, $temp_directory . $package)) + { + if (file_exists($temp_directory . $package)) { + $md5_xml = $temp['data']['brands']['md5sum']; + $md5_pkg = md5_file($temp_directory . $package); + + outn(_("Checking MD5sum of Package.... ")); + if ($md5_xml == $md5_pkg) { + out(_("Done!")); + + outn(_("Extracting Tarball........ ")); + //TODO: PENDIENTE VALIDAR SI DA ERROR LA DESCOMPRESION + exec("tar -xvf " . $temp_directory . $package . " -C " . $temp_directory); + out(_("Done!")); + + //Update File in the temp directory + copy($this->PHONE_MODULES_PATH . 'endpoint/' . $row[0]['directory'] . '/brand_data.json', $temp_directory . $row[0]['directory'] . '/brand_data.json'); + $this->update_brand($row[0]['directory'], TRUE); + } else { + out(_("MD5 Did not match!")); + out(sprintf(_("MD5 XML: %s"), $md5_xml)); + out(sprintf(_("MD5 PKG: %s"), $md5_pkg)); + } + } else { + out(_("Error: Can't Find Downloaded File!")); + } + } else { + out(_("Error download Brand package!")); + } + } else { + out(_("Error!")); + out(_("Error Connecting to the Package Repository. Module not installed. Please Try again later.")); + out(_("You Can Also Manually Update The Repository By Downloading Files here: Release Repo ")); + out(_("Then Use Manual Upload in Advanced Settings.")); + } + } else { + out(_("Error: Installing brands is disabled while in repo mode!")); + } + } + + /** + * This will install or updated a brand package (which is the same thing to this) + * Still needs way to determine when models move...perhaps another function? + */ + function update_brand($package, $remote=TRUE) { + out(sprintf(_("Update Brand %s ... "), $package)); + + $temp_directory = $this->system->sys_get_temp_dir() . "/epm_temp/"; + //DEBUG + out(_("Processing ".$temp_directory.$package."/brand_data.json...")); + + if (file_exists($temp_directory . $package . '/brand_data.json')) { + $temp = $this->file2json($temp_directory . $package . '/brand_data.json'); + if (key_exists('directory', $temp['data']['brands'])) { + out(_("Appears to be a valid Provisioner.net JSON file.....Continuing")); + //Pull in all variables + $directory = $temp['data']['brands']['directory']; + $brand_name = $temp['data']['brands']['name']; + $brand_id = $temp['data']['brands']['brand_id']; + $brand_version = $temp['data']['brands']['last_modified']; + + //create directory structure and move files + out(sprintf(_("Creating Directory Structure for Brand '%s' and Moving Files..."), $brand_name)); + + if (!file_exists($this->PHONE_MODULES_PATH . "endpoint/" . $directory)) { + mkdir($this->PHONE_MODULES_PATH . "endpoint/" . $directory); + } + + $dir_iterator = new \RecursiveDirectoryIterator($temp_directory . $directory . "/"); + $iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::SELF_FIRST); + foreach ($iterator as $file) { + if (is_dir($file)) { + $dir = str_replace($temp_directory . $directory . "/", "", $file); + if (!file_exists($this->PHONE_MODULES_PATH . "endpoint/" . $directory . "/" . $dir)) { + mkdir($this->PHONE_MODULES_PATH . "endpoint/" . $directory . "/" . $dir, 0775, TRUE); +//echo "."; + } + } else { + if ((basename($file) != "brand_data.json") OR (!$remote)) { + $dir = str_replace($temp_directory . $directory . "/", "", $file); + $stats = rename($file, $this->PHONE_MODULES_PATH . "endpoint/" . $directory . "/" . $dir); + if ($stats === FALSE) { + out(sprintf(_("- Error Moving %s!"), basename($file))); + } + chmod($this->PHONE_MODULES_PATH . "endpoint/" . $directory . "/" . $dir, 0775); +//echo "."; + } + } + } + out(_("All Done!")); + + if ($remote) { + $local = 0; + } else { + $local = 1; + } + + $b_data = sql("SELECT id FROM endpointman_brand_list WHERE id = '" . $brand_id . "'", 'getOne'); + if ($b_data) { + outn(sprintf(_("Updating %s brand data ..."), $brand_name)); + $sql = "UPDATE endpointman_brand_list SET local = '" . $local . "', name = '" . $brand_name . "', cfg_ver = '" . $brand_version . "', installed = 1, hidden = 0 WHERE id = " . $brand_id; + sql($sql); + out(_("Done!")); + } else { + outn(sprintf(_("Inserting %s brand data ..."), $brand_name)); + $sql = "INSERT INTO endpointman_brand_list (id, name, directory, cfg_ver, local, installed) VALUES ('" . $brand_id . "', '" . $brand_name . "', '" . $directory . "', '" . $brand_version . "', '" . $local . "', '1')"; + sql($sql); + out(_("Done!")); + } + + $last_mod = ""; + foreach ($temp['data']['brands']['family_list'] as $family_list) { + out(_("Updating Family Lines ...")); + + $last_mod = max($last_mod, $family_list['last_modified']); + + $family_line_xml = $this->file2json($this->PHONE_MODULES_PATH . '/endpoint/' . $directory . '/' . $family_list['directory'] . '/family_data.json'); + $family_line_xml['data']['last_modified'] = isset($family_line_xml['data']['last_modified']) ? $family_line_xml['data']['last_modified'] : ''; + + $require_firmware = NULL; + if ((key_exists('require_firmware', $family_line_xml['data'])) && ($remote) && ($family_line_xml['data']['require_firmware'] == "TRUE")) { + out(_("Firmware Requirment Detected!..........")); + $this->install_firmware($family_line_xml['data']['id']); + } + + $data = sql("SELECT id FROM endpointman_product_list WHERE id='" . $brand_id . $family_line_xml['data']['id'] . "'", 'getOne'); + $short_name = preg_replace("/\[(.*?)\]/si", "", $family_line_xml['data']['name']); + + if ($data) { + if ($this->configmod->get('debug')) echo "-Updating Family ".$short_name."
"; + $sql = "UPDATE endpointman_product_list SET short_name = '" . str_replace("'", "''", $short_name) . "', long_name = '" . str_replace("'", "''", $family_line_xml['data']['name']) . "', cfg_ver = '" . $family_line_xml['data']['version'] . "', config_files='" . $family_line_xml['data']['configuration_files'] . "' WHERE id = '" . $brand_id . $family_line_xml['data']['id'] . "'"; + } + else { + if ($this->configmod->get('debug')) echo "-Inserting Family ".$short_name."
"; + $sql = "INSERT INTO endpointman_product_list (`id`, `brand`, `short_name`, `long_name`, `cfg_dir`, `cfg_ver`, `config_files`, `hidden`) VALUES ('" . $brand_id . $family_line_xml['data']['id'] . "', '" . $brand_id . "', '" . str_replace("'", "''", $short_name) . "', '" . str_replace("'", "''", $family_line_xml['data']['name']) . "', '" . $family_line_xml['data']['directory'] . "', '" . $family_line_xml['data']['last_modified'] . "','" . $family_line_xml['data']['configuration_files'] . "', '0')"; + } + sql($sql); + + + if (count($family_line_xml['data']['model_list']) > 0) { + out(_("-- Updating Model Lines ... ")); + foreach ($family_line_xml['data']['model_list'] as $model_list) { + $template_list = implode(",", $model_list['template_data']); + + $model_final_id = $brand_id . $family_line_xml['data']['id'] . $model_list['id']; + $sql = 'SELECT id, global_custom_cfg_data, global_user_cfg_data FROM endpointman_mac_list WHERE model = ' . $model_final_id; + $old_data = NULL; + $old_data = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach ($old_data as $data) { + $global_custom_cfg_data = unserialize($data['global_custom_cfg_data']); + if ((is_array($global_custom_cfg_data)) AND (!array_key_exists('data', $global_custom_cfg_data))) { +outn(_("----Old Data Detected! Migrating ... ")); + $new_data = array(); + $new_ari = array(); + foreach ($global_custom_cfg_data as $key => $old_keys) { + if (array_key_exists('value', $old_keys)) { + $new_data[$key] = $old_keys['value']; + } else { + $breaks = explode("_", $key); + $new_data["loop|" . $key] = $old_keys[$breaks[2]]; + } + if (array_key_exists('ari', $old_keys)) { + $new_ari[$key] = 1; + } + } + $final_data = array(); + $final_data['data'] = $new_data; + $final_data['ari'] = $new_ari; + $final_data = serialize($final_data); + $sql = "UPDATE endpointman_mac_list SET global_custom_cfg_data = '" . $final_data . "' WHERE id =" . $data['id']; + sql($sql); + out(_("Done!")); + } + + $global_user_cfg_data = unserialize($data['global_user_cfg_data']); + $old_check = FALSE; + if (is_array($global_user_cfg_data)) { + foreach ($global_user_cfg_data as $stuff) { + if (is_array($stuff)) { + if (array_key_exists('value', $stuff)) { + $old_check = TRUE; + break; + } else { + break; + } + } else { + break; + } + } + } + if ((is_array($global_user_cfg_data)) AND ($old_check)) { +outn(_("Old Data Detected! Migrating ... ")); + $new_data = array(); + foreach ($global_user_cfg_data as $key => $old_keys) { + if (array_key_exists('value', $old_keys)) { + $exploded = explode("_", $key); + $counted = count($exploded); + $counted = $counted - 1; + if (is_numeric($exploded[$counted])) { + $key = "loop|" . $key; + } + $new_data[$key] = $old_keys['value']; + } + } + $final_data = serialize($new_data); + $sql = "UPDATE endpointman_mac_list SET global_user_cfg_data = '" . $final_data . "' WHERE id =" . $data['id']; + sql($sql); + out(_("Done!")); + } + } + $old_data = NULL; + $sql = 'SELECT id, global_custom_cfg_data FROM endpointman_template_list WHERE model_id = ' . $model_final_id; + $old_data = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach ($old_data as $data) { + $global_custom_cfg_data = unserialize($data['global_custom_cfg_data']); + if ((is_array($global_custom_cfg_data)) AND (!array_key_exists('data', $global_custom_cfg_data))) { +out(_("Old Data Detected! Migrating ... ")); + $new_data = array(); + $new_ari = array(); + foreach ($global_custom_cfg_data as $key => $old_keys) { + if (array_key_exists('value', $old_keys)) { + $new_data[$key] = $old_keys['value']; + } else { + $breaks = explode("_", $key); + $new_data["loop|" . $key] = $old_keys[$breaks[2]]; + } + if (array_key_exists('ari', $old_keys)) { + $new_ari[$key] = 1; + } + } + $final_data = array(); + $final_data['data'] = $new_data; + $final_data['ari'] = $new_ari; + $final_data = serialize($final_data); + $sql = "UPDATE endpointman_template_list SET global_custom_cfg_data = '" . $final_data . "' WHERE id =" . $data['id']; + sql($sql); + out(_("Done!")); + } + } + + $m_data = sql("SELECT id FROM endpointman_model_list WHERE id='" . $brand_id . $family_line_xml['data']['id'] . $model_list['id'] . "'", 'getOne'); + if ($m_data) { +if ($this->configmod->get('debug')) echo format_txt(_("---Updating Model %_NAMEMOD_%"), "", array("%_NAMEMOD_%" => $model_list['model'])); + $sql = "UPDATE endpointman_model_list SET max_lines = '" . $model_list['lines'] . "', model = '" . $model_list['model'] . "', template_list = '" . $template_list . "' WHERE id = '" . $brand_id . $family_line_xml['data']['id'] . $model_list['id'] . "'"; + } + else { +if ($this->configmod->get('debug')) echo format_txt(_("---Inserting Model %_NAMEMOD_%"), "", array("%_NAMEMOD_%" => $model_list['model'])); + $sql = "INSERT INTO endpointman_model_list (`id`, `brand`, `model`, `max_lines`, `product_id`, `template_list`, `enabled`, `hidden`) VALUES ('" . $brand_id . $family_line_xml['data']['id'] . $model_list['id'] . "', '" . $brand_id . "', '" . $model_list['model'] . "', '" . $model_list['lines'] . "', '" . $brand_id . $family_line_xml['data']['id'] . "', '" . $template_list . "', '0', '0')"; + } + sql($sql); + + //echo "brand_id:".$brand_id. " - family_line_xml:" . $family_line_xml['data']['id'] . "- model_list:" . $model_list['id']."
"; + if (!$this->sync_model($brand_id . $family_line_xml['data']['id'] . $model_list['id'], $errlog)) { + out(_("Error: System Error in Sync Model Function, Load Failure!")); + out(_("Error: ").$errlog['sync_model']); + } + unset ($errlog); + } + } + //END Updating Model Lines................ + + //Phone Models Move Here + $family_id = $brand_id . $family_line_xml['data']['id']; + $sql = "SELECT * FROM endpointman_model_list WHERE product_id = " . $family_id; + $products = sql($sql, 'getall', DB_FETCHMODE_ASSOC); + foreach ($products as $data) { + if (!$this->system->arraysearchrecursive($data['model'], $family_line_xml['data']['model_list'], 'model')) { + outn(sprintf(_("Moving/Removing Model '%s' not present in JSON file ... "), $data['model'])); + $model_name = $data['model']; + $sql = 'DELETE FROM endpointman_model_list WHERE id = ' . $data['id']; + sql($sql); + $sql = "SELECT id FROM endpointman_model_list WHERE model LIKE '" . $model_name . "'"; + $new_model_id = sql($sql, 'getOne'); + if ($new_model_id) { + $sql = "UPDATE endpointman_mac_list SET model = '" . $new_model_id . "' WHERE model = '" . $data['id'] . "'"; + } else { + $sql = "UPDATE endpointman_mac_list SET model = '0' WHERE model = '" . $data['id'] . "'"; + } + sql($sql); + out(_("Done!")); + } + } + } + out(_("All Done!")); + //END Updating Family Lines + + outn(_("Updating OUI list in DB ... ")); + if ((isset($temp['data']['brands']['oui_list'])) AND (count($temp['data']['brands']['oui_list']) > 0)) + { + foreach ($temp['data']['brands']['oui_list'] as $oui) { + $sql = "REPLACE INTO endpointman_oui_list (`oui`, `brand`, `custom`) VALUES ('" . $oui . "', '" . $brand_id . "', '0')"; + sql($sql); + } + } + out(_("Done!")); + } else { + outn(sprintf(_("Error: Invalid JSON Structure in %s/brand_data.json"), $temp_directory.$package)); + } + } else { + out(_("Error: No 'brand_data.xml' file exists!")); + } + + outn(_("Removing Temporary Files... ")); + $this->system->rmrf($temp_directory . $package); + out(_("Done!")); + } + + /** + * Remove the brand + * @param int $id Brand ID + */ + function remove_brand($id=NULL, $remove_configs=FALSE, $force=FALSE) { + out(_("Uninstalla Brand...")); + + if (!$this->configmod->get('use_repo')) { + $sql = "SELECT id, firmware_vers FROM endpointman_product_list WHERE brand = '" . $id . "'"; + $products = sql($sql, 'getall', DB_FETCHMODE_ASSOC); + + foreach ($products as $data) { + if ($data['firmware_vers'] != "") { + $this->remove_firmware($data['id']); + } + } + + $sql = "SELECT directory FROM endpointman_brand_list WHERE id = '" . $id . "'"; + $brand_dir = sql($sql, 'getOne'); + $this->system->rmrf($this->PHONE_MODULES_PATH . "endpoint/" . $brand_dir); + + $sql = "DELETE FROM endpointman_model_list WHERE brand = '" . $id . "'"; + sql($sql); + + $sql = "DELETE FROM endpointman_product_list WHERE brand = '" . $id . "'"; + sql($sql); + + $sql = "DELETE FROM endpointman_oui_list WHERE brand = '" . $id . "'"; + sql($sql); + + $this->system->rmrf($this->PHONE_MODULES_PATH . $brand_dir); + $sql = "DELETE FROM endpointman_brand_list WHERE id = '" . $id . "'"; + sql($sql); + + out(_("All Done!")); + } + elseif ($force) { + $sql = "SELECT directory FROM endpointman_brand_list WHERE id = '" . $id . "'"; + $brand_dir = sql($sql, 'getOne'); + + $sql = "DELETE FROM endpointman_model_list WHERE brand = '" . $id . "'"; + sql($sql); + + $sql = "DELETE FROM endpointman_product_list WHERE brand = '" . $id . "'"; + sql($sql); + + $sql = "DELETE FROM endpointman_oui_list WHERE brand = '" . $id . "'"; + sql($sql); + + $sql = "DELETE FROM endpointman_brand_list WHERE id = '" . $id . "'"; + sql($sql); + + out(_("Done!")); + } + else { + out(_("Error: Not allowed in repo mode!!")); + } + } + + /** + * Install Firmware for the specified Product Line + * @param $product_id Product ID + */ + function install_firmware($product_id) { + out(_("Installa frimware... ")); + + $temp_directory = $this->system->sys_get_temp_dir() . "/epm_temp/"; + $sql = 'SELECT endpointman_product_list.*, endpointman_brand_list.directory FROM endpointman_product_list, endpointman_brand_list WHERE endpointman_product_list.brand = endpointman_brand_list.id AND endpointman_product_list.id = ' . $product_id; + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + $json_data = $this->file2json($this->PHONE_MODULES_PATH . "endpoint/" . $row['directory'] . "/" . $row['cfg_dir'] . "/family_data.json"); + + if ((! isset($json_data['data']['firmware_ver'])) OR (empty($json_data['data']['firmware_ver']))) { + out (_("Error: The version of the firmware package is blank!")); + return false; + } + + if ((! isset($json_data['data']['firmware_pkg'])) OR (empty($json_data['data']['firmware_pkg'])) OR ($json_data['data']['firmware_pkg'] == "NULL")) { + out (_("Error: The package name of the firmware to be downloaded is Null or blank!")); + return false; + } + + if ($json_data['data']['firmware_ver'] > $row['firmware_vers']) { + if (!file_exists($temp_directory)) { + mkdir($temp_directory); + } + $md5_xml = $json_data['data']['firmware_md5sum']; + $firmware_pkg = $json_data['data']['firmware_pkg']; + + if (file_exists($temp_directory . $firmware_pkg)) { + $md5_pkg = md5_file($temp_directory . $firmware_pkg); + if ($md5_xml == $md5_pkg) { + out(_("Skipping download, updated local version...")); + } else { + out(_("Downloading firmware...")); + if (! $this->system->download_file_with_progress_bar($this->UPDATE_PATH . $row['directory'] . "/" . $firmware_pkg, $temp_directory . $firmware_pkg)) { + out(_("Error download frimware package!")); + return false; + } + $md5_pkg = md5_file($temp_directory . $firmware_pkg); + } + } else { + out(_("Downloading firmware...")); + if (! $this->system->download_file_with_progress_bar($this->UPDATE_PATH . $row['directory'] . "/" . $firmware_pkg, $temp_directory . $firmware_pkg)) { + out(_("Error download frimware package!")); + return false; + } + $md5_pkg = md5_file($temp_directory . $firmware_pkg); + } + + outn(_("Checking MD5sum of Package... ")); + if ($md5_xml == $md5_pkg) { + out(_("Matches!")); + + if (file_exists($temp_directory . $row['directory'] . "/" . $row['cfg_dir'] . "/firmware")) { + $this->system->rmrf($temp_directory . $row['directory'] . "/" . $row['cfg_dir'] . "/firmware"); + } + mkdir($temp_directory . $row['directory'] . "/" . $row['cfg_dir'] . "/firmware", 0777, TRUE); + + out(_("Installing Firmware...")); + //TODO: AÑADIR VALIDACION EXTRACCION CORRECTA + exec("tar -xvf " . $temp_directory . $firmware_pkg . " -C " . $temp_directory . $row['directory'] . "/" . $row['cfg_dir']); + $i = 0; + foreach (glob($temp_directory . $row['directory'] . "/" . $row['cfg_dir'] . "/firmware/*") as $filename) { + $file = basename($filename); + $list[$i] = $file; + if (!@copy($filename, $this->configmod->get('config_location') . $file)) { + out(sprintf(_("- Failed To Copy %s!"), $file)); + $copy_error = TRUE; + } elseif ($this->configmod->get('debug')) { + out(sprintf(_("- Copied %s to %s."), $file, $this->configmod->get('config_location'))); + } + $i++; + } + + $this->system->rmrf($temp_directory . $row['directory']); + $list = implode(",", $list); + $sql = "UPDATE endpointman_product_list SET firmware_vers = '" . $json_data['data']['firmware_ver'] . "', firmware_files = '" . $list . "' WHERE id = " . $row['id']; + sql($sql); + + if (isset($copy_error)) { + out(_("Copy Error Detected! Aborting Install!")); + $this->remove_firmware($product_id); + out(_("Info: Please Check Directory/Permissions!")); + } + else { + out(_("Done!")); + } + } + else { + out(_("Firmware MD5 didn't match!")); + } + } + else { + out(_("Your Firmware is already up to date.")); + } + } + + /** + * Remove firmware from the Hard Drive + * @param int $id Product ID + */ + function remove_firmware($id) { + outn(_("Uninstalla frimware... ")); + + $sql = "SELECT firmware_files FROM endpointman_product_list WHERE id ='" . $id . "'"; + $files = sql($sql, 'getOne'); + + $file_list = explode(",", $files); + $i = 0; + foreach ($file_list as $file) { + if (trim($file) == "") { continue; } + if (! file_exists($this->configmod->get('config_location') . $file)) { continue; } + if (! is_file($this->configmod->get('config_location') . $file)) { continue; } + unlink($this->configmod->get('config_location') . $file); + } + $sql = "UPDATE endpointman_product_list SET firmware_files = '', firmware_vers = '' WHERE id = '" . $id . "'"; + sql($sql); + + out(_("Done!")); + } + + + + + /** + * Check for new firmware on the servers + * @param int $id Product ID + * @return bool True on yes False on no + */ + function firmware_update_check($id=NULL) { + $sql = "SELECT * FROM endpointman_product_list WHERE id ='" . $id . "'"; + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $sql = "SELECT directory FROM endpointman_brand_list WHERE id ='" . $row['brand'] . "'"; + $brand_directory = sql($sql, 'getOne'); + + //config drive unknown! + if ($row['cfg_dir'] == "") { + return FALSE; + } else { + $temp = $this->file2json($this->PHONE_MODULES_PATH . "endpoint/" . $brand_directory . "/" . $row['cfg_dir'] . "/family_data.json"); + if ((array_key_exists('data', $temp)) AND (!is_array($temp['data']['firmware_ver']))) { + if ($row['firmware_vers'] < $temp['data']['firmware_ver']) { + return $temp; + } else { + return FALSE; + } + } else { + return FALSE; + } + } + } + + /** + * Check to see the status of the firmware locally (installed or not) + * @param int $id + * @return string + */ + function firmware_local_check($id=NULL) { + $sql = "SELECT * FROM endpointman_product_list WHERE hidden = 0 AND id ='" . $id . "'"; + $res = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + + if (count($res) > 0) { + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + $sql = "SELECT directory FROM endpointman_brand_list WHERE hidden = 0 AND id ='" . $row['brand'] . "'"; + $brand_directory = sql($sql, 'getOne'); + + //config drive unknown! + if ($row['cfg_dir'] == "") { + return("nothing"); + } else { + $temp = $this->file2json($this->PHONE_MODULES_PATH . "endpoint/" . $brand_directory . "/" . $row['cfg_dir'] . "/family_data.json"); + if ( (isset($temp['data']['firmware_ver'])) AND (! empty ($temp['data']['firmware_ver'])) ) { + if ($row['firmware_vers'] == "") { + return("install"); + } else { + return("remove"); + } + } else { + return("nothing"); + } + } + } else { + return("nothing"); + } + } + + + + + + + + + + + /** + * Reads a file. Json decodes it and will report any errors back + * @param string $file location of file + * @return mixed false on error, array on success + * @version 2.11 + */ + function file2json($file) { + if (file_exists($file)) { + $json = file_get_contents($file); + $data = json_decode($json, TRUE); + if(function_exists('json_last_error')) { + switch (json_last_error()) { + case JSON_ERROR_NONE: + return($data); + break; + case JSON_ERROR_DEPTH: + $this->error['file2json'] = _('Maximum stack depth exceeded'); + break; + case JSON_ERROR_STATE_MISMATCH: + $this->error['file2json'] = _('Underflow or the modes mismatch'); + break; + case JSON_ERROR_CTRL_CHAR: + $this->error['file2json'] = _('Unexpected control character found'); + break; + case JSON_ERROR_SYNTAX: + $this->error['file2json'] = _('Syntax error, malformed JSON'); + break; + case JSON_ERROR_UTF8: + $this->error['file2json'] = _('Malformed UTF-8 characters, possibly incorrectly encoded'); + break; + default: + $this->error['file2json'] = _('Unknown error'); + break; + } + return(false); + } else { + //Probably an older version of PHP. That's ok though + return($data); + } + } else { + $this->error['file2json'] = _('Cant find file:').' '.$file ; + return(false); + } + } + + + + + + + function merge_data($path, $template_list, $maxlines = 12) { + //TODO: fix + foreach ($template_list as $files_data) { + $full_path = $path . $files_data; + if (file_exists($full_path)) { + $temp_files_data = $this->file2json($full_path); + foreach ($temp_files_data['template_data']['category'] as $category) { + $category_name = $category['name']; + foreach ($category['subcategory'] as $subcategory) { + $subcategory_name = $subcategory['name']; + $items_fin = array(); + $items_loop = array(); + $break_count = 0; + foreach ($subcategory['item'] as $item) { + switch ($item['type']) { + case 'loop_line_options': + for ($i = 1; $i <= $maxlines; $i++) { + $var_nam = "lineloop|line_" . $i; + foreach ($item['data']['item'] as $item_loop) { + if ($item_loop['type'] != 'break') { + $z = str_replace("\$", "", $item_loop['variable']); + $items_loop[$var_nam][$z] = $item_loop; + $items_loop[$var_nam][$z]['description'] = str_replace('{$count}', $i, $items_loop[$var_nam][$z]['description']); + $items_loop[$var_nam][$z]['default_value'] = $items_loop[$var_nam][$z]['default_value']; + $items_loop[$var_nam][$z]['default_value'] = str_replace('{$count}', $i, $items_loop[$var_nam][$z]['default_value']); + $items_loop[$var_nam][$z]['line_loop'] = TRUE; + $items_loop[$var_nam][$z]['line_count'] = $i; + } elseif ($item_loop['type'] == 'break') { + $items_loop[$var_nam]['break_' . $break_count]['type'] = 'break'; + $break_count++; + } + } + } + $items_fin = array_merge($items_fin, $items_loop); + break; + case 'loop': + for ($i = $item['loop_start']; $i <= $item['loop_end']; $i++) { + $name = explode("_", $item['data']['item'][0]['variable']); + $var_nam = "loop|" . str_replace("\$", "", $name[0]) . "_" . $i; + foreach ($item['data']['item'] as $item_loop) { + if ($item_loop['type'] != 'break') { + if (!empty($item_loop['variable'])){ + $z_tmp = explode("_", $item_loop['variable']); + $z = $z_tmp[1]; + $items_loop[$var_nam][$z] = $item_loop; + $items_loop[$var_nam][$z]['description'] = str_replace('{$count}', $i, $items_loop[$var_nam][$z]['description']); + $items_loop[$var_nam][$z]['variable'] = str_replace('_', '_' . $i . '_', $items_loop[$var_nam][$z]['variable']); + $items_loop[$var_nam][$z]['default_value'] = isset($items_loop[$var_nam][$z]['default_value']) ? $items_loop[$var_nam][$z]['default_value'] : ''; + $items_loop[$var_nam][$z]['loop'] = TRUE; + $items_loop[$var_nam][$z]['loop_count'] = $i; + } + } elseif ($item_loop['type'] == 'break') { + $items_loop[$var_nam]['break_' . $break_count]['type'] = 'break'; + $break_count++; + } + } + } + $items_fin = array_merge($items_fin, $items_loop); + break; + case 'break': + $items_fin['break|' . $break_count]['type'] = 'break'; + $break_count++; + break; + default: + $var_nam = "option|" . str_replace("\$", "", (isset($item['variable'])? $item['variable'] : "")); + $items_fin[$var_nam] = $item; + break; + } + } + if (isset($data['data'][$category_name][$subcategory_name])) { + $old_sc = $data['data'][$category_name][$subcategory_name]; + $sub_cat_data[$category_name][$subcategory_name] = array(); + $sub_cat_data[$category_name][$subcategory_name] = array_merge($old_sc, $items_fin); + } else { + $sub_cat_data[$category_name][$subcategory_name] = $items_fin; + } + } + if (isset($data['data'][$category_name])) { + $old_c = $data['data'][$category_name]; + $new_c = $sub_cat_data[$category_name]; + $sub_cat_data[$category_name] = array(); + $data['data'][$category_name] = array_merge($old_c, $new_c); + } else { + $data['data'][$category_name] = $sub_cat_data[$category_name]; + } + } + } + } + return($data); + } + + +} +?> diff --git a/Endpointman_Devices.class.php b/Endpointman_Devices.class.php new file mode 100644 index 00000000..c71448db --- /dev/null +++ b/Endpointman_Devices.class.php @@ -0,0 +1,74 @@ +freepbx = $freepbx; + $this->db = $freepbx->Database; + $this->config = $freepbx->Config; + $this->configmod = $cfgmod; + } + + public function myShowPage(&$pagedata) { + if(empty($pagedata)) + { + $pagedata['main'] = array( + "name" => _("Devices"), + "page" => 'views/epm_devices_main.page.php' + ); + } + } + + public function ajaxRequest($req, &$setting) { + /* + $arrVal = array(""); + if (in_array($req, $arrVal)) { + $setting['authenticate'] = true; + $setting['allowremote'] = false; + return true; + } + */ + return false; + } + + public function ajaxHandler($module_tab = "", $command = "") + { + $retarr = ""; + if ($module_tab == "manager") + { + switch ($command) + { + default: + $retarr = array("status" => false, "message" => _("Command not found!") . " [" .$command. "]"); + break; + } + } + else { + $retarr = array("status" => false, "message" => _("Tab not found!") . " [" .$module_tab. "]"); + } + return $retarr; + } + + public function doConfigPageInit($module_tab = "", $command = "") { + + } + + public function getRightNav($request) { + return ""; + } + + public function getActionBar($request) { + return ""; + } + +} \ No newline at end of file diff --git a/Endpointman_Templates.class.php b/Endpointman_Templates.class.php new file mode 100644 index 00000000..4fc55a28 --- /dev/null +++ b/Endpointman_Templates.class.php @@ -0,0 +1,1093 @@ +freepbx = $freepbx; + $this->db = $freepbx->Database; + $this->config = $freepbx->Config; + $this->configmod = $cfgmod; + $this->epm_config = $epm_config; + $this->eda = $eda; + } + + public function myShowPage(&$pagedata) { + if(empty($pagedata)) + { + $pagedata['manager'] = array( + "name" => _("Current Templates"), + "page" => 'views/epm_templates_manager.page.php' + ); + $pagedata['editor'] = array( + "name" => _("Template Editor"), + "page" => 'views/epm_templates_editor.page.php' + ); + } + } + + public function ajaxRequest($req, &$setting) { + $arrVal = array("model_clone", "list_current_template", "add_template", "del_template", "custom_config_get_gloabl", "custom_config_update_gloabl", "custom_config_reset_gloabl", "list_files_edit"); + if (in_array($req, $arrVal)) { + $setting['authenticate'] = true; + $setting['allowremote'] = false; + return true; + } + else + { + return false; + } + } + + public function ajaxHandler($module_tab = "", $command = "") + { + $retarr = ""; + if ($module_tab == "manager") + { + switch ($command) + { + case "list_current_template": + $retarr = $this->epm_templates_list_current_templates(); + break; + + case "model_clone": + $retarr = $this->epm_templates_model_clone(); + break; + + case "add_template": + $retarr = $this->epm_templates_add_template(); + break; + + case "del_template": + $retarr = $this->epm_templates_del_template(); + break; + + default: + $retarr = array("status" => false, "message" => _("Command not found!") . " [" .$command. "]"); + break; + } + } + elseif ($module_tab == "editor") + { + switch ($command) + { + case "custom_config_get_gloabl": + $retarr = $this->epm_template_custom_config_get_global(); + break; + + case "custom_config_update_gloabl": + $retarr = $this->epm_template_custom_config_update_global(); + break; + + case "custom_config_reset_gloabl": + $retarr = $this->epm_template_custom_config_reset_global(); + break; + + case "list_files_edit": + /* + $return = array(); + $return[] = array('value' => 'va11', 'txt' => 'txt1', 'select' => "OFF"); + $return[] = array('value' => 'va12', 'txt' => 'txt2', 'select' => "ON"); + $return[] = array('value' => 'va13', 'txt' => 'txt3', 'select' => "OFF"); + */ + return $this->edit_template_display_files($_REQUEST['idsel'],$_REQUEST['custom'], $_REQUEST['namefile']); + break; + + default: + $retarr = array("status" => false, "message" => _("Command not found!") . " [" .$command. "]"); + break; + } + } + else { + $retarr = array("status" => false, "message" => _("Tab not found!") . " [" .$module_tab. "]"); + } + return $retarr; + } + + public function doConfigPageInit($module_tab = "", $command = "") { + + } + + public function getRightNav($request) { + if(isset($request['subpage']) && $request['subpage'] == "editor") { + return load_view(__DIR__."/views/epm_templates/editor.views.rnav.php",array()); + } else { + return ''; + } + } + + public function getActionBar($request) { + $buttons = array(); + switch($request['subpage']) { + case 'editor': + $buttons = array( + 'delete' => array( + 'name' => 'delete', + 'id' => 'delete', + 'value' => _('Delete'), + 'hidden' => '' + ), + 'save' => array( + 'name' => 'submit', + 'id' => 'save', + 'value' => _('Save'), + 'hidden' => '' + ) + ); + + if(empty($request['idsel']) && empty($request['custom'])){ + $buttons = NULL; + } + break; + + default: + } + return $buttons; + } + + + + + + + public function epm_template_custom_config_get_global() + { + if (! isset($_REQUEST['custom'])) { + $retarr = array("status" => false, "message" => _("No send Custom Value!")); + } + elseif (! isset($_REQUEST['tid'])) { + $retarr = array("status" => false, "message" => _("No send TID!")); + } + elseif (! is_numeric($_REQUEST['tid'])) { + $retarr = array("status" => false, "message" => _("TID is not number!")); + } + else + { + $dget['custom'] = $_REQUEST['custom']; + $dget['tid'] = $_REQUEST['tid']; + + if($dget['custom'] == 0) { + //This is a group template + $sql = 'SELECT global_settings_override FROM endpointman_template_list WHERE id = '.$dget['tid']; + } else { + //This is an individual template + $sql = 'SELECT global_settings_override FROM endpointman_mac_list WHERE id = '.$dget['tid'];; + } + $settings = sql($sql, 'getOne'); + + if ((isset($settings)) and (strlen($settings) > 0)) { + $settings = unserialize($settings); + //$settings['tz'] = FreePBX::Endpointman()->listTZ(FreePBX::Endpointman()->configmod->get("tz")); + } + else { + $settings['srvip'] = ""; //$this->configmod->get("srvip"); + $settings['ntp'] = ""; //$this->configmod->get("ntp"); + $settings['config_location'] = ""; //$this->configmod->get("config_location"); + $settings['tz'] = $this->configmod->get("tz"); + $settings['server_type'] = $this->configmod->get("server_type"); + } + + $retarr = array("status" => true, "settings" => $settings, "message" => _("Global Config Read OK!")); + unset($dget); + } + return $retarr; + } + + + public function epm_template_custom_config_update_global () + { + if (! isset($_REQUEST['custom'])) { + $retarr = array("status" => false, "message" => _("No send Custom Value!")); + } + elseif (! isset($_REQUEST['tid'])) { + $retarr = array("status" => false, "message" => _("No send TID!")); + } + elseif (! is_numeric($_REQUEST['tid'])) { + $retarr = array("status" => false, "message" => _("TID is not number!")); + } + else + { + $dget['custom'] = $_REQUEST['custom']; + $dget['tid'] = $_REQUEST['tid']; + + + $_REQUEST['srvip'] = trim($_REQUEST['srvip']); #trim whitespace from IP address + $_REQUEST['config_loc'] = trim($_REQUEST['config_loc']); #trim whitespace from Config Location + + $settings_warning = ""; + if (strlen($_REQUEST['config_loc']) > 0) { + //No trailing slash. Help the user out and add one :-) + if($_REQUEST['config_loc'][strlen($_REQUEST['config_loc'])-1] != "/") { + $_REQUEST['config_loc'] = $_REQUEST['config_loc'] ."/"; + } + + if((isset($_REQUEST['config_loc'])) AND ($_REQUEST['config_loc'] != "")) { + if((file_exists($_REQUEST['config_loc'])) AND (is_dir($_REQUEST['config_loc']))) { + if(is_writable($_REQUEST['config_loc'])) { + $_REQUEST['config_loc'] = $_REQUEST['config_loc']; + } else { + $settings_warning = _("Directory Not Writable!"); + $_REQUEST['config_loc'] = $this->configmod->get('config_location'); + } + } else { + $settings_warning = _("Not a Vaild Directory"); + $_REQUEST['config_loc'] = $this->configmod->get('config_location'); + } + } else { + $settings_warning = _("No Configuration Location Defined!"); + $_REQUEST['config_loc'] = $this->configmod->get('config_location'); + } + } + + $settings['config_location'] = $_REQUEST['config_loc']; + $settings['server_type'] = (isset($_REQUEST['server_type']) ? $_REQUEST['server_type'] : ""); //REVISAR NO ESTABA ANTES + $settings['srvip'] = (isset($_REQUEST['srvip']) ? $_REQUEST['srvip'] : ""); + $settings['ntp'] = (isset($_REQUEST['ntp_server']) ? $_REQUEST['ntp_server'] : ""); + $settings['tz'] = (isset($_REQUEST['tz']) ? $_REQUEST['tz'] : ""); + $settings_ser = serialize($settings); + unset($settings); + + if($dget['custom'] == 0) { + //This is a group template + $sql = "UPDATE endpointman_template_list SET global_settings_override = '".addslashes($settings_ser)."' WHERE id = ".$dget['tid']; + } else { + //This is an individual template + $sql = "UPDATE endpointman_mac_list SET global_settings_override = '".addslashes($settings_ser)."' WHERE id = ".$dget['tid']; + } + unset($settings_ser); + sql($sql); + + if (strlen($settings_warning) > 0) { $settings_warning = " ".$settings_warning; } + $retarr = array("status" => true, "message" => _("Updated!").$settings_warning); + unset($dget); + } + return $retarr; + } + + + public function epm_template_custom_config_reset_global() + { + if (! isset($_REQUEST['custom'])) { + $retarr = array("status" => false, "message" => _("No send Custom Value!")); + } + elseif (! isset($_REQUEST['tid'])) { + $retarr = array("status" => false, "message" => _("No send TID!")); + } + elseif (! is_numeric($_REQUEST['tid'])) { + $retarr = array("status" => false, "message" => _("TID is not number!")); + } + else + { + $dget['custom'] = $_REQUEST['custom']; + $dget['tid'] = $_REQUEST['tid']; + + if($dget['custom'] == 0) { + //This is a group template + $sql = "UPDATE endpointman_template_list SET global_settings_override = NULL WHERE id = ".$dget['tid']; + } else { + //This is an individual template + $sql = "UPDATE endpointman_mac_list SET global_settings_override = NULL WHERE id = ".$dget['tid']; + } + sql($sql); + + $retarr = array("status" => true, "message" => _("Globals Reset to Default!")); + unset($dget); + } + return $retarr; + } + + + + + /**** FUNCIONES SEC MODULO "epm_template\manager" ****/ + public function epm_templates_del_template() + { + if (! isset($_REQUEST['idsel'])) { + $retarr = array("status" => false, "message" => _("No send ID!")); + } + elseif (! is_numeric($_REQUEST['idsel'])) { + $retarr = array("status" => false, "message" => _("ID is not number!")); + } + elseif ($_REQUEST['idsel'] <= 0) { + $retarr = array("status" => false, "message" => _("ID send is negative!")); + } + else { + $dget['idsel'] = $_REQUEST['idsel']; + + $sql = "DELETE FROM endpointman_template_list WHERE id = ". $dget['idsel']; + sql($sql); + $sql = "UPDATE endpointman_mac_list SET template_id = 0 WHERE template_id = ".$dget['idsel']; + sql($sql); + + $retarr = array("status" => true, "message" => _("Delete Template OK!")); + unset($dget); + } + return $retarr; + } + + public function epm_templates_add_template () + { + $arrVal['VAR_REQUEST'] = array("newnametemplate", "newproductselec", "newclonemodel"); + foreach ($arrVal['VAR_REQUEST'] as $valor) { + if (! array_key_exists($valor, $_REQUEST)) { + return array("status" => false, "message" => _("No send value!")." [".$valor."]"); + } + } + + $arrVal['VAR_IS_NUM'] = array("newproductselec", "newclonemodel"); + foreach ($arrVal['VAR_IS_NUM'] as $valor) { + if (! is_numeric($_REQUEST[$valor])) { + return array("status" => false, "message" => _("Value send is not number!")." [".$valor."]"); + } + } + + if (empty($_REQUEST['newnametemplate'])) { + $retarr = array("status" => false, "message" => _("Name is null!")); + } + elseif ($_REQUEST['newproductselec'] <= 0) { + $retarr = array("status" => false, "message" => _("Product send is negative!")); + } + elseif ($_REQUEST['newclonemodel'] <= 0) { + $retarr = array("status" => false, "message" => _("Clone Model send is negative!")); + } + else { + $dget['newnametemplate'] = $_REQUEST['newnametemplate']; + $dget['newproductselec'] = $_REQUEST['newproductselec']; + $dget['newclonemodel'] = $_REQUEST['newclonemodel']; + + $db = $this->db; + $sql = "INSERT INTO endpointman_template_list (product_id, name, model_id) VALUES (?,?,?)"; + $q = $db->prepare($sql); + $ob = $q->execute(array($dget['newproductselec'], addslashes($dget['newnametemplate']), $dget['newclonemodel'])); + $newid = $db->lastInsertId(); + //$this->edit_template_display($newid,0); + + $retarr = array("status" => true, "message" => _("Add New Template OK!"), "newid" => $newid); + unset($dget); + } + return $retarr; + } + + public function epm_templates_model_clone () + { + if (! isset($_REQUEST['id'])) { + $retarr = array("status" => false, "message" => _("No send ID!")); + } + elseif (! is_numeric($_REQUEST['id'])) { + $retarr = array("status" => false, "message" => _("ID send is not number!")); + } + elseif ($_REQUEST['id'] <= 0) { + $retarr = array("status" => false, "message" => _("ID send is number not valid!")); + } + else + { + $dget['id'] = $_REQUEST['id']; + + $i=0; + $out = array(); + $sql = "SELECT endpointman_model_list.id, endpointman_model_list.model as model FROM endpointman_model_list, endpointman_product_list WHERE endpointman_product_list.id = endpointman_model_list.product_id AND endpointman_model_list.enabled = 1 AND endpointman_model_list.hidden = 0 AND product_id = '". $dget['id']."'"; + $result = sql($sql,'getAll', DB_FETCHMODE_ASSOC); + foreach($result as $row) { + $out[$i]['optionValue'] = $row['id']; + $out[$i]['optionDisplay'] = $row['model']; + $i++; + } + $retarr = array("status" => true, "message" => _("Generate list Ok!"), "listopt" => $out); + + unset($dget); + } + return $retarr; + } + + public function epm_templates_list_current_templates () + { + + $sql = 'SELECT endpointman_template_list.*, endpointman_product_list.short_name as model_class, endpointman_model_list.model as model_clone, endpointman_model_list.enabled FROM endpointman_template_list, endpointman_model_list, endpointman_product_list WHERE endpointman_model_list.hidden = 0 AND endpointman_template_list.model_id = endpointman_model_list.id AND endpointman_template_list.product_id = endpointman_product_list.id'; + $template_list = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + $i = 0; + $row_out = array(); + foreach($template_list as $row) { + $row_out[$i] = $row; + $row_out[$i]['custom'] = 0; + if(!$row['enabled']) { + $row_out[$i]['model_clone'] = $row_out[$i]['model_clone']; + } + $i++; + } + + $sql = 'SELECT endpointman_mac_list.mac, endpointman_mac_list.id, endpointman_mac_list.model, endpointman_model_list.model as model_clone, endpointman_product_list.short_name as model_class FROM endpointman_mac_list, endpointman_model_list, endpointman_product_list WHERE endpointman_product_list.id = endpointman_model_list.product_id AND endpointman_mac_list.global_custom_cfg_data IS NOT NULL AND endpointman_model_list.id = endpointman_mac_list.model AND endpointman_mac_list.template_id = 0'; + $template_list = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + foreach($template_list as $row) { + $sql = 'SELECT description , line FROM endpointman_line_list WHERE mac_id ='. $row['id'].' ORDER BY line ASC'; + $line_list = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + $description = ""; + $c = 0; + foreach($line_list as $line_row) { + if($c > 0) { + $description .= ", "; + } + $description .= $line_row['description']; + $c++; + } + $row_out[$i] = $row; + $row_out[$i]['custom'] = 1; + $row_out[$i]['name'] = $row['mac']; + $row_out[$i]['description'] = $description; + $i++; + } + + /* + //$sql = 'SELECT endpointman_oui_list.id, endpointman_oui_list.oui , endpointman_brand_list.name, endpointman_oui_list.custom FROM endpointman_oui_list , endpointman_brand_list WHERE endpointman_oui_list.brand = endpointman_brand_list.id ORDER BY endpointman_oui_list.oui ASC'; + $sql = 'SELECT T1.id, T1.oui, T2.name, T1.custom FROM endpointman_oui_list as T1 , endpointman_brand_list as T2 WHERE T1.brand = T2.id ORDER BY T1.oui ASC'; + $data = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + $ret = array(); + foreach ($data as $item) { + $ret[] = array('id' => $item['id'], 'oui' => $item['oui'], 'brand' => $item['name'], 'custom' => $item['custom']); + } + */ + return $row_out; + } + + + + + + + + + + function edit_template_display_files($id, $custom, $namefile = "") + { + if ($custom == 0) { + $sql = "SELECT model_id FROM endpointman_template_list WHERE id=" . $id; + } else { + $sql = "SELECT model FROM endpointman_mac_list WHERE id=" . $id; + } + $model_id = sql($sql, 'getOne'); + if (!$this->epm_config->sync_model($model_id)) { + die("unable to sync local template files - TYPE:" . $custom); + } + + $dReturn = array(); + if ($custom == 0) { + $sql = "SELECT endpointman_model_list.max_lines, endpointman_model_list.model as model_name, endpointman_template_list.global_custom_cfg_data, endpointman_product_list.config_files, endpointman_product_list.short_name, endpointman_product_list.id as product_id, endpointman_model_list.template_data, endpointman_model_list.id as model_id, endpointman_template_list.* FROM endpointman_product_list, endpointman_model_list, endpointman_template_list WHERE endpointman_product_list.id = endpointman_template_list.product_id AND endpointman_template_list.model_id = endpointman_model_list.id AND endpointman_template_list.id = " . $id; + } else { + $sql = "SELECT endpointman_model_list.max_lines, endpointman_model_list.model as model_name, endpointman_mac_list.global_custom_cfg_data, endpointman_product_list.config_files, endpointman_mac_list.*, endpointman_line_list.*, endpointman_model_list.id as model_id, endpointman_model_list.template_data, endpointman_product_list.id as product_id, endpointman_product_list.short_name, endpointman_product_list.cfg_dir, endpointman_brand_list.directory FROM endpointman_brand_list, endpointman_mac_list, endpointman_model_list, endpointman_product_list, endpointman_line_list WHERE endpointman_mac_list.id=" . $id . " AND endpointman_mac_list.id = endpointman_line_list.mac_id AND endpointman_mac_list.model = endpointman_model_list.id AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id"; + } + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + + if ($row['config_files_override'] == "") { + $config_files_saved = ""; + } else { + $config_files_saved = unserialize($row['config_files_override']); + } + $config_files_list = explode(",", $row['config_files']); + asort($config_files_list); + + $i = 0; + $b = 0; + $alt_configs = array(); + $only_configs = array(); + foreach ($config_files_list as $files) + { + if ($namefile != $files) { continue; } + + $only_configs[$b]['id'] = $b; + $only_configs[$b]['id_d'] = $id; + $only_configs[$b]['id_p'] = $row['product_id']; + $only_configs[$b]['name'] = $files; + $only_configs[$b]['select'] = "ON"; + + $sql = "SELECT * FROM endpointman_custom_configs WHERE product_id = '" . $row['product_id'] . "' AND original_name = '" . $files . "'"; + $alt_configs_list = sql($sql, 'getAll', DB_FETCHMODE_ASSOC ); + + if ( count($alt_configs_list) > 0) + { + $files = str_replace(".", "_", $files); + foreach ($alt_configs_list as $ccf) + { + $cf_key = $files; + if ((isset($config_files_saved[$cf_key])) AND (is_array($config_files_saved)) AND ($config_files_saved[$cf_key] == $ccf['id'])) { + $alt_configs[$i]['select'] = 'ON'; + $only_configs[$b]['select'] = "OFF"; + } + else { + $alt_configs[$i]['select'] = 'OFF'; + } + $alt_configs[$i]['id'] = $ccf['id']; + $alt_configs[$i]['id_p'] = $row['product_id']; + $alt_configs[$i]['name'] = $ccf['name']; + $alt_configs[$i]['name_original'] = $files; + + $i++; + } + } + } + + $dReturn['only_configs'] = $only_configs; + $dReturn['alt_configs'] = $alt_configs; + + return $dReturn; + } + + function edit_template_display_files_list($id, $custom) + { + if ($custom == 0) { + $sql = "SELECT model_id FROM endpointman_template_list WHERE id=" . $id; + } else { + $sql = "SELECT model FROM endpointman_mac_list WHERE id=" . $id; + } + $model_id = sql($sql, 'getOne'); + if (!$this->epm_config->sync_model($model_id)) { + die("unable to sync local template files - TYPE:" . $custom); + } + + + if ($custom == 0) { + $sql = "SELECT endpointman_model_list.max_lines, endpointman_model_list.model as model_name, endpointman_template_list.global_custom_cfg_data, endpointman_product_list.config_files, endpointman_product_list.short_name, endpointman_product_list.id as product_id, endpointman_model_list.template_data, endpointman_model_list.id as model_id, endpointman_template_list.* FROM endpointman_product_list, endpointman_model_list, endpointman_template_list WHERE endpointman_product_list.id = endpointman_template_list.product_id AND endpointman_template_list.model_id = endpointman_model_list.id AND endpointman_template_list.id = " . $id; + } else { + $sql = "SELECT endpointman_model_list.max_lines, endpointman_model_list.model as model_name, endpointman_mac_list.global_custom_cfg_data, endpointman_product_list.config_files, endpointman_mac_list.*, endpointman_line_list.*, endpointman_model_list.id as model_id, endpointman_model_list.template_data, endpointman_product_list.id as product_id, endpointman_product_list.short_name, endpointman_product_list.cfg_dir, endpointman_brand_list.directory FROM endpointman_brand_list, endpointman_mac_list, endpointman_model_list, endpointman_product_list, endpointman_line_list WHERE endpointman_mac_list.id=" . $id . " AND endpointman_mac_list.id = endpointman_line_list.mac_id AND endpointman_mac_list.model = endpointman_model_list.id AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id"; + } + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + $config_files_list = explode(",", $row['config_files']); + asort($config_files_list); + + $i = 0; + $b = 0; + $dReturn = array(); + foreach ($config_files_list as $files) + { + $dReturn[$b]['id'] = $b; + $dReturn[$b]['id_d'] = $id; + $dReturn[$b]['id_p'] = $row['product_id']; + $dReturn[$b]['name'] = $files; + $b++; + } + unset($config_files_list); + + return $dReturn; + } + + + + + + /** + * Custom Means specific to that MAC + * id is either the mac ID (not address) or the template ID + * @param integer $id + * @param integer $custom + */ + function edit_template_display($id, $custom) { + //endpointman_flush_buffers(); + + $alt_configs = NULL; + + if ($custom == 0) { + $sql = "SELECT model_id FROM endpointman_template_list WHERE id=" . $id; + } else { + $sql = "SELECT model FROM endpointman_mac_list WHERE id=" . $id; + } + + $model_id = sql($sql, 'getOne'); + + //Make sure the model data from the local confg files are stored in the database and vice-versa. Serious errors will occur if the database is not in sync with the local file + if (!$this->epm_config->sync_model($model_id)) { + die("unable to sync local template files - TYPE:" . $custom); + } + + $dReturn = array(); + + + //Determine if we are dealing with a general template or a specific [for that phone only] template (custom =0 means general) + if ($custom == 0) { + $sql = "SELECT endpointman_model_list.max_lines, endpointman_model_list.model as model_name, endpointman_template_list.global_custom_cfg_data, endpointman_product_list.config_files, endpointman_product_list.short_name, endpointman_product_list.id as product_id, endpointman_model_list.template_data, endpointman_model_list.id as model_id, endpointman_template_list.* FROM endpointman_product_list, endpointman_model_list, endpointman_template_list WHERE endpointman_product_list.id = endpointman_template_list.product_id AND endpointman_template_list.model_id = endpointman_model_list.id AND endpointman_template_list.id = " . $id; + } else { + $sql = "SELECT endpointman_model_list.max_lines, endpointman_model_list.model as model_name, endpointman_mac_list.global_custom_cfg_data, endpointman_product_list.config_files, endpointman_mac_list.*, endpointman_line_list.*, endpointman_model_list.id as model_id, endpointman_model_list.template_data, endpointman_product_list.id as product_id, endpointman_product_list.short_name, endpointman_product_list.cfg_dir, endpointman_brand_list.directory FROM endpointman_brand_list, endpointman_mac_list, endpointman_model_list, endpointman_product_list, endpointman_line_list WHERE endpointman_mac_list.id=" . $id . " AND endpointman_mac_list.id = endpointman_line_list.mac_id AND endpointman_mac_list.model = endpointman_model_list.id AND endpointman_model_list.brand = endpointman_brand_list.id AND endpointman_model_list.product_id = endpointman_product_list.id"; + } + $row = sql($sql, 'getRow', DB_FETCHMODE_ASSOC); + + + $dReturn['template_editor_display'] = 1; + + //Let the template system know if we are working with a general template or a specific [for that phone only] template + $dReturn['custom'] = $custom; + if ($custom) + { + $dReturn['ext'] = $row['ext']; + } + else + { + $dReturn['template_name'] = $row['name']; + } + $dReturn['product'] = $row['short_name']; + $dReturn['model'] = $row['model_name']; + + if ($ma = $this->models_available($row['model_id'], NULL, $row['product_id'])) { + $dReturn['models_ava'] = $ma; + } + + if (isset($_REQUEST['maxlines'])) { + $areas = $this->areaAvailable($row['model_id'], $_REQUEST['maxlines']); + } else { + $areas = $this->areaAvailable($row['model_id'], 1); + } + $dReturn['area_ava'] = $areas; + + //Start the display of the html file in the product folder + if ($row['config_files_override'] == "") { + $config_files_saved = ""; + } else { + $config_files_saved = unserialize($row['config_files_override']); + } + $config_files_list = explode(",", $row['config_files']); + asort($config_files_list); + + $alt = 0; + $i = 0; + $b = 0; + $only_configs = array(); + foreach ($config_files_list as $files) { + $sql = "SELECT * FROM endpointman_custom_configs WHERE product_id = '" . $row['product_id'] . "' AND original_name = '" . $files . "'"; + $alt_configs_list_count = sql($sql, 'getAll', DB_FETCHMODE_ASSOC ); + if (! empty($alt_configs_list_count)) { + $alt_configs_list = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); + $alt_configs[$i]['name'] = $files; + $alt_configs[$i]['id_p'] = $row['product_id']; + $files = str_replace(".", "_", $files); + $h = 0; + foreach ($alt_configs_list as $ccf) { + $alt_configs[$i]['list'][$h]['id'] = $ccf['id']; + $cf_key = $files; + if ((isset($config_files_saved[$cf_key])) AND (is_array($config_files_saved)) AND ($config_files_saved[$cf_key] == $ccf['id'])) { + $alt_configs[$i]['list'][$h]['selected'] = 'selected'; + } + $alt_configs[$i]['list'][$h]['id'] = $h; + $alt_configs[$i]['list'][$h]['name'] = $ccf['name']; + $h++; + } + $alt = 1; + } + else { + $only_configs[$b]['id'] = $b; + $only_configs[$b]['id_d'] = $id; + $only_configs[$b]['id_p'] = $row['product_id']; + $only_configs[$b]['name'] = $files; + $b++; + } + $i++; + } + + $dReturn['only_configs'] = $only_configs; + $dReturn['alt_configs'] = $alt_configs; + $dReturn['alt'] = $alt; + + if (!isset($_REQUEST['maxlines'])) { + $maxlines = 1; + } else { + $maxlines = $_REQUEST['maxlines']; + } + if ($row['template_data'] != "") { + $out = $this->generate_gui_html($row['template_data'], $row['global_custom_cfg_data'], TRUE, NULL, $maxlines); + } else { + $out = "No Template Data has been defined for this Product
"; + } + + $dReturn['template_editor'] = $out; + $dReturn['hidden_id'] = $row['id']; + $dReturn['hidden_custom'] = $custom; + + return $dReturn; + } + + + + + /** + * + * @param integer $model model ID + * @param integer $brand brand ID + * @param integer $product product ID + * @return array + */ + function models_available($model=NULL, $brand=NULL, $product=NULL) { + + if ((!isset($oui)) && (!isset($brand)) && (!isset($model))) { + $result1 = $this->eda->all_models(); + } elseif ((isset($brand)) && ($brand != 0)) { + $result1 = $this->eda->all_models_by_brand($brand); + } elseif ((isset($product)) && ($product != 0)) { + $result1 = $this->eda->all_models_by_product($product); + } else { + $result1 = $this->eda->all_models(); + } + + $i = 1; + foreach ($result1 as $row) { + if ($row['id'] == $model) { + $temp[$i]['value'] = $row['id']; + $temp[$i]['text'] = $row['model']; + $temp[$i]['selected'] = 'selected'; + } else { + $temp[$i]['value'] = $row['id']; + $temp[$i]['text'] = $row['model']; + $temp[$i]['selected'] = 0; + } + $i++; + } + + if (!isset($temp)) { + if (! $this->configmod->isExiste('new')) { + $this->error['modelsAvailable'] = "You need to enable at least ONE model"; + } + return(FALSE); + } else { + return($temp); + } + } + + + + function areaAvailable($model, $area=NULL) { + $sql = "SELECT max_lines FROM endpointman_model_list WHERE id = '" . $model . "'"; + $count = sql($sql, 'getOne'); + + for ($z = 0; $z < $count; $z++) { + $result[$z]['id'] = $z + 1; + $result[$z]['model'] = $z + 1; + } + + $i = 1; + foreach ($result as $row) { + if ($row['id'] == $area) { + $temp[$i]['value'] = $row['id']; + $temp[$i]['text'] = $row['model']; + $temp[$i]['selected'] = 'selected'; + } else { + $temp[$i]['value'] = $row['id']; + $temp[$i]['text'] = $row['model']; + $temp[$i]['selected'] = 0; + } + $i++; + } + + return($temp); + } + + /** + * Generates the Visual Display for the end user + * @param $cfg_data + * @param $custom_cfg_data + * @param $admin + * @param $user_cfg_data + * @return + */ + function generate_gui_html($cfg_data, $custom_cfg_data=NULL, $admin=FALSE, $user_cfg_data=NULL, $max_lines=3, $ext=NULL) { + //take the data out of the database and turn it back into an array for use + $cfg_data = unserialize($cfg_data); + $template_type = 'GENERAL'; + //Check to see if there is a custom template for this phone already listed in the endpointman_mac_list database + if (!empty($custom_cfg_data)) { + $custom_cfg_data = unserialize($custom_cfg_data); + if (array_key_exists('data', $custom_cfg_data)) { + if (array_key_exists('ari', $custom_cfg_data)) { + $extra_data = $custom_cfg_data['ari']; + } else { + $template_type = 'GLOBAL'; + $extra_data = $custom_cfg_data['freepbx']; + } + $custom_cfg_data = $custom_cfg_data['data']; + } else { + $extra_data = array(); + } + } else { + $custom_cfg_data = array(); + $extra_data = array(); + } + if (isset($user_cfg_data)) { + $user_cfg_data = unserialize($user_cfg_data); + } + + $template_variables_array = array(); + $group_count = 0; + $variables_count = 0; + + foreach ($cfg_data['data'] as $cats_name => $cats) { + if ($admin) { + $group_count++; + $template_variables_array[$group_count]['title'] = $cats_name; + } else { + //Group all ARI stuff into one tab + $template_variables_array[$group_count]['title'] = "Your Phone Settings"; + } + foreach ($cats as $subcat_name => $subcats) { + foreach ($subcats as $item_var => $config_options) { + if (preg_match('/(.*)\|(.*)/i', $item_var, $matches)) { + $type = $matches[1]; + $variable = $matches[2]; + } else { + die('no matches!'); + } + if ($admin) { + //Administration View Only + switch ($type) { + case "lineloop": + //line|1|display_name + foreach ($config_options as $var_name => $var_items) { + $lcount = isset($var_items['line_count']) ? $var_items['line_count'] : $lcount; + $key = "line|" . $lcount . "|" . $var_name; + $items[$variables_count] = $items; + $template_variables_array[$group_count]['data'][$variables_count] = $this->generate_form_data($variables_count, $var_items, $key, $custom_cfg_data, $admin, $user_cfg_data, $extra_data, $template_type); + $template_variables_array[$group_count]['data'][$variables_count]['looping'] = TRUE; + $variables_count++; + } + + if ($lcount <= $max_lines) { + $template_variables_array[$group_count]['title'] = "Line Options for Line " . $lcount; + $group_count++; + } else { + unset($template_variables_array[$group_count]); + } + + continue 2; + case "loop": + foreach ($config_options as $var_name => $var_items) { + //loop|remotephonebook_url_0 + $tv = explode('_', $variable); + $key = "loop|" . $tv[0] . "_" . $var_name . (isset($var_items['loop_count']) ? "_" . $var_items['loop_count'] : ''); + $items[$variables_count] = $var_items; + $template_variables_array[$group_count]['data'][$variables_count] = $this->generate_form_data($variables_count, $var_items, $key, $custom_cfg_data, $admin, $user_cfg_data, $extra_data, $template_type); + $template_variables_array[$group_count]['data'][$variables_count]['looping'] = TRUE; + $variables_count++; + } + continue 2; + } + } else { + //ARI View Only + switch ($type) { + case "loop_line_options": + //$a is the line number + $sql = "SELECT line FROM endpointman_line_list WHERE ext = " . $ext; + $a = $this->eda->sql($sql, 'getOne'); + //TODO: fix this area + $template_variables_array[$group_count]['data'][$variables_count]['type'] = "break"; + $variables_count++; + continue 2; + case "loop": + foreach ($config_options as $var_name => $var_items) { + $tv = explode('_', $variable); + $key = "loop|" . $tv[0] . "_" . $var_name . "_" . $var_items['loop_count']; + if (isset($extra_data[$key])) { + $items[$variables_count] = $var_items; + $template_variables_array[$group_count]['data'][$variables_count] = $this->generate_form_data($variables_count, $var_items, $key, $custom_cfg_data, $admin, $user_cfg_data, $extra_data, $template_type); + $template_variables_array[$group_count]['data'][$variables_count]['looping'] = TRUE; + $variables_count++; + } + } + continue 2; + } + } + //Both Views + switch ($config_options['type']) { + case "break": + $template_variables_array[$group_count]['data'][$variables_count] = $this->generate_form_data($variables_count, $config_options, $key, $custom_cfg_data, $admin, $user_cfg_data, $extra_data, $template_type); + $variables_count++; + break; + default: + if (array_key_exists('variable', $config_options)) { + $key = str_replace('$', '', $config_options['variable']); + //TODO: Move this into the sync function + //Checks to see if values are defined in the database, if not then we assume this is a new option and we need a default value here! + if (!isset($custom_cfg_data[$key])) { + //xml2array will take values that have no data and turn them into arrays, we want to avoid the word 'array' as a default value, so we blank it out here if we are an array + if ((array_key_exists('default_value', $config_options)) AND (is_array($config_options['default_value']))) { + $custom_cfg_data[$key] = ""; + } elseif ((array_key_exists('default_value', $config_options)) AND (!is_array($config_options['default_value']))) { + $custom_cfg_data[$key] = $config_options['default_value']; + } + } + if ((!$admin) AND (isset($extra_data[$key]))) { + $custom_cfg_data[$key] = $user_cfg_data[$key]; + $template_variables_array[$group_count]['data'][$variables_count] = $this->generate_form_data($variables_count, $config_options, $key, $custom_cfg_data, $admin, $user_cfg_data, $extra_data, $template_type); + $variables_count++; + } elseif ($admin) { + $template_variables_array[$group_count]['data'][$variables_count] = $this->generate_form_data($variables_count, $config_options, $key, $custom_cfg_data, $admin, $user_cfg_data, $extra_data, $template_type); + $variables_count++; + } + } + break; + } + continue; + } + } + } + + return($template_variables_array); + } + + + /** + * Generate an array that will get parsed as HTML from an array of values from XML + * @param int $i + * @param array $cfg_data + * @param string $key + * @param array $custom_cfg_data + * @return array + */ + function generate_form_data($i, $cfg_data, $key=NULL, $custom_cfg_data=NULL, $admin=FALSE, $user_cfg_data=NULL, $extra_data=NULL, $template_type='GENERAL') { + switch ($cfg_data['type']) { + case "input": + if ((!$admin) && (isset($user_cfg_data[$key]))) { + $custom_cfg_data[$key] = $user_cfg_data[$key]; + } + $template_variables_array['type'] = "input"; + if (isset($cfg_data['max_chars'])) { + $template_variables_array['max_chars'] = $cfg_data['max_chars']; + } + $template_variables_array['key'] = $key; + $template_variables_array['value'] = isset($custom_cfg_data[$key]) ? $custom_cfg_data[$key] : $cfg_data['default_value']; + $template_variables_array['description'] = $cfg_data['description']; + break; + + case "radio": + if ((!$admin) && (isset($user_cfg_data[$key]))) { + $custom_cfg_data[$key] = $user_cfg_data[$key]; + } + $num = isset($custom_cfg_data[$key]) ? $custom_cfg_data[$key] : $cfg_data['default_value']; + $template_variables_array['type'] = "radio"; + $template_variables_array['key'] = $key; + $template_variables_array['description'] = $cfg_data['description']; + $z = 0; + while ($z < count($cfg_data['data'])) { + $template_variables_array['data'][$z]['key'] = $key; + $template_variables_array['data'][$z]['value'] = $cfg_data['data'][$z]['value']; + $template_variables_array['data'][$z]['description'] = $cfg_data['data'][$z]['text']; + if ($cfg_data['data'][$z]['value'] == $num) { + $template_variables_array['data'][$z]['checked'] = 'checked'; + } + $z++; + } + break; + + case "list": + if ((!$admin) && (isset($user_cfg_data[$key]))) { + $custom_cfg_data[$key] = $user_cfg_data[$key]; + } + $num = isset($custom_cfg_data[$key]) ? $custom_cfg_data[$key] : $cfg_data['default_value']; + $template_variables_array['type'] = "list"; + $template_variables_array['key'] = $key; + $template_variables_array['description'] = $cfg_data['description']; + $z = 0; + while ($z < count($cfg_data['data'])) { + $template_variables_array['data'][$z]['value'] = $cfg_data['data'][$z]['value']; + $template_variables_array['data'][$z]['description'] = $cfg_data['data'][$z]['text']; + if (isset($cfg_data['data'][$z]['disable'])) { + $cfg_data['data'][$z]['disable'] = str_replace('{$count}', $z, $cfg_data['data'][$z]['disable']); + $template_variables_array['data'][$z]['disables'] = explode(",", $cfg_data['data'][$z]['disable']); + } + if (isset($cfg_data['data'][$z]['enable'])) { + $cfg_data['data'][$z]['enable'] = str_replace('{$count}', $z, $cfg_data['data'][$z]['enable']); + $template_variables_array['data'][$z]['enables'] = explode(",", $cfg_data['data'][$z]['enable']); + } + if ($cfg_data['data'][$z]['value'] == $num) { + $template_variables_array['data'][$z]['selected'] = 'selected'; + } + $z++; + } + break; + + case "checkbox": + if ((!$admin) && (isset($user_cfg_data[$key]))) { + $custom_cfg_data[$key] = $user_cfg_data[$key]; + } + $num = isset($custom_cfg_data[$key]) ? $custom_cfg_data[$key] : $cfg_data['default_value']; + $template_variables_array['type'] = "checkbox"; + $template_variables_array['key'] = $key; + $template_variables_array['description'] = $cfg_data['description']; + $template_variables_array['checked'] = $custom_cfg_data[$key] ? TRUE : NULL; + $template_variables_array['value'] = $key; + break; + + case "group"; + $template_variables_array['type'] = "group"; + $template_variables_array['description'] = $cfg_data['description']; + break; + + case "header"; + $template_variables_array['type'] = "header"; + $template_variables_array['description'] = $cfg_data['description']; + break; + + case "textarea": + if ((!$admin) && (isset($user_cfg_data[$key]))) { + $custom_cfg_data[$key] = $user_cfg_data[$key]; + } + $template_variables_array['type'] = "textarea"; + if (isset($cfg_data['rows'])) { + $template_variables_array['rows'] = $cfg_data['rows']; + } + if (isset($cfg_data['cols'])) { + $template_variables_array['cols'] = $cfg_data['cols']; + } + $template_variables_array['key'] = $key; + $template_variables_array['value'] = isset($custom_cfg_data[$key]) ? $custom_cfg_data[$key] : $cfg_data['default_value']; + $template_variables_array['description'] = $cfg_data['description']; + break; + + case "break": + if ($admin) { + $template_variables_array['type'] = "break"; + } else { + $template_variables_array['type'] = "NA"; + } + break; + + default: + $template_variables_array['type'] = "NA"; + break; + } + + if (isset($cfg_data['tooltip'])) { + $template_variables_array['tooltip'] = htmlentities($cfg_data['tooltip']); + } + + if (($this->configmod->get('enable_ari')) AND ($admin) AND ($cfg_data['type'] != "break") AND ($cfg_data['type'] != "group") AND ($template_type == 'GENERAL')) { + + $template_variables_array['aried'] = 1; + $template_variables_array['ari']['key'] = $key; + + if (isset($extra_data[$key])) { + $template_variables_array['ari']['checked'] = "checked"; + } + } + + if ($template_type == 'GLOBAL') { + $template_variables_array['freepbxed'] = 1; + $template_variables_array['freepbx']['key'] = $key; + if (empty($extra_data)) { + $template_variables_array['freepbx']['checked'] = TRUE; + } elseif (isset($extra_data[$key])) { + $template_variables_array['freepbx']['checked'] = TRUE; + } + } + return($template_variables_array); + } + + + + + + + + +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program 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. + + This program 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 this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 00000000..2132a722 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +``` + ______ _____ ______ __ +| ____| | __ \| _ \ \ / / +| |__ _ __ ___ ___| |__) | |_) \ V / +| __| '__/ _ \/ _ \ ___/| _ < > < +| | | | | __/ __/ | | |_) / . \ +|_| |_| \___|\___|_| |____/_/ \_\ +Your Open Source Asterisk PBX GUI Solution +``` +### What? +endpointman +This is a module for [FreePBX©](http://www.freepbx.org/ "FreePBX Home Page"). [FreePBX](http://www.freepbx.org/ "FreePBX Home Page") is an open source GUI (graphical user interface) that controls and manages [Asterisk©](http://www.asterisk.org/ "Asterisk Home Page") (PBX). FreePBX is licensed under GPL. +[FreePBX](http://www.freepbx.org/ "FreePBX Home Page") is a completely modular GUI for Asterisk written in PHP and Javascript. Meaning you can easily write any module you can think of and distribute it free of cost to your clients so that they can take advantage of beneficial features in [Asterisk](http://www.asterisk.org/ "Asterisk Home Page") + +### Setting up a FreePBX system +[See our WIKI](http://wiki.freepbx.org/display/FOP/Install+FreePBX) +### License +[This modules code is licensed as GPLv3+](http://www.gnu.org/licenses/gpl-3.0.txt) +### Contributing +To contribute code or modules back into the [FreePBX](http://www.freepbx.org/ "FreePBX Home Page") ecosystem you must fully read our Code License Agreement. We are not able to look at or accept patches or code of any kind until this document is filled out. Please take a look at [http://wiki.freepbx.org/display/DC/Code+License+Agreement](http://wiki.freepbx.org/display/DC/Code+License+Agreement) for more information +### Issues +Please file bug reports at http://issues.freepbx.org \ No newline at end of file diff --git a/ajax_select.html.php b/ajax_select.html.php old mode 100755 new mode 100644 index db55739e..d432db61 --- a/ajax_select.html.php +++ b/ajax_select.html.php @@ -6,4 +6,4 @@ * @license MPL / GPLv2 / LGPL * @package Endpoint Manager */ -include('includes/ajax_select.php'); \ No newline at end of file +include('includes/ajax.inc'); \ No newline at end of file diff --git a/ari/js/ajax_req.js b/ari/js/ajax_req.js old mode 100755 new mode 100644 diff --git a/ari/js/jquery-1.3.2.min.js b/ari/js/jquery-1.3.2.min.js old mode 100755 new mode 100644 diff --git a/ari/js/jquery.coda-slider-2.0.js b/ari/js/jquery.coda-slider-2.0.js old mode 100755 new mode 100644 diff --git a/ari/js/jquery.cookie.js b/ari/js/jquery.cookie.js old mode 100755 new mode 100644 diff --git a/ari/js/jquery.easing.1.3.js b/ari/js/jquery.easing.1.3.js old mode 100755 new mode 100644 diff --git a/ari/js/jquery.js b/ari/js/jquery.js old mode 100755 new mode 100644 diff --git a/ari/js/jquery.jstree.js b/ari/js/jquery.jstree.js old mode 100755 new mode 100644 diff --git a/ari/js/jquery.tools.min.js b/ari/js/jquery.tools.min.js old mode 100755 new mode 100644 diff --git a/ari/modules/phonesettings.module b/ari/modules/phonesettings.module old mode 100755 new mode 100644 index 40d6b22f..b13ee8a9 --- a/ari/modules/phonesettings.module +++ b/ari/modules/phonesettings.module @@ -46,7 +46,7 @@ class phonesettings { $results = $_SESSION['dbh_asterisk']->getAll($sql, DB_FETCHMODE_ASSOC); // and we are not logged in as admin - if (($exten!=$ARI_ADMIN_USERNAME) AND ($results[0]['value'])) { + if (!DB::IsError($results) && ($exten!=$ARI_ADMIN_USERNAME) AND ($results[0]['value'])) { $ret .= "

" . _("Phone Settings") . "


"; } @@ -70,7 +70,7 @@ class phonesettings { $endpoint = new endpointmanager(); $sql = "SELECT mac_id, line FROM endpointman_line_list WHERE ext = '".$_SESSION['ari_user']['extension']."' "; - $mac_row =& $endpoint->db->getRow($sql, array(), DB_FETCHMODE_ASSOC); + $mac_row = $endpoint->eda->sql($sql, 'getrow', DB_FETCHMODE_ASSOC); $mac_id = $mac_row['mac_id']; $line = $mac_row['line']; @@ -107,7 +107,7 @@ class phonesettings { $custom_cfg_data = serialize($custom_cfg_data); $sql = "UPDATE endpointman_mac_list SET global_user_cfg_data = '".$custom_cfg_data."' WHERE id = ". $mac_id; - $endpoint->db->query($sql); + $endpoint->eda->sql($sql); $reboot = isset($_REQUEST['epm_reboot'])?$_REQUEST['epm_reboot']:null; @@ -157,10 +157,10 @@ class phonesettings { $sql = "SELECT mac_id, line FROM endpointman_line_list WHERE ext = '".$_SESSION['ari_user']['extension']."' "; - $res =& $endpoint->db->query($sql); - if($res->numRows()) { + $res = $endpoint->eda->sql($sql); + if(count($res)) { - $mac_row =& $endpoint->db->getRow($sql, array(), DB_FETCHMODE_ASSOC); + $mac_row = $endpoint->eda->sql($sql, 'getrow', DB_FETCHMODE_ASSOC); $mac_id = $mac_row['mac_id']; $line = $mac_row['line']; @@ -206,7 +206,7 @@ class phonesettings { $m = "phonesettings"; - $ret = "
+ $ret = " @@ -228,4 +228,4 @@ class phonesettings { return($ret); } } -} \ No newline at end of file +} diff --git a/ari/theme/coda-slider-2.0a.css b/ari/theme/coda-slider-2.0a.css old mode 100755 new mode 100644 diff --git a/ari/theme/reset.css b/ari/theme/reset.css old mode 100755 new mode 100644 diff --git a/assets/css/ajax-bootstrap-select.css b/assets/css/ajax-bootstrap-select.css new file mode 100644 index 00000000..05bd2c02 --- /dev/null +++ b/assets/css/ajax-bootstrap-select.css @@ -0,0 +1,27 @@ +/*! + * Ajax Bootstrap Select + * + * Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON. + * + * @version 1.3.7 + * @author Adam Heim - https://github.com/truckingsim + * @link https://github.com/truckingsim/Ajax-Bootstrap-Select + * @copyright 2016 Adam Heim + * @license Released under the MIT license. + * + * Contributors: + * Mark Carver - https://github.com/markcarver + * + * Last build: 2016-06-24 1:36:44 PM EDT + */ +.bootstrap-select .status { + background: #f0f0f0; + clear: both; + color: #999; + font-size: 11px; + font-style: italic; + font-weight: 500; + line-height: 1; + margin-bottom: -5px; + padding: 10px 20px; +} diff --git a/assets/css/animate.css b/assets/css/animate.css new file mode 100644 index 00000000..188e78f6 --- /dev/null +++ b/assets/css/animate.css @@ -0,0 +1,3340 @@ +@charset "UTF-8"; + +/*! + * animate.css -http://daneden.me/animate + * Version - 3.5.0 + * Licensed under the MIT license - http://opensource.org/licenses/MIT + * + * Copyright (c) 2016 Daniel Eden + */ + +.animated { + -webkit-animation-duration: 1s; + animation-duration: 1s; + -webkit-animation-fill-mode: both; + animation-fill-mode: both; +} + +.animated.infinite { + -webkit-animation-iteration-count: infinite; + animation-iteration-count: infinite; +} + +.animated.hinge { + -webkit-animation-duration: 2s; + animation-duration: 2s; +} + +.animated.flipOutX, +.animated.flipOutY, +.animated.bounceIn, +.animated.bounceOut { + -webkit-animation-duration: .75s; + animation-duration: .75s; +} + +@-webkit-keyframes bounce { + from, 20%, 53%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + -webkit-transform: translate3d(0,0,0); + transform: translate3d(0,0,0); + } + + 40%, 43% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -30px, 0); + transform: translate3d(0, -30px, 0); + } + + 70% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -15px, 0); + transform: translate3d(0, -15px, 0); + } + + 90% { + -webkit-transform: translate3d(0,-4px,0); + transform: translate3d(0,-4px,0); + } +} + +@keyframes bounce { + from, 20%, 53%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + -webkit-transform: translate3d(0,0,0); + transform: translate3d(0,0,0); + } + + 40%, 43% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -30px, 0); + transform: translate3d(0, -30px, 0); + } + + 70% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -15px, 0); + transform: translate3d(0, -15px, 0); + } + + 90% { + -webkit-transform: translate3d(0,-4px,0); + transform: translate3d(0,-4px,0); + } +} + +.bounce { + -webkit-animation-name: bounce; + animation-name: bounce; + -webkit-transform-origin: center bottom; + transform-origin: center bottom; +} + +@-webkit-keyframes flash { + from, 50%, to { + opacity: 1; + } + + 25%, 75% { + opacity: 0; + } +} + +@keyframes flash { + from, 50%, to { + opacity: 1; + } + + 25%, 75% { + opacity: 0; + } +} + +.flash { + -webkit-animation-name: flash; + animation-name: flash; +} + +/* originally authored by Nick Pettit - https://github.com/nickpettit/glide */ + +@-webkit-keyframes pulse { + from { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + + 50% { + -webkit-transform: scale3d(1.05, 1.05, 1.05); + transform: scale3d(1.05, 1.05, 1.05); + } + + to { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +@keyframes pulse { + from { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + + 50% { + -webkit-transform: scale3d(1.05, 1.05, 1.05); + transform: scale3d(1.05, 1.05, 1.05); + } + + to { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +.pulse { + -webkit-animation-name: pulse; + animation-name: pulse; +} + +@-webkit-keyframes rubberBand { + from { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + + 30% { + -webkit-transform: scale3d(1.25, 0.75, 1); + transform: scale3d(1.25, 0.75, 1); + } + + 40% { + -webkit-transform: scale3d(0.75, 1.25, 1); + transform: scale3d(0.75, 1.25, 1); + } + + 50% { + -webkit-transform: scale3d(1.15, 0.85, 1); + transform: scale3d(1.15, 0.85, 1); + } + + 65% { + -webkit-transform: scale3d(.95, 1.05, 1); + transform: scale3d(.95, 1.05, 1); + } + + 75% { + -webkit-transform: scale3d(1.05, .95, 1); + transform: scale3d(1.05, .95, 1); + } + + to { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +@keyframes rubberBand { + from { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + + 30% { + -webkit-transform: scale3d(1.25, 0.75, 1); + transform: scale3d(1.25, 0.75, 1); + } + + 40% { + -webkit-transform: scale3d(0.75, 1.25, 1); + transform: scale3d(0.75, 1.25, 1); + } + + 50% { + -webkit-transform: scale3d(1.15, 0.85, 1); + transform: scale3d(1.15, 0.85, 1); + } + + 65% { + -webkit-transform: scale3d(.95, 1.05, 1); + transform: scale3d(.95, 1.05, 1); + } + + 75% { + -webkit-transform: scale3d(1.05, .95, 1); + transform: scale3d(1.05, .95, 1); + } + + to { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +.rubberBand { + -webkit-animation-name: rubberBand; + animation-name: rubberBand; +} + +@-webkit-keyframes shake { + from, to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + 10%, 30%, 50%, 70%, 90% { + -webkit-transform: translate3d(-10px, 0, 0); + transform: translate3d(-10px, 0, 0); + } + + 20%, 40%, 60%, 80% { + -webkit-transform: translate3d(10px, 0, 0); + transform: translate3d(10px, 0, 0); + } +} + +@keyframes shake { + from, to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + 10%, 30%, 50%, 70%, 90% { + -webkit-transform: translate3d(-10px, 0, 0); + transform: translate3d(-10px, 0, 0); + } + + 20%, 40%, 60%, 80% { + -webkit-transform: translate3d(10px, 0, 0); + transform: translate3d(10px, 0, 0); + } +} + +.shake { + -webkit-animation-name: shake; + animation-name: shake; +} + +@-webkit-keyframes headShake { + 0% { + -webkit-transform: translateX(0); + transform: translateX(0); + } + + 6.5% { + -webkit-transform: translateX(-6px) rotateY(-9deg); + transform: translateX(-6px) rotateY(-9deg); + } + + 18.5% { + -webkit-transform: translateX(5px) rotateY(7deg); + transform: translateX(5px) rotateY(7deg); + } + + 31.5% { + -webkit-transform: translateX(-3px) rotateY(-5deg); + transform: translateX(-3px) rotateY(-5deg); + } + + 43.5% { + -webkit-transform: translateX(2px) rotateY(3deg); + transform: translateX(2px) rotateY(3deg); + } + + 50% { + -webkit-transform: translateX(0); + transform: translateX(0); + } +} + +@keyframes headShake { + 0% { + -webkit-transform: translateX(0); + transform: translateX(0); + } + + 6.5% { + -webkit-transform: translateX(-6px) rotateY(-9deg); + transform: translateX(-6px) rotateY(-9deg); + } + + 18.5% { + -webkit-transform: translateX(5px) rotateY(7deg); + transform: translateX(5px) rotateY(7deg); + } + + 31.5% { + -webkit-transform: translateX(-3px) rotateY(-5deg); + transform: translateX(-3px) rotateY(-5deg); + } + + 43.5% { + -webkit-transform: translateX(2px) rotateY(3deg); + transform: translateX(2px) rotateY(3deg); + } + + 50% { + -webkit-transform: translateX(0); + transform: translateX(0); + } +} + +.headShake { + -webkit-animation-timing-function: ease-in-out; + animation-timing-function: ease-in-out; + -webkit-animation-name: headShake; + animation-name: headShake; +} + +@-webkit-keyframes swing { + 20% { + -webkit-transform: rotate3d(0, 0, 1, 15deg); + transform: rotate3d(0, 0, 1, 15deg); + } + + 40% { + -webkit-transform: rotate3d(0, 0, 1, -10deg); + transform: rotate3d(0, 0, 1, -10deg); + } + + 60% { + -webkit-transform: rotate3d(0, 0, 1, 5deg); + transform: rotate3d(0, 0, 1, 5deg); + } + + 80% { + -webkit-transform: rotate3d(0, 0, 1, -5deg); + transform: rotate3d(0, 0, 1, -5deg); + } + + to { + -webkit-transform: rotate3d(0, 0, 1, 0deg); + transform: rotate3d(0, 0, 1, 0deg); + } +} + +@keyframes swing { + 20% { + -webkit-transform: rotate3d(0, 0, 1, 15deg); + transform: rotate3d(0, 0, 1, 15deg); + } + + 40% { + -webkit-transform: rotate3d(0, 0, 1, -10deg); + transform: rotate3d(0, 0, 1, -10deg); + } + + 60% { + -webkit-transform: rotate3d(0, 0, 1, 5deg); + transform: rotate3d(0, 0, 1, 5deg); + } + + 80% { + -webkit-transform: rotate3d(0, 0, 1, -5deg); + transform: rotate3d(0, 0, 1, -5deg); + } + + to { + -webkit-transform: rotate3d(0, 0, 1, 0deg); + transform: rotate3d(0, 0, 1, 0deg); + } +} + +.swing { + -webkit-transform-origin: top center; + transform-origin: top center; + -webkit-animation-name: swing; + animation-name: swing; +} + +@-webkit-keyframes tada { + from { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + + 10%, 20% { + -webkit-transform: scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg); + transform: scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg); + } + + 30%, 50%, 70%, 90% { + -webkit-transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg); + transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg); + } + + 40%, 60%, 80% { + -webkit-transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg); + transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg); + } + + to { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +@keyframes tada { + from { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + + 10%, 20% { + -webkit-transform: scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg); + transform: scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg); + } + + 30%, 50%, 70%, 90% { + -webkit-transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg); + transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg); + } + + 40%, 60%, 80% { + -webkit-transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg); + transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg); + } + + to { + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +.tada { + -webkit-animation-name: tada; + animation-name: tada; +} + +/* originally authored by Nick Pettit - https://github.com/nickpettit/glide */ + +@-webkit-keyframes wobble { + from { + -webkit-transform: none; + transform: none; + } + + 15% { + -webkit-transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg); + transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg); + } + + 30% { + -webkit-transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg); + transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg); + } + + 45% { + -webkit-transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg); + transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg); + } + + 60% { + -webkit-transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg); + transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg); + } + + 75% { + -webkit-transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg); + transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg); + } + + to { + -webkit-transform: none; + transform: none; + } +} + +@keyframes wobble { + from { + -webkit-transform: none; + transform: none; + } + + 15% { + -webkit-transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg); + transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg); + } + + 30% { + -webkit-transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg); + transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg); + } + + 45% { + -webkit-transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg); + transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg); + } + + 60% { + -webkit-transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg); + transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg); + } + + 75% { + -webkit-transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg); + transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg); + } + + to { + -webkit-transform: none; + transform: none; + } +} + +.wobble { + -webkit-animation-name: wobble; + animation-name: wobble; +} + +@-webkit-keyframes jello { + from, 11.1%, to { + -webkit-transform: none; + transform: none; + } + + 22.2% { + -webkit-transform: skewX(-12.5deg) skewY(-12.5deg); + transform: skewX(-12.5deg) skewY(-12.5deg); + } + + 33.3% { + -webkit-transform: skewX(6.25deg) skewY(6.25deg); + transform: skewX(6.25deg) skewY(6.25deg); + } + + 44.4% { + -webkit-transform: skewX(-3.125deg) skewY(-3.125deg); + transform: skewX(-3.125deg) skewY(-3.125deg); + } + + 55.5% { + -webkit-transform: skewX(1.5625deg) skewY(1.5625deg); + transform: skewX(1.5625deg) skewY(1.5625deg); + } + + 66.6% { + -webkit-transform: skewX(-0.78125deg) skewY(-0.78125deg); + transform: skewX(-0.78125deg) skewY(-0.78125deg); + } + + 77.7% { + -webkit-transform: skewX(0.390625deg) skewY(0.390625deg); + transform: skewX(0.390625deg) skewY(0.390625deg); + } + + 88.8% { + -webkit-transform: skewX(-0.1953125deg) skewY(-0.1953125deg); + transform: skewX(-0.1953125deg) skewY(-0.1953125deg); + } +} + +@keyframes jello { + from, 11.1%, to { + -webkit-transform: none; + transform: none; + } + + 22.2% { + -webkit-transform: skewX(-12.5deg) skewY(-12.5deg); + transform: skewX(-12.5deg) skewY(-12.5deg); + } + + 33.3% { + -webkit-transform: skewX(6.25deg) skewY(6.25deg); + transform: skewX(6.25deg) skewY(6.25deg); + } + + 44.4% { + -webkit-transform: skewX(-3.125deg) skewY(-3.125deg); + transform: skewX(-3.125deg) skewY(-3.125deg); + } + + 55.5% { + -webkit-transform: skewX(1.5625deg) skewY(1.5625deg); + transform: skewX(1.5625deg) skewY(1.5625deg); + } + + 66.6% { + -webkit-transform: skewX(-0.78125deg) skewY(-0.78125deg); + transform: skewX(-0.78125deg) skewY(-0.78125deg); + } + + 77.7% { + -webkit-transform: skewX(0.390625deg) skewY(0.390625deg); + transform: skewX(0.390625deg) skewY(0.390625deg); + } + + 88.8% { + -webkit-transform: skewX(-0.1953125deg) skewY(-0.1953125deg); + transform: skewX(-0.1953125deg) skewY(-0.1953125deg); + } +} + +.jello { + -webkit-animation-name: jello; + animation-name: jello; + -webkit-transform-origin: center; + transform-origin: center; +} + +@-webkit-keyframes bounceIn { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + 0% { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + + 20% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + + 40% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + + 80% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + + to { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +@keyframes bounceIn { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + 0% { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + + 20% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + + 40% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + + 80% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + + to { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +.bounceIn { + -webkit-animation-name: bounceIn; + animation-name: bounceIn; +} + +@-webkit-keyframes bounceInDown { + from, 60%, 75%, 90%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + 0% { + opacity: 0; + -webkit-transform: translate3d(0, -3000px, 0); + transform: translate3d(0, -3000px, 0); + } + + 60% { + opacity: 1; + -webkit-transform: translate3d(0, 25px, 0); + transform: translate3d(0, 25px, 0); + } + + 75% { + -webkit-transform: translate3d(0, -10px, 0); + transform: translate3d(0, -10px, 0); + } + + 90% { + -webkit-transform: translate3d(0, 5px, 0); + transform: translate3d(0, 5px, 0); + } + + to { + -webkit-transform: none; + transform: none; + } +} + +@keyframes bounceInDown { + from, 60%, 75%, 90%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + 0% { + opacity: 0; + -webkit-transform: translate3d(0, -3000px, 0); + transform: translate3d(0, -3000px, 0); + } + + 60% { + opacity: 1; + -webkit-transform: translate3d(0, 25px, 0); + transform: translate3d(0, 25px, 0); + } + + 75% { + -webkit-transform: translate3d(0, -10px, 0); + transform: translate3d(0, -10px, 0); + } + + 90% { + -webkit-transform: translate3d(0, 5px, 0); + transform: translate3d(0, 5px, 0); + } + + to { + -webkit-transform: none; + transform: none; + } +} + +.bounceInDown { + -webkit-animation-name: bounceInDown; + animation-name: bounceInDown; +} + +@-webkit-keyframes bounceInLeft { + from, 60%, 75%, 90%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + 0% { + opacity: 0; + -webkit-transform: translate3d(-3000px, 0, 0); + transform: translate3d(-3000px, 0, 0); + } + + 60% { + opacity: 1; + -webkit-transform: translate3d(25px, 0, 0); + transform: translate3d(25px, 0, 0); + } + + 75% { + -webkit-transform: translate3d(-10px, 0, 0); + transform: translate3d(-10px, 0, 0); + } + + 90% { + -webkit-transform: translate3d(5px, 0, 0); + transform: translate3d(5px, 0, 0); + } + + to { + -webkit-transform: none; + transform: none; + } +} + +@keyframes bounceInLeft { + from, 60%, 75%, 90%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + 0% { + opacity: 0; + -webkit-transform: translate3d(-3000px, 0, 0); + transform: translate3d(-3000px, 0, 0); + } + + 60% { + opacity: 1; + -webkit-transform: translate3d(25px, 0, 0); + transform: translate3d(25px, 0, 0); + } + + 75% { + -webkit-transform: translate3d(-10px, 0, 0); + transform: translate3d(-10px, 0, 0); + } + + 90% { + -webkit-transform: translate3d(5px, 0, 0); + transform: translate3d(5px, 0, 0); + } + + to { + -webkit-transform: none; + transform: none; + } +} + +.bounceInLeft { + -webkit-animation-name: bounceInLeft; + animation-name: bounceInLeft; +} + +@-webkit-keyframes bounceInRight { + from, 60%, 75%, 90%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + from { + opacity: 0; + -webkit-transform: translate3d(3000px, 0, 0); + transform: translate3d(3000px, 0, 0); + } + + 60% { + opacity: 1; + -webkit-transform: translate3d(-25px, 0, 0); + transform: translate3d(-25px, 0, 0); + } + + 75% { + -webkit-transform: translate3d(10px, 0, 0); + transform: translate3d(10px, 0, 0); + } + + 90% { + -webkit-transform: translate3d(-5px, 0, 0); + transform: translate3d(-5px, 0, 0); + } + + to { + -webkit-transform: none; + transform: none; + } +} + +@keyframes bounceInRight { + from, 60%, 75%, 90%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + from { + opacity: 0; + -webkit-transform: translate3d(3000px, 0, 0); + transform: translate3d(3000px, 0, 0); + } + + 60% { + opacity: 1; + -webkit-transform: translate3d(-25px, 0, 0); + transform: translate3d(-25px, 0, 0); + } + + 75% { + -webkit-transform: translate3d(10px, 0, 0); + transform: translate3d(10px, 0, 0); + } + + 90% { + -webkit-transform: translate3d(-5px, 0, 0); + transform: translate3d(-5px, 0, 0); + } + + to { + -webkit-transform: none; + transform: none; + } +} + +.bounceInRight { + -webkit-animation-name: bounceInRight; + animation-name: bounceInRight; +} + +@-webkit-keyframes bounceInUp { + from, 60%, 75%, 90%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + from { + opacity: 0; + -webkit-transform: translate3d(0, 3000px, 0); + transform: translate3d(0, 3000px, 0); + } + + 60% { + opacity: 1; + -webkit-transform: translate3d(0, -20px, 0); + transform: translate3d(0, -20px, 0); + } + + 75% { + -webkit-transform: translate3d(0, 10px, 0); + transform: translate3d(0, 10px, 0); + } + + 90% { + -webkit-transform: translate3d(0, -5px, 0); + transform: translate3d(0, -5px, 0); + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +@keyframes bounceInUp { + from, 60%, 75%, 90%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + + from { + opacity: 0; + -webkit-transform: translate3d(0, 3000px, 0); + transform: translate3d(0, 3000px, 0); + } + + 60% { + opacity: 1; + -webkit-transform: translate3d(0, -20px, 0); + transform: translate3d(0, -20px, 0); + } + + 75% { + -webkit-transform: translate3d(0, 10px, 0); + transform: translate3d(0, 10px, 0); + } + + 90% { + -webkit-transform: translate3d(0, -5px, 0); + transform: translate3d(0, -5px, 0); + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +.bounceInUp { + -webkit-animation-name: bounceInUp; + animation-name: bounceInUp; +} + +@-webkit-keyframes bounceOut { + 20% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + + 50%, 55% { + opacity: 1; + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + + to { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } +} + +@keyframes bounceOut { + 20% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + + 50%, 55% { + opacity: 1; + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + + to { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } +} + +.bounceOut { + -webkit-animation-name: bounceOut; + animation-name: bounceOut; +} + +@-webkit-keyframes bounceOutDown { + 20% { + -webkit-transform: translate3d(0, 10px, 0); + transform: translate3d(0, 10px, 0); + } + + 40%, 45% { + opacity: 1; + -webkit-transform: translate3d(0, -20px, 0); + transform: translate3d(0, -20px, 0); + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, 2000px, 0); + transform: translate3d(0, 2000px, 0); + } +} + +@keyframes bounceOutDown { + 20% { + -webkit-transform: translate3d(0, 10px, 0); + transform: translate3d(0, 10px, 0); + } + + 40%, 45% { + opacity: 1; + -webkit-transform: translate3d(0, -20px, 0); + transform: translate3d(0, -20px, 0); + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, 2000px, 0); + transform: translate3d(0, 2000px, 0); + } +} + +.bounceOutDown { + -webkit-animation-name: bounceOutDown; + animation-name: bounceOutDown; +} + +@-webkit-keyframes bounceOutLeft { + 20% { + opacity: 1; + -webkit-transform: translate3d(20px, 0, 0); + transform: translate3d(20px, 0, 0); + } + + to { + opacity: 0; + -webkit-transform: translate3d(-2000px, 0, 0); + transform: translate3d(-2000px, 0, 0); + } +} + +@keyframes bounceOutLeft { + 20% { + opacity: 1; + -webkit-transform: translate3d(20px, 0, 0); + transform: translate3d(20px, 0, 0); + } + + to { + opacity: 0; + -webkit-transform: translate3d(-2000px, 0, 0); + transform: translate3d(-2000px, 0, 0); + } +} + +.bounceOutLeft { + -webkit-animation-name: bounceOutLeft; + animation-name: bounceOutLeft; +} + +@-webkit-keyframes bounceOutRight { + 20% { + opacity: 1; + -webkit-transform: translate3d(-20px, 0, 0); + transform: translate3d(-20px, 0, 0); + } + + to { + opacity: 0; + -webkit-transform: translate3d(2000px, 0, 0); + transform: translate3d(2000px, 0, 0); + } +} + +@keyframes bounceOutRight { + 20% { + opacity: 1; + -webkit-transform: translate3d(-20px, 0, 0); + transform: translate3d(-20px, 0, 0); + } + + to { + opacity: 0; + -webkit-transform: translate3d(2000px, 0, 0); + transform: translate3d(2000px, 0, 0); + } +} + +.bounceOutRight { + -webkit-animation-name: bounceOutRight; + animation-name: bounceOutRight; +} + +@-webkit-keyframes bounceOutUp { + 20% { + -webkit-transform: translate3d(0, -10px, 0); + transform: translate3d(0, -10px, 0); + } + + 40%, 45% { + opacity: 1; + -webkit-transform: translate3d(0, 20px, 0); + transform: translate3d(0, 20px, 0); + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, -2000px, 0); + transform: translate3d(0, -2000px, 0); + } +} + +@keyframes bounceOutUp { + 20% { + -webkit-transform: translate3d(0, -10px, 0); + transform: translate3d(0, -10px, 0); + } + + 40%, 45% { + opacity: 1; + -webkit-transform: translate3d(0, 20px, 0); + transform: translate3d(0, 20px, 0); + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, -2000px, 0); + transform: translate3d(0, -2000px, 0); + } +} + +.bounceOutUp { + -webkit-animation-name: bounceOutUp; + animation-name: bounceOutUp; +} + +@-webkit-keyframes fadeIn { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} + +@keyframes fadeIn { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} + +.fadeIn { + -webkit-animation-name: fadeIn; + animation-name: fadeIn; +} + +@-webkit-keyframes fadeInDown { + from { + opacity: 0; + -webkit-transform: translate3d(0, -100%, 0); + transform: translate3d(0, -100%, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +@keyframes fadeInDown { + from { + opacity: 0; + -webkit-transform: translate3d(0, -100%, 0); + transform: translate3d(0, -100%, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +.fadeInDown { + -webkit-animation-name: fadeInDown; + animation-name: fadeInDown; +} + +@-webkit-keyframes fadeInDownBig { + from { + opacity: 0; + -webkit-transform: translate3d(0, -2000px, 0); + transform: translate3d(0, -2000px, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +@keyframes fadeInDownBig { + from { + opacity: 0; + -webkit-transform: translate3d(0, -2000px, 0); + transform: translate3d(0, -2000px, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +.fadeInDownBig { + -webkit-animation-name: fadeInDownBig; + animation-name: fadeInDownBig; +} + +@-webkit-keyframes fadeInLeft { + from { + opacity: 0; + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +@keyframes fadeInLeft { + from { + opacity: 0; + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +.fadeInLeft { + -webkit-animation-name: fadeInLeft; + animation-name: fadeInLeft; +} + +@-webkit-keyframes fadeInLeftBig { + from { + opacity: 0; + -webkit-transform: translate3d(-2000px, 0, 0); + transform: translate3d(-2000px, 0, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +@keyframes fadeInLeftBig { + from { + opacity: 0; + -webkit-transform: translate3d(-2000px, 0, 0); + transform: translate3d(-2000px, 0, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +.fadeInLeftBig { + -webkit-animation-name: fadeInLeftBig; + animation-name: fadeInLeftBig; +} + +@-webkit-keyframes fadeInRight { + from { + opacity: 0; + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +@keyframes fadeInRight { + from { + opacity: 0; + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +.fadeInRight { + -webkit-animation-name: fadeInRight; + animation-name: fadeInRight; +} + +@-webkit-keyframes fadeInRightBig { + from { + opacity: 0; + -webkit-transform: translate3d(2000px, 0, 0); + transform: translate3d(2000px, 0, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +@keyframes fadeInRightBig { + from { + opacity: 0; + -webkit-transform: translate3d(2000px, 0, 0); + transform: translate3d(2000px, 0, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +.fadeInRightBig { + -webkit-animation-name: fadeInRightBig; + animation-name: fadeInRightBig; +} + +@-webkit-keyframes fadeInUp { + from { + opacity: 0; + -webkit-transform: translate3d(0, 100%, 0); + transform: translate3d(0, 100%, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +@keyframes fadeInUp { + from { + opacity: 0; + -webkit-transform: translate3d(0, 100%, 0); + transform: translate3d(0, 100%, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +.fadeInUp { + -webkit-animation-name: fadeInUp; + animation-name: fadeInUp; +} + +@-webkit-keyframes fadeInUpBig { + from { + opacity: 0; + -webkit-transform: translate3d(0, 2000px, 0); + transform: translate3d(0, 2000px, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +@keyframes fadeInUpBig { + from { + opacity: 0; + -webkit-transform: translate3d(0, 2000px, 0); + transform: translate3d(0, 2000px, 0); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +.fadeInUpBig { + -webkit-animation-name: fadeInUpBig; + animation-name: fadeInUpBig; +} + +@-webkit-keyframes fadeOut { + from { + opacity: 1; + } + + to { + opacity: 0; + } +} + +@keyframes fadeOut { + from { + opacity: 1; + } + + to { + opacity: 0; + } +} + +.fadeOut { + -webkit-animation-name: fadeOut; + animation-name: fadeOut; +} + +@-webkit-keyframes fadeOutDown { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, 100%, 0); + transform: translate3d(0, 100%, 0); + } +} + +@keyframes fadeOutDown { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, 100%, 0); + transform: translate3d(0, 100%, 0); + } +} + +.fadeOutDown { + -webkit-animation-name: fadeOutDown; + animation-name: fadeOutDown; +} + +@-webkit-keyframes fadeOutDownBig { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, 2000px, 0); + transform: translate3d(0, 2000px, 0); + } +} + +@keyframes fadeOutDownBig { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, 2000px, 0); + transform: translate3d(0, 2000px, 0); + } +} + +.fadeOutDownBig { + -webkit-animation-name: fadeOutDownBig; + animation-name: fadeOutDownBig; +} + +@-webkit-keyframes fadeOutLeft { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + } +} + +@keyframes fadeOutLeft { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + } +} + +.fadeOutLeft { + -webkit-animation-name: fadeOutLeft; + animation-name: fadeOutLeft; +} + +@-webkit-keyframes fadeOutLeftBig { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(-2000px, 0, 0); + transform: translate3d(-2000px, 0, 0); + } +} + +@keyframes fadeOutLeftBig { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(-2000px, 0, 0); + transform: translate3d(-2000px, 0, 0); + } +} + +.fadeOutLeftBig { + -webkit-animation-name: fadeOutLeftBig; + animation-name: fadeOutLeftBig; +} + +@-webkit-keyframes fadeOutRight { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + } +} + +@keyframes fadeOutRight { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + } +} + +.fadeOutRight { + -webkit-animation-name: fadeOutRight; + animation-name: fadeOutRight; +} + +@-webkit-keyframes fadeOutRightBig { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(2000px, 0, 0); + transform: translate3d(2000px, 0, 0); + } +} + +@keyframes fadeOutRightBig { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(2000px, 0, 0); + transform: translate3d(2000px, 0, 0); + } +} + +.fadeOutRightBig { + -webkit-animation-name: fadeOutRightBig; + animation-name: fadeOutRightBig; +} + +@-webkit-keyframes fadeOutUp { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, -100%, 0); + transform: translate3d(0, -100%, 0); + } +} + +@keyframes fadeOutUp { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, -100%, 0); + transform: translate3d(0, -100%, 0); + } +} + +.fadeOutUp { + -webkit-animation-name: fadeOutUp; + animation-name: fadeOutUp; +} + +@-webkit-keyframes fadeOutUpBig { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, -2000px, 0); + transform: translate3d(0, -2000px, 0); + } +} + +@keyframes fadeOutUpBig { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(0, -2000px, 0); + transform: translate3d(0, -2000px, 0); + } +} + +.fadeOutUpBig { + -webkit-animation-name: fadeOutUpBig; + animation-name: fadeOutUpBig; +} + +@-webkit-keyframes flip { + from { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -360deg); + transform: perspective(400px) rotate3d(0, 1, 0, -360deg); + -webkit-animation-timing-function: ease-out; + animation-timing-function: ease-out; + } + + 40% { + -webkit-transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -190deg); + transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -190deg); + -webkit-animation-timing-function: ease-out; + animation-timing-function: ease-out; + } + + 50% { + -webkit-transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -170deg); + transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -170deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } + + 80% { + -webkit-transform: perspective(400px) scale3d(.95, .95, .95); + transform: perspective(400px) scale3d(.95, .95, .95); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } + + to { + -webkit-transform: perspective(400px); + transform: perspective(400px); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } +} + +@keyframes flip { + from { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -360deg); + transform: perspective(400px) rotate3d(0, 1, 0, -360deg); + -webkit-animation-timing-function: ease-out; + animation-timing-function: ease-out; + } + + 40% { + -webkit-transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -190deg); + transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -190deg); + -webkit-animation-timing-function: ease-out; + animation-timing-function: ease-out; + } + + 50% { + -webkit-transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -170deg); + transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -170deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } + + 80% { + -webkit-transform: perspective(400px) scale3d(.95, .95, .95); + transform: perspective(400px) scale3d(.95, .95, .95); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } + + to { + -webkit-transform: perspective(400px); + transform: perspective(400px); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } +} + +.animated.flip { + -webkit-backface-visibility: visible; + backface-visibility: visible; + -webkit-animation-name: flip; + animation-name: flip; +} + +@-webkit-keyframes flipInX { + from { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, 90deg); + transform: perspective(400px) rotate3d(1, 0, 0, 90deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + opacity: 0; + } + + 40% { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, -20deg); + transform: perspective(400px) rotate3d(1, 0, 0, -20deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } + + 60% { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, 10deg); + transform: perspective(400px) rotate3d(1, 0, 0, 10deg); + opacity: 1; + } + + 80% { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, -5deg); + transform: perspective(400px) rotate3d(1, 0, 0, -5deg); + } + + to { + -webkit-transform: perspective(400px); + transform: perspective(400px); + } +} + +@keyframes flipInX { + from { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, 90deg); + transform: perspective(400px) rotate3d(1, 0, 0, 90deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + opacity: 0; + } + + 40% { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, -20deg); + transform: perspective(400px) rotate3d(1, 0, 0, -20deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } + + 60% { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, 10deg); + transform: perspective(400px) rotate3d(1, 0, 0, 10deg); + opacity: 1; + } + + 80% { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, -5deg); + transform: perspective(400px) rotate3d(1, 0, 0, -5deg); + } + + to { + -webkit-transform: perspective(400px); + transform: perspective(400px); + } +} + +.flipInX { + -webkit-backface-visibility: visible !important; + backface-visibility: visible !important; + -webkit-animation-name: flipInX; + animation-name: flipInX; +} + +@-webkit-keyframes flipInY { + from { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + opacity: 0; + } + + 40% { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -20deg); + transform: perspective(400px) rotate3d(0, 1, 0, -20deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } + + 60% { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 10deg); + transform: perspective(400px) rotate3d(0, 1, 0, 10deg); + opacity: 1; + } + + 80% { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -5deg); + transform: perspective(400px) rotate3d(0, 1, 0, -5deg); + } + + to { + -webkit-transform: perspective(400px); + transform: perspective(400px); + } +} + +@keyframes flipInY { + from { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + opacity: 0; + } + + 40% { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -20deg); + transform: perspective(400px) rotate3d(0, 1, 0, -20deg); + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; + } + + 60% { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 10deg); + transform: perspective(400px) rotate3d(0, 1, 0, 10deg); + opacity: 1; + } + + 80% { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -5deg); + transform: perspective(400px) rotate3d(0, 1, 0, -5deg); + } + + to { + -webkit-transform: perspective(400px); + transform: perspective(400px); + } +} + +.flipInY { + -webkit-backface-visibility: visible !important; + backface-visibility: visible !important; + -webkit-animation-name: flipInY; + animation-name: flipInY; +} + +@-webkit-keyframes flipOutX { + from { + -webkit-transform: perspective(400px); + transform: perspective(400px); + } + + 30% { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, -20deg); + transform: perspective(400px) rotate3d(1, 0, 0, -20deg); + opacity: 1; + } + + to { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, 90deg); + transform: perspective(400px) rotate3d(1, 0, 0, 90deg); + opacity: 0; + } +} + +@keyframes flipOutX { + from { + -webkit-transform: perspective(400px); + transform: perspective(400px); + } + + 30% { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, -20deg); + transform: perspective(400px) rotate3d(1, 0, 0, -20deg); + opacity: 1; + } + + to { + -webkit-transform: perspective(400px) rotate3d(1, 0, 0, 90deg); + transform: perspective(400px) rotate3d(1, 0, 0, 90deg); + opacity: 0; + } +} + +.flipOutX { + -webkit-animation-name: flipOutX; + animation-name: flipOutX; + -webkit-backface-visibility: visible !important; + backface-visibility: visible !important; +} + +@-webkit-keyframes flipOutY { + from { + -webkit-transform: perspective(400px); + transform: perspective(400px); + } + + 30% { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -15deg); + transform: perspective(400px) rotate3d(0, 1, 0, -15deg); + opacity: 1; + } + + to { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + opacity: 0; + } +} + +@keyframes flipOutY { + from { + -webkit-transform: perspective(400px); + transform: perspective(400px); + } + + 30% { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -15deg); + transform: perspective(400px) rotate3d(0, 1, 0, -15deg); + opacity: 1; + } + + to { + -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + opacity: 0; + } +} + +.flipOutY { + -webkit-backface-visibility: visible !important; + backface-visibility: visible !important; + -webkit-animation-name: flipOutY; + animation-name: flipOutY; +} + +@-webkit-keyframes lightSpeedIn { + from { + -webkit-transform: translate3d(100%, 0, 0) skewX(-30deg); + transform: translate3d(100%, 0, 0) skewX(-30deg); + opacity: 0; + } + + 60% { + -webkit-transform: skewX(20deg); + transform: skewX(20deg); + opacity: 1; + } + + 80% { + -webkit-transform: skewX(-5deg); + transform: skewX(-5deg); + opacity: 1; + } + + to { + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +@keyframes lightSpeedIn { + from { + -webkit-transform: translate3d(100%, 0, 0) skewX(-30deg); + transform: translate3d(100%, 0, 0) skewX(-30deg); + opacity: 0; + } + + 60% { + -webkit-transform: skewX(20deg); + transform: skewX(20deg); + opacity: 1; + } + + 80% { + -webkit-transform: skewX(-5deg); + transform: skewX(-5deg); + opacity: 1; + } + + to { + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +.lightSpeedIn { + -webkit-animation-name: lightSpeedIn; + animation-name: lightSpeedIn; + -webkit-animation-timing-function: ease-out; + animation-timing-function: ease-out; +} + +@-webkit-keyframes lightSpeedOut { + from { + opacity: 1; + } + + to { + -webkit-transform: translate3d(100%, 0, 0) skewX(30deg); + transform: translate3d(100%, 0, 0) skewX(30deg); + opacity: 0; + } +} + +@keyframes lightSpeedOut { + from { + opacity: 1; + } + + to { + -webkit-transform: translate3d(100%, 0, 0) skewX(30deg); + transform: translate3d(100%, 0, 0) skewX(30deg); + opacity: 0; + } +} + +.lightSpeedOut { + -webkit-animation-name: lightSpeedOut; + animation-name: lightSpeedOut; + -webkit-animation-timing-function: ease-in; + animation-timing-function: ease-in; +} + +@-webkit-keyframes rotateIn { + from { + -webkit-transform-origin: center; + transform-origin: center; + -webkit-transform: rotate3d(0, 0, 1, -200deg); + transform: rotate3d(0, 0, 1, -200deg); + opacity: 0; + } + + to { + -webkit-transform-origin: center; + transform-origin: center; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +@keyframes rotateIn { + from { + -webkit-transform-origin: center; + transform-origin: center; + -webkit-transform: rotate3d(0, 0, 1, -200deg); + transform: rotate3d(0, 0, 1, -200deg); + opacity: 0; + } + + to { + -webkit-transform-origin: center; + transform-origin: center; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +.rotateIn { + -webkit-animation-name: rotateIn; + animation-name: rotateIn; +} + +@-webkit-keyframes rotateInDownLeft { + from { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: rotate3d(0, 0, 1, -45deg); + transform: rotate3d(0, 0, 1, -45deg); + opacity: 0; + } + + to { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +@keyframes rotateInDownLeft { + from { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: rotate3d(0, 0, 1, -45deg); + transform: rotate3d(0, 0, 1, -45deg); + opacity: 0; + } + + to { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +.rotateInDownLeft { + -webkit-animation-name: rotateInDownLeft; + animation-name: rotateInDownLeft; +} + +@-webkit-keyframes rotateInDownRight { + from { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: rotate3d(0, 0, 1, 45deg); + transform: rotate3d(0, 0, 1, 45deg); + opacity: 0; + } + + to { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +@keyframes rotateInDownRight { + from { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: rotate3d(0, 0, 1, 45deg); + transform: rotate3d(0, 0, 1, 45deg); + opacity: 0; + } + + to { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +.rotateInDownRight { + -webkit-animation-name: rotateInDownRight; + animation-name: rotateInDownRight; +} + +@-webkit-keyframes rotateInUpLeft { + from { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: rotate3d(0, 0, 1, 45deg); + transform: rotate3d(0, 0, 1, 45deg); + opacity: 0; + } + + to { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +@keyframes rotateInUpLeft { + from { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: rotate3d(0, 0, 1, 45deg); + transform: rotate3d(0, 0, 1, 45deg); + opacity: 0; + } + + to { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +.rotateInUpLeft { + -webkit-animation-name: rotateInUpLeft; + animation-name: rotateInUpLeft; +} + +@-webkit-keyframes rotateInUpRight { + from { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: rotate3d(0, 0, 1, -90deg); + transform: rotate3d(0, 0, 1, -90deg); + opacity: 0; + } + + to { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +@keyframes rotateInUpRight { + from { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: rotate3d(0, 0, 1, -90deg); + transform: rotate3d(0, 0, 1, -90deg); + opacity: 0; + } + + to { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: none; + transform: none; + opacity: 1; + } +} + +.rotateInUpRight { + -webkit-animation-name: rotateInUpRight; + animation-name: rotateInUpRight; +} + +@-webkit-keyframes rotateOut { + from { + -webkit-transform-origin: center; + transform-origin: center; + opacity: 1; + } + + to { + -webkit-transform-origin: center; + transform-origin: center; + -webkit-transform: rotate3d(0, 0, 1, 200deg); + transform: rotate3d(0, 0, 1, 200deg); + opacity: 0; + } +} + +@keyframes rotateOut { + from { + -webkit-transform-origin: center; + transform-origin: center; + opacity: 1; + } + + to { + -webkit-transform-origin: center; + transform-origin: center; + -webkit-transform: rotate3d(0, 0, 1, 200deg); + transform: rotate3d(0, 0, 1, 200deg); + opacity: 0; + } +} + +.rotateOut { + -webkit-animation-name: rotateOut; + animation-name: rotateOut; +} + +@-webkit-keyframes rotateOutDownLeft { + from { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + opacity: 1; + } + + to { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: rotate3d(0, 0, 1, 45deg); + transform: rotate3d(0, 0, 1, 45deg); + opacity: 0; + } +} + +@keyframes rotateOutDownLeft { + from { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + opacity: 1; + } + + to { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: rotate3d(0, 0, 1, 45deg); + transform: rotate3d(0, 0, 1, 45deg); + opacity: 0; + } +} + +.rotateOutDownLeft { + -webkit-animation-name: rotateOutDownLeft; + animation-name: rotateOutDownLeft; +} + +@-webkit-keyframes rotateOutDownRight { + from { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + opacity: 1; + } + + to { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: rotate3d(0, 0, 1, -45deg); + transform: rotate3d(0, 0, 1, -45deg); + opacity: 0; + } +} + +@keyframes rotateOutDownRight { + from { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + opacity: 1; + } + + to { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: rotate3d(0, 0, 1, -45deg); + transform: rotate3d(0, 0, 1, -45deg); + opacity: 0; + } +} + +.rotateOutDownRight { + -webkit-animation-name: rotateOutDownRight; + animation-name: rotateOutDownRight; +} + +@-webkit-keyframes rotateOutUpLeft { + from { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + opacity: 1; + } + + to { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: rotate3d(0, 0, 1, -45deg); + transform: rotate3d(0, 0, 1, -45deg); + opacity: 0; + } +} + +@keyframes rotateOutUpLeft { + from { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + opacity: 1; + } + + to { + -webkit-transform-origin: left bottom; + transform-origin: left bottom; + -webkit-transform: rotate3d(0, 0, 1, -45deg); + transform: rotate3d(0, 0, 1, -45deg); + opacity: 0; + } +} + +.rotateOutUpLeft { + -webkit-animation-name: rotateOutUpLeft; + animation-name: rotateOutUpLeft; +} + +@-webkit-keyframes rotateOutUpRight { + from { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + opacity: 1; + } + + to { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: rotate3d(0, 0, 1, 90deg); + transform: rotate3d(0, 0, 1, 90deg); + opacity: 0; + } +} + +@keyframes rotateOutUpRight { + from { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + opacity: 1; + } + + to { + -webkit-transform-origin: right bottom; + transform-origin: right bottom; + -webkit-transform: rotate3d(0, 0, 1, 90deg); + transform: rotate3d(0, 0, 1, 90deg); + opacity: 0; + } +} + +.rotateOutUpRight { + -webkit-animation-name: rotateOutUpRight; + animation-name: rotateOutUpRight; +} + +@-webkit-keyframes hinge { + 0% { + -webkit-transform-origin: top left; + transform-origin: top left; + -webkit-animation-timing-function: ease-in-out; + animation-timing-function: ease-in-out; + } + + 20%, 60% { + -webkit-transform: rotate3d(0, 0, 1, 80deg); + transform: rotate3d(0, 0, 1, 80deg); + -webkit-transform-origin: top left; + transform-origin: top left; + -webkit-animation-timing-function: ease-in-out; + animation-timing-function: ease-in-out; + } + + 40%, 80% { + -webkit-transform: rotate3d(0, 0, 1, 60deg); + transform: rotate3d(0, 0, 1, 60deg); + -webkit-transform-origin: top left; + transform-origin: top left; + -webkit-animation-timing-function: ease-in-out; + animation-timing-function: ease-in-out; + opacity: 1; + } + + to { + -webkit-transform: translate3d(0, 700px, 0); + transform: translate3d(0, 700px, 0); + opacity: 0; + } +} + +@keyframes hinge { + 0% { + -webkit-transform-origin: top left; + transform-origin: top left; + -webkit-animation-timing-function: ease-in-out; + animation-timing-function: ease-in-out; + } + + 20%, 60% { + -webkit-transform: rotate3d(0, 0, 1, 80deg); + transform: rotate3d(0, 0, 1, 80deg); + -webkit-transform-origin: top left; + transform-origin: top left; + -webkit-animation-timing-function: ease-in-out; + animation-timing-function: ease-in-out; + } + + 40%, 80% { + -webkit-transform: rotate3d(0, 0, 1, 60deg); + transform: rotate3d(0, 0, 1, 60deg); + -webkit-transform-origin: top left; + transform-origin: top left; + -webkit-animation-timing-function: ease-in-out; + animation-timing-function: ease-in-out; + opacity: 1; + } + + to { + -webkit-transform: translate3d(0, 700px, 0); + transform: translate3d(0, 700px, 0); + opacity: 0; + } +} + +.hinge { + -webkit-animation-name: hinge; + animation-name: hinge; +} + +/* originally authored by Nick Pettit - https://github.com/nickpettit/glide */ + +@-webkit-keyframes rollIn { + from { + opacity: 0; + -webkit-transform: translate3d(-100%, 0, 0) rotate3d(0, 0, 1, -120deg); + transform: translate3d(-100%, 0, 0) rotate3d(0, 0, 1, -120deg); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +@keyframes rollIn { + from { + opacity: 0; + -webkit-transform: translate3d(-100%, 0, 0) rotate3d(0, 0, 1, -120deg); + transform: translate3d(-100%, 0, 0) rotate3d(0, 0, 1, -120deg); + } + + to { + opacity: 1; + -webkit-transform: none; + transform: none; + } +} + +.rollIn { + -webkit-animation-name: rollIn; + animation-name: rollIn; +} + +/* originally authored by Nick Pettit - https://github.com/nickpettit/glide */ + +@-webkit-keyframes rollOut { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(100%, 0, 0) rotate3d(0, 0, 1, 120deg); + transform: translate3d(100%, 0, 0) rotate3d(0, 0, 1, 120deg); + } +} + +@keyframes rollOut { + from { + opacity: 1; + } + + to { + opacity: 0; + -webkit-transform: translate3d(100%, 0, 0) rotate3d(0, 0, 1, 120deg); + transform: translate3d(100%, 0, 0) rotate3d(0, 0, 1, 120deg); + } +} + +.rollOut { + -webkit-animation-name: rollOut; + animation-name: rollOut; +} + +@-webkit-keyframes zoomIn { + from { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + + 50% { + opacity: 1; + } +} + +@keyframes zoomIn { + from { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + + 50% { + opacity: 1; + } +} + +.zoomIn { + -webkit-animation-name: zoomIn; + animation-name: zoomIn; +} + +@-webkit-keyframes zoomInDown { + from { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(0, -1000px, 0); + transform: scale3d(.1, .1, .1) translate3d(0, -1000px, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(0, 60px, 0); + transform: scale3d(.475, .475, .475) translate3d(0, 60px, 0); + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +@keyframes zoomInDown { + from { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(0, -1000px, 0); + transform: scale3d(.1, .1, .1) translate3d(0, -1000px, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(0, 60px, 0); + transform: scale3d(.475, .475, .475) translate3d(0, 60px, 0); + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +.zoomInDown { + -webkit-animation-name: zoomInDown; + animation-name: zoomInDown; +} + +@-webkit-keyframes zoomInLeft { + from { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(-1000px, 0, 0); + transform: scale3d(.1, .1, .1) translate3d(-1000px, 0, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(10px, 0, 0); + transform: scale3d(.475, .475, .475) translate3d(10px, 0, 0); + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +@keyframes zoomInLeft { + from { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(-1000px, 0, 0); + transform: scale3d(.1, .1, .1) translate3d(-1000px, 0, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(10px, 0, 0); + transform: scale3d(.475, .475, .475) translate3d(10px, 0, 0); + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +.zoomInLeft { + -webkit-animation-name: zoomInLeft; + animation-name: zoomInLeft; +} + +@-webkit-keyframes zoomInRight { + from { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(1000px, 0, 0); + transform: scale3d(.1, .1, .1) translate3d(1000px, 0, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(-10px, 0, 0); + transform: scale3d(.475, .475, .475) translate3d(-10px, 0, 0); + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +@keyframes zoomInRight { + from { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(1000px, 0, 0); + transform: scale3d(.1, .1, .1) translate3d(1000px, 0, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(-10px, 0, 0); + transform: scale3d(.475, .475, .475) translate3d(-10px, 0, 0); + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +.zoomInRight { + -webkit-animation-name: zoomInRight; + animation-name: zoomInRight; +} + +@-webkit-keyframes zoomInUp { + from { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(0, 1000px, 0); + transform: scale3d(.1, .1, .1) translate3d(0, 1000px, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0); + transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0); + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +@keyframes zoomInUp { + from { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(0, 1000px, 0); + transform: scale3d(.1, .1, .1) translate3d(0, 1000px, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + 60% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0); + transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0); + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +.zoomInUp { + -webkit-animation-name: zoomInUp; + animation-name: zoomInUp; +} + +@-webkit-keyframes zoomOut { + from { + opacity: 1; + } + + 50% { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + + to { + opacity: 0; + } +} + +@keyframes zoomOut { + from { + opacity: 1; + } + + 50% { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + + to { + opacity: 0; + } +} + +.zoomOut { + -webkit-animation-name: zoomOut; + animation-name: zoomOut; +} + +@-webkit-keyframes zoomOutDown { + 40% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0); + transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + to { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(0, 2000px, 0); + transform: scale3d(.1, .1, .1) translate3d(0, 2000px, 0); + -webkit-transform-origin: center bottom; + transform-origin: center bottom; + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +@keyframes zoomOutDown { + 40% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0); + transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + to { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(0, 2000px, 0); + transform: scale3d(.1, .1, .1) translate3d(0, 2000px, 0); + -webkit-transform-origin: center bottom; + transform-origin: center bottom; + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +.zoomOutDown { + -webkit-animation-name: zoomOutDown; + animation-name: zoomOutDown; +} + +@-webkit-keyframes zoomOutLeft { + 40% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(42px, 0, 0); + transform: scale3d(.475, .475, .475) translate3d(42px, 0, 0); + } + + to { + opacity: 0; + -webkit-transform: scale(.1) translate3d(-2000px, 0, 0); + transform: scale(.1) translate3d(-2000px, 0, 0); + -webkit-transform-origin: left center; + transform-origin: left center; + } +} + +@keyframes zoomOutLeft { + 40% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(42px, 0, 0); + transform: scale3d(.475, .475, .475) translate3d(42px, 0, 0); + } + + to { + opacity: 0; + -webkit-transform: scale(.1) translate3d(-2000px, 0, 0); + transform: scale(.1) translate3d(-2000px, 0, 0); + -webkit-transform-origin: left center; + transform-origin: left center; + } +} + +.zoomOutLeft { + -webkit-animation-name: zoomOutLeft; + animation-name: zoomOutLeft; +} + +@-webkit-keyframes zoomOutRight { + 40% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(-42px, 0, 0); + transform: scale3d(.475, .475, .475) translate3d(-42px, 0, 0); + } + + to { + opacity: 0; + -webkit-transform: scale(.1) translate3d(2000px, 0, 0); + transform: scale(.1) translate3d(2000px, 0, 0); + -webkit-transform-origin: right center; + transform-origin: right center; + } +} + +@keyframes zoomOutRight { + 40% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(-42px, 0, 0); + transform: scale3d(.475, .475, .475) translate3d(-42px, 0, 0); + } + + to { + opacity: 0; + -webkit-transform: scale(.1) translate3d(2000px, 0, 0); + transform: scale(.1) translate3d(2000px, 0, 0); + -webkit-transform-origin: right center; + transform-origin: right center; + } +} + +.zoomOutRight { + -webkit-animation-name: zoomOutRight; + animation-name: zoomOutRight; +} + +@-webkit-keyframes zoomOutUp { + 40% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(0, 60px, 0); + transform: scale3d(.475, .475, .475) translate3d(0, 60px, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + to { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(0, -2000px, 0); + transform: scale3d(.1, .1, .1) translate3d(0, -2000px, 0); + -webkit-transform-origin: center bottom; + transform-origin: center bottom; + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +@keyframes zoomOutUp { + 40% { + opacity: 1; + -webkit-transform: scale3d(.475, .475, .475) translate3d(0, 60px, 0); + transform: scale3d(.475, .475, .475) translate3d(0, 60px, 0); + -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190); + } + + to { + opacity: 0; + -webkit-transform: scale3d(.1, .1, .1) translate3d(0, -2000px, 0); + transform: scale3d(.1, .1, .1) translate3d(0, -2000px, 0); + -webkit-transform-origin: center bottom; + transform-origin: center bottom; + -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1); + } +} + +.zoomOutUp { + -webkit-animation-name: zoomOutUp; + animation-name: zoomOutUp; +} + +@-webkit-keyframes slideInDown { + from { + -webkit-transform: translate3d(0, -100%, 0); + transform: translate3d(0, -100%, 0); + visibility: visible; + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +@keyframes slideInDown { + from { + -webkit-transform: translate3d(0, -100%, 0); + transform: translate3d(0, -100%, 0); + visibility: visible; + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +.slideInDown { + -webkit-animation-name: slideInDown; + animation-name: slideInDown; +} + +@-webkit-keyframes slideInLeft { + from { + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + visibility: visible; + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +@keyframes slideInLeft { + from { + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + visibility: visible; + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +.slideInLeft { + -webkit-animation-name: slideInLeft; + animation-name: slideInLeft; +} + +@-webkit-keyframes slideInRight { + from { + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + visibility: visible; + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +@keyframes slideInRight { + from { + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + visibility: visible; + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +.slideInRight { + -webkit-animation-name: slideInRight; + animation-name: slideInRight; +} + +@-webkit-keyframes slideInUp { + from { + -webkit-transform: translate3d(0, 100%, 0); + transform: translate3d(0, 100%, 0); + visibility: visible; + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +@keyframes slideInUp { + from { + -webkit-transform: translate3d(0, 100%, 0); + transform: translate3d(0, 100%, 0); + visibility: visible; + } + + to { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } +} + +.slideInUp { + -webkit-animation-name: slideInUp; + animation-name: slideInUp; +} + +@-webkit-keyframes slideOutDown { + from { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + to { + visibility: hidden; + -webkit-transform: translate3d(0, 100%, 0); + transform: translate3d(0, 100%, 0); + } +} + +@keyframes slideOutDown { + from { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + to { + visibility: hidden; + -webkit-transform: translate3d(0, 100%, 0); + transform: translate3d(0, 100%, 0); + } +} + +.slideOutDown { + -webkit-animation-name: slideOutDown; + animation-name: slideOutDown; +} + +@-webkit-keyframes slideOutLeft { + from { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + to { + visibility: hidden; + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + } +} + +@keyframes slideOutLeft { + from { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + to { + visibility: hidden; + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + } +} + +.slideOutLeft { + -webkit-animation-name: slideOutLeft; + animation-name: slideOutLeft; +} + +@-webkit-keyframes slideOutRight { + from { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + to { + visibility: hidden; + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + } +} + +@keyframes slideOutRight { + from { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + to { + visibility: hidden; + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + } +} + +.slideOutRight { + -webkit-animation-name: slideOutRight; + animation-name: slideOutRight; +} + +@-webkit-keyframes slideOutUp { + from { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + to { + visibility: hidden; + -webkit-transform: translate3d(0, -100%, 0); + transform: translate3d(0, -100%, 0); + } +} + +@keyframes slideOutUp { + from { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + to { + visibility: hidden; + -webkit-transform: translate3d(0, -100%, 0); + transform: translate3d(0, -100%, 0); + } +} + +.slideOutUp { + -webkit-animation-name: slideOutUp; + animation-name: slideOutUp; +} diff --git a/includes/databases/freepbxv3.inc b/assets/css/bootstrap-fix.css old mode 100755 new mode 100644 similarity index 100% rename from includes/databases/freepbxv3.inc rename to assets/css/bootstrap-fix.css diff --git a/assets/css/bootstrap-select.css b/assets/css/bootstrap-select.css new file mode 100644 index 00000000..5cc79e49 --- /dev/null +++ b/assets/css/bootstrap-select.css @@ -0,0 +1,305 @@ +/*! + * Bootstrap-select v1.11.2 (http://silviomoreto.github.io/bootstrap-select) + * + * Copyright 2013-2016 bootstrap-select + * Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE) + */ + +select.bs-select-hidden, +select.selectpicker { + display: none !important; +} +.bootstrap-select { + width: 220px \0; + /*IE9 and below*/ +} +.bootstrap-select > .dropdown-toggle { + width: 100%; + padding-right: 25px; + z-index: 1; +} +.bootstrap-select > .dropdown-toggle.bs-placeholder, +.bootstrap-select > .dropdown-toggle.bs-placeholder:hover, +.bootstrap-select > .dropdown-toggle.bs-placeholder:focus, +.bootstrap-select > .dropdown-toggle.bs-placeholder:active { + color: #999; +} +.bootstrap-select > select { + position: absolute !important; + bottom: 0; + left: 50%; + display: block !important; + width: 0.5px !important; + height: 100% !important; + padding: 0 !important; + opacity: 0 !important; + border: none; +} +.bootstrap-select > select.mobile-device { + top: 0; + left: 0; + display: block !important; + width: 100% !important; + z-index: 2; +} +.has-error .bootstrap-select .dropdown-toggle, +.error .bootstrap-select .dropdown-toggle { + border-color: #b94a48; +} +.bootstrap-select.fit-width { + width: auto !important; +} +.bootstrap-select:not([class*="col-"]):not([class*="form-control"]):not(.input-group-btn) { + width: 220px; +} +.bootstrap-select .dropdown-toggle:focus { + outline: thin dotted #333333 !important; + outline: 5px auto -webkit-focus-ring-color !important; + outline-offset: -2px; +} +.bootstrap-select.form-control { + margin-top: 0; + margin-bottom: 0; + padding: 0; + border: none; +} +.input-group-br > .bootstrap-select.form-control { + height:auto; +} +.bootstrap-select.form-control:not([class*="col-"]) { + width: 100%; +} +.bootstrap-select.form-control.input-group-btn { + z-index: auto; +} +.bootstrap-select.form-control.input-group-btn:not(:first-child):not(:last-child) > .btn { + border-radius: 0; +} +.bootstrap-select.btn-group:not(.input-group-btn), +.bootstrap-select.btn-group[class*="col-"] { + float: none; + display: inline-block; + margin-left: 0; +} +.bootstrap-select.btn-group.dropdown-menu-right, +.bootstrap-select.btn-group[class*="col-"].dropdown-menu-right, +.row .bootstrap-select.btn-group[class*="col-"].dropdown-menu-right { + float: right; +} +.form-inline .bootstrap-select.btn-group, +.form-horizontal .bootstrap-select.btn-group, +.form-group .bootstrap-select.btn-group { + margin-bottom: 0; +} +.form-group-lg .bootstrap-select.btn-group.form-control, +.form-group-sm .bootstrap-select.btn-group.form-control { + padding: 0; +} +.form-inline .bootstrap-select.btn-group .form-control { + width: 100%; +} +.bootstrap-select.btn-group.disabled, +.bootstrap-select.btn-group > .disabled { + cursor: not-allowed; +} +.bootstrap-select.btn-group.disabled:focus, +.bootstrap-select.btn-group > .disabled:focus { + outline: none !important; +} +.bootstrap-select.btn-group.bs-container { + position: absolute; + height: 0 !important; + padding: 0 !important; +} +.bootstrap-select.btn-group.bs-container .dropdown-menu { + z-index: 1060; +} +.bootstrap-select.btn-group .dropdown-toggle .filter-option { + display: inline-block; + overflow: hidden; + width: 100%; + text-align: left; +} +.bootstrap-select.btn-group .dropdown-toggle .caret { + position: absolute; + top: 50%; + right: 12px; + margin-top: -2px; + vertical-align: middle; +} +.bootstrap-select.btn-group[class*="col-"] .dropdown-toggle { + width: 100%; +} +.bootstrap-select.btn-group .dropdown-menu { + min-width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.bootstrap-select.btn-group .dropdown-menu.inner { + position: static; + float: none; + border: 0; + padding: 0; + margin: 0; + border-radius: 0; + -webkit-box-shadow: none; + box-shadow: none; +} +.bootstrap-select.btn-group .dropdown-menu li { + position: relative; +} +.bootstrap-select.btn-group .dropdown-menu li.active small { + color: #fff; +} +.bootstrap-select.btn-group .dropdown-menu li.disabled a { + cursor: not-allowed; +} +.bootstrap-select.btn-group .dropdown-menu li a { + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.bootstrap-select.btn-group .dropdown-menu li a.opt { + position: relative; + padding-left: 2.25em; +} +.bootstrap-select.btn-group .dropdown-menu li a span.check-mark { + display: none; +} +.bootstrap-select.btn-group .dropdown-menu li a span.text { + display: inline-block; +} +.bootstrap-select.btn-group .dropdown-menu li small { + padding-left: 0.5em; +} +.bootstrap-select.btn-group .dropdown-menu .notify { + position: absolute; + bottom: 5px; + width: 96%; + margin: 0 2%; + min-height: 26px; + padding: 3px 5px; + background: #f5f5f5; + border: 1px solid #e3e3e3; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); + pointer-events: none; + opacity: 0.9; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.bootstrap-select.btn-group .no-results { + padding: 3px; + background: #f5f5f5; + margin: 0 5px; + white-space: nowrap; +} +.bootstrap-select.btn-group.fit-width .dropdown-toggle .filter-option { + position: static; +} +.bootstrap-select.btn-group.fit-width .dropdown-toggle .caret { + position: static; + top: auto; + margin-top: -1px; +} +.bootstrap-select.btn-group.show-tick .dropdown-menu li.selected a span.check-mark { + position: absolute; + display: inline-block; + right: 15px; + margin-top: 5px; +} +.bootstrap-select.btn-group.show-tick .dropdown-menu li a span.text { + margin-right: 34px; +} +.bootstrap-select.show-menu-arrow.open > .dropdown-toggle { + z-index: 1061; +} +.bootstrap-select.show-menu-arrow .dropdown-toggle:before { + content: ''; + border-left: 7px solid transparent; + border-right: 7px solid transparent; + border-bottom: 7px solid rgba(204, 204, 204, 0.2); + position: absolute; + bottom: -4px; + left: 9px; + display: none; +} +.bootstrap-select.show-menu-arrow .dropdown-toggle:after { + content: ''; + border-left: 6px solid transparent; + border-right: 6px solid transparent; + border-bottom: 6px solid white; + position: absolute; + bottom: -4px; + left: 10px; + display: none; +} +.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:before { + bottom: auto; + top: -3px; + border-top: 7px solid rgba(204, 204, 204, 0.2); + border-bottom: 0; +} +.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:after { + bottom: auto; + top: -3px; + border-top: 6px solid white; + border-bottom: 0; +} +.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:before { + right: 12px; + left: auto; +} +.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:after { + right: 13px; + left: auto; +} +.bootstrap-select.show-menu-arrow.open > .dropdown-toggle:before, +.bootstrap-select.show-menu-arrow.open > .dropdown-toggle:after { + display: block; +} +.bs-searchbox, +.bs-actionsbox, +.bs-donebutton { + padding: 4px 8px; +} +.bs-actionsbox { + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.bs-actionsbox .btn-group { + display: flex; + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.bs-actionsbox .btn-group button { + width: 50%; + flex: 1; +} +.bs-donebutton { + float: left; + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.bs-donebutton .btn-group button { + width: 100%; +} +.bs-searchbox + .bs-actionsbox { + padding: 0 8px 4px; +} +.bs-searchbox .form-control { + margin-bottom: 0; + width: 100%; + float: none; +} +/*# sourceMappingURL=bootstrap-select.css.map */ \ No newline at end of file diff --git a/assets/css/coda-slider-2.0a.css b/assets/css/coda-slider-2.0a.css new file mode 100644 index 00000000..376e9510 --- /dev/null +++ b/assets/css/coda-slider-2.0a.css @@ -0,0 +1,122 @@ +/* + jQuery Coda-Slider v2.0 - http://www.ndoherty.biz/coda-slider + Copyright (c) 2009 Niall Doherty + This plugin available for use in all personal or commercial projects under both MIT and GPL licenses. +*/ + + +/* Most common stuff you'll need to change */ +.coda-slider-wrapper { + padding: 20px 0 !important; + width: 100% !important; +} + +.coda-slider { + background: #ebebeb !important; + border: solid 1px red !important; +} + +/* Panel padding */ +.coda-slider .panel-wrapper { padding: 20px } + +/* Preloader */ +.coda-slider p.loading { + padding: 20px !important; + text-align: center !important; + width: 100% !important; + border: solid 1px red !important; +} + + +.coda-slider-wrapper.arrows .coda-slider { + margin: 0 10px; +} + + + + + + + +/* Tabbed nav */ +.coda-nav ul { + clear: both !important; + display: block !important; + margin: auto !important; + overflow: hidden !important; +} +.coda-nav ul li { + display: inline !important; +} +.coda-nav ul li a { + background: #000 !important; + color: #fff !important; + /*display: block;*/ + /*float: left;*/ + width: 200px !important; + margin-right: 1px !important; + padding: 3px 6px !important; + text-decoration: none !important; + text-align: center !important; +} + +.coda-nav ul li a.current { + background: #39c +} + +.coda-nav-left a, .coda-nav-right a { + background: #000; + color: #fff; + padding: 5px; + width: 100px +} +*/ + + + + + + + + + + + + + + + + +/* Use this to keep the slider content contained in a box even when JavaScript is disabled */ +/* +.coda-slider-no-js .coda-slider { + height: 200px; + overflow: auto !important; + padding-right: 20px +} +*/ +/* Change the width of the entire slider (without dynamic arrows) */ +/* +.coda-slider, .coda-slider .panel { + width: 900px; +} +*/ +/* Change margin and width of the slider (with dynamic arrows) */ +/* +.coda-slider-wrapper.arrows .coda-slider, .coda-slider-wrapper.arrows .coda-slider .panel { + width: 600px; +} + + + + +/* Don't change anything below here unless you know what you're doing */ + +/* Miscellaneous */ + +.coda-slider-wrapper { clear: both; overflow: auto } +.coda-slider { float: left; overflow: hidden; position: relative } +.coda-slider .panel { display: block; float: left } +.coda-slider .panel-container { position: relative } +.coda-nav-left, .coda-nav-right { float: left } +.coda-nav-left a, .coda-nav-right a { display: block; text-align: center; text-decoration: none } diff --git a/assets/css/coda-slider.css b/assets/css/coda-slider.css new file mode 100644 index 00000000..cf0e781e --- /dev/null +++ b/assets/css/coda-slider.css @@ -0,0 +1,357 @@ +/*********************************************************************** + jQuery Coda-Slider v3.0 - kevinbatdorf.github.com/codaslider + Copyright (c) 2012 Kevin Batdorf + This plugin available for use in all personal or commercial projects under both MIT and GPL licenses. +************************************************************************/ +/******************************************** +SASS stylesheet. + +No idea what CSS preprocessing is all about? No problem... just use the style.css file instead. +If you want to learn more, check out this article by Chris Coyier + +css-tricks.com/musings-on-preprocessing/ + +********************************************/ + +.coda-slider-wrapper { + /******************************************************* + * + * Most common stuff you'll need to change + * will be below this line. + * + ********************************************************/ + /****************************************************** + * + * Main wrapper padding + * + *******************************************************/ + padding: 20px 0; +} + + .coda-slider-wrapper .coda-slider { + /****************************************************** + * + * Inner wrapper styles + * + *******************************************************/ + background: #f2f2f2; + /****************************************************** + * + * Width of the container. Typically you will want to + * match this with the width of the panel as well. + * + *******************************************************/ + width: 700px; + } + + .coda-slider-wrapper .coda-slider .panel { + /****************************************************** + * + * Width of each individual panel. + * Typically you will want to match this with the width + * of the container as well. + * + *******************************************************/ + width: 700px; + } + + .coda-slider-wrapper .coda-slider .panel .panel-wrapper { + /****************************************************** + * + * Panel wrapper styles + * + *******************************************************/ + padding: 20px; + } + + .coda-slider-wrapper .coda-nav { + /****************************************************** + * + * Tab styles + * + *******************************************************/ + } + + .coda-slider-wrapper .coda-nav .current { + /****************************************************** + * + * Current tab styles + * + *******************************************************/ + background: #0090FF; + } + + .coda-slider-wrapper .coda-nav a { + /****************************************************** + * + * Tab styles + * + *******************************************************/ + background: #000; + color: #fff; + margin-right: 1px; + padding: 3px 6px; + } + + .coda-slider-wrapper .coda-nav a:hover { + /****************************************************** + * + * Tab styles + * + *******************************************************/ + background: #000; + color: #fff; + text-shadow: none; + } + + .coda-slider-wrapper .coda-nav-left, .coda-slider-wrapper .coda-nav-right { + /****************************************************** + * + * Arrow Styles + * + *******************************************************/ + } + + .coda-slider-wrapper .coda-nav-left a, .coda-slider-wrapper .coda-nav-right a { + /****************************************************** + * + * Arrow Styles + * + *******************************************************/ + background: #000; + color: #fff; + padding: 5px; + width: 100px; + } + + .coda-slider-wrapper .coda-nav-left-arrow { + /****************************************************** + * + * Graphical arrow styles + * + *******************************************************/ + width: 25px; + height: 25px; + background: url(../img/arrow.png) no-repeat top left; + margin-top:50px; + } + +.coda-slider-wrapper .coda-nav-left-arrow a { + /****************************************************** + * + * Graphical arrow styles + * + *******************************************************/ + width: 0; + height: 0; + border:none; + } + + .coda-slider-wrapper .coda-nav-left-arrow:hover { + /************************************************ + * + * Graphical arrows hover left + * + *************************************************/ + background: url(../img/arrow.png) no-repeat bottom left; + } + + .coda-slider-wrapper .coda-nav-right-arrow { + /****************************************************** + * + * Graphical arrow styles + * + *******************************************************/ + width: 25px; + height: 25px; + background: url(../img/arrow.png) no-repeat top right; + margin-top:50px; + } +.coda-slider-wrapper .coda-nav-right-arrow a { + /****************************************************** + * + * Graphical arrow styles + * + *******************************************************/ + width: 0; + height: 0; + background: none; + margin-top:0; + border:none; + } + + .coda-slider-wrapper .coda-nav-right-arrow:hover { + /************************************************ + * + * Graphical arrows hover right + * + *************************************************/ + background: url(../img/arrow.png) no-repeat bottom right; + } + + .coda-slider-wrapper .coda-nav-left-arrow:active, .coda-slider-wrapper .coda-nav-right-arrow:active { + /************************************************ + * + * Graphical arrows active + * + *************************************************/ + margin-top: 55px; + } + + .coda-slider-wrapper .loading { + /****************************************************** + * + * Style for preloader + * + *******************************************************/ + height: 100%; + padding: 20px; + text-align: center; + } + + + + +.arrows .coda-slider { + /****************************************************** + * + * Margin between slider and arrows + * + *******************************************************/ + margin: 0 10px; +} + +/********************************************************************** +* +* Don't change anything below here unless you know what you're doing +* +***********************************************************************/ + +.coda-slider-wrapper { + /************************************************ + * + * Wrapper styles + * + *************************************************/ + clear: both; + overflow: auto; +} + + .coda-slider-wrapper .coda-slider { + /************************************************ + * + * slider styles + * + *************************************************/ + float: left; + overflow: hidden; + position: relative; + } + + .coda-slider-wrapper .coda-slider .panel-container { + /************************************************ + * + * Panel container styles + * + *************************************************/ + position: relative; + } + + .coda-slider-wrapper .coda-slider .panel-container .panel { + /************************************************ + * + * Panel styles + * + *************************************************/ + display: block; + float: left; + } + + .coda-slider-wrapper .coda-nav { + /************************************************ + * + * Navigation tabs + * + *************************************************/ + } + + .coda-slider-wrapper .coda-nav ul { + /************************************************ + * + * Navigation tabs + * + *************************************************/ + padding:0; + clear: both; + display: block; + margin: auto; + overflow: hidden; + } + + .coda-slider-wrapper .coda-nav ul li { + /************************************************ + * + * Navigation tabs + * + *************************************************/ + display: inline; + } + + .coda-slider-wrapper .coda-nav ul li a { + /************************************************ + * + * Navigation tabs + * + *************************************************/ + display: block; + float: left; + text-decoration: none; + } + + .coda-slider-wrapper .coda-nav-left-arrow, .coda-slider-wrapper .coda-nav-right-arrow { + /************************************************ + * + * Graphical arrows + * + *************************************************/ + cursor: pointer; + float: left; + } + + .coda-slider-wrapper .coda-nav-left-arrow a, .coda-slider-wrapper .coda-nav-right-arrow a { + /************************************************ + * + * Graphical arrows + * + *************************************************/ + display: block; + } + + .coda-slider-wrapper .coda-nav-left, .coda-slider-wrapper .coda-nav-right { + /************************************************ + * + * Html arrows + * + *************************************************/ + float: left; + } + + .coda-slider-wrapper .coda-nav-left a, .coda-slider-wrapper .coda-nav-right a { + /************************************************ + * + * Html arrow styles + * + *************************************************/ + display: block; + text-align: center; + text-decoration: none; + } + + .coda-slider-wrapper .coda-nav-left, .coda-slider-wrapper .coda-nav-left-arrow { + /************************************************ + * + * Html and graphical arrow styles + * + *************************************************/ + clear: both; + } \ No newline at end of file diff --git a/assets/css/codemirror.css b/assets/css/codemirror.css new file mode 100644 index 00000000..fa219400 --- /dev/null +++ b/assets/css/codemirror.css @@ -0,0 +1,347 @@ +/* BASICS */ + +.CodeMirror { + /* Set height, width, borders, and global font properties here */ + font-family: monospace; + height: 300px; + color: black; +} + +/* PADDING */ + +.CodeMirror-lines { + padding: 4px 0; /* Vertical padding around content */ +} +.CodeMirror pre { + padding: 0 4px; /* Horizontal padding of content */ +} + +.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { + background-color: white; /* The little square between H and V scrollbars */ +} + +/* GUTTER */ + +.CodeMirror-gutters { + border-right: 1px solid #ddd; + background-color: #f7f7f7; + white-space: nowrap; +} +.CodeMirror-linenumbers {} +.CodeMirror-linenumber { + padding: 0 3px 0 5px; + min-width: 20px; + text-align: right; + color: #999; + white-space: nowrap; +} + +.CodeMirror-guttermarker { color: black; } +.CodeMirror-guttermarker-subtle { color: #999; } + +/* CURSOR */ + +.CodeMirror-cursor { + border-left: 1px solid black; + border-right: none; + width: 0; +} +/* Shown when moving in bi-directional text */ +.CodeMirror div.CodeMirror-secondarycursor { + border-left: 1px solid silver; +} +.cm-fat-cursor .CodeMirror-cursor { + width: auto; + border: 0 !important; + background: #7e7; +} +.cm-fat-cursor div.CodeMirror-cursors { + z-index: 1; +} + +.cm-animate-fat-cursor { + width: auto; + border: 0; + -webkit-animation: blink 1.06s steps(1) infinite; + -moz-animation: blink 1.06s steps(1) infinite; + animation: blink 1.06s steps(1) infinite; + background-color: #7e7; +} +@-moz-keyframes blink { + 0% {} + 50% { background-color: transparent; } + 100% {} +} +@-webkit-keyframes blink { + 0% {} + 50% { background-color: transparent; } + 100% {} +} +@keyframes blink { + 0% {} + 50% { background-color: transparent; } + 100% {} +} + +/* Can style cursor different in overwrite (non-insert) mode */ +.CodeMirror-overwrite .CodeMirror-cursor {} + +.cm-tab { display: inline-block; text-decoration: inherit; } + +.CodeMirror-rulers { + position: absolute; + left: 0; right: 0; top: -50px; bottom: -20px; + overflow: hidden; +} +.CodeMirror-ruler { + border-left: 1px solid #ccc; + top: 0; bottom: 0; + position: absolute; +} + +/* DEFAULT THEME */ + +.cm-s-default .cm-header {color: blue;} +.cm-s-default .cm-quote {color: #090;} +.cm-negative {color: #d44;} +.cm-positive {color: #292;} +.cm-header, .cm-strong {font-weight: bold;} +.cm-em {font-style: italic;} +.cm-link {text-decoration: underline;} +.cm-strikethrough {text-decoration: line-through;} + +.cm-s-default .cm-keyword {color: #708;} +.cm-s-default .cm-atom {color: #219;} +.cm-s-default .cm-number {color: #164;} +.cm-s-default .cm-def {color: #00f;} +.cm-s-default .cm-variable, +.cm-s-default .cm-punctuation, +.cm-s-default .cm-property, +.cm-s-default .cm-operator {} +.cm-s-default .cm-variable-2 {color: #05a;} +.cm-s-default .cm-variable-3 {color: #085;} +.cm-s-default .cm-comment {color: #a50;} +.cm-s-default .cm-string {color: #a11;} +.cm-s-default .cm-string-2 {color: #f50;} +.cm-s-default .cm-meta {color: #555;} +.cm-s-default .cm-qualifier {color: #555;} +.cm-s-default .cm-builtin {color: #30a;} +.cm-s-default .cm-bracket {color: #997;} +.cm-s-default .cm-tag {color: #170;} +.cm-s-default .cm-attribute {color: #00c;} +.cm-s-default .cm-hr {color: #999;} +.cm-s-default .cm-link {color: #00c;} + +.cm-s-default .cm-error {color: #f00;} +.cm-invalidchar {color: #f00;} + +.CodeMirror-composing { border-bottom: 2px solid; } + +/* Default styles for common addons */ + +div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;} +div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} +.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } +.CodeMirror-activeline-background {background: #e8f2ff;} + +/* STOP */ + +/* The rest of this file contains styles related to the mechanics of + the editor. You probably shouldn't touch them. */ + +.CodeMirror { + position: relative; + overflow: hidden; + background: white; +} + +.CodeMirror-scroll { + overflow: scroll !important; /* Things will break if this is overridden */ + /* 30px is the magic margin used to hide the element's real scrollbars */ + /* See overflow: hidden in .CodeMirror */ + margin-bottom: -30px; margin-right: -30px; + padding-bottom: 30px; + height: 100%; + outline: none; /* Prevent dragging from highlighting the element */ + position: relative; +} +.CodeMirror-sizer { + position: relative; + border-right: 30px solid transparent; +} + +/* The fake, visible scrollbars. Used to force redraw during scrolling + before actual scrolling happens, thus preventing shaking and + flickering artifacts. */ +.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { + position: absolute; + z-index: 6; + display: none; +} +.CodeMirror-vscrollbar { + right: 0; top: 0; + overflow-x: hidden; + overflow-y: scroll; +} +.CodeMirror-hscrollbar { + bottom: 0; left: 0; + overflow-y: hidden; + overflow-x: scroll; +} +.CodeMirror-scrollbar-filler { + right: 0; bottom: 0; +} +.CodeMirror-gutter-filler { + left: 0; bottom: 0; +} + +.CodeMirror-gutters { + position: absolute; left: 0; top: 0; + min-height: 100%; + z-index: 3; +} +.CodeMirror-gutter { + white-space: normal; + height: 100%; + display: inline-block; + vertical-align: top; + margin-bottom: -30px; + /* Hack to make IE7 behave */ + *zoom:1; + *display:inline; +} +.CodeMirror-gutter-wrapper { + position: absolute; + z-index: 4; + background: none !important; + border: none !important; +} +.CodeMirror-gutter-background { + position: absolute; + top: 0; bottom: 0; + z-index: 4; +} +.CodeMirror-gutter-elt { + position: absolute; + cursor: default; + z-index: 4; +} +.CodeMirror-gutter-wrapper { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; +} + +.CodeMirror-lines { + cursor: text; + min-height: 1px; /* prevents collapsing before first draw */ +} +.CodeMirror pre { + /* Reset some styles that the rest of the page might have set */ + -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; + border-width: 0; + background: transparent; + font-family: inherit; + font-size: inherit; + margin: 0; + white-space: pre; + word-wrap: normal; + line-height: inherit; + color: inherit; + z-index: 2; + position: relative; + overflow: visible; + -webkit-tap-highlight-color: transparent; + -webkit-font-variant-ligatures: none; + font-variant-ligatures: none; +} +.CodeMirror-wrap pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: normal; +} + +.CodeMirror-linebackground { + position: absolute; + left: 0; right: 0; top: 0; bottom: 0; + z-index: 0; +} + +.CodeMirror-linewidget { + position: relative; + z-index: 2; + overflow: auto; +} + +.CodeMirror-widget {} + +.CodeMirror-code { + outline: none; +} + +/* Force content-box sizing for the elements where we expect it */ +.CodeMirror-scroll, +.CodeMirror-sizer, +.CodeMirror-gutter, +.CodeMirror-gutters, +.CodeMirror-linenumber { + -moz-box-sizing: content-box; + box-sizing: content-box; +} + +.CodeMirror-measure { + position: absolute; + width: 100%; + height: 0; + overflow: hidden; + visibility: hidden; +} + +.CodeMirror-cursor { + position: absolute; + pointer-events: none; +} +.CodeMirror-measure pre { position: static; } + +div.CodeMirror-cursors { + visibility: hidden; + position: relative; + z-index: 3; +} +div.CodeMirror-dragcursors { + visibility: visible; +} + +.CodeMirror-focused div.CodeMirror-cursors { + visibility: visible; +} + +.CodeMirror-selected { background: #d9d9d9; } +.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } +.CodeMirror-crosshair { cursor: crosshair; } +.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; } +.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } + +.cm-searching { + background: #ffa; + background: rgba(255, 255, 0, .4); +} + +/* IE7 hack to prevent it from returning funny offsetTops on the spans */ +.CodeMirror span { *vertical-align: text-bottom; } + +/* Used to force a border model for a node */ +.cm-force-border { padding-right: .1px; } + +@media print { + /* Hide the cursor when printing */ + .CodeMirror div.CodeMirror-cursors { + visibility: hidden; + } +} + +/* See issue #2901 */ +.cm-tab-wrap-hack:after { content: ''; } + +/* Help users use markselection to safely style text background */ +span.CodeMirror-selectedtext { background: none; } \ No newline at end of file diff --git a/assets/css/codemirror_fullscreen.css b/assets/css/codemirror_fullscreen.css new file mode 100644 index 00000000..c876aac0 --- /dev/null +++ b/assets/css/codemirror_fullscreen.css @@ -0,0 +1,6 @@ +.CodeMirror-fullscreen { + position: fixed; + top: 45px; left: 10px; right: 10px; bottom: 10px; + height: auto; + z-index: 9; +} diff --git a/assets/css/codemirror_simplescrollbars.css b/assets/css/codemirror_simplescrollbars.css new file mode 100644 index 00000000..2eca94c0 --- /dev/null +++ b/assets/css/codemirror_simplescrollbars.css @@ -0,0 +1,66 @@ +.CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div { + position: absolute; + background: #ccc; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 1px solid #bbb; + border-radius: 2px; +} + +.CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical { + position: absolute; + z-index: 6; + background: #eee; +} + +.CodeMirror-simplescroll-horizontal { + bottom: 0; left: 0; + height: 8px; +} +.CodeMirror-simplescroll-horizontal div { + bottom: 0; + height: 100%; +} + +.CodeMirror-simplescroll-vertical { + right: 0; top: 0; + width: 8px; +} +.CodeMirror-simplescroll-vertical div { + right: 0; + width: 100%; +} + + +.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler { + display: none; +} + +.CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div { + position: absolute; + background: #bcd; + border-radius: 3px; +} + +.CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical { + position: absolute; + z-index: 6; +} + +.CodeMirror-overlayscroll-horizontal { + bottom: 0; left: 0; + height: 6px; +} +.CodeMirror-overlayscroll-horizontal div { + bottom: 0; + height: 100%; +} + +.CodeMirror-overlayscroll-vertical { + right: 0; top: 0; + width: 6px; +} +.CodeMirror-overlayscroll-vertical div { + right: 0; + width: 100%; +} \ No newline at end of file diff --git a/assets/css/default.css b/assets/css/default.css new file mode 100644 index 00000000..e68f0fb3 --- /dev/null +++ b/assets/css/default.css @@ -0,0 +1,19 @@ +.cm-s-default span.cm-keyword {color: #708;} +.cm-s-default span.cm-atom {color: #219;} +.cm-s-default span.cm-number {color: #164;} +.cm-s-default span.cm-def {color: #00f;} +.cm-s-default span.cm-variable {color: black;} +.cm-s-default span.cm-variable-2 {color: #05a;} +.cm-s-default span.cm-variable-3 {color: #0a5;} +.cm-s-default span.cm-property {color: black;} +.cm-s-default span.cm-operator {color: black;} +.cm-s-default span.cm-comment {color: #a50;} +.cm-s-default span.cm-string {color: #a11;} +.cm-s-default span.cm-string-2 {color: #f50;} +.cm-s-default span.cm-meta {color: #555;} +.cm-s-default span.cm-error {color: #f00;} +.cm-s-default span.cm-qualifier {color: #555;} +.cm-s-default span.cm-builtin {color: #30a;} +.cm-s-default span.cm-bracket {color: #cc7;} +.cm-s-default span.cm-tag {color: #170;} +.cm-s-default span.cm-attribute {color: #00c;} diff --git a/assets/css/epm_advanced.css b/assets/css/epm_advanced.css new file mode 100644 index 00000000..4bb045be --- /dev/null +++ b/assets/css/epm_advanced.css @@ -0,0 +1,177 @@ +@CHARSET "ISO-8859-1"; + +#epm_advanced .linedwrap { + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-style: solid; + border-right-style: solid; + border-bottom-style: solid; + border-left-style: solid; + border-top-color: #00dddd; + border-right-color: #00dddd; + border-bottom-color: #00dddd; + border-left-color: #00dddd; + border-image-source: none; + border-image-slice: 100% 100% 100% 100%; + border-image-width: 1 1 1 1; + border-image-outset: 0 0 0 0; + border-image-repeat: stretch stretch; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + border-bottom-left-radius: 4px; + + box-shadow: 4px 4px 2px #00dddd; + -webkit-box-shadow: 4px 4px 2px #00dddd; + -moz-box-shadow: 4px 4px 2px #00dddd; +} + +#epm_advanced .custom_box_import div.col-md-9 { + display: table; +} + +#epm_advanced .custom_box_import div.col-md-9 span { + display: table-cell; + margin: 0px; + padding: 0px 0px 0px 10px; +} + + +#poce .dropdown-menu { + width: 100%; + background-color: #d7ebf9; +} + +#poce .dropdown-item +{ + display: block; + width: 100%; + padding-top: 3px; + padding-right: 20px; + padding-bottom: 3px; + padding-left: 20px; + clear: both; + font-weight: 400; + line-height: 1.5; + color: #373a3c; + text-align: inherit; + white-space: nowrap; + + background-color: transparent; + background-image: none; + background-repeat: repeat; + background-attachment: scroll; + background-position: 0px 0px; + background-clip: border-box; + background-origin: padding-box; + background-size: auto auto; + + border-top-width: 0px; + border-right-width: 0px; + border-bottom-width: 0px; + border-left-width: 0px; + + border-top-style: none; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + + border-image-source: none; + border-image-slice: 100% 100% 100% 100%; + border-image-width: 1 1 1 1; + border-image-outset: 0 0 0 0; + border-image-repeat: stretch stretch; +} + +#poce .dropdown-item:focus, #poce .dropdown-item:hover +{ + color: #2b2d2f; + text-decoration-line: none; + text-decoration-style: solid; + background-color: #f5f5f5; +} + +#poce .dropdown-item:focus, #poce .dropdown-item:hover +{ + color: #2b2d2f; + text-decoration-line: none; + text-decoration-style: solid; + background-color: #f5f5f5; +} + +#poce > #config_textarea { + width: 100%; + -ms-overflow-style: none; + overflow: hidden; +} + + +#box_bt_save, #box_bt_save_as, #box_bt_share { + margin-bottom: 10px; + +} + + +#epm_advanced div.CodeMirror +{ + /* + transition-property: border, box-shadow; + transition-duration: 0.2s, 0.2s; + transition-timing-function: linear, linear; + transition-delay: 0s, 0s; +*/ + + padding-top: 0px; + padding-right: 0px; + padding-bottom: 0px; + padding-left: 0px; + + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-style: solid; + border-right-style: solid; + border-bottom-style: solid; + border-left-style: solid; + border-top-color: #cccccc; + border-right-color: #cccccc; + border-bottom-color: #cccccc; + border-left-color: #cccccc; + border-image-source: none; + border-image-slice: 100% 100% 100% 100%; + border-image-width: 1 1 1 1; + border-image-outset: 0 0 0 0; + border-image-repeat: stretch stretch; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + border-bottom-left-radius: 3px; + + margin-top: 5px; + margin-bottom: 10px; + background-color: #FFFFCC; + font-family: Courier, "dejavu sans mono","monaco","lucida console","courier new",monospace; +} + +#epm_advanced div.CodeMirror:hover +{ + border-top-color: rgba(171, 213, 242, 0.9); + border-right-color: rgba(171, 213, 242, 0.9); + border-bottom-color: rgba(171, 213, 242, 0.9); + border-left-color: rgba(171, 213, 242, 0.9); + box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.075) inset, 0px 0px 8px rgba(27, 118, 182, 0.6); +} + +/* +#epm_advanced div.CodeMirror:hover +{ + border-top-color: rgba(82, 168, 236, 0.8); + border-right-color: rgba(82, 168, 236, 0.8); + border-bottom-color: rgba(82, 168, 236, 0.8); + border-left-color: rgba(82, 168, 236, 0.8); + box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1) inset, 0px 0px 8px rgba(82, 168, 236, 0.6); +} +*/ diff --git a/assets/css/epm_config.css b/assets/css/epm_config.css new file mode 100644 index 00000000..79c90b2a --- /dev/null +++ b/assets/css/epm_config.css @@ -0,0 +1,60 @@ +@CHARSET "ISO-8859-1"; + +/* +#epm_config div.sortable +{ + background: transparent; + + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-style: solid; + border-right-style: solid; + border-bottom-style: solid; + border-left-style: solid; + border-top-color: #00dddd; + border-right-color: #00dddd; + border-bottom-color: #00dddd; + border-left-color: #00dddd; + border-image-source: none; + border-image-slice: 100% 100% 100% 100%; + border-image-width: 1 1 1 1; + border-image-outset: 0 0 0 0; + border-image-repeat: stretch stretch; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + border-bottom-left-radius: 4px; + + padding-top: 0px; + padding-right: 0px; + padding-bottom: 0px; + padding-left: 0px; + + margin-top: 15px; + margin-bottom: 15px; + margin-right: 10px; + + box-shadow: 4px 4px 2px #00dddd; + -webkit-box-shadow: 4px 4px 2px #00dddd; + -moz-box-shadow: 4px 4px 2px #00dddd; +} +*/ + +#moduledialogwrapper p { + padding: 0px; + font-weight: bold; +} + +#moduledialogwrapper p.error { + color: red; +} + +#moduledialogwrapper p.done { + color: green; +} + +#moduledialogwrapper p.txt { + font-weight: normal; +} \ No newline at end of file diff --git a/assets/css/epm_devices.css b/assets/css/epm_devices.css new file mode 100644 index 00000000..b5734659 --- /dev/null +++ b/assets/css/epm_devices.css @@ -0,0 +1 @@ +@CHARSET "ISO-8859-1"; \ No newline at end of file diff --git a/assets/css/epm_global.css b/assets/css/epm_global.css new file mode 100644 index 00000000..eaa3e204 --- /dev/null +++ b/assets/css/epm_global.css @@ -0,0 +1,38 @@ +@CHARSET "ISO-8859-1"; + +#epm_templates option[value=""], #epm_advanced option[value=""], #epm_config option[value=""] { + background-color: #E5FFCC; +} + + +.section-title { + margin: 10px 10px 0px 10px; +} + +.section { + margin-left: 10px; + margin-right: 10px; + margin-bottom: 10px; +} + +.pull-xs-right +{ + float: right; +} + + + + + + +/* Class */ +.center-block { + display: block; + margin-left: auto; + margin-right: auto; +} + +/* Usage as a mixin */ +.element { + @include center-block; +} \ No newline at end of file diff --git a/assets/css/epm_templates.css b/assets/css/epm_templates.css new file mode 100644 index 00000000..706d756a --- /dev/null +++ b/assets/css/epm_templates.css @@ -0,0 +1,93 @@ +@CHARSET "ISO-8859-1"; + + +#epm_templates code.inline { + padding: 2px 4px; + font-size: 0.8em; + background-color: #f7f7f9; + border: 1px solid #e1e1e8; +} + +#epm_templates ul.nobullets { + list-style-type: none; +} + +#epm_templates li { + line-height: 24px; +} + +div.input-group-br { + margin-bottom: 5px; +} + + + + + + + + + + + + + + + + +#epm_templates #config_textarea { + width: 100%; + -ms-overflow-style: none; + overflow: hidden; +} + +#epm_templates div.CodeMirror +{ + /* + transition-property: border, box-shadow; + transition-duration: 0.2s, 0.2s; + transition-timing-function: linear, linear; + transition-delay: 0s, 0s; +*/ + + padding-top: 0px; + padding-right: 0px; + padding-bottom: 0px; + padding-left: 0px; + + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-style: solid; + border-right-style: solid; + border-bottom-style: solid; + border-left-style: solid; + border-top-color: #cccccc; + border-right-color: #cccccc; + border-bottom-color: #cccccc; + border-left-color: #cccccc; + border-image-source: none; + border-image-slice: 100% 100% 100% 100%; + border-image-width: 1 1 1 1; + border-image-outset: 0 0 0 0; + border-image-repeat: stretch stretch; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + border-bottom-left-radius: 3px; + + margin-top: 5px; + margin-bottom: 10px; + background-color: #FFFFCC; + font-family: Courier, "dejavu sans mono","monaco","lucida console","courier new",monospace; +} + +#epm_templates div.CodeMirror:hover +{ + border-top-color: rgba(171, 213, 242, 0.9); + border-right-color: rgba(171, 213, 242, 0.9); + border-bottom-color: rgba(171, 213, 242, 0.9); + border-left-color: rgba(171, 213, 242, 0.9); + box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.075) inset, 0px 0px 8px rgba(27, 118, 182, 0.6); +} \ No newline at end of file diff --git a/assets/css/font-awesome-3.2.1.css b/assets/css/font-awesome-3.2.1.css new file mode 100644 index 00000000..7ede1828 --- /dev/null +++ b/assets/css/font-awesome-3.2.1.css @@ -0,0 +1,1479 @@ +/*! + * Font Awesome 3.2.1 + * the iconic font designed for Bootstrap + * ------------------------------------------------------------------------------ + * The full suite of pictographic icons, examples, and documentation can be + * found at http://fontawesome.io. Stay up to date on Twitter at + * http://twitter.com/fontawesome. + * + * License + * ------------------------------------------------------------------------------ + * - The Font Awesome font is licensed under SIL OFL 1.1 - + * http://scripts.sil.org/OFL + * - Font Awesome CSS, LESS, and SASS files are licensed under MIT License - + * http://opensource.org/licenses/mit-license.html + * - Font Awesome documentation licensed under CC BY 3.0 - + * http://creativecommons.org/licenses/by/3.0/ + * - Attribution is no longer required in Font Awesome 3.0, but much appreciated: + * "Font Awesome by Dave Gandy - http://fontawesome.io" + * + * Author - Dave Gandy + * ------------------------------------------------------------------------------ + * Email: dave@fontawesome.io + * Twitter: http://twitter.com/davegandy + * Work: Lead Product Designer @ Kyruus - http://kyruus.com + */ +/* FONT PATH + * -------------------------- */ +@font-face { + font-family: 'FontAwesome'; + src: url('../font/fontawesome-webfont.eot?v=3.2.1'); + src: url('../font/fontawesome-webfont.eot?#iefix&v=3.2.1') format('embedded-opentype'), url('../font/fontawesome-webfont.woff?v=3.2.1') format('woff'), url('../font/fontawesome-webfont.ttf?v=3.2.1') format('truetype'), url('../font/fontawesome-webfont.svg#fontawesomeregular?v=3.2.1') format('svg'); + font-weight: normal; + font-style: normal; +} +/* FONT AWESOME CORE + * -------------------------- */ +[class^="icon-"], +[class*=" icon-"] { + font-family: FontAwesome; + font-weight: normal; + font-style: normal; + text-decoration: inherit; + -webkit-font-smoothing: antialiased; + *margin-right: .3em; +} +[class^="icon-"]:before, +[class*=" icon-"]:before { + text-decoration: inherit; + display: inline-block; + speak: none; +} +/* makes the font 33% larger relative to the icon container */ +.icon-large:before { + vertical-align: -10%; + font-size: 1.3333333333333333em; +} +/* makes sure icons active on rollover in links */ +a [class^="icon-"], +a [class*=" icon-"] { + display: inline; +} +/* increased font size for icon-large */ +[class^="icon-"].icon-fixed-width, +[class*=" icon-"].icon-fixed-width { + display: inline-block; + width: 1.1428571428571428em; + text-align: right; + padding-right: 0.2857142857142857em; +} +[class^="icon-"].icon-fixed-width.icon-large, +[class*=" icon-"].icon-fixed-width.icon-large { + width: 1.4285714285714286em; +} +.icons-ul { + margin-left: 2.142857142857143em; + list-style-type: none; +} +.icons-ul > li { + position: relative; +} +.icons-ul .icon-li { + position: absolute; + left: -2.142857142857143em; + width: 2.142857142857143em; + text-align: center; + line-height: inherit; +} +[class^="icon-"].hide, +[class*=" icon-"].hide { + display: none; +} +.icon-muted { + color: #eeeeee; +} +.icon-light { + color: #ffffff; +} +.icon-dark { + color: #333333; +} +.icon-border { + border: solid 1px #eeeeee; + padding: .2em .25em .15em; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} +.icon-2x { + font-size: 2em; +} +.icon-2x.icon-border { + border-width: 2px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} +.icon-3x { + font-size: 3em; +} +.icon-3x.icon-border { + border-width: 3px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} +.icon-4x { + font-size: 4em; +} +.icon-4x.icon-border { + border-width: 4px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} +.icon-5x { + font-size: 5em; +} +.icon-5x.icon-border { + border-width: 5px; + -webkit-border-radius: 7px; + -moz-border-radius: 7px; + border-radius: 7px; +} +.pull-right { + float: right; +} +.pull-left { + float: left; +} +[class^="icon-"].pull-left, +[class*=" icon-"].pull-left { + margin-right: .3em; +} +[class^="icon-"].pull-right, +[class*=" icon-"].pull-right { + margin-left: .3em; +} +/* BOOTSTRAP SPECIFIC CLASSES + * -------------------------- */ +/* Bootstrap 2.0 sprites.less reset */ +[class^="icon-"], +[class*=" icon-"] { + display: inline; + width: auto; + height: auto; + line-height: normal; + vertical-align: baseline; + background-image: none; + background-position: 0% 0%; + background-repeat: repeat; + margin-top: 0; +} +/* more sprites.less reset */ +.icon-white, +.nav-pills > .active > a > [class^="icon-"], +.nav-pills > .active > a > [class*=" icon-"], +.nav-list > .active > a > [class^="icon-"], +.nav-list > .active > a > [class*=" icon-"], +.navbar-inverse .nav > .active > a > [class^="icon-"], +.navbar-inverse .nav > .active > a > [class*=" icon-"], +.dropdown-menu > li > a:hover > [class^="icon-"], +.dropdown-menu > li > a:hover > [class*=" icon-"], +.dropdown-menu > .active > a > [class^="icon-"], +.dropdown-menu > .active > a > [class*=" icon-"], +.dropdown-submenu:hover > a > [class^="icon-"], +.dropdown-submenu:hover > a > [class*=" icon-"] { + background-image: none; +} +/* keeps Bootstrap styles with and without icons the same */ +.btn [class^="icon-"].icon-large, +.nav [class^="icon-"].icon-large, +.btn [class*=" icon-"].icon-large, +.nav [class*=" icon-"].icon-large { + line-height: .9em; +} +.btn [class^="icon-"].icon-spin, +.nav [class^="icon-"].icon-spin, +.btn [class*=" icon-"].icon-spin, +.nav [class*=" icon-"].icon-spin { + display: inline-block; +} +.nav-tabs [class^="icon-"], +.nav-pills [class^="icon-"], +.nav-tabs [class*=" icon-"], +.nav-pills [class*=" icon-"], +.nav-tabs [class^="icon-"].icon-large, +.nav-pills [class^="icon-"].icon-large, +.nav-tabs [class*=" icon-"].icon-large, +.nav-pills [class*=" icon-"].icon-large { + line-height: .9em; +} +.btn [class^="icon-"].pull-left.icon-2x, +.btn [class*=" icon-"].pull-left.icon-2x, +.btn [class^="icon-"].pull-right.icon-2x, +.btn [class*=" icon-"].pull-right.icon-2x { + margin-top: .18em; +} +.btn [class^="icon-"].icon-spin.icon-large, +.btn [class*=" icon-"].icon-spin.icon-large { + line-height: .8em; +} +.btn.btn-small [class^="icon-"].pull-left.icon-2x, +.btn.btn-small [class*=" icon-"].pull-left.icon-2x, +.btn.btn-small [class^="icon-"].pull-right.icon-2x, +.btn.btn-small [class*=" icon-"].pull-right.icon-2x { + margin-top: .25em; +} +.btn.btn-large [class^="icon-"], +.btn.btn-large [class*=" icon-"] { + margin-top: 0; +} +.btn.btn-large [class^="icon-"].pull-left.icon-2x, +.btn.btn-large [class*=" icon-"].pull-left.icon-2x, +.btn.btn-large [class^="icon-"].pull-right.icon-2x, +.btn.btn-large [class*=" icon-"].pull-right.icon-2x { + margin-top: .05em; +} +.btn.btn-large [class^="icon-"].pull-left.icon-2x, +.btn.btn-large [class*=" icon-"].pull-left.icon-2x { + margin-right: .2em; +} +.btn.btn-large [class^="icon-"].pull-right.icon-2x, +.btn.btn-large [class*=" icon-"].pull-right.icon-2x { + margin-left: .2em; +} +/* Fixes alignment in nav lists */ +.nav-list [class^="icon-"], +.nav-list [class*=" icon-"] { + line-height: inherit; +} +/* EXTRAS + * -------------------------- */ +/* Stacked and layered icon */ +.icon-stack { + position: relative; + display: inline-block; + width: 2em; + height: 2em; + line-height: 2em; + vertical-align: -35%; +} +.icon-stack [class^="icon-"], +.icon-stack [class*=" icon-"] { + display: block; + text-align: center; + position: absolute; + width: 100%; + height: 100%; + font-size: 1em; + line-height: inherit; + *line-height: 2em; +} +.icon-stack .icon-stack-base { + font-size: 2em; + *line-height: 1em; +} +/* Animated rotating icon */ +.icon-spin { + display: inline-block; + -moz-animation: spin 2s infinite linear; + -o-animation: spin 2s infinite linear; + -webkit-animation: spin 2s infinite linear; + animation: spin 2s infinite linear; +} +/* Prevent stack and spinners from being taken inline when inside a link */ +a .icon-stack, +a .icon-spin { + display: inline-block; + text-decoration: none; +} +@-moz-keyframes spin { + 0% { + -moz-transform: rotate(0deg); + } + 100% { + -moz-transform: rotate(359deg); + } +} +@-webkit-keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + } +} +@-o-keyframes spin { + 0% { + -o-transform: rotate(0deg); + } + 100% { + -o-transform: rotate(359deg); + } +} +@-ms-keyframes spin { + 0% { + -ms-transform: rotate(0deg); + } + 100% { + -ms-transform: rotate(359deg); + } +} +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(359deg); + } +} +/* Icon rotations and mirroring */ +.icon-rotate-90:before { + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -ms-transform: rotate(90deg); + -o-transform: rotate(90deg); + transform: rotate(90deg); + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1); +} +.icon-rotate-180:before { + -webkit-transform: rotate(180deg); + -moz-transform: rotate(180deg); + -ms-transform: rotate(180deg); + -o-transform: rotate(180deg); + transform: rotate(180deg); + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2); +} +.icon-rotate-270:before { + -webkit-transform: rotate(270deg); + -moz-transform: rotate(270deg); + -ms-transform: rotate(270deg); + -o-transform: rotate(270deg); + transform: rotate(270deg); + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); +} +.icon-flip-horizontal:before { + -webkit-transform: scale(-1, 1); + -moz-transform: scale(-1, 1); + -ms-transform: scale(-1, 1); + -o-transform: scale(-1, 1); + transform: scale(-1, 1); +} +.icon-flip-vertical:before { + -webkit-transform: scale(1, -1); + -moz-transform: scale(1, -1); + -ms-transform: scale(1, -1); + -o-transform: scale(1, -1); + transform: scale(1, -1); +} +/* ensure rotation occurs inside anchor tags */ +a .icon-rotate-90:before, +a .icon-rotate-180:before, +a .icon-rotate-270:before, +a .icon-flip-horizontal:before, +a .icon-flip-vertical:before { + display: inline-block; +} +/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen + readers do not read off random characters that represent icons */ +.icon-glass:before { + content: "\f000"; +} +.icon-music:before { + content: "\f001"; +} +.icon-search:before { + content: "\f002"; +} +.icon-envelope-alt:before { + content: "\f003"; +} +.icon-heart:before { + content: "\f004"; +} +.icon-star:before { + content: "\f005"; +} +.icon-star-empty:before { + content: "\f006"; +} +.icon-user:before { + content: "\f007"; +} +.icon-film:before { + content: "\f008"; +} +.icon-th-large:before { + content: "\f009"; +} +.icon-th:before { + content: "\f00a"; +} +.icon-th-list:before { + content: "\f00b"; +} +.icon-ok:before { + content: "\f00c"; +} +.icon-remove:before { + content: "\f00d"; +} +.icon-zoom-in:before { + content: "\f00e"; +} +.icon-zoom-out:before { + content: "\f010"; +} +.icon-power-off:before, +.icon-off:before { + content: "\f011"; +} +.icon-signal:before { + content: "\f012"; +} +.icon-gear:before, +.icon-cog:before { + content: "\f013"; +} +.icon-trash:before { + content: "\f014"; +} +.icon-home:before { + content: "\f015"; +} +.icon-file-alt:before { + content: "\f016"; +} +.icon-time:before { + content: "\f017"; +} +.icon-road:before { + content: "\f018"; +} +.icon-download-alt:before { + content: "\f019"; +} +.icon-download:before { + content: "\f01a"; +} +.icon-upload:before { + content: "\f01b"; +} +.icon-inbox:before { + content: "\f01c"; +} +.icon-play-circle:before { + content: "\f01d"; +} +.icon-rotate-right:before, +.icon-repeat:before { + content: "\f01e"; +} +.icon-refresh:before { + content: "\f021"; +} +.icon-list-alt:before { + content: "\f022"; +} +.icon-lock:before { + content: "\f023"; +} +.icon-flag:before { + content: "\f024"; +} +.icon-headphones:before { + content: "\f025"; +} +.icon-volume-off:before { + content: "\f026"; +} +.icon-volume-down:before { + content: "\f027"; +} +.icon-volume-up:before { + content: "\f028"; +} +.icon-qrcode:before { + content: "\f029"; +} +.icon-barcode:before { + content: "\f02a"; +} +.icon-tag:before { + content: "\f02b"; +} +.icon-tags:before { + content: "\f02c"; +} +.icon-book:before { + content: "\f02d"; +} +.icon-bookmark:before { + content: "\f02e"; +} +.icon-print:before { + content: "\f02f"; +} +.icon-camera:before { + content: "\f030"; +} +.icon-font:before { + content: "\f031"; +} +.icon-bold:before { + content: "\f032"; +} +.icon-italic:before { + content: "\f033"; +} +.icon-text-height:before { + content: "\f034"; +} +.icon-text-width:before { + content: "\f035"; +} +.icon-align-left:before { + content: "\f036"; +} +.icon-align-center:before { + content: "\f037"; +} +.icon-align-right:before { + content: "\f038"; +} +.icon-align-justify:before { + content: "\f039"; +} +.icon-list:before { + content: "\f03a"; +} +.icon-indent-left:before { + content: "\f03b"; +} +.icon-indent-right:before { + content: "\f03c"; +} +.icon-facetime-video:before { + content: "\f03d"; +} +.icon-picture:before { + content: "\f03e"; +} +.icon-pencil:before { + content: "\f040"; +} +.icon-map-marker:before { + content: "\f041"; +} +.icon-adjust:before { + content: "\f042"; +} +.icon-tint:before { + content: "\f043"; +} +.icon-edit:before { + content: "\f044"; +} +.icon-share:before { + content: "\f045"; +} +.icon-check:before { + content: "\f046"; +} +.icon-move:before { + content: "\f047"; +} +.icon-step-backward:before { + content: "\f048"; +} +.icon-fast-backward:before { + content: "\f049"; +} +.icon-backward:before { + content: "\f04a"; +} +.icon-play:before { + content: "\f04b"; +} +.icon-pause:before { + content: "\f04c"; +} +.icon-stop:before { + content: "\f04d"; +} +.icon-forward:before { + content: "\f04e"; +} +.icon-fast-forward:before { + content: "\f050"; +} +.icon-step-forward:before { + content: "\f051"; +} +.icon-eject:before { + content: "\f052"; +} +.icon-chevron-left:before { + content: "\f053"; +} +.icon-chevron-right:before { + content: "\f054"; +} +.icon-plus-sign:before { + content: "\f055"; +} +.icon-minus-sign:before { + content: "\f056"; +} +.icon-remove-sign:before { + content: "\f057"; +} +.icon-ok-sign:before { + content: "\f058"; +} +.icon-question-sign:before { + content: "\f059"; +} +.icon-info-sign:before { + content: "\f05a"; +} +.icon-screenshot:before { + content: "\f05b"; +} +.icon-remove-circle:before { + content: "\f05c"; +} +.icon-ok-circle:before { + content: "\f05d"; +} +.icon-ban-circle:before { + content: "\f05e"; +} +.icon-arrow-left:before { + content: "\f060"; +} +.icon-arrow-right:before { + content: "\f061"; +} +.icon-arrow-up:before { + content: "\f062"; +} +.icon-arrow-down:before { + content: "\f063"; +} +.icon-mail-forward:before, +.icon-share-alt:before { + content: "\f064"; +} +.icon-resize-full:before { + content: "\f065"; +} +.icon-resize-small:before { + content: "\f066"; +} +.icon-plus:before { + content: "\f067"; +} +.icon-minus:before { + content: "\f068"; +} +.icon-asterisk:before { + content: "\f069"; +} +.icon-exclamation-sign:before { + content: "\f06a"; +} +.icon-gift:before { + content: "\f06b"; +} +.icon-leaf:before { + content: "\f06c"; +} +.icon-fire:before { + content: "\f06d"; +} +.icon-eye-open:before { + content: "\f06e"; +} +.icon-eye-close:before { + content: "\f070"; +} +.icon-warning-sign:before { + content: "\f071"; +} +.icon-plane:before { + content: "\f072"; +} +.icon-calendar:before { + content: "\f073"; +} +.icon-random:before { + content: "\f074"; +} +.icon-comment:before { + content: "\f075"; +} +.icon-magnet:before { + content: "\f076"; +} +.icon-chevron-up:before { + content: "\f077"; +} +.icon-chevron-down:before { + content: "\f078"; +} +.icon-retweet:before { + content: "\f079"; +} +.icon-shopping-cart:before { + content: "\f07a"; +} +.icon-folder-close:before { + content: "\f07b"; +} +.icon-folder-open:before { + content: "\f07c"; +} +.icon-resize-vertical:before { + content: "\f07d"; +} +.icon-resize-horizontal:before { + content: "\f07e"; +} +.icon-bar-chart:before { + content: "\f080"; +} +.icon-twitter-sign:before { + content: "\f081"; +} +.icon-facebook-sign:before { + content: "\f082"; +} +.icon-camera-retro:before { + content: "\f083"; +} +.icon-key:before { + content: "\f084"; +} +.icon-gears:before, +.icon-cogs:before { + content: "\f085"; +} +.icon-comments:before { + content: "\f086"; +} +.icon-thumbs-up-alt:before { + content: "\f087"; +} +.icon-thumbs-down-alt:before { + content: "\f088"; +} +.icon-star-half:before { + content: "\f089"; +} +.icon-heart-empty:before { + content: "\f08a"; +} +.icon-signout:before { + content: "\f08b"; +} +.icon-linkedin-sign:before { + content: "\f08c"; +} +.icon-pushpin:before { + content: "\f08d"; +} +.icon-external-link:before { + content: "\f08e"; +} +.icon-signin:before { + content: "\f090"; +} +.icon-trophy:before { + content: "\f091"; +} +.icon-github-sign:before { + content: "\f092"; +} +.icon-upload-alt:before { + content: "\f093"; +} +.icon-lemon:before { + content: "\f094"; +} +.icon-phone:before { + content: "\f095"; +} +.icon-unchecked:before, +.icon-check-empty:before { + content: "\f096"; +} +.icon-bookmark-empty:before { + content: "\f097"; +} +.icon-phone-sign:before { + content: "\f098"; +} +.icon-twitter:before { + content: "\f099"; +} +.icon-facebook:before { + content: "\f09a"; +} +.icon-github:before { + content: "\f09b"; +} +.icon-unlock:before { + content: "\f09c"; +} +.icon-credit-card:before { + content: "\f09d"; +} +.icon-rss:before { + content: "\f09e"; +} +.icon-hdd:before { + content: "\f0a0"; +} +.icon-bullhorn:before { + content: "\f0a1"; +} +.icon-bell:before { + content: "\f0a2"; +} +.icon-certificate:before { + content: "\f0a3"; +} +.icon-hand-right:before { + content: "\f0a4"; +} +.icon-hand-left:before { + content: "\f0a5"; +} +.icon-hand-up:before { + content: "\f0a6"; +} +.icon-hand-down:before { + content: "\f0a7"; +} +.icon-circle-arrow-left:before { + content: "\f0a8"; +} +.icon-circle-arrow-right:before { + content: "\f0a9"; +} +.icon-circle-arrow-up:before { + content: "\f0aa"; +} +.icon-circle-arrow-down:before { + content: "\f0ab"; +} +.icon-globe:before { + content: "\f0ac"; +} +.icon-wrench:before { + content: "\f0ad"; +} +.icon-tasks:before { + content: "\f0ae"; +} +.icon-filter:before { + content: "\f0b0"; +} +.icon-briefcase:before { + content: "\f0b1"; +} +.icon-fullscreen:before { + content: "\f0b2"; +} +.icon-group:before { + content: "\f0c0"; +} +.icon-link:before { + content: "\f0c1"; +} +.icon-cloud:before { + content: "\f0c2"; +} +.icon-beaker:before { + content: "\f0c3"; +} +.icon-cut:before { + content: "\f0c4"; +} +.icon-copy:before { + content: "\f0c5"; +} +.icon-paperclip:before, +.icon-paper-clip:before { + content: "\f0c6"; +} +.icon-save:before { + content: "\f0c7"; +} +.icon-sign-blank:before { + content: "\f0c8"; +} +.icon-reorder:before { + content: "\f0c9"; +} +.icon-list-ul:before { + content: "\f0ca"; +} +.icon-list-ol:before { + content: "\f0cb"; +} +.icon-strikethrough:before { + content: "\f0cc"; +} +.icon-underline:before { + content: "\f0cd"; +} +.icon-table:before { + content: "\f0ce"; +} +.icon-magic:before { + content: "\f0d0"; +} +.icon-truck:before { + content: "\f0d1"; +} +.icon-pinterest:before { + content: "\f0d2"; +} +.icon-pinterest-sign:before { + content: "\f0d3"; +} +.icon-google-plus-sign:before { + content: "\f0d4"; +} +.icon-google-plus:before { + content: "\f0d5"; +} +.icon-money:before { + content: "\f0d6"; +} +.icon-caret-down:before { + content: "\f0d7"; +} +.icon-caret-up:before { + content: "\f0d8"; +} +.icon-caret-left:before { + content: "\f0d9"; +} +.icon-caret-right:before { + content: "\f0da"; +} +.icon-columns:before { + content: "\f0db"; +} +.icon-sort:before { + content: "\f0dc"; +} +.icon-sort-down:before { + content: "\f0dd"; +} +.icon-sort-up:before { + content: "\f0de"; +} +.icon-envelope:before { + content: "\f0e0"; +} +.icon-linkedin:before { + content: "\f0e1"; +} +.icon-rotate-left:before, +.icon-undo:before { + content: "\f0e2"; +} +.icon-legal:before { + content: "\f0e3"; +} +.icon-dashboard:before { + content: "\f0e4"; +} +.icon-comment-alt:before { + content: "\f0e5"; +} +.icon-comments-alt:before { + content: "\f0e6"; +} +.icon-bolt:before { + content: "\f0e7"; +} +.icon-sitemap:before { + content: "\f0e8"; +} +.icon-umbrella:before { + content: "\f0e9"; +} +.icon-paste:before { + content: "\f0ea"; +} +.icon-lightbulb:before { + content: "\f0eb"; +} +.icon-exchange:before { + content: "\f0ec"; +} +.icon-cloud-download:before { + content: "\f0ed"; +} +.icon-cloud-upload:before { + content: "\f0ee"; +} +.icon-user-md:before { + content: "\f0f0"; +} +.icon-stethoscope:before { + content: "\f0f1"; +} +.icon-suitcase:before { + content: "\f0f2"; +} +.icon-bell-alt:before { + content: "\f0f3"; +} +.icon-coffee:before { + content: "\f0f4"; +} +.icon-food:before { + content: "\f0f5"; +} +.icon-file-text-alt:before { + content: "\f0f6"; +} +.icon-building:before { + content: "\f0f7"; +} +.icon-hospital:before { + content: "\f0f8"; +} +.icon-ambulance:before { + content: "\f0f9"; +} +.icon-medkit:before { + content: "\f0fa"; +} +.icon-fighter-jet:before { + content: "\f0fb"; +} +.icon-beer:before { + content: "\f0fc"; +} +.icon-h-sign:before { + content: "\f0fd"; +} +.icon-plus-sign-alt:before { + content: "\f0fe"; +} +.icon-double-angle-left:before { + content: "\f100"; +} +.icon-double-angle-right:before { + content: "\f101"; +} +.icon-double-angle-up:before { + content: "\f102"; +} +.icon-double-angle-down:before { + content: "\f103"; +} +.icon-angle-left:before { + content: "\f104"; +} +.icon-angle-right:before { + content: "\f105"; +} +.icon-angle-up:before { + content: "\f106"; +} +.icon-angle-down:before { + content: "\f107"; +} +.icon-desktop:before { + content: "\f108"; +} +.icon-laptop:before { + content: "\f109"; +} +.icon-tablet:before { + content: "\f10a"; +} +.icon-mobile-phone:before { + content: "\f10b"; +} +.icon-circle-blank:before { + content: "\f10c"; +} +.icon-quote-left:before { + content: "\f10d"; +} +.icon-quote-right:before { + content: "\f10e"; +} +.icon-spinner:before { + content: "\f110"; +} +.icon-circle:before { + content: "\f111"; +} +.icon-mail-reply:before, +.icon-reply:before { + content: "\f112"; +} +.icon-github-alt:before { + content: "\f113"; +} +.icon-folder-close-alt:before { + content: "\f114"; +} +.icon-folder-open-alt:before { + content: "\f115"; +} +.icon-expand-alt:before { + content: "\f116"; +} +.icon-collapse-alt:before { + content: "\f117"; +} +.icon-smile:before { + content: "\f118"; +} +.icon-frown:before { + content: "\f119"; +} +.icon-meh:before { + content: "\f11a"; +} +.icon-gamepad:before { + content: "\f11b"; +} +.icon-keyboard:before { + content: "\f11c"; +} +.icon-flag-alt:before { + content: "\f11d"; +} +.icon-flag-checkered:before { + content: "\f11e"; +} +.icon-terminal:before { + content: "\f120"; +} +.icon-code:before { + content: "\f121"; +} +.icon-reply-all:before { + content: "\f122"; +} +.icon-mail-reply-all:before { + content: "\f122"; +} +.icon-star-half-full:before, +.icon-star-half-empty:before { + content: "\f123"; +} +.icon-location-arrow:before { + content: "\f124"; +} +.icon-crop:before { + content: "\f125"; +} +.icon-code-fork:before { + content: "\f126"; +} +.icon-unlink:before { + content: "\f127"; +} +.icon-question:before { + content: "\f128"; +} +.icon-info:before { + content: "\f129"; +} +.icon-exclamation:before { + content: "\f12a"; +} +.icon-superscript:before { + content: "\f12b"; +} +.icon-subscript:before { + content: "\f12c"; +} +.icon-eraser:before { + content: "\f12d"; +} +.icon-puzzle-piece:before { + content: "\f12e"; +} +.icon-microphone:before { + content: "\f130"; +} +.icon-microphone-off:before { + content: "\f131"; +} +.icon-shield:before { + content: "\f132"; +} +.icon-calendar-empty:before { + content: "\f133"; +} +.icon-fire-extinguisher:before { + content: "\f134"; +} +.icon-rocket:before { + content: "\f135"; +} +.icon-maxcdn:before { + content: "\f136"; +} +.icon-chevron-sign-left:before { + content: "\f137"; +} +.icon-chevron-sign-right:before { + content: "\f138"; +} +.icon-chevron-sign-up:before { + content: "\f139"; +} +.icon-chevron-sign-down:before { + content: "\f13a"; +} +.icon-html5:before { + content: "\f13b"; +} +.icon-css3:before { + content: "\f13c"; +} +.icon-anchor:before { + content: "\f13d"; +} +.icon-unlock-alt:before { + content: "\f13e"; +} +.icon-bullseye:before { + content: "\f140"; +} +.icon-ellipsis-horizontal:before { + content: "\f141"; +} +.icon-ellipsis-vertical:before { + content: "\f142"; +} +.icon-rss-sign:before { + content: "\f143"; +} +.icon-play-sign:before { + content: "\f144"; +} +.icon-ticket:before { + content: "\f145"; +} +.icon-minus-sign-alt:before { + content: "\f146"; +} +.icon-check-minus:before { + content: "\f147"; +} +.icon-level-up:before { + content: "\f148"; +} +.icon-level-down:before { + content: "\f149"; +} +.icon-check-sign:before { + content: "\f14a"; +} +.icon-edit-sign:before { + content: "\f14b"; +} +.icon-external-link-sign:before { + content: "\f14c"; +} +.icon-share-sign:before { + content: "\f14d"; +} +.icon-compass:before { + content: "\f14e"; +} +.icon-collapse:before { + content: "\f150"; +} +.icon-collapse-top:before { + content: "\f151"; +} +.icon-expand:before { + content: "\f152"; +} +.icon-euro:before, +.icon-eur:before { + content: "\f153"; +} +.icon-gbp:before { + content: "\f154"; +} +.icon-dollar:before, +.icon-usd:before { + content: "\f155"; +} +.icon-rupee:before, +.icon-inr:before { + content: "\f156"; +} +.icon-yen:before, +.icon-jpy:before { + content: "\f157"; +} +.icon-renminbi:before, +.icon-cny:before { + content: "\f158"; +} +.icon-won:before, +.icon-krw:before { + content: "\f159"; +} +.icon-bitcoin:before, +.icon-btc:before { + content: "\f15a"; +} +.icon-file:before { + content: "\f15b"; +} +.icon-file-text:before { + content: "\f15c"; +} +.icon-sort-by-alphabet:before { + content: "\f15d"; +} +.icon-sort-by-alphabet-alt:before { + content: "\f15e"; +} +.icon-sort-by-attributes:before { + content: "\f160"; +} +.icon-sort-by-attributes-alt:before { + content: "\f161"; +} +.icon-sort-by-order:before { + content: "\f162"; +} +.icon-sort-by-order-alt:before { + content: "\f163"; +} +.icon-thumbs-up:before { + content: "\f164"; +} +.icon-thumbs-down:before { + content: "\f165"; +} +.icon-youtube-sign:before { + content: "\f166"; +} +.icon-youtube:before { + content: "\f167"; +} +.icon-xing:before { + content: "\f168"; +} +.icon-xing-sign:before { + content: "\f169"; +} +.icon-youtube-play:before { + content: "\f16a"; +} +.icon-dropbox:before { + content: "\f16b"; +} +.icon-stackexchange:before { + content: "\f16c"; +} +.icon-instagram:before { + content: "\f16d"; +} +.icon-flickr:before { + content: "\f16e"; +} +.icon-adn:before { + content: "\f170"; +} +.icon-bitbucket:before { + content: "\f171"; +} +.icon-bitbucket-sign:before { + content: "\f172"; +} +.icon-tumblr:before { + content: "\f173"; +} +.icon-tumblr-sign:before { + content: "\f174"; +} +.icon-long-arrow-down:before { + content: "\f175"; +} +.icon-long-arrow-up:before { + content: "\f176"; +} +.icon-long-arrow-left:before { + content: "\f177"; +} +.icon-long-arrow-right:before { + content: "\f178"; +} +.icon-apple:before { + content: "\f179"; +} +.icon-windows:before { + content: "\f17a"; +} +.icon-android:before { + content: "\f17b"; +} +.icon-linux:before { + content: "\f17c"; +} +.icon-dribbble:before { + content: "\f17d"; +} +.icon-skype:before { + content: "\f17e"; +} +.icon-foursquare:before { + content: "\f180"; +} +.icon-trello:before { + content: "\f181"; +} +.icon-female:before { + content: "\f182"; +} +.icon-male:before { + content: "\f183"; +} +.icon-gittip:before { + content: "\f184"; +} +.icon-sun:before { + content: "\f185"; +} +.icon-moon:before { + content: "\f186"; +} +.icon-archive:before { + content: "\f187"; +} +.icon-bug:before { + content: "\f188"; +} +.icon-vk:before { + content: "\f189"; +} +.icon-weibo:before { + content: "\f18a"; +} +.icon-renren:before { + content: "\f18b"; +} diff --git a/assets/css/jquery-colorbox.css b/assets/css/jquery-colorbox.css new file mode 100644 index 00000000..f7d6aaa2 --- /dev/null +++ b/assets/css/jquery-colorbox.css @@ -0,0 +1,66 @@ +/* + Colorbox Core Style: + The following CSS is consistent between example themes and should not be altered. +*/ +#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden; -webkit-transform: translate3d(0,0,0);} +#cboxWrapper {max-width:none;} +#cboxOverlay{position:fixed; width:100%; height:100%;} +#cboxMiddleLeft, #cboxBottomLeft{clear:left;} +#cboxContent{position:relative;} +#cboxLoadedContent{overflow:auto; -webkit-overflow-scrolling: touch;} +#cboxTitle{margin:0;} +#cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;} +#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;} +.cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;} +.cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;} +#colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;} + +/* + User Style: + Change the following styles to modify the appearance of Colorbox. They are + ordered & tabbed in a way that represents the nesting of the generated HTML. +*/ +#cboxOverlay{background:#000; opacity: 0.9; filter: alpha(opacity = 90);} +#colorbox{outline:0;} + #cboxTopLeft{width:25px; height:25px; background:url(../images/border1.png) no-repeat 0 0;} + #cboxTopCenter{height:25px; background:url(../images/border1.png) repeat-x 0 -50px;} + #cboxTopRight{width:25px; height:25px; background:url(../images/border1.png) no-repeat -25px 0;} + #cboxBottomLeft{width:25px; height:25px; background:url(../images/border1.png) no-repeat 0 -25px;} + #cboxBottomCenter{height:25px; background:url(../images/border1.png) repeat-x 0 -75px;} + #cboxBottomRight{width:25px; height:25px; background:url(../images/border1.png) no-repeat -25px -25px;} + #cboxMiddleLeft{width:25px; background:url(../images/border2.png) repeat-y 0 0;} + #cboxMiddleRight{width:25px; background:url(../images/border2.png) repeat-y -25px 0;} + #cboxContent{background:#fff; overflow:hidden;} + .cboxIframe{background:#fff;} + #cboxError{padding:50px; border:1px solid #ccc;} + #cboxLoadedContent{margin-bottom:20px;} + #cboxTitle{position:absolute; bottom:0px; left:0; text-align:center; width:100%; color:#999;} + #cboxCurrent{position:absolute; bottom:0px; left:100px; color:#999;} + #cboxLoadingOverlay{background:#fff url(../images/loading.gif) no-repeat 5px 5px;} + + /* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */ + #cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {border:0; padding:0; margin:0; overflow:visible; width:auto; background:none; } + + /* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */ + #cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;} + + #cboxSlideshow{position:absolute; bottom:0px; right:42px; color:#444;} + #cboxPrevious{position:absolute; bottom:0px; left:0; color:#444;} + #cboxNext{position:absolute; bottom:0px; left:63px; color:#444;} + #cboxClose{position:absolute; bottom:0; right:0; display:block; color:#444;} + +/* + The following fixes a problem where IE7 and IE8 replace a PNG's alpha transparency with a black fill + when an alpha filter (opacity change) is set on the element or ancestor element. This style is not applied to or needed in IE9. + See: http://jacklmoore.com/notes/ie-transparency-problems/ +*/ +.cboxIE #cboxTopLeft, +.cboxIE #cboxTopCenter, +.cboxIE #cboxTopRight, +.cboxIE #cboxBottomLeft, +.cboxIE #cboxBottomCenter, +.cboxIE #cboxBottomRight, +.cboxIE #cboxMiddleLeft, +.cboxIE #cboxMiddleRight { + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF); +} \ No newline at end of file diff --git a/assets/css/jquery-linedtextarea.css b/assets/css/jquery-linedtextarea.css new file mode 100644 index 00000000..9fec32a5 --- /dev/null +++ b/assets/css/jquery-linedtextarea.css @@ -0,0 +1,68 @@ +/** + * jQuery Lined Textarea Plugin + * http://alan.blog-city.com/jquerylinedtextarea.htm + * + * Copyright (c) 2010 Alan Williamson + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + * Usage: + * Displays a line number count column to the left of the textarea + * + * Class up your textarea with a given class, or target it directly + * with JQuery Selectors + * + * $(".lined").linedtextarea({ + * selectedLine: 10, + * selectedClass: 'lineselect' + * }); + * + */ + +.linedwrap { + border: 1px solid #c0c0c0; + padding: 3px; +} + +.linedtextarea { + padding: 0px; + margin: 0px; +} + +.linedtextarea textarea, .linedwrap .codelines .lineno { + font-size: 10pt; + font-family: monospace; + line-height: normal !important; +} + +.linedtextarea textarea { + padding-right:0.3em; + padding-top:0.3em; + border: 0; +} + +.linedwrap .lines { + margin-top: 0px; + width: 50px; + float: left; + overflow: hidden; + border-right: 1px solid #c0c0c0; + margin-right: 10px; +} + +.linedwrap .codelines { + padding-top: 5px; +} + +.linedwrap .codelines .lineno { + color:#AAAAAA; + padding-right: 0.5em; + padding-top: 0.0em; + text-align: right; + white-space: nowrap; +} + +.linedwrap .codelines .lineselect { + color: red; +} \ No newline at end of file diff --git a/assets/css/liquid-slider.css b/assets/css/liquid-slider.css new file mode 100644 index 00000000..a4c933fd --- /dev/null +++ b/assets/css/liquid-slider.css @@ -0,0 +1,283 @@ +/* + * Liquid Slider v2 + * Copyright 2012 Kevin Batdorf + * http://liquidslider.com + * MIT license + */ + +.no-js .liquid-slider { + height: 100%; + overflow:scroll; +} +.ls-preloader { + background: url("/admin/assets/endpointman/images/ic_progress_azul.gif") #64C3FF no-repeat center 50%; + opacity:1; + width:100%; + height:100%; + position:absolute; + top:0; + left:0; + z-index:2; + + border-radius: 5px 5px 5px 5px; + -moz-border-radius: 5px 5px 5px 5px; + -webkit-border-radius: 5px 5px 5px 5px; +} + +/*** Containers ***/ +.ls-wrapper { + clear: both; + overflow: auto; + position: relative; + + border-radius: 25px 25px 25px 25px; + -moz-border-radius: 25px 25px 25px 25px; + -webkit-border-radius: 25px 25px 25px 25px; + + padding: 15px; + -webkit-box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.4); + -moz-box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.4); + box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.4); + + margin-bottom: 20px; +} +.liquid-slider { + width: 100%; +/* margin: 0 auto;*/ + float: left; + overflow: hidden; + position: relative; + + visibility: hidden; + +/* background: #e7a61a;*/ + border-radius: 25px 25px 25px 25px; + -moz-border-radius: 25px 25px 25px 25px; + -webkit-border-radius: 25px 25px 25px 25px; + + -webkit-box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.4); + -moz-box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.4); + box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.4); +} +.arrows .liquid-slider { + /* Margin between slider and arrows */ + margin: 0 10px; +} +.ls-responsive .liquid-slider { + width: 100%; + margin: 0; +} +.panel-container { + position: relative; + -webkit-backface-visibility: hidden; + -webkit-perspective: 1000; + /* from http://davidwalsh.name/translate3d */ +} +.liquid-slider .panel-container .fade { + width:100%; + opacity: 0; + position: absolute; + top: 0; + left: 0; + display: block; +} + +/*** Panels ***/ +.liquid-slider .ls-panel { + width: 100%; + display: block; + float: left; +} +.panel-wrapper { + padding: 15px 40px; + position:relative; +} + + + + + + + +/*** Tabbed Navigation ***/ +.ls-nav { + overflow:hidden; + clear:both; + + padding: 20px; +} +.ls-nav a { + display: inline-block; + color: white; + text-align: center; + padding: 14px 16px; + text-decoration: none; + outline:0; + + text-shadow: 3px 3px 4px rgba(255, 255, 255, 0.76); + font-weight: bold; + text-transform: capitalize; +} +.ls-nav a:hover { + background-color: #111; +} +.ls-nav .current a, .ls-nav .current a:hover { + background-color: #4CAF50; + text-shadow: 3px 3px 4px rgba(0, 0, 0, 0.76); +} +.currentCrossLink { + /*font-weight: bold;*/ +} +.ls-nav ul { + clear: both; + display: inline-block; + list-style-type: none; + margin: 0 auto; + padding: 0; + overflow: hidden; + background-color: #333; + + border-radius: 25px 25px 25px 25px; + -moz-border-radius: 25px 25px 25px 25px; + -webkit-border-radius: 25px 25px 25px 25px; + + -webkit-box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.4); + -moz-box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.4); + box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.4); + + position: relative; + left: 50%; + transform: translate(-50%); + + /*width: 100%; //SI SE ACTIVA ESTA LINEA SE VERA EL LISTADO EN MODO MOVIL*/ + } +.ls-nav ul li, .ls-nav ul li a { + display: inline-block; +} +.ls-nav ul li a { + color: white; + text-align: center; + padding: 15px 40px; + text-decoration: none; +} +.ls-nav ul li a:hover { + background-color: #111; +} + + + + +/*** Mobile Navigation ***/ +.ls-select-box { + width: 100%; + height: 35px; + overflow: hidden; + + background-image: url("/admin/assets/endpointman/images/menu.png"); + background-repeat: no-repeat; + background-position: right 10px center; + background-color: #4CAF50; + + color: #FFFFFF; + border-radius: 10px 10px 10px 0px; + -moz-border-radius: 10px 10px 10px 0px; + -webkit-border-radius: 10px 10px 10px 0px; +} +.ls-select-box select { + width: 100%; + -webkit-appearance: none; + -moz-appearance: none; + appearance:none; + background: transparent; + padding: 5px; + font-size: 110%; + border: none; + height: 35px; + cursor:pointer; + outline: 0; + +/* background-color:#000000;*/ + color: #FFFFFF; +} + +/*** Arrow Navigation (non-graphical) ***/ +.ls-nav-left, .ls-nav-right { + top:0; + float: left; + clear:both; +} +.ls-nav-left a, .ls-nav-right a { + background: #000; + color: #fff; + padding: 5px; + width: 100px; + display: block; + text-align: center; + text-decoration: none; +} +.ls-responsive .ls-nav-left { + position: absolute; + left: 0; + z-index: 2; +} +.ls-responsive .ls-nav-left a { + background: #9A9A9A; + width: 80px; +} +.ls-responsive .ls-nav-left a:hover { + background: #747474; +} +.ls-responsive .ls-nav-right { + position: absolute; + right: 0; + z-index: 2; +} +.ls-responsive .ls-nav-right a { + background: #9A9A9A; + width: 80px; +} +.ls-responsive .ls-nav-right a:hover { + background: #747474; +} + +/*** Arrow Navigation (graphical) ***/ +.ls-nav-left-arrow, .ls-nav-right-arrow { + cursor: pointer; + float: left; + clear: both; +} +.ls-nav-left-arrow a, .ls-nav-right-arrow a { + display: block; +} +[class$="-arrow"] { + width: 25px; + height: 25px; + background-image: url("/admin/assets/endpointman/images/arrow.png"); + background-repeat: no-repeat; + margin-top: 50px; + position:relative; +} +.ls-nav-right-arrow { + background-position: top right; + margin-right: 5px; +} +.ls-nav-left-arrow { + background-position: top left; + margin-left: 5px; +} +.ls-nav-left-arrow:hover { + background-position: bottom left; +} +.ls-nav-right-arrow:hover { + background-position: bottom right; +} +.ls-responsive .ls-nav-left-arrow { + position: absolute; + left: 20px; + z-index: 2; +} +.ls-responsive .ls-nav-right-arrow { + position: absolute; + right: 20px; + z-index: 2; +} diff --git a/assets/css/main.css b/assets/css/main.css new file mode 100644 index 00000000..4df10827 --- /dev/null +++ b/assets/css/main.css @@ -0,0 +1,69 @@ +/* + Document : main.css + Created on : Feb 7, 2011, 3:12:27 AM + Author : Andrew + Description: + Purpose of the stylesheet follows. +*/ + +/* + TODO customize this sample style + Syntax recommendation http://www.w3.org/TR/REC-CSS2/ +*/ + +.red, .error { + color: #d9534f; + font-color: #d9534f; +} + +.green, .success { + color: #5cb85c; + font-color: #5cb85c; +} + +.yellow, .warning { + color: #f0ad4e; + font-color: #f0ad4e; +} + +.cyan, .info { + color: #5bc0de; + font-color: #5bc0de; +} + +.blue, .primary { + color: #428bca; + font-color: #428bca; +} + +.gray, .disabled { + color: #474949; + font-color: #474949; +} + +code.inline { + padding: 2px 4px; + font-size: 0.8em; + background-color: #f7f7f9; + border: 1px solid #e1e1e8; +} + +ul.nobullets { + list-style-type: none; +} + +li { + line-height: 24px; +} + +.button_Enable { + background: none; + color: #003300; + background-color: #66F966; +} + +.button_Disable { + background: none; + color: #330000; + background-color: #F96666; +} diff --git a/assets/css/reset.css b/assets/css/reset.css new file mode 100644 index 00000000..e69de29b diff --git a/assets/images/.htaccess b/assets/images/.htaccess deleted file mode 100755 index 9b8684ca..00000000 --- a/assets/images/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Allow from All \ No newline at end of file diff --git a/assets/images/15xvbd5.png b/assets/images/15xvbd5.png new file mode 100644 index 00000000..7ebb1fb3 Binary files /dev/null and b/assets/images/15xvbd5.png differ diff --git a/assets/images/add.png b/assets/images/add.png old mode 100755 new mode 100644 diff --git a/assets/images/add_old.png b/assets/images/add_old.png old mode 100755 new mode 100644 diff --git a/assets/images/ajax-loader-bar.gif b/assets/images/ajax-loader-bar.gif new file mode 100644 index 00000000..09d621ed Binary files /dev/null and b/assets/images/ajax-loader-bar.gif differ diff --git a/assets/images/ajax-loader.gif b/assets/images/ajax-loader.gif old mode 100755 new mode 100644 diff --git a/assets/images/ajax-loader_bar.gif b/assets/images/ajax-loader_bar.gif new file mode 100644 index 00000000..09d621ed Binary files /dev/null and b/assets/images/ajax-loader_bar.gif differ diff --git a/assets/images/arrow.png b/assets/images/arrow.png new file mode 100644 index 00000000..3c057b57 Binary files /dev/null and b/assets/images/arrow.png differ diff --git a/assets/images/black_arrow.png b/assets/images/black_arrow.png old mode 100755 new mode 100644 diff --git a/assets/images/border1.png b/assets/images/border1.png new file mode 100644 index 00000000..ea73e159 Binary files /dev/null and b/assets/images/border1.png differ diff --git a/assets/images/border2.png b/assets/images/border2.png new file mode 100644 index 00000000..72cad44c Binary files /dev/null and b/assets/images/border2.png differ diff --git a/assets/images/bullet_minus.png b/assets/images/bullet_minus.png old mode 100755 new mode 100644 diff --git a/assets/images/bullet_plus.png b/assets/images/bullet_plus.png old mode 100755 new mode 100644 diff --git a/assets/images/collapse.png b/assets/images/collapse.png old mode 100755 new mode 100644 diff --git a/assets/images/delete.gif b/assets/images/delete.gif old mode 100755 new mode 100644 diff --git a/assets/images/delete.png b/assets/images/delete.png old mode 100755 new mode 100644 diff --git a/assets/images/edit.gif b/assets/images/edit.gif old mode 100755 new mode 100644 diff --git a/assets/images/edit.png b/assets/images/edit.png old mode 100755 new mode 100644 diff --git a/assets/images/expand.png b/assets/images/expand.png old mode 100755 new mode 100644 diff --git a/assets/images/ic_progress_azul.gif b/assets/images/ic_progress_azul.gif new file mode 100644 index 00000000..b0030d03 Binary files /dev/null and b/assets/images/ic_progress_azul.gif differ diff --git a/assets/images/ic_progress_rojo.gif b/assets/images/ic_progress_rojo.gif new file mode 100644 index 00000000..8938195f Binary files /dev/null and b/assets/images/ic_progress_rojo.gif differ diff --git a/assets/images/ic_progress_verde.gif b/assets/images/ic_progress_verde.gif new file mode 100644 index 00000000..2e7f8bee Binary files /dev/null and b/assets/images/ic_progress_verde.gif differ diff --git a/assets/images/loading.gif b/assets/images/loading.gif new file mode 100644 index 00000000..1f3a2c0a Binary files /dev/null and b/assets/images/loading.gif differ diff --git a/assets/images/menu.png b/assets/images/menu.png new file mode 100644 index 00000000..a22e331f Binary files /dev/null and b/assets/images/menu.png differ diff --git a/assets/images/trash.gif b/assets/images/trash.gif old mode 100755 new mode 100644 diff --git a/assets/js/addon/fullscreen.js b/assets/js/addon/fullscreen.js new file mode 100644 index 00000000..54d2037c --- /dev/null +++ b/assets/js/addon/fullscreen.js @@ -0,0 +1,41 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.defineOption("fullScreen", false, function(cm, val, old) { + if (old == CodeMirror.Init) old = false; + if (!old == !val) return; + if (val) setFullscreen(cm); + else setNormal(cm); + }); + + function setFullscreen(cm) { + var wrap = cm.getWrapperElement(); + cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, + width: wrap.style.width, height: wrap.style.height}; + wrap.style.width = ""; + wrap.style.height = "auto"; + wrap.className += " CodeMirror-fullscreen"; + document.documentElement.style.overflow = "hidden"; + cm.refresh(); + } + + function setNormal(cm) { + var wrap = cm.getWrapperElement(); + wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, ""); + document.documentElement.style.overflow = ""; + var info = cm.state.fullScreenRestore; + wrap.style.width = info.width; wrap.style.height = info.height; + window.scrollTo(info.scrollLeft, info.scrollTop); + cm.refresh(); + } +}); \ No newline at end of file diff --git a/assets/js/addon/simplescrollbars.js b/assets/js/addon/simplescrollbars.js new file mode 100644 index 00000000..86f8e00d --- /dev/null +++ b/assets/js/addon/simplescrollbars.js @@ -0,0 +1,152 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + function Bar(cls, orientation, scroll) { + this.orientation = orientation; + this.scroll = scroll; + this.screen = this.total = this.size = 1; + this.pos = 0; + + this.node = document.createElement("div"); + this.node.className = cls + "-" + orientation; + this.inner = this.node.appendChild(document.createElement("div")); + + var self = this; + CodeMirror.on(this.inner, "mousedown", function(e) { + if (e.which != 1) return; + CodeMirror.e_preventDefault(e); + var axis = self.orientation == "horizontal" ? "pageX" : "pageY"; + var start = e[axis], startpos = self.pos; + function done() { + CodeMirror.off(document, "mousemove", move); + CodeMirror.off(document, "mouseup", done); + } + function move(e) { + if (e.which != 1) return done(); + self.moveTo(startpos + (e[axis] - start) * (self.total / self.size)); + } + CodeMirror.on(document, "mousemove", move); + CodeMirror.on(document, "mouseup", done); + }); + + CodeMirror.on(this.node, "click", function(e) { + CodeMirror.e_preventDefault(e); + var innerBox = self.inner.getBoundingClientRect(), where; + if (self.orientation == "horizontal") + where = e.clientX < innerBox.left ? -1 : e.clientX > innerBox.right ? 1 : 0; + else + where = e.clientY < innerBox.top ? -1 : e.clientY > innerBox.bottom ? 1 : 0; + self.moveTo(self.pos + where * self.screen); + }); + + function onWheel(e) { + var moved = CodeMirror.wheelEventPixels(e)[self.orientation == "horizontal" ? "x" : "y"]; + var oldPos = self.pos; + self.moveTo(self.pos + moved); + if (self.pos != oldPos) CodeMirror.e_preventDefault(e); + } + CodeMirror.on(this.node, "mousewheel", onWheel); + CodeMirror.on(this.node, "DOMMouseScroll", onWheel); + } + + Bar.prototype.setPos = function(pos, force) { + if (pos < 0) pos = 0; + if (pos > this.total - this.screen) pos = this.total - this.screen; + if (!force && pos == this.pos) return false; + this.pos = pos; + this.inner.style[this.orientation == "horizontal" ? "left" : "top"] = + (pos * (this.size / this.total)) + "px"; + return true + }; + + Bar.prototype.moveTo = function(pos) { + if (this.setPos(pos)) this.scroll(pos, this.orientation); + } + + var minButtonSize = 10; + + Bar.prototype.update = function(scrollSize, clientSize, barSize) { + var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize + if (sizeChanged) { + this.screen = clientSize; + this.total = scrollSize; + this.size = barSize; + } + + var buttonSize = this.screen * (this.size / this.total); + if (buttonSize < minButtonSize) { + this.size -= minButtonSize - buttonSize; + buttonSize = minButtonSize; + } + this.inner.style[this.orientation == "horizontal" ? "width" : "height"] = + buttonSize + "px"; + this.setPos(this.pos, sizeChanged); + }; + + function SimpleScrollbars(cls, place, scroll) { + this.addClass = cls; + this.horiz = new Bar(cls, "horizontal", scroll); + place(this.horiz.node); + this.vert = new Bar(cls, "vertical", scroll); + place(this.vert.node); + this.width = null; + } + + SimpleScrollbars.prototype.update = function(measure) { + if (this.width == null) { + var style = window.getComputedStyle ? window.getComputedStyle(this.horiz.node) : this.horiz.node.currentStyle; + if (style) this.width = parseInt(style.height); + } + var width = this.width || 0; + + var needsH = measure.scrollWidth > measure.clientWidth + 1; + var needsV = measure.scrollHeight > measure.clientHeight + 1; + this.vert.node.style.display = needsV ? "block" : "none"; + this.horiz.node.style.display = needsH ? "block" : "none"; + + if (needsV) { + this.vert.update(measure.scrollHeight, measure.clientHeight, + measure.viewHeight - (needsH ? width : 0)); + this.vert.node.style.bottom = needsH ? width + "px" : "0"; + } + if (needsH) { + this.horiz.update(measure.scrollWidth, measure.clientWidth, + measure.viewWidth - (needsV ? width : 0) - measure.barLeft); + this.horiz.node.style.right = needsV ? width + "px" : "0"; + this.horiz.node.style.left = measure.barLeft + "px"; + } + + return {right: needsV ? width : 0, bottom: needsH ? width : 0}; + }; + + SimpleScrollbars.prototype.setScrollTop = function(pos) { + this.vert.setPos(pos); + }; + + SimpleScrollbars.prototype.setScrollLeft = function(pos) { + this.horiz.setPos(pos); + }; + + SimpleScrollbars.prototype.clear = function() { + var parent = this.horiz.node.parentNode; + parent.removeChild(this.horiz.node); + parent.removeChild(this.vert.node); + }; + + CodeMirror.scrollbarModel.simple = function(place, scroll) { + return new SimpleScrollbars("CodeMirror-simplescroll", place, scroll); + }; + CodeMirror.scrollbarModel.overlay = function(place, scroll) { + return new SimpleScrollbars("CodeMirror-overlayscroll", place, scroll); + }; +}); \ No newline at end of file diff --git a/assets/js/ajax-bootstrap-select-en-US.js b/assets/js/ajax-bootstrap-select-en-US.js new file mode 100644 index 00000000..10045d47 --- /dev/null +++ b/assets/js/ajax-bootstrap-select-en-US.js @@ -0,0 +1,96 @@ +/*! + * Ajax Bootstrap Select + * + * Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON. + * + * @version 1.3.7 + * @author Adam Heim - https://github.com/truckingsim + * @link https://github.com/truckingsim/Ajax-Bootstrap-Select + * @copyright 2016 Adam Heim + * @license Released under the MIT license. + * + * Contributors: + * Mark Carver - https://github.com/markcarver + * + * Last build: 2016-06-24 1:36:43 PM EDT + */ +!(function ($) { +/* + * Note: You do not have to load this translation file. English is the + * default language of this plugin and is compiled into it automatically. + * + * This file is just to serve as the default string mappings and as a + * template for future translations. + * @see: ./src/js/locale/en-US.js + * + * Four character language codes are supported ("en-US") and will always + * take precedence over two character language codes ("en") if present. + * + * When copying this file, remove all comments except the one above the + * definition objection giving credit to the translation author. + */ + +/*! + * English translation for the "en-US" and "en" language codes. + * Mark Carver + */ +if (typeof $.fn.ajaxSelectPicker == 'undefined') { return; } +$.fn.ajaxSelectPicker.locale['en-US'] = { + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} currentlySelected = 'Currently Selected' + * @markdown + * The text to use for the label of the option group when currently selected options are preserved. + */ + currentlySelected: 'Currently Selected', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} emptyTitle = 'Select and begin typing' + * @markdown + * The text to use as the title for the select element when there are no items to display. + */ + emptyTitle: 'Select and begin typing', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} errorText = ''Unable to retrieve results' + * @markdown + * The text to use in the status container when a request returns with an error. + */ + errorText: 'Unable to retrieve results', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} searchPlaceholder = 'Search...' + * @markdown + * The text to use for the search input placeholder attribute. + */ + searchPlaceholder: 'Search...', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusInitialized = 'Start typing a search query' + * @markdown + * The text used in the status container when it is initialized. + */ + statusInitialized: 'Start typing a search query', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusNoResults = 'No Results' + * @markdown + * The text used in the status container when the request returns no results. + */ + statusNoResults: 'No Results', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusSearching = 'Searching...' + * @markdown + * The text to use in the status container when a request is being initiated. + */ + statusSearching: 'Searching...' +}; +$.fn.ajaxSelectPicker.locale.en = $.fn.ajaxSelectPicker.locale['en-US']; +})(jQuery); diff --git a/assets/js/ajax-bootstrap-select-es-ES.js b/assets/js/ajax-bootstrap-select-es-ES.js new file mode 100644 index 00000000..fba6d139 --- /dev/null +++ b/assets/js/ajax-bootstrap-select-es-ES.js @@ -0,0 +1,81 @@ +/*! + * Ajax Bootstrap Select + * + * Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON. + * + * @version 1.3.7 + * @author Adam Heim - https://github.com/truckingsim + * @link https://github.com/truckingsim/Ajax-Bootstrap-Select + * @copyright 2016 Adam Heim + * @license Released under the MIT license. + * + * Contributors: + * Mark Carver - https://github.com/markcarver + * + * Last build: 2016-06-24 1:36:43 PM EDT + */ +!(function ($) { + /*! + * Spanish translation for the "es-ES" and "es" language codes. + * Diomedes Domínguez + */ + if (typeof $.fn.ajaxSelectPicker == 'undefined') { return; } + $.fn.ajaxSelectPicker.locale["es-ES"] = { + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} currentlySelected = 'Currently Selected' + * @markdown + * El texto que se utilizará para la etiqueta del grupo de opciones cuando se conservan las opciones seleccionadas. + */ + currentlySelected: "Seleccionado", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} emptyTitle = 'Select and begin typing' + * @markdown + * El texto que se utilizará como título para el elemento de selección cuando no hay elementos para mostrar. + */ + emptyTitle: "Seleccione y comience a escribir", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} errorText = ''Unable to retrieve results' + * @markdown + * El texto que se utilizan en el contenedor de estado cuando una solicitud devuelve con un error. + */ + errorText: "No se puede recuperar resultados", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} searchPlaceholder = 'Search...' + * @markdown + * El texto que se utilizará para el atributo marcador de posición de entrada de búsqueda. + */ + searchPlaceholder: "Buscar...", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusInitialized = 'Start typing a search query' + * @markdown + * El texto utilizado en el contenedor de estado cuando se inicializa. + */ + statusInitialized: "Empieza a escribir una consulta de búsqueda", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusNoResults = 'No Results' + * @markdown + * El texto utilizado en el contenedor de estado cuando la solicitud no devolvió resultados. + */ + statusNoResults: "Sin Resultados", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusSearching = 'Searching...' + * @markdown + * El texto que se utilizan en el contenedor de estado cuando se está iniciando una solicitud. + */ + statusSearching: "Buscando..." + }; + $.fn.ajaxSelectPicker.locale.es = $.fn.ajaxSelectPicker.locale["es-ES"]; +})(jQuery); diff --git a/assets/js/ajax-bootstrap-select.en-US.js b/assets/js/ajax-bootstrap-select.en-US.js new file mode 100644 index 00000000..c349fcae --- /dev/null +++ b/assets/js/ajax-bootstrap-select.en-US.js @@ -0,0 +1,95 @@ +/*! + * Ajax Bootstrap Select + * + * Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON. + * + * @version 1.3.7 + * @author Adam Heim - https://github.com/truckingsim + * @link https://github.com/truckingsim/Ajax-Bootstrap-Select + * @copyright 2016 Adam Heim + * @license Released under the MIT license. + * + * Contributors: + * Mark Carver - https://github.com/markcarver + * + * Last build: 2016-06-24 1:36:43 PM EDT + */ +!(function ($) { +/* + * Note: You do not have to load this translation file. English is the + * default language of this plugin and is compiled into it automatically. + * + * This file is just to serve as the default string mappings and as a + * template for future translations. + * @see: ./src/js/locale/en-US.js + * + * Four character language codes are supported ("en-US") and will always + * take precedence over two character language codes ("en") if present. + * + * When copying this file, remove all comments except the one above the + * definition objection giving credit to the translation author. + */ + +/*! + * English translation for the "en-US" and "en" language codes. + * Mark Carver + */ +$.fn.ajaxSelectPicker.locale['en-US'] = { + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} currentlySelected = 'Currently Selected' + * @markdown + * The text to use for the label of the option group when currently selected options are preserved. + */ + currentlySelected: 'Currently Selected', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} emptyTitle = 'Select and begin typing' + * @markdown + * The text to use as the title for the select element when there are no items to display. + */ + emptyTitle: 'Select and begin typing', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} errorText = ''Unable to retrieve results' + * @markdown + * The text to use in the status container when a request returns with an error. + */ + errorText: 'Unable to retrieve results', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} searchPlaceholder = 'Search...' + * @markdown + * The text to use for the search input placeholder attribute. + */ + searchPlaceholder: 'Search...', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusInitialized = 'Start typing a search query' + * @markdown + * The text used in the status container when it is initialized. + */ + statusInitialized: 'Start typing a search query', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusNoResults = 'No Results' + * @markdown + * The text used in the status container when the request returns no results. + */ + statusNoResults: 'No Results', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusSearching = 'Searching...' + * @markdown + * The text to use in the status container when a request is being initiated. + */ + statusSearching: 'Searching...' +}; +$.fn.ajaxSelectPicker.locale.en = $.fn.ajaxSelectPicker.locale['en-US']; +})(jQuery); diff --git a/assets/js/ajax-bootstrap-select.es-ES.js b/assets/js/ajax-bootstrap-select.es-ES.js new file mode 100644 index 00000000..b9ffae5c --- /dev/null +++ b/assets/js/ajax-bootstrap-select.es-ES.js @@ -0,0 +1,80 @@ +/*! + * Ajax Bootstrap Select + * + * Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON. + * + * @version 1.3.7 + * @author Adam Heim - https://github.com/truckingsim + * @link https://github.com/truckingsim/Ajax-Bootstrap-Select + * @copyright 2016 Adam Heim + * @license Released under the MIT license. + * + * Contributors: + * Mark Carver - https://github.com/markcarver + * + * Last build: 2016-06-24 1:36:43 PM EDT + */ +!(function ($) { + /*! + * Spanish translation for the "es-ES" and "es" language codes. + * Diomedes Domínguez + */ + $.fn.ajaxSelectPicker.locale["es-ES"] = { + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} currentlySelected = 'Currently Selected' + * @markdown + * El texto que se utilizará para la etiqueta del grupo de opciones cuando se conservan las opciones seleccionadas. + */ + currentlySelected: "Seleccionado", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} emptyTitle = 'Select and begin typing' + * @markdown + * El texto que se utilizará como título para el elemento de selección cuando no hay elementos para mostrar. + */ + emptyTitle: "Seleccione y comience a escribir", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} errorText = ''Unable to retrieve results' + * @markdown + * El texto que se utilizan en el contenedor de estado cuando una solicitud devuelve con un error. + */ + errorText: "No se puede recuperar resultados", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} searchPlaceholder = 'Search...' + * @markdown + * El texto que se utilizará para el atributo marcador de posición de entrada de búsqueda. + */ + searchPlaceholder: "Buscar...", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusInitialized = 'Start typing a search query' + * @markdown + * El texto utilizado en el contenedor de estado cuando se inicializa. + */ + statusInitialized: "Empieza a escribir una consulta de búsqueda", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusNoResults = 'No Results' + * @markdown + * El texto utilizado en el contenedor de estado cuando la solicitud no devolvió resultados. + */ + statusNoResults: "Sin Resultados", + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusSearching = 'Searching...' + * @markdown + * El texto que se utilizan en el contenedor de estado cuando se está iniciando una solicitud. + */ + statusSearching: "Buscando..." + }; + $.fn.ajaxSelectPicker.locale.es = $.fn.ajaxSelectPicker.locale["es-ES"]; +})(jQuery); diff --git a/assets/js/ajax-bootstrap-select.js b/assets/js/ajax-bootstrap-select.js new file mode 100644 index 00000000..d3b7c74d --- /dev/null +++ b/assets/js/ajax-bootstrap-select.js @@ -0,0 +1,1584 @@ +/*! + * Ajax Bootstrap Select + * + * Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON. + * + * @version 1.3.7 + * @author Adam Heim - https://github.com/truckingsim + * @link https://github.com/truckingsim/Ajax-Bootstrap-Select + * @copyright 2016 Adam Heim + * @license Released under the MIT license. + * + * Contributors: + * Mark Carver - https://github.com/markcarver + * + * Last build: 2016-06-24 1:36:43 PM EDT + */ +!(function ($, window) { + +/** + * @class AjaxBootstrapSelect + * + * @param {jQuery|HTMLElement} element + * The select element this plugin is to affect. + * @param {Object} [options={}] + * The options used to affect the desired functionality of this plugin. + * + * @return {AjaxBootstrapSelect|null} + * A new instance of this class or null if unable to instantiate. + */ +var AjaxBootstrapSelect = function (element, options) { + var i, l, plugin = this; + options = options || {}; + + /** + * The select element this plugin is being attached to. + * @type {jQuery} + */ + this.$element = $(element); + + /** + * The merged default and passed options. + * @type {Object} + */ + this.options = $.extend(true, {}, $.fn.ajaxSelectPicker.defaults, options); + + /** + * Used for logging error messages. + * @type {Number} + */ + this.LOG_ERROR = 1; + + /** + * Used for logging warning messages. + * @type {Number} + */ + this.LOG_WARNING = 2; + + /** + * Used for logging informational messages. + * @type {Number} + */ + this.LOG_INFO = 3; + + /** + * Used for logging debug messages. + * @type {Number} + */ + this.LOG_DEBUG = 4; + + /** + * The jqXHR object of the last request, false if there was none. + * @type {jqXHR|Boolean} + */ + this.lastRequest = false; + + /** + * The previous query that was requested. + * @type {String} + */ + this.previousQuery = ''; + + /** + * The current query being requested. + * @type {String} + */ + this.query = ''; + + /** + * The jqXHR object of the current request, false if there is none. + * @type {jqXHR|Boolean} + */ + this.request = false; + + // Maps deprecated options to new ones between releases. + var deprecatedOptionsMap = [ + // @todo Remove these options in next minor release. + { + from: 'ajaxResultsPreHook', + to: 'preprocessData' + }, + { + from: 'ajaxSearchUrl', + to: { + ajax: { + url: '{{{value}}}' + } + } + }, + { + from: 'ajaxOptions', + to: 'ajax' + }, + { + from: 'debug', + to: function (map) { + var _options = {}; + _options.log = Boolean(plugin.options[map.from]) ? plugin.LOG_DEBUG : 0; + plugin.options = $.extend(true, {}, plugin.options, _options); + delete plugin.options[map.from]; + plugin.log(plugin.LOG_WARNING, 'Deprecated option "' + map.from + '". Update code to use:', _options); + } + }, + { + from: 'mixWithCurrents', + to: 'preserveSelected' + }, + { + from: 'placeHolderOption', + to: { + locale: { + emptyTitle: '{{{value}}}' + } + } + } + ]; + if (deprecatedOptionsMap.length) { + $.map(deprecatedOptionsMap, function (map) { + // Depreciated option detected. + if (plugin.options[map.from]) { + // Map with an object. Use "{{{value}}}" anywhere in the object to + // replace it with the passed value. + if ($.isPlainObject(map.to)) { + plugin.replaceValue(map.to, '{{{value}}}', plugin.options[map.from]); + plugin.options = $.extend(true, {}, plugin.options, map.to); + plugin.log(plugin.LOG_WARNING, 'Deprecated option "' + map.from + '". Update code to use:', map.to); + delete plugin.options[map.from]; + } + // Map with a function. Functions are silos. They are responsible + // for deleting the original option and displaying debug info. + else if ($.isFunction(map.to)) { + map.to.apply(plugin, [map]); + } + // Map normally. + else { + var _options = {}; + _options[map.to] = plugin.options[map.from]; + plugin.options = $.extend(true, {}, plugin.options, _options); + plugin.log(plugin.LOG_WARNING, 'Deprecated option "' + map.from + '". Update code to use:', _options); + delete plugin.options[map.from]; + } + } + }); + } + + // Retrieve the element data attributes. + var data = this.$element.data(); + + // @todo Deprecated. Remove this in the next minor release. + if (data['searchUrl']) { + plugin.log(plugin.LOG_WARNING, 'Deprecated attribute name: "data-search-url". Update markup to use: \' data-abs-ajax-url="' + data['searchUrl'] + '" \''); + this.options.ajax.url = data['searchUrl']; + } + + // Helper functions. + var matchToLowerCase = function (match, p1) { return p1.toLowerCase(); }; + var expandObject = function (keys, value, obj) { + var k = [].concat(keys), l = k.length, o = obj || {}; + if (l) { var key = k.shift(); o[key] = expandObject(k, value, o[key]); } + return l ? o : value; + }; + + // Filter out only the data attributes prefixed with 'data-abs-'. + var dataKeys = Object.keys(data).filter(/./.test.bind(new RegExp('^abs[A-Z]'))); + + // Map the data attributes to their respective place in the options object. + if (dataKeys.length) { + // Object containing the data attribute options. + var dataOptions = {}; + var flattenedOptions = ['locale']; + for (i = 0, l = dataKeys.length; i < l; i++) { + var name = dataKeys[i].replace(/^abs([A-Z])/, matchToLowerCase).replace(/([A-Z])/g, '-$1').toLowerCase(); + var keys = name.split('-'); + + // Certain options should be flattened to a single object + // and not fully expanded (such as Locale). + if (keys[0] && keys.length > 1 && flattenedOptions.indexOf(keys[0]) !== -1) { + var newKeys = [keys.shift()]; + var property = ''; + // Combine the remaining keys as a single property. + for (var ii = 0; ii < keys.length; ii++) { + property += (ii === 0 ? keys[ii] : keys[ii].charAt(0).toUpperCase() + keys[ii].slice(1)); + } + newKeys.push(property); + keys = newKeys; + } + this.log(this.LOG_DEBUG, 'Processing data attribute "data-abs-' + name + '":', data[dataKeys[i]]); + expandObject(keys, data[dataKeys[i]], dataOptions); + } + this.options = $.extend(true, {}, this.options, dataOptions); + this.log(this.LOG_DEBUG, 'Merged in the data attribute options: ', dataOptions, this.options); + } + + /** + * Reference to the selectpicker instance. + * @type {Selectpicker} + */ + this.selectpicker = data['selectpicker']; + if (!this.selectpicker) { + this.log(this.LOG_ERROR, 'Cannot instantiate an AjaxBootstrapSelect instance without selectpicker first being initialized!'); + return null; + } + + // Ensure there is a URL. + if (!this.options.ajax.url) { + this.log(this.LOG_ERROR, 'Option "ajax.url" must be set! Options:', this.options); + return null; + } + + // Initialize the locale strings. + this.locale = $.extend(true, {}, $.fn.ajaxSelectPicker.locale); + + // Ensure the langCode is properly set. + this.options.langCode = this.options.langCode || window.navigator.userLanguage || window.navigator.language || 'en'; + if (!this.locale[this.options.langCode]) { + var langCode = this.options.langCode; + + // Reset the language code. + this.options.langCode = 'en'; + + // Check for both the two and four character language codes, using + // the later first. + var langCodeArray = langCode.split('-'); + for (i = 0, l = langCodeArray.length; i < l; i++) { + var code = langCodeArray.join('-'); + if (code.length && this.locale[code]) { + this.options.langCode = code; + break; + } + langCodeArray.pop(); + } + this.log(this.LOG_WARNING, 'Unknown langCode option: "' + langCode + '". Using the following langCode instead: "' + this.options.langCode + '".'); + } + + // Allow options to override locale specific strings. + this.locale[this.options.langCode] = $.extend(true, {}, this.locale[this.options.langCode], this.options.locale); + + /** + * The select list. + * @type {AjaxBootstrapSelectList} + */ + this.list = new window.AjaxBootstrapSelectList(this); + this.list.refresh(); + + // We need for selectpicker to be attached first. Putting the init in a + // setTimeout is the easiest way to ensure this. + // @todo Figure out a better way to do this (hopefully listen for an event). + setTimeout(function () { + plugin.init(); + }, 500); +}; + +/** + * Initializes this plugin on a selectpicker instance. + */ +AjaxBootstrapSelect.prototype.init = function () { + var requestDelayTimer, plugin = this; + + // Rebind select/deselect to process preserved selections. + if (this.options.preserveSelected) { + this.selectpicker.$menu.off('click', '.actions-btn').on('click', '.actions-btn', function (e) { + if (plugin.selectpicker.options.liveSearch) { + plugin.selectpicker.$searchbox.focus(); + } + else { + plugin.selectpicker.$button.focus(); + } + e.preventDefault(); + e.stopPropagation(); + if ($(this).is('.bs-select-all')) { + if (plugin.selectpicker.$lis === null) { + plugin.selectpicker.$lis = plugin.selectpicker.$menu.find('li'); + } + plugin.$element.find('option:enabled').prop('selected', true); + $(plugin.selectpicker.$lis).not('.disabled').addClass('selected'); + plugin.selectpicker.render(); + } + else { + if (plugin.selectpicker.$lis === null) { + plugin.selectpicker.$lis = plugin.selectpicker.$menu.find('li'); + } + plugin.$element.find('option:enabled').prop('selected', false); + $(plugin.selectpicker.$lis).not('.disabled').removeClass('selected'); + plugin.selectpicker.render(); + } + plugin.selectpicker.$element.change(); + }); + } + + // Add placeholder text to the search input. + this.selectpicker.$searchbox + .attr('placeholder', this.t('searchPlaceholder')) + // Remove selectpicker events on the search input. + .off('input propertychange'); + + // Bind this plugin's event. + this.selectpicker.$searchbox.on(this.options.bindEvent, function (e) { + var query = plugin.selectpicker.$searchbox.val(); + + plugin.log(plugin.LOG_DEBUG, 'Bind event fired: "' + plugin.options.bindEvent + '", keyCode:', e.keyCode, e); + + // Dynamically ignore the "enter" key (13) so it doesn't + // create an additional request if the "cache" option has + // been disabled. + if (!plugin.options.cache) { + plugin.options.ignoredKeys[13] = 'enter'; + } + + // Don't process ignored keys. + if (plugin.options.ignoredKeys[e.keyCode]) { + plugin.log(plugin.LOG_DEBUG, 'Key ignored.'); + return; + } + + // Clear out any existing timer. + clearTimeout(requestDelayTimer); + + // Process empty search value. + if (!query.length) { + // Clear the select list. + if (plugin.options.clearOnEmpty) { + plugin.list.destroy(); + } + + // Don't invoke a request. + if (!plugin.options.emptyRequest) { + return; + } + } + + // Store the query. + plugin.previousQuery = plugin.query; + plugin.query = query; + + // Return the cached results, if any. + if (plugin.options.cache && e.keyCode !== 13) { + var cache = plugin.list.cacheGet(plugin.query); + if (cache) { + plugin.list.setStatus(!cache.length ? plugin.t('statusNoResults') : ''); + plugin.list.replaceOptions(cache); + plugin.log(plugin.LOG_INFO, 'Rebuilt options from cached data.'); + return; + } + } + + requestDelayTimer = setTimeout(function () { + // Abort any previous requests. + if (plugin.lastRequest && plugin.lastRequest.jqXHR && $.isFunction(plugin.lastRequest.jqXHR.abort)) { + plugin.lastRequest.jqXHR.abort(); + } + + // Create a new request. + plugin.request = new window.AjaxBootstrapSelectRequest(plugin); + + // Store as the previous request once finished. + plugin.request.jqXHR.always(function () { + plugin.lastRequest = plugin.request; + plugin.request = false; + }); + }, plugin.options.requestDelay || 300); + }); +}; + +/** + * Wrapper function for logging messages to window.console. + * + * @param {Number} type + * The type of message to log. Must be one of: + * + * - AjaxBootstrapSelect.LOG_ERROR + * - AjaxBootstrapSelect.LOG_WARNING + * - AjaxBootstrapSelect.LOG_INFO + * - AjaxBootstrapSelect.LOG_DEBUG + * + * @param {String|Object|*...} message + * The message(s) to log. Multiple arguments can be passed. + * + * @return {void} + */ +AjaxBootstrapSelect.prototype.log = function (type, message) { + if (window.console && this.options.log) { + // Ensure the logging level is always an integer. + if (typeof this.options.log !== 'number') { + if (typeof this.options.log === 'string') { + this.options.log = this.options.log.toLowerCase(); + } + switch (this.options.log) { + case true: + case 'debug': + this.options.log = this.LOG_DEBUG; + break; + + case 'info': + this.options.log = this.LOG_INFO; + break; + + case 'warn': + case 'warning': + this.options.log = this.LOG_WARNING; + break; + + default: + case false: + case 'error': + this.options.log = this.LOG_ERROR; + break; + } + } + if (type <= this.options.log) { + var args = [].slice.apply(arguments, [2]); + + // Determine the correct console method to use. + switch (type) { + case this.LOG_DEBUG: + type = 'debug'; + break; + case this.LOG_INFO: + type = 'info'; + break; + case this.LOG_WARNING: + type = 'warn'; + break; + default: + case this.LOG_ERROR: + type = 'error'; + break; + } + + // Prefix the message. + var prefix = '[' + type.toUpperCase() + '] AjaxBootstrapSelect:'; + if (typeof message === 'string') { + args.unshift(prefix + ' ' + message); + } + else { + args.unshift(message); + args.unshift(prefix); + } + + // Display the message(s). + window.console[type].apply(window.console, args); + } + } +}; + +/** + * Replaces an old value in an object or array with a new value. + * + * @param {Object|Array} obj + * The object (or array) to iterate over. + * @param {*} needle + * The value to search for. + * @param {*} value + * The value to replace with. + * @param {Object} [options] + * Additional options for restricting replacement: + * - recursive: {boolean} Whether or not to iterate over the entire + * object or array, defaults to true. + * - depth: {int} The number of level this method is to search + * down into child elements, defaults to false (no limit). + * - limit: {int} The number of times a replacement should happen, + * defaults to false (no limit). + * + * @return {void} + */ +AjaxBootstrapSelect.prototype.replaceValue = function (obj, needle, value, options) { + var plugin = this; + options = $.extend({ + recursive: true, + depth: false, + limit: false + }, options); + // The use of $.each() opposed to native loops here is beneficial + // since obj can be either an array or an object. This helps reduce + // the amount of duplicate code needed. + $.each(obj, function (k, v) { + if (options.limit !== false && typeof options.limit === 'number' && options.limit <= 0) { + return false; + } + if ($.isArray(obj[k]) || $.isPlainObject(obj[k])) { + if ((options.recursive && options.depth === false) || (options.recursive && typeof options.depth === 'number' && options.depth > 0)) { + plugin.replaceValue(obj[k], needle, value, options); + } + } + else { + if (v === needle) { + if (options.limit !== false && typeof options.limit === 'number') { + options.limit--; + } + obj[k] = value; + } + } + }); +}; + +/** + * Generates a translated {@link $.fn.ajaxSelectPicker.locale locale string} for a given locale key. + * + * @param {String} key + * The translation key to use. + * @param {String} [langCode] + * Overrides the currently set {@link $.fn.ajaxSelectPicker.defaults#langCode langCode} option. + * + * @return + * The translated string. + */ +AjaxBootstrapSelect.prototype.t = function (key, langCode) { + langCode = langCode || this.options.langCode; + if (this.locale[langCode] && this.locale[langCode].hasOwnProperty(key)) { + return this.locale[langCode][key]; + } + this.log(this.LOG_WARNING, 'Unknown translation key:', key); + return key; +}; + +/** + * Use an existing definition in the Window object or create a new one. + * + * Note: This must be the last statement of this file. + * + * @type {AjaxBootstrapSelect} + * @ignore + */ +window.AjaxBootstrapSelect = window.AjaxBootstrapSelect || AjaxBootstrapSelect; + +/** + * @class AjaxBootstrapSelectList + * Maintains the select options and selectpicker menu. + * + * @param {AjaxBootstrapSelect} plugin + * The plugin instance. + * + * @return {AjaxBootstrapSelectList} + * A new instance of this class. + */ +var AjaxBootstrapSelectList = function (plugin) { + var that = this; + + /** + * DOM element used for updating the status of requests and list counts. + * @type {jQuery} + */ + this.$status = $(plugin.options.templates.status).hide().appendTo(plugin.selectpicker.$menu); + var statusInitialized = plugin.t('statusInitialized'); + if (statusInitialized && statusInitialized.length) { + this.setStatus(statusInitialized); + } + + /** + * Container for cached data. + * @type {Object} + */ + this.cache = {}; + + /** + * Reference the plugin for internal use. + * @type {AjaxBootstrapSelect} + */ + this.plugin = plugin; + + /** + * Container for current selections. + * @type {Array} + */ + this.selected = []; + + /** + * Containers for previous titles. + */ + this.title = null; + this.selectedTextFormat = plugin.selectpicker.options.selectedTextFormat; + + // Save initial options + var initial_options = []; + plugin.$element.find('option').each(function() { + var $option = $(this); + var value = $option.attr('value'); + initial_options.push({ + value: value, + text: $option.text(), + 'class': $option.attr('class') || '', + data: $option.data() || {}, + preserved: plugin.options.preserveSelected, + selected: !!$option.attr('selected') + }); + }); + this.cacheSet(/*query=*/'', initial_options); + + // Preserve selected options. + if (plugin.options.preserveSelected) { + that.selected = initial_options; + plugin.$element.on('change.abs.preserveSelected', function (e) { + var $selected = plugin.$element.find(':selected'); + that.selected = []; + // If select does not have multiple selection, ensure that only the + // last selected option is preserved. + if (!plugin.selectpicker.multiple) { + $selected = $selected.last(); + } + $selected.each(function () { + var $option = $(this); + var value = $option.attr('value'); + that.selected.push({ + value: value, + text: $option.text(), + 'class': $option.attr('class') || '', + data: $option.data() || {}, + preserved: true, + selected: true + }); + }); + that.replaceOptions(that.cacheGet(that.plugin.query)); + }); + } +}; + +/** + * Builds the options for placing into the element. + * + * @param {Array} data + * The data to use when building options for the select list. Each + * array item must be an Object structured as follows: + * - {int|string} value: Required, a unique value identifying the + * item. Optionally not required if divider is passed instead. + * - {boolean} [divider]: Optional, if passed all other values are + * ignored and this item becomes a divider. + * - {string} [text]: Optional, the text to display for the item. + * If none is provided, the value will be used. + * - {String} [class]: Optional, the classes to apply to the option. + * - {boolean} [disabled]: Optional, flag that determines if the + * option is disabled. + * - {boolean} [selected]: Optional, flag that determines if the + * option is selected. Useful only for select lists that have the + * "multiple" attribute. If it is a single select list, each item + * that passes this property as true will void the previous one. + * - {Object} [data]: Optional, the additional data attributes to + * attach to the option element. These are processed by the + * bootstrap-select plugin. + * + * @return {String} + * HTML containing the