mirror of https://github.com/avecms/AVE.cms.git
M@d D3n
7 years ago
141 changed files with 4686 additions and 6653 deletions
@ -1,35 +1,34 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
if (!defined('ACP')) |
||||
{ |
||||
header('Location:index.php'); |
||||
exit; |
||||
} |
||||
if (! defined('ACP')) |
||||
{ |
||||
header('Location:index.php'); |
||||
exit; |
||||
} |
||||
|
||||
get_ave_info(); |
||||
getInstaledModules(); |
||||
DisplayMainDocuments(); |
||||
get_online_users(); |
||||
getLogRecords(); |
||||
|
||||
//$AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/main.txt', 'index'); |
||||
$AVE_Template->assign('php_version', (@PHP_VERSION != '') ? @PHP_VERSION : 'unknow'); |
||||
$AVE_Template->assign('domain', $_SERVER["HTTP_HOST"]); |
||||
$AVE_Template->assign('mysql_version', $GLOBALS['AVE_DB']->mysql_version()); |
||||
$AVE_Template->assign('mysql_size', get_mysql_size()); |
||||
$AVE_Template->assign('navi', $AVE_Template->fetch('navi/navi.tpl')); |
||||
$AVE_Template->assign('navi_top', $AVE_Template->fetch('navi/navi_top.tpl')); |
||||
$AVE_Template->assign('content', $AVE_Template->fetch('start.tpl')); |
||||
get_ave_info(); |
||||
getInstaledModules(); |
||||
DisplayMainDocuments(); |
||||
get_online_users(); |
||||
getLogRecords(); |
||||
|
||||
//$AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/main.txt', 'index'); |
||||
$AVE_Template->assign('php_version', (@PHP_VERSION != '') ? @PHP_VERSION : 'unknow'); |
||||
$AVE_Template->assign('domain', $_SERVER["HTTP_HOST"]); |
||||
$AVE_Template->assign('mysql_version', $GLOBALS['AVE_DB']->mysql_version()); |
||||
$AVE_Template->assign('mysql_size', get_mysql_size()); |
||||
$AVE_Template->assign('navi', $AVE_Template->fetch('navi/navi.tpl')); |
||||
$AVE_Template->assign('navi_top', $AVE_Template->fetch('navi/navi_top.tpl')); |
||||
$AVE_Template->assign('content', $AVE_Template->fetch('start.tpl')); |
||||
?> |
@ -1,174 +1,175 @@
|
||||
<?php |
||||
|
||||
// Проверка |
||||
if (! defined('BASE_DIR')) |
||||
exit('Access denied'); |
||||
// Проверка |
||||
if (! defined('BASE_DIR')) |
||||
exit('Access denied'); |
||||
|
||||
/** |
||||
* This source file is part of the AVE.cms. More information, |
||||
* documentation and tutorials can be found at http://www.ave-cms.ru |
||||
* |
||||
* @package AVE.cms |
||||
* @file system/helpers/hooks.php |
||||
* @author @ |
||||
* @copyright 2007-2016 (c) AVE.cms |
||||
* @link http://www.ave-cms.ru |
||||
* @version 4.0 |
||||
* @since $date$ |
||||
* @license license GPL v.2 http://www.ave-cms.ru/license.txt |
||||
*/ |
||||
|
||||
class Hooks |
||||
{ |
||||
public static $instance; |
||||
/** |
||||
* This source file is part of the AVE.cms. More information, |
||||
* documentation and tutorials can be found at http://www.ave-cms.ru |
||||
* |
||||
* @package AVE.cms |
||||
* @file system/helpers/hooks.php |
||||
* @author @ |
||||
* @copyright 2007-2016 (c) AVE.cms |
||||
* @link http://www.ave-cms.ru |
||||
* @version 4.0 |
||||
* @since $date$ |
||||
* @license license GPL v.2 http://www.ave-cms.ru/license.txt |
||||
*/ |
||||
|
||||
class Hooks |
||||
{ |
||||
public static $instance; |
||||
|
||||
public static $hooks; |
||||
public static $hooks; |
||||
|
||||
public static $current_hook; |
||||
public static $current_hook; |
||||
|
||||
public static $run_hooks; |
||||
public static $run_hooks; |
||||
|
||||
|
||||
public static function init() |
||||
{ |
||||
if (!self::$instance) { |
||||
self::$instance = new Hooks(); |
||||
} |
||||
return self::$instance; |
||||
} |
||||
|
||||
/** |
||||
* Add Hook |
||||
*/ |
||||
public static function register($name, $function, $priority = 10) |
||||
{ |
||||
// If we have already registered this action return true |
||||
if (isset(self::$hooks[$name][$priority][$function])) |
||||
public static function init() |
||||
{ |
||||
return true; |
||||
if (!self::$instance) { |
||||
self::$instance = new Hooks(); |
||||
} |
||||
return self::$instance; |
||||
} |
||||
|
||||
/** |
||||
* Allows us to iterate through multiple action hooks. |
||||
* Add Hook |
||||
*/ |
||||
if (is_array($name)) |
||||
public static function register($name, $function, $priority = 10) |
||||
{ |
||||
foreach ($name AS $item) |
||||
// If we have already registered this action return true |
||||
if (isset(self::$hooks[$name][$priority][$function])) |
||||
{ |
||||
return true; |
||||
} |
||||
/** |
||||
* Allows us to iterate through multiple action hooks. |
||||
*/ |
||||
if (is_array($name)) |
||||
{ |
||||
foreach ($name AS $item) |
||||
{ |
||||
// Store the action hook in the $hooks array |
||||
self::$hooks[$item][$priority][$function] = array( |
||||
"function" => $function |
||||
); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
// Store the action hook in the $hooks array |
||||
self::$hooks[$item][$priority][$function] = array( |
||||
self::$hooks[$name][$priority][$function] = array( |
||||
"function" => $function |
||||
); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
// Store the action hook in the $hooks array |
||||
self::$hooks[$name][$priority][$function] = array( |
||||
"function" => $function |
||||
); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* Do Hook |
||||
*/ |
||||
public static function trigger($name, $arguments = "") |
||||
{ |
||||
// Oh, no you didn't. Are you trying to run an action hook that doesn't exist? |
||||
if (! isset(self::$hooks[$name])) |
||||
/** |
||||
* Do Hook |
||||
*/ |
||||
public static function trigger($name, $arguments = "") |
||||
{ |
||||
return $arguments; |
||||
} |
||||
// Oh, no you didn't. Are you trying to run an action hook that doesn't exist? |
||||
if (! isset(self::$hooks[$name])) |
||||
{ |
||||
return $arguments; |
||||
} |
||||
|
||||
// Set the current running hook to this |
||||
self::$current_hook = $name; |
||||
// Set the current running hook to this |
||||
self::$current_hook = $name; |
||||
|
||||
// Key sort our action hooks |
||||
ksort(self::$hooks[$name]); |
||||
foreach (self::$hooks[$name] AS $priority => $names) |
||||
{ |
||||
if (is_array($names)) |
||||
// Key sort our action hooks |
||||
ksort(self::$hooks[$name]); |
||||
foreach (self::$hooks[$name] AS $priority => $names) |
||||
{ |
||||
foreach ($names AS $name) |
||||
if (is_array($names)) |
||||
{ |
||||
$return = call_user_func_array($name['function'], array( |
||||
&$arguments |
||||
)); |
||||
|
||||
if ($return) |
||||
foreach ($names AS $name) |
||||
{ |
||||
$arguments = $return; |
||||
} |
||||
$return = call_user_func_array($name['function'], array( |
||||
&$arguments |
||||
)); |
||||
|
||||
if ($return) |
||||
{ |
||||
$arguments = $return; |
||||
} |
||||
|
||||
self::$run_hooks[$name][$priority]; |
||||
self::$run_hooks[$name][$priority]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
self::$current_hook = ''; |
||||
self::$current_hook = ''; |
||||
|
||||
return $arguments; |
||||
} |
||||
|
||||
/** |
||||
* Remove Hook |
||||
*/ |
||||
public static function unregister($name, $function, $priority = 10) |
||||
{ |
||||
// If the action hook doesn't, just return true |
||||
if (!isset(self::$hooks[$name][$priority][$function])) |
||||
{ |
||||
return true; |
||||
return $arguments; |
||||
} |
||||
// Remove the action hook from our hooks array |
||||
unset(self::$hooks[$name][$priority][$function]); |
||||
|
||||
return ''; |
||||
} |
||||
|
||||
/** |
||||
* Remove Hook |
||||
*/ |
||||
public static function unregister($name, $function, $priority = 10) |
||||
{ |
||||
// If the action hook doesn't, just return true |
||||
if (!isset(self::$hooks[$name][$priority][$function])) |
||||
{ |
||||
return true; |
||||
} |
||||
// Remove the action hook from our hooks array |
||||
unset(self::$hooks[$name][$priority][$function]); |
||||
|
||||
/** |
||||
* Current Hook |
||||
* |
||||
* Get the currently running action hook |
||||
* |
||||
*/ |
||||
public static function current() |
||||
{ |
||||
return self::$current_hook; |
||||
} |
||||
return ''; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Has Run |
||||
*/ |
||||
public static function has($hook, $priority = 10) |
||||
{ |
||||
if (isset(self::$hooks[$hook][$priority])) |
||||
{ |
||||
return true; |
||||
} |
||||
else |
||||
/** |
||||
* Current Hook |
||||
* |
||||
* Get the currently running action hook |
||||
* |
||||
*/ |
||||
public static function current() |
||||
{ |
||||
return false; |
||||
return self::$current_hook; |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Hook Exists |
||||
*/ |
||||
public static function exists($name) |
||||
{ |
||||
if (isset(self::$hooks[$name])) |
||||
/** |
||||
* Has Run |
||||
*/ |
||||
public static function has($hook, $priority = 10) |
||||
{ |
||||
return true; |
||||
if (isset(self::$hooks[$hook][$priority])) |
||||
{ |
||||
return true; |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
else |
||||
|
||||
|
||||
/** |
||||
* Hook Exists |
||||
*/ |
||||
public static function exists($name) |
||||
{ |
||||
return false; |
||||
if (isset(self::$hooks[$name])) |
||||
{ |
||||
return true; |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
?> |
@ -1,350 +1,349 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* Класс, предназначенный для управления журналом системных сообщений |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
*/ |
||||
|
||||
class AVE_Logs |
||||
{ |
||||
|
||||
/** |
||||
* Свойства класса |
||||
*/ |
||||
|
||||
/** |
||||
* Файлы для хранения записей |
||||
* AVE.cms |
||||
* |
||||
* Класс, предназначенный для управления журналом системных сообщений |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @public |
||||
*/ |
||||
public $_404dir = '/cache/404.php'; |
||||
public $_logdir = '/cache/log.php'; |
||||
public $_sqldir = '/cache/sql.php'; |
||||
|
||||
/** |
||||
* Внутренние методы класса |
||||
*/ |
||||
class AVE_Logs |
||||
{ |
||||
|
||||
/** |
||||
* Свойства класса |
||||
*/ |
||||
|
||||
/** |
||||
* Внешние методы класса |
||||
*/ |
||||
/** |
||||
* Файлы для хранения записей |
||||
* |
||||
* @public |
||||
*/ |
||||
public $_404dir = '/tmp/logs/404.php'; |
||||
public $_logdir = '/tmp/logs/log.php'; |
||||
public $_sqldir = '/tmp/logs/sql.php'; |
||||
|
||||
/** |
||||
* Метод, предназначенный для отображения всех записей Журнала событий |
||||
* |
||||
* Внутренние методы класса |
||||
*/ |
||||
function logList() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
$logdata = array(); |
||||
|
||||
$logfile = BASE_DIR.$this->_logdir; |
||||
/** |
||||
* Внешние методы класса |
||||
*/ |
||||
|
||||
if(file_exists($logfile)) |
||||
@eval('?>'.file_get_contents($logfile).'<?'); |
||||
/** |
||||
* Метод, предназначенный для отображения всех записей Журнала событий |
||||
* |
||||
*/ |
||||
function logList() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
arsort($logdata); |
||||
$logdata = array(); |
||||
|
||||
// Передаем данные в шаблон для вывода и отображаем страницу |
||||
$AVE_Template->assign('logs', $logdata); |
||||
$AVE_Template->assign('content', $AVE_Template->fetch('logs/logs.tpl')); |
||||
} |
||||
$logfile = BASE_DIR.$this->_logdir; |
||||
|
||||
/** |
||||
* Метод, предназначенный для отображения всех записей Журнала событий 404 |
||||
* |
||||
*/ |
||||
function List404() |
||||
{ |
||||
global $AVE_Template; |
||||
if(file_exists($logfile)) |
||||
@eval(' ?>'.file_get_contents($logfile).'<?php '); |
||||
|
||||
$log404 = array(); |
||||
arsort($logdata); |
||||
|
||||
$logfile = BASE_DIR . $this->_404dir; |
||||
// Передаем данные в шаблон для вывода и отображаем страницу |
||||
$AVE_Template->assign('logs', $logdata); |
||||
$AVE_Template->assign('content', $AVE_Template->fetch('logs/logs.tpl')); |
||||
} |
||||
|
||||
if(file_exists($logfile)) |
||||
include($logfile); |
||||
/** |
||||
* Метод, предназначенный для отображения всех записей Журнала событий 404 |
||||
* |
||||
*/ |
||||
function List404() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
arsort($log404); |
||||
$log404 = array(); |
||||
|
||||
// Передаем данные в шаблон для вывода и отображаем страницу |
||||
$AVE_Template->assign('logs', $log404); |
||||
$AVE_Template->assign('content', $AVE_Template->fetch('logs/404.tpl')); |
||||
} |
||||
$logfile = BASE_DIR . $this->_404dir; |
||||
|
||||
/** |
||||
* Метод, предназначенный для отображения всех записей Журнала событий 404 |
||||
* |
||||
*/ |
||||
function ListSql() |
||||
{ |
||||
global $AVE_Template; |
||||
if(file_exists($logfile)) |
||||
include($logfile); |
||||
|
||||
$logsql = array(); |
||||
arsort($log404); |
||||
|
||||
$logfile = BASE_DIR . $this->_sqldir; |
||||
// Передаем данные в шаблон для вывода и отображаем страницу |
||||
$AVE_Template->assign('logs', $log404); |
||||
$AVE_Template->assign('content', $AVE_Template->fetch('logs/404.tpl')); |
||||
} |
||||
|
||||
if(file_exists($logfile)) |
||||
include($logfile); |
||||
/** |
||||
* Метод, предназначенный для отображения всех записей Журнала событий 404 |
||||
* |
||||
*/ |
||||
function ListSql() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
arsort($logsql); |
||||
$logsql = array(); |
||||
|
||||
// Передаем данные в шаблон для вывода и отображаем страницу |
||||
$AVE_Template->assign('logs', $logsql); |
||||
$AVE_Template->assign('content', $AVE_Template->fetch('logs/sql.tpl')); |
||||
} |
||||
$logfile = BASE_DIR . $this->_sqldir; |
||||
|
||||
/** |
||||
* Метод, предназначенный для удаление записей Журнала событий |
||||
* |
||||
*/ |
||||
function logDelete() |
||||
{ |
||||
global $AVE_Template; |
||||
if(file_exists($logfile)) |
||||
include($logfile); |
||||
|
||||
$logfile = BASE_DIR . $this->_logdir; |
||||
arsort($logsql); |
||||
|
||||
if(file_exists($logfile)) |
||||
unlink($logfile); |
||||
// Передаем данные в шаблон для вывода и отображаем страницу |
||||
$AVE_Template->assign('logs', $logsql); |
||||
$AVE_Template->assign('content', $AVE_Template->fetch('logs/sql.tpl')); |
||||
} |
||||
|
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_CLEAN')); |
||||
/** |
||||
* Метод, предназначенный для удаление записей Журнала событий |
||||
* |
||||
*/ |
||||
function logDelete() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
header('Location:index.php?do=logs&cp=' . SESSION); |
||||
exit; |
||||
} |
||||
$logfile = BASE_DIR . $this->_logdir; |
||||
|
||||
/** |
||||
* Метод, предназначенный для удаление записей Журнала событий 404 |
||||
* |
||||
*/ |
||||
function DeleteSql() |
||||
{ |
||||
global $AVE_Template; |
||||
if(file_exists($logfile)) |
||||
unlink($logfile); |
||||
|
||||
$logfile = BASE_DIR . $this->_sqldir; |
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_CLEAN')); |
||||
|
||||
if(file_exists($logfile)) |
||||
unlink($logfile); |
||||
header('Location:index.php?do=logs&cp=' . SESSION); |
||||
exit; |
||||
} |
||||
|
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_SQL_CLEAN')); |
||||
/** |
||||
* Метод, предназначенный для удаление записей Журнала событий 404 |
||||
* |
||||
*/ |
||||
function DeleteSql() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
header('Location:index.php?do=logs&action=logsql&cp=' . SESSION); |
||||
exit; |
||||
} |
||||
$logfile = BASE_DIR . $this->_sqldir; |
||||
|
||||
/** |
||||
* Метод, предназначенный для удаление записей Журнала событий 404 |
||||
* |
||||
*/ |
||||
function Delete404() |
||||
{ |
||||
global $AVE_Template; |
||||
if(file_exists($logfile)) |
||||
unlink($logfile); |
||||
|
||||
$logfile = BASE_DIR . $this->_404dir; |
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_SQL_CLEAN')); |
||||
|
||||
if(file_exists($logfile)) |
||||
unlink($logfile); |
||||
header('Location:index.php?do=logs&action=logsql&cp=' . SESSION); |
||||
exit; |
||||
} |
||||
|
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_404_CLEAN')); |
||||
/** |
||||
* Метод, предназначенный для удаление записей Журнала событий 404 |
||||
* |
||||
*/ |
||||
function Delete404() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
header('Location:index.php?do=logs&action=log404&cp=' . SESSION); |
||||
exit; |
||||
} |
||||
$logfile = BASE_DIR . $this->_404dir; |
||||
|
||||
/** |
||||
* Метод, предназначенный для экспорта системных сообщений |
||||
* |
||||
*/ |
||||
function logExport() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
// Определяем тип файла (CSV), формат имени файла, разделители и т.д. |
||||
$datstring = ''; |
||||
$dattype = 'text/csv'; |
||||
$datname = 'system_log_' . date('dmyhis', time()) . '.csv'; |
||||
|
||||
$separator = ';'; |
||||
$enclosed = '"'; |
||||
|
||||
// Выполняем запрос к БД на получение списка всех системных сообщений |
||||
$logdata=array(); |
||||
$logfile = BASE_DIR.$this->_logdir; |
||||
if(file_exists($logfile)) |
||||
@eval('?>'.file_get_contents($logfile).'<?'); |
||||
arsort($logdata); |
||||
$fieldcount = count($logdata[0]); |
||||
|
||||
foreach($logdata[0] as $k=>$v) |
||||
$datstring .= $enclosed . $k . $enclosed . $separator; |
||||
$datstring .= PHP_EOL; |
||||
|
||||
// Циклически обрабатываем данные и формируем CSV файл с учетом указаны выше параметров |
||||
foreach($logdata as $k=>$v) |
||||
if(file_exists($logfile)) |
||||
unlink($logfile); |
||||
|
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_404_CLEAN')); |
||||
|
||||
header('Location:index.php?do=logs&action=log404&cp=' . SESSION); |
||||
exit; |
||||
} |
||||
|
||||
/** |
||||
* Метод, предназначенный для экспорта системных сообщений |
||||
* |
||||
*/ |
||||
function logExport() |
||||
{ |
||||
foreach ($v as $key => $val) |
||||
global $AVE_Template; |
||||
|
||||
// Определяем тип файла (CSV), формат имени файла, разделители и т.д. |
||||
$datstring = ''; |
||||
$dattype = 'text/csv'; |
||||
$datname = 'system_log_' . date('dmyhis', time()) . '.csv'; |
||||
|
||||
$separator = ';'; |
||||
$enclosed = '"'; |
||||
|
||||
// Выполняем запрос к БД на получение списка всех системных сообщений |
||||
$logdata=array(); |
||||
$logfile = BASE_DIR.$this->_logdir; |
||||
if(file_exists($logfile)) |
||||
@eval(' ?>'.file_get_contents($logfile).'<?php '); |
||||
arsort($logdata); |
||||
$fieldcount = count($logdata[0]); |
||||
|
||||
foreach($logdata[0] as $k=>$v) |
||||
$datstring .= $enclosed . $k . $enclosed . $separator; |
||||
$datstring .= PHP_EOL; |
||||
|
||||
// Циклически обрабатываем данные и формируем CSV файл с учетом указаны выше параметров |
||||
foreach($logdata as $k=>$v) |
||||
{ |
||||
$val = ($key=='log_time') ? date('d-m-Y, H:i:s', $val) : $val; |
||||
$datstring .= ($val == '') ? $separator : $enclosed . stripslashes($val) . $enclosed . $separator; |
||||
foreach ($v as $key => $val) |
||||
{ |
||||
$val = ($key=='log_time') ? date('d-m-Y, H:i:s', $val) : $val; |
||||
$datstring .= ($val == '') ? $separator : $enclosed . stripslashes($val) . $enclosed . $separator; |
||||
} |
||||
$datstring .= PHP_EOL; |
||||
} |
||||
$datstring .= PHP_EOL; |
||||
} |
||||
|
||||
// Определяем заголовки документа |
||||
header('Content-Encoding: windows-1251'); |
||||
header('Content-type: text/csv; charset=windows-1251'); |
||||
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
||||
header('Content-Disposition: attachment; filename="' . $datname . '"'); |
||||
header('Content-Length: ' . strlen($datstring)); |
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||||
header('Pragma: public'); |
||||
// Определяем заголовки документа |
||||
header('Content-Encoding: windows-1251'); |
||||
header('Content-type: text/csv; charset=windows-1251'); |
||||
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
||||
header('Content-Disposition: attachment; filename="' . $datname . '"'); |
||||
header('Content-Length: ' . strlen($datstring)); |
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||||
header('Pragma: public'); |
||||
|
||||
// Выводим данные |
||||
echo mb_convert_encoding($datstring, 'windows-1251', 'UTF-8'); |
||||
// Выводим данные |
||||
echo mb_convert_encoding($datstring, 'windows-1251', 'UTF-8'); |
||||
|
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_EXPORT')); |
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_EXPORT')); |
||||
|
||||
exit; |
||||
} |
||||
exit; |
||||
} |
||||
|
||||
/** |
||||
* Метод, предназначенный для экспорта сообщений 404 |
||||
* |
||||
*/ |
||||
function Export404() |
||||
{ |
||||
global $AVE_Template; |
||||
/** |
||||
* Метод, предназначенный для экспорта сообщений 404 |
||||
* |
||||
*/ |
||||
function Export404() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
// Определяем тип файла (CSV), формат имени файла, разделители и т.д. |
||||
$datstring = ''; |
||||
$dattype = 'text/csv'; |
||||
$datname = 'system_log_' . date('dmyhis', time()) . '.csv'; |
||||
// Определяем тип файла (CSV), формат имени файла, разделители и т.д. |
||||
$datstring = ''; |
||||
$dattype = 'text/csv'; |
||||
$datname = 'system_log_' . date('dmyhis', time()) . '.csv'; |
||||
|
||||
$separator = ';'; |
||||
$enclosed = '"'; |
||||
$separator = ';'; |
||||
$enclosed = '"'; |
||||
|
||||
// Выполняем запрос к БД на получение списка всех системных сообщений |
||||
$log404 = array(); |
||||
// Выполняем запрос к БД на получение списка всех системных сообщений |
||||
$log404 = array(); |
||||
|
||||
$logfile = BASE_DIR.$this->_404dir; |
||||
$logfile = BASE_DIR.$this->_404dir; |
||||
|
||||
if(file_exists($logfile)) |
||||
include($logfile); |
||||
if(file_exists($logfile)) |
||||
include($logfile); |
||||
|
||||
arsort($log404); |
||||
arsort($log404); |
||||
|
||||
$fieldcount = count($log404[0]); |
||||
$fieldcount = count($log404[0]); |
||||
|
||||
foreach($log404[0] as $k=>$v) |
||||
$datstring .= $enclosed . $k . $enclosed . $separator; |
||||
foreach($log404[0] as $k=>$v) |
||||
$datstring .= $enclosed . $k . $enclosed . $separator; |
||||
|
||||
$datstring .= PHP_EOL; |
||||
$datstring .= PHP_EOL; |
||||
|
||||
// Циклически обрабатываем данные и формируем CSV файл с учетом указаны выше параметров |
||||
foreach($log404 as $k=>$v) |
||||
{ |
||||
foreach ($v as $key => $val) |
||||
// Циклически обрабатываем данные и формируем CSV файл с учетом указаны выше параметров |
||||
foreach($log404 as $k=>$v) |
||||
{ |
||||
$val = ($key=='log_time') ? date('d-m-Y, H:i:s', $val) : $val; |
||||
$datstring .= ($val == '') ? $separator : $enclosed . stripslashes($val) . $enclosed . $separator; |
||||
foreach ($v as $key => $val) |
||||
{ |
||||
$val = ($key=='log_time') ? date('d-m-Y, H:i:s', $val) : $val; |
||||
$datstring .= ($val == '') ? $separator : $enclosed . stripslashes($val) . $enclosed . $separator; |
||||
} |
||||
$datstring .= PHP_EOL; |
||||
} |
||||
$datstring .= PHP_EOL; |
||||
} |
||||
|
||||
// Определяем заголовки документа |
||||
header('Content-Encoding: windows-1251'); |
||||
header('Content-type: text/csv; charset=windows-1251'); |
||||
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
||||
header('Content-Disposition: attachment; filename="' . $datname . '"'); |
||||
header('Content-Length: ' . strlen($datstring)); |
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||||
header('Pragma: public'); |
||||
// Определяем заголовки документа |
||||
header('Content-Encoding: windows-1251'); |
||||
header('Content-type: text/csv; charset=windows-1251'); |
||||
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
||||
header('Content-Disposition: attachment; filename="' . $datname . '"'); |
||||
header('Content-Length: ' . strlen($datstring)); |
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||||
header('Pragma: public'); |
||||
|
||||
// Выводим данные |
||||
echo mb_convert_encoding(strip_tags($datstring), 'windows-1251', 'UTF-8'); |
||||
// Выводим данные |
||||
echo mb_convert_encoding(strip_tags($datstring), 'windows-1251', 'UTF-8'); |
||||
|
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_404_EXPORT')); |
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_404_EXPORT')); |
||||
|
||||
exit; |
||||
} |
||||
exit; |
||||
} |
||||
|
||||
/** |
||||
* Метод, предназначенный для экспорта сообщений 404 |
||||
* |
||||
*/ |
||||
function ExportSql() |
||||
{ |
||||
global $AVE_Template; |
||||
/** |
||||
* Метод, предназначенный для экспорта сообщений 404 |
||||
* |
||||
*/ |
||||
function ExportSql() |
||||
{ |
||||
global $AVE_Template; |
||||
|
||||
// Определяем тип файла (CSV), формат имени файла, разделители и т.д. |
||||
$datstring = ''; |
||||
$dattype = 'text/csv'; |
||||
$datname = 'system_log_' . date('dmyhis', time()) . '.csv'; |
||||
// Определяем тип файла (CSV), формат имени файла, разделители и т.д. |
||||
$datstring = ''; |
||||
$dattype = 'text/csv'; |
||||
$datname = 'system_log_' . date('dmyhis', time()) . '.csv'; |
||||
|
||||
$separator = ';'; |
||||
$enclosed = '"'; |
||||
$separator = ';'; |
||||
$enclosed = '"'; |
||||
|
||||
// Выполняем запрос к БД на получение списка всех системных сообщений |
||||
$logsql = array(); |
||||
// Выполняем запрос к БД на получение списка всех системных сообщений |
||||
$logsql = array(); |
||||
|
||||
$logfile = BASE_DIR . $this->_sqldir; |
||||
$logfile = BASE_DIR . $this->_sqldir; |
||||
|
||||
if(file_exists($logfile)) |
||||
include($logfile); |
||||
if(file_exists($logfile)) |
||||
include($logfile); |
||||
|
||||
arsort($logsql); |
||||
arsort($logsql); |
||||
|
||||
$fieldcount = count($logsql[0]); |
||||
$fieldcount = count($logsql[0]); |
||||
|
||||
foreach($logsql[0] as $k=>$v) |
||||
$datstring .= $enclosed . $k . $enclosed . $separator; |
||||
foreach($logsql[0] as $k=>$v) |
||||
$datstring .= $enclosed . $k . $enclosed . $separator; |
||||
|
||||
$datstring .= PHP_EOL; |
||||
$datstring .= PHP_EOL; |
||||
|
||||
// Циклически обрабатываем данные и формируем CSV файл с учетом указаны выше параметров |
||||
foreach($logsql as $k => $v) |
||||
{ |
||||
foreach ($v as $key => $val) |
||||
// Циклически обрабатываем данные и формируем CSV файл с учетом указаны выше параметров |
||||
foreach($logsql as $k => $v) |
||||
{ |
||||
$val = ($key == 'log_time') ? date('d-m-Y, H:i:s', $val) : $val; |
||||
$val = ($key == 'log_text') ? serialize($val) : $val; |
||||
$datstring .= ($val == '') ? $separator : $enclosed . stripslashes($val) . $enclosed . $separator; |
||||
foreach ($v as $key => $val) |
||||
{ |
||||
$val = ($key == 'log_time') ? date('d-m-Y, H:i:s', $val) : $val; |
||||
$val = ($key == 'log_text') ? serialize($val) : $val; |
||||
$datstring .= ($val == '') ? $separator : $enclosed . stripslashes($val) . $enclosed . $separator; |
||||
} |
||||
$datstring .= PHP_EOL; |
||||
} |
||||
$datstring .= PHP_EOL; |
||||
} |
||||
|
||||
// Определяем заголовки документа |
||||
header('Content-Encoding: windows-1251'); |
||||
header('Content-type: text/csv; charset=windows-1251'); |
||||
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
||||
header('Content-Disposition: attachment; filename="' . $datname . '"'); |
||||
header('Content-Length: ' . strlen($datstring)); |
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||||
header('Pragma: public'); |
||||
|
||||
// Выводим данные |
||||
echo mb_convert_encoding(strip_tags($datstring), 'windows-1251', 'UTF-8'); |
||||
// Определяем заголовки документа |
||||
header('Content-Encoding: windows-1251'); |
||||
header('Content-type: text/csv; charset=windows-1251'); |
||||
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
||||
header('Content-Disposition: attachment; filename="' . $datname . '"'); |
||||
header('Content-Length: ' . strlen($datstring)); |
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||||
header('Pragma: public'); |
||||
|
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_SQL_EXPORT')); |
||||
// Выводим данные |
||||
echo mb_convert_encoding(strip_tags($datstring), 'windows-1251', 'UTF-8'); |
||||
|
||||
exit; |
||||
} |
||||
// Сохраняем системное сообщение в журнал |
||||
reportLog($AVE_Template->get_config_vars('LOGS_SQL_EXPORT')); |
||||
|
||||
} |
||||
exit; |
||||
} |
||||
|
||||
} |
||||
?> |
@ -1,140 +1,142 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
class AVE_Session |
||||
{ |
||||
|
||||
public $sess_lifetime; |
||||
|
||||
function __construct() |
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
class AVE_Session |
||||
{ |
||||
ini_set('session.save_handler', 'user'); |
||||
|
||||
$this->sess_lifetime = (defined('SESSION_LIFETIME') && is_numeric(SESSION_LIFETIME)) |
||||
? SESSION_LIFETIME |
||||
: (get_cfg_var("session.gc_maxlifetime") < 1440 ? 1440 : get_cfg_var("session.gc_maxlifetime")); |
||||
public $sess_lifetime; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/* Open session */ |
||||
function _open($sess_save_path, $session_name) |
||||
{ |
||||
global $sess_save_path, $sess_session_name; |
||||
|
||||
$sess_save_path = BASE_DIR . '/session'; |
||||
$sess_session_name = $session_name; |
||||
|
||||
return true; |
||||
} |
||||
function __construct() |
||||
{ |
||||
ini_set('session.save_handler', 'user'); |
||||
|
||||
/* Close session */ |
||||
function _close() |
||||
{ |
||||
$this->_gc($this->sess_lifetime); |
||||
return true; |
||||
} |
||||
$this->sess_lifetime = (defined('SESSION_LIFETIME') && is_numeric(SESSION_LIFETIME)) |
||||
? SESSION_LIFETIME |
||||
: (get_cfg_var("session.gc_maxlifetime") < 1440 ? 1440 : get_cfg_var("session.gc_maxlifetime")); |
||||
|
||||
/* Read session */ |
||||
function _read($id) |
||||
{ |
||||
global $sess_save_path, $sess_session_name, $sess_session_id; |
||||
return true; |
||||
} |
||||
|
||||
$sess_session_id = $id; |
||||
$sess_file = $this->_folder() . '/' . $id . '.sess'; |
||||
/* Open session */ |
||||
function _open($sess_save_path, $session_name) |
||||
{ |
||||
global $sess_save_path, $sess_session_name; |
||||
|
||||
if (!file_exists($sess_file)) return ""; |
||||
$sess_save_path = BASE_DIR . '/tmp/session'; |
||||
$sess_session_name = $session_name; |
||||
|
||||
if ($fp = @fopen($sess_file, "r")) |
||||
{ |
||||
$sess_data = fread($fp, filesize($sess_file)); |
||||
return($sess_data); |
||||
return true; |
||||
} |
||||
else |
||||
|
||||
/* Close session */ |
||||
function _close() |
||||
{ |
||||
return ''; |
||||
$this->_gc($this->sess_lifetime); |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
/* Write new data */ |
||||
function _write ($id, $sess_data) |
||||
{ |
||||
global $sess_save_path, $sess_session_name, $sess_session_id; |
||||
/* Read session */ |
||||
function _read($id) |
||||
{ |
||||
global $sess_save_path, $sess_session_name, $sess_session_id; |
||||
|
||||
$sess_session_id = $id; |
||||
$sess_file = $this->_folder() . '/' . $id . '.sess'; |
||||
$sess_session_id = $id; |
||||
$sess_file = $this->_folder() . '/' . $id . '.sess'; |
||||
|
||||
if(!file_exists($this->_folder())) |
||||
mkdir($this->_folder(), 0777, true); |
||||
if (!file_exists($sess_file)) return ""; |
||||
|
||||
if ($fp = @fopen($sess_file, "w")) |
||||
{ |
||||
return fwrite($fp, $sess_data); |
||||
if ($fp = @fopen($sess_file, "r")) |
||||
{ |
||||
$sess_data = fread($fp, filesize($sess_file)); |
||||
return($sess_data); |
||||
} |
||||
else |
||||
{ |
||||
return ''; |
||||
} |
||||
} |
||||
else |
||||
|
||||
/* Write new data */ |
||||
function _write ($id, $sess_data) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
global $sess_save_path, $sess_session_name, $sess_session_id; |
||||
|
||||
/* Destroy session */ |
||||
function _destroy ($id) |
||||
{ |
||||
global $sess_save_path, $sess_session_name, $sess_session_id; |
||||
$sess_session_id = $id; |
||||
$sess_file = $this->_folder() . '/' . $id . '.sess'; |
||||
|
||||
$sess_session_id = $id; |
||||
$sess_dir = $this->_folder(); |
||||
$sess_file = $sess_dir . '/' . $id . '.sess'; |
||||
if(!file_exists($this->_folder())) |
||||
mkdir($this->_folder(), 0777, true); |
||||
|
||||
return @unlink($sess_file); |
||||
} |
||||
if ($fp = @fopen($sess_file, "w")) |
||||
{ |
||||
return fwrite($fp, $sess_data); |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/* Garbage collection, deletes old sessions */ |
||||
function _gc ($maxlifetime) |
||||
{ |
||||
global $sess_save_path, $sess_session_id; |
||||
/* Destroy session */ |
||||
function _destroy ($id) |
||||
{ |
||||
global $sess_save_path, $sess_session_name, $sess_session_id; |
||||
|
||||
$this->_clear($sess_save_path, 'sess', $maxlifetime); |
||||
$sess_session_id = $id; |
||||
$sess_dir = $this->_folder(); |
||||
$sess_file = $sess_dir . '/' . $id . '.sess'; |
||||
|
||||
return true; |
||||
} |
||||
return @unlink($sess_file); |
||||
} |
||||
|
||||
function _clear($dir, $mask, $maxlifetime) |
||||
{ |
||||
foreach(glob($dir . '/*') as $filename) { |
||||
/* Garbage collection, deletes old sessions */ |
||||
function _gc ($maxlifetime) |
||||
{ |
||||
global $sess_save_path, $sess_session_id; |
||||
|
||||
if(strtolower(substr($filename, strlen($filename) - strlen($mask), strlen($mask))) == strtolower($mask)) { |
||||
if((filemtime($filename) + $maxlifetime) < time()) |
||||
@unlink($filename); |
||||
} |
||||
$this->_clear($sess_save_path, 'sess', $maxlifetime); |
||||
|
||||
if(is_dir($filename)) |
||||
if (!count(glob($filename.'/*'))) @rmdir($filename); |
||||
self::_clear($filename, $mask, $maxlifetime); |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
function _folder() |
||||
{ |
||||
global $sess_session_id, $sess_save_path; |
||||
function _clear($dir, $mask, $maxlifetime) |
||||
{ |
||||
foreach(glob($dir . '/*') as $filename) |
||||
{ |
||||
if (strtolower(substr($filename, strlen($filename) - strlen($mask), strlen($mask))) == strtolower($mask)) |
||||
{ |
||||
if ((filemtime($filename) + $maxlifetime) < time()) |
||||
@unlink($filename); |
||||
} |
||||
|
||||
if (is_dir($filename)) |
||||
if (! count(glob($filename.'/*'))) |
||||
@rmdir($filename); |
||||
|
||||
self::_clear($filename, $mask, $maxlifetime); |
||||
} |
||||
} |
||||
|
||||
return $sess_save_path . '/' . mb_substr($sess_session_id, 0, 3); |
||||
} |
||||
function _folder() |
||||
{ |
||||
global $sess_session_id, $sess_save_path; |
||||
|
||||
function __destruct () |
||||
{ |
||||
register_shutdown_function('session_write_close'); |
||||
} |
||||
return $sess_save_path . '/' . mb_substr($sess_session_id, 0, 3); |
||||
} |
||||
|
||||
} |
||||
function __destruct () |
||||
{ |
||||
register_shutdown_function('session_write_close'); |
||||
} |
||||
} |
||||
?> |
@ -1,50 +1,49 @@
|
||||
<? |
||||
|
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
|
||||
/** |
||||
* Обработка парного тега [tag:hide:X,X:text]...[/tag:hide] (скрытый текст) |
||||
* Заменяет скрываемый текст в зависимости от группы пользователя |
||||
* |
||||
* @param string $data обрабатываемый текст |
||||
* @return string обработанный текст |
||||
*/ |
||||
function parse_hide($data) |
||||
{ |
||||
static $matches = null; |
||||
|
||||
static $i = null; |
||||
|
||||
preg_match_all('/\[tag:hide:(\d+,)*'. UGROUP .'(,\d+)*(:.*?)?].*?\[\/tag:hide]/s', $data, $matches, PREG_SET_ORDER); |
||||
|
||||
$count_matches = count($matches); |
||||
|
||||
if ($count_matches > 0) |
||||
<?php |
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
|
||||
/** |
||||
* Обработка парного тега [tag:hide:X,X:text]...[/tag:hide] (скрытый текст) |
||||
* Заменяет скрываемый текст в зависимости от группы пользователя |
||||
* |
||||
* @param string $data обрабатываемый текст |
||||
* @return string обработанный текст |
||||
*/ |
||||
function parse_hide($data) |
||||
{ |
||||
for ($i=0; $i <= $count_matches; $i++) |
||||
static $matches = null; |
||||
|
||||
static $i = null; |
||||
|
||||
preg_match_all('/\[tag:hide:(\d+,)*'. UGROUP .'(,\d+)*(:.*?)?].*?\[\/tag:hide]/s', $data, $matches, PREG_SET_ORDER); |
||||
|
||||
$count_matches = count($matches); |
||||
|
||||
if ($count_matches > 0) |
||||
{ |
||||
for ($i=0; $i <= $count_matches; $i++) |
||||
{ |
||||
|
||||
$hidden_text = substr(@$matches[$i][3], 1); |
||||
$hidden_text = substr(@$matches[$i][3], 1); |
||||
|
||||
if ($hidden_text == "") |
||||
$hidden_text = trim(get_settings('hidden_text')); |
||||
if ($hidden_text == "") |
||||
$hidden_text = trim(get_settings('hidden_text')); |
||||
|
||||
$data = preg_replace('/\[tag:hide:(\d+,)*'. UGROUP .'(,\d+)*(:.*?)?].*?\[\/tag:hide]/s', $hidden_text, $data, 1); |
||||
$data = preg_replace('/\[tag:hide:(\d+,)*'. UGROUP .'(,\d+)*(:.*?)?].*?\[\/tag:hide]/s', $hidden_text, $data, 1); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$data = preg_replace('/\[tag:hide:\d+(,\d+)*.*?](.*?)\[\/tag:hide]/s', '\\2', $data); |
||||
$data = preg_replace('/\[tag:hide:\d+(,\d+)*.*?](.*?)\[\/tag:hide]/s', '\\2', $data); |
||||
|
||||
return $data; |
||||
} |
||||
return $data; |
||||
} |
||||
?> |
@ -1,107 +1,112 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
|
||||
/** |
||||
* Запись события в лог |
||||
* |
||||
* @param string $message Текст сообщения |
||||
* @param int $typ тип сообщения |
||||
* @param int $rub номер рубрики |
||||
* @return |
||||
*/ |
||||
function reportLog($message, $typ = 0, $rub = 0) |
||||
{ |
||||
$logdata=array(); |
||||
|
||||
$logfile=BASE_DIR.'/cache/log.php'; |
||||
if(file_exists($logfile)) |
||||
@eval('?>'.file_get_contents($logfile).'<?'); |
||||
$logdata[]=array( |
||||
'log_time' =>time(), |
||||
'log_ip' =>$_SERVER['REMOTE_ADDR'], |
||||
'log_url' =>$_SERVER['QUERY_STRING'], |
||||
'log_user_id' =>(isset($_SESSION['user_id']) ? $_SESSION['user_id'] : '0'), |
||||
'log_user_name' =>(isset($_SESSION['user_name']) ? $_SESSION['user_name'] : 'Anonymous'), |
||||
'log_text' =>$message, |
||||
'log_type' =>(int)$typ, |
||||
'log_rubric' =>(int)$rub |
||||
); |
||||
$messlimit = 1000; |
||||
$logdata = array_slice($logdata,-1*$messlimit); |
||||
file_put_contents($logfile,'<?php $logdata=' . var_export($logdata,true) . ' ?>');
|
||||
} |
||||
|
||||
/** |
||||
* Запись события в лог для Sql ошибок |
||||
* |
||||
* @param string $message Текст сообщения |
||||
* @return |
||||
*/ |
||||
function reportSqlLog($message) |
||||
{ |
||||
$logsql = array(); |
||||
|
||||
$logfile = BASE_DIR . '/cache/sql.php'; |
||||
|
||||
if(file_exists($logfile)) |
||||
@eval('?>'.file_get_contents($logfile).'<?'); |
||||
|
||||
$logsql[] = array( |
||||
'log_time' =>time(), |
||||
'log_ip' =>$_SERVER['REMOTE_ADDR'], |
||||
'log_url' =>$_SERVER['QUERY_STRING'], |
||||
'log_user_id' =>$_SESSION['user_id'], |
||||
'log_user_name' =>$_SESSION['user_name'], |
||||
'log_text' =>$message |
||||
); |
||||
|
||||
$messlimit = 1000; |
||||
|
||||
$logsql = array_slice($logsql,-1*$messlimit); |
||||
|
||||
file_put_contents($logfile, '<?php $logsql = ' . var_export($logsql, true) . ' ?>');
|
||||
} |
||||
|
||||
/** |
||||
* Запись события в лог для 404 ошибок |
||||
* |
||||
* @param string $message Текст сообщения |
||||
* @return |
||||
*/ |
||||
function report404() |
||||
{ |
||||
$log404 = array(); |
||||
|
||||
$logfile = BASE_DIR . '/cache/404.php'; |
||||
|
||||
if(file_exists($logfile)) |
||||
@include($logfile); |
||||
|
||||
$log404[] = array( |
||||
'log_time' => time(), |
||||
'log_ip' => @$_SERVER['REMOTE_ADDR'], |
||||
'log_query' => @$_SERVER['QUERY_STRING'], |
||||
'log_user_agent' => @$_SERVER['HTTP_USER_AGENT'], |
||||
'log_user_referer' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''), |
||||
'log_request_uri' => @$_SERVER['REQUEST_URI'] |
||||
); |
||||
|
||||
$messlimit = 1000; |
||||
|
||||
$log404 = array_slice($log404, -1*$messlimit); |
||||
|
||||
file_put_contents($logfile,'<?php $log404=' . var_export($log404, true) . ' ?>');
|
||||
} |
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
|
||||
/** |
||||
* Запись события в лог |
||||
* |
||||
* @param string $message Текст сообщения |
||||
* @param int $typ тип сообщения |
||||
* @param int $rub номер рубрики |
||||
* @return |
||||
*/ |
||||
function reportLog($message, $typ = 0, $rub = 0) |
||||
{ |
||||
$logdata=array(); |
||||
|
||||
$logfile = BASE_DIR . '/tmp/logs/log.php'; |
||||
|
||||
if (file_exists($logfile)) |
||||
@eval(' ?'.'>' . file_get_contents($logfile) . '<?'.'php '); |
||||
|
||||
$logdata[]=array( |
||||
'log_time' => time(), |
||||
'log_ip' => $_SERVER['REMOTE_ADDR'], |
||||
'log_url' => $_SERVER['QUERY_STRING'], |
||||
'log_user_id' => (isset($_SESSION['user_id']) ? $_SESSION['user_id'] : '0'), |
||||
'log_user_name' => (isset($_SESSION['user_name']) ? $_SESSION['user_name'] : 'Anonymous'), |
||||
'log_text' => $message, |
||||
'log_type' => (int)$typ, |
||||
'log_rubric' => (int)$rub |
||||
); |
||||
|
||||
$messlimit = 1000; |
||||
|
||||
$logdata = array_slice($logdata,-1*$messlimit); |
||||
|
||||
file_put_contents($logfile,'<?php $logdata=' . var_export($logdata,true) . ' ?>');
|
||||
} |
||||
|
||||
/** |
||||
* Запись события в лог для Sql ошибок |
||||
* |
||||
* @param string $message Текст сообщения |
||||
* @return |
||||
*/ |
||||
function reportSqlLog($message) |
||||
{ |
||||
$logsql = array(); |
||||
|
||||
$logfile = BASE_DIR . '/tmp/logs/sql.php'; |
||||
|
||||
if (file_exists($logfile)) |
||||
@eval(' ?'.'>' . file_get_contents($logfile) . '<?'.'php '); |
||||
|
||||
$logsql[] = array( |
||||
'log_time' => time(), |
||||
'log_ip' => $_SERVER['REMOTE_ADDR'], |
||||
'log_url' => $_SERVER['QUERY_STRING'], |
||||
'log_user_id' => $_SESSION['user_id'], |
||||
'log_user_name' => $_SESSION['user_name'], |
||||
'log_text' => $message |
||||
); |
||||
|
||||
$messlimit = 1000; |
||||
|
||||
$logsql = array_slice($logsql,-1*$messlimit); |
||||
|
||||
file_put_contents($logfile, '<?php $logsql = ' . var_export($logsql, true) . ' ?>');
|
||||
} |
||||
|
||||
/** |
||||
* Запись события в лог для 404 ошибок |
||||
* |
||||
* @param string $message Текст сообщения |
||||
* @return |
||||
*/ |
||||
function report404() |
||||
{ |
||||
$log404 = array(); |
||||
|
||||
$logfile = BASE_DIR . '/tmp/logs/404.php'; |
||||
|
||||
if (file_exists($logfile)) |
||||
@include($logfile); |
||||
|
||||
$log404[] = array( |
||||
'log_time' => time(), |
||||
'log_ip' => @$_SERVER['REMOTE_ADDR'], |
||||
'log_query' => @$_SERVER['QUERY_STRING'], |
||||
'log_user_agent' => @$_SERVER['HTTP_USER_AGENT'], |
||||
'log_user_referer' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''), |
||||
'log_request_uri' => @$_SERVER['REQUEST_URI'] |
||||
); |
||||
|
||||
$messlimit = 1000; |
||||
|
||||
$log404 = array_slice($log404, -1*$messlimit); |
||||
|
||||
file_put_contents($logfile,'<?php $log404=' . var_export($log404, true) . ' ?>');
|
||||
} |
||||
|
||||
?> |
@ -1,77 +1,77 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
function get_securecode() |
||||
{ |
||||
@require('./db.config.php'); |
||||
function get_securecode() |
||||
{ |
||||
@require('./db.config.php'); |
||||
|
||||
if (! isset($config)) die; |
||||
if (! isset($config)) die; |
||||
|
||||
if (! (isset($config) && isset($_GET['cp_secureimage']) && is_numeric($_GET['cp_secureimage']))) die; |
||||
if (! (isset($config) && isset($_GET['cp_secureimage']) && is_numeric($_GET['cp_secureimage']))) die; |
||||
|
||||
if (! @mysql_select_db($config['dbname'], @mysql_connect($config['dbhost'], $config['dbuser'], $config['dbpass']))) die; |
||||
if (! @mysql_select_db($config['dbname'], @mysql_connect($config['dbhost'], $config['dbuser'], $config['dbpass']))) die; |
||||
|
||||
if (! $row = mysql_fetch_assoc(mysql_query("SELECT Code FROM " . $config['dbpref'] . "_antispam WHERE Id = '" . $_GET['cp_secureimage'] . "'"))) die; |
||||
if (! $row = mysql_fetch_assoc(mysql_query("SELECT Code FROM " . $config['dbpref'] . "_antispam WHERE Id = '" . $_GET['cp_secureimage'] . "'"))) die; |
||||
|
||||
return $row['Code']; |
||||
} |
||||
return $row['Code']; |
||||
} |
||||
|
||||
$code = get_securecode(); |
||||
$code = get_securecode(); |
||||
|
||||
$font = 'fonts/ft16.ttf'; |
||||
$raster = 0; |
||||
$step = 10; |
||||
$size = 26; |
||||
$code_top = 38; |
||||
$rect_width = 120; |
||||
$rect_height = 40; |
||||
$font = 'fonts/ft16.ttf'; |
||||
$raster = 0; |
||||
$step = 10; |
||||
$size = 26; |
||||
$code_top = 38; |
||||
$rect_width = 120; |
||||
$rect_height = 40; |
||||
|
||||
$bild = imagecreate(++$rect_width, ++$rect_height); |
||||
$back = imagecolorallocate($bild, 255, 255, 255); |
||||
$gelb = imagecolorallocate($bild, 238, 192, 10); |
||||
$schwarz = imagecolorallocate($bild, 0, 0, 0); |
||||
$grau = imagecolorallocate($bild, 204, 204, 204); |
||||
$dunkelgrau = imagecolorallocate($bild, 119, 119, 119); |
||||
$bild = imagecreate(++$rect_width, ++$rect_height); |
||||
$back = imagecolorallocate($bild, 255, 255, 255); |
||||
$gelb = imagecolorallocate($bild, 238, 192, 10); |
||||
$schwarz = imagecolorallocate($bild, 0, 0, 0); |
||||
$grau = imagecolorallocate($bild, 204, 204, 204); |
||||
$dunkelgrau = imagecolorallocate($bild, 119, 119, 119); |
||||
|
||||
// Prevent the browser from caching the result. |
||||
// Date in the past |
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ; |
||||
// always modified |
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ; |
||||
// HTTP/1.1 |
||||
header('Cache-Control: no-store, no-cache, must-revalidate') ; |
||||
header('Cache-Control: post-check=0, pre-check=0', false) ; |
||||
// HTTP/1.0 |
||||
header('Pragma: no-cache') ; |
||||
// Prevent the browser from caching the result. |
||||
// Date in the past |
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ; |
||||
// always modified |
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ; |
||||
// HTTP/1.1 |
||||
header('Cache-Control: no-store, no-cache, must-revalidate') ; |
||||
header('Cache-Control: post-check=0, pre-check=0', false) ; |
||||
// HTTP/1.0 |
||||
header('Pragma: no-cache') ; |
||||
|
||||
// Set the response format. |
||||
header('Content-type: image/jpeg'); |
||||
// Set the response format. |
||||
header('Content-type: image/jpeg'); |
||||
|
||||
$count_vert = $rect_width/$step; |
||||
$count_hori = $rect_height/$step; |
||||
if ($raster == 1) |
||||
{ |
||||
for($i=0;$i<$count_vert;$i++) imageline($bild, $i*$step, 0, $i*$step, $rect_height, $grau); |
||||
for($i=0;$i<$count_hori;$i++) imageline($bild, 0, $i*$step, $rect_width, $i*$step, $grau); |
||||
} |
||||
else |
||||
{ |
||||
for($a=0;$a<$count_hori;$a++) for($i=0;$i<$count_vert;$i++) imagesetpixel($bild, $i*$step, $a*$step, $grau); |
||||
} |
||||
$count_vert = $rect_width/$step; |
||||
$count_hori = $rect_height/$step; |
||||
if ($raster == 1) |
||||
{ |
||||
for($i=0;$i<$count_vert;$i++) imageline($bild, $i*$step, 0, $i*$step, $rect_height, $grau); |
||||
for($i=0;$i<$count_hori;$i++) imageline($bild, 0, $i*$step, $rect_width, $i*$step, $grau); |
||||
} |
||||
else |
||||
{ |
||||
for($a=0;$a<$count_hori;$a++) for($i=0;$i<$count_vert;$i++) imagesetpixel($bild, $i*$step, $a*$step, $grau); |
||||
} |
||||
|
||||
imagettftext($bild, $size, 7, 25, $code_top, $dunkelgrau, $font, $code); |
||||
imagerectangle($bild, 0, 0, $rect_width, $rect_height, $dunkelgrau); |
||||
imagejpeg($bild); |
||||
imagedestroy($bild); |
||||
imagettftext($bild, $size, 7, 25, $code_top, $dunkelgrau, $font, $code); |
||||
imagerectangle($bild, 0, 0, $rect_width, $rect_height, $dunkelgrau); |
||||
imagejpeg($bild); |
||||
imagedestroy($bild); |
||||
|
||||
?> |
@ -1,533 +1,528 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
/** |
||||
* Функции |
||||
*/ |
||||
|
||||
function check_mysql_connect($dbhost = '', $dbuser = '', $dbpass = '') |
||||
{ |
||||
if ($dbhost != '' && $dbuser != '') |
||||
/** |
||||
* AVE.cms |
||||
* |
||||
* @package AVE.cms |
||||
* @version 3.x |
||||
* @filesource |
||||
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru |
||||
* |
||||
* @license GPL v.2 |
||||
*/ |
||||
|
||||
/** |
||||
* Функции |
||||
*/ |
||||
|
||||
function check_mysql_connect($dbhost = '', $dbuser = '', $dbpass = '') |
||||
{ |
||||
if (@mysqli_connect($dbhost, $dbuser, $dbpass)) return true; |
||||
} |
||||
if ($dbhost != '' && $dbuser != '') |
||||
{ |
||||
if (@mysqli_connect($dbhost, $dbuser, $dbpass)) return true; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
function check_mysql_query($link = '', $sql = '') |
||||
{ |
||||
if ($sql != '' && $link != '') |
||||
function check_mysql_query($link = '', $sql = '') |
||||
{ |
||||
if (@mysqli_query($link, $sql)) return true; |
||||
} |
||||
if ($sql != '' && $link != '') |
||||
{ |
||||
if (@mysqli_query($link, $sql)) return true; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
function check_db_connect($dbhost = '', $dbuser = '', $dbpass = '', $dbname = '') |
||||
{ |
||||
if ($dbhost != '' && $dbuser != '' && $dbname != '') |
||||
function check_db_connect($dbhost = '', $dbuser = '', $dbpass = '', $dbname = '') |
||||
{ |
||||
if (@mysqli_select_db(@mysqli_connect($dbhost, $dbuser, $dbpass), $dbname)) return true; |
||||
if ($dbhost != '' && $dbuser != '' && $dbname != '') |
||||
{ |
||||
if (@mysqli_select_db(@mysqli_connect($dbhost, $dbuser, $dbpass), $dbname)) return true; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
function check_installed($prefix) |
||||
{ |
||||
global $config; |
||||
|
||||
function check_installed($prefix) |
||||
{ |
||||
global $config; |
||||
$mysql = @mysqli_connect($config['dbhost'], $config['dbuser'], $config['dbpass'], $config['dbname']); |
||||
$query = @mysqli_query($mysql, "SELECT 1 FROM " . $prefix . "_users LIMIT 1"); |
||||
|
||||
$mysql = @mysqli_connect($config['dbhost'], $config['dbuser'], $config['dbpass'], $config['dbname']); |
||||
$query = @mysqli_query($mysql, "SELECT 1 FROM " . $prefix . "_users LIMIT 1"); |
||||
if (@mysqli_num_rows($query)) return true; |
||||
else return false; |
||||
} |
||||
|
||||
if (@mysqli_num_rows($query)) return true; |
||||
else return false; |
||||
} |
||||
function check_required() |
||||
{ |
||||
global $error_is_required, $lang_i; |
||||
|
||||
function check_required() |
||||
{ |
||||
global $error_is_required, $lang_i; |
||||
$required_php = 522; |
||||
$required = array(); |
||||
$required[] = '/install/eula/ru.tpl'; |
||||
|
||||
$required_php = 522; |
||||
$required = array(); |
||||
$required[] = '/install/eula/ru.tpl'; |
||||
foreach ($required as $is_required) |
||||
{ |
||||
if (@!is_file(BASE_DIR . $is_required)) |
||||
{ |
||||
array_push($error_is_required, $lang_i['error_is_required'] . $is_required . $lang_i['error_is_required_2'] ); |
||||
} |
||||
} |
||||
|
||||
foreach ($required as $is_required) |
||||
{ |
||||
if (@!is_file(BASE_DIR . $is_required)) |
||||
$myphp = @PHP_VERSION; |
||||
if ($myphp) |
||||
{ |
||||
array_push($error_is_required, $lang_i['error_is_required'] . $is_required . $lang_i['error_is_required_2'] ); |
||||
$myphp_v = str_replace('.', '', $myphp); |
||||
if ($myphp_v < $required_php) |
||||
{ |
||||
array_push($error_is_required, $lang_i['phpversion_toold'] . $required_php); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$myphp = @PHP_VERSION; |
||||
if ($myphp) |
||||
function check_writable() |
||||
{ |
||||
$myphp_v = str_replace('.', '', $myphp); |
||||
if ($myphp_v < $required_php) |
||||
global $error_is_required, $lang_i; |
||||
|
||||
$writeable = array(); |
||||
$writeable[] = '/tmp/'; |
||||
$writeable[] = '/tmp/cache/'; |
||||
$writeable[] = '/uploads/'; |
||||
$writeable[] = '/config/db.config.php'; |
||||
|
||||
foreach ($writeable as $must_writeable) |
||||
{ |
||||
array_push($error_is_required, $lang_i['phpversion_toold'] . $required_php); |
||||
if (! is_writable(BASE_DIR . $must_writeable)) |
||||
{ |
||||
array_push($error_is_required, $lang_i['error_is_writeable'] . $must_writeable . $lang_i['error_is_writeable_2'] ); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
function check_writable() |
||||
{ |
||||
global $error_is_required, $lang_i; |
||||
function clean_db ($name="", $prefix="", $mysql_connect) |
||||
{ |
||||
@mysqli_select_db($mysql_connect, $name); |
||||
$query = @mysqli_query($mysql_connect, "SHOW TABLES FROM " . $name); |
||||
|
||||
$writeable = array(); |
||||
$writeable[] = '/cache/'; |
||||
$writeable[] = '/uploads/'; |
||||
$writeable[] = '/inc/db.config.php'; |
||||
while ($row = @mysqli_fetch_array($query, MYSQL_NUM)) |
||||
{ |
||||
if (preg_match("/^" . $prefix . "/", $row[0])) |
||||
{ |
||||
@mysqli_query($mysql_connect ,"DROP TABLE " . $row[0]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
foreach ($writeable as $must_writeable) |
||||
/** |
||||
* Convert size from 10M to bytes |
||||
* |
||||
* @param string $str e.g. 10M |
||||
* @return int |
||||
*/ |
||||
function convertSizeToBytes($str) |
||||
{ |
||||
if (!is_writable(BASE_DIR . $must_writeable)) |
||||
$str = trim($str); |
||||
if (strlen($str) > 0) |
||||
{ |
||||
$cLastAlpha = strtolower(substr($str, -1)); |
||||
$size = intval($str); |
||||
switch($cLastAlpha) |
||||
{ |
||||
case 't': |
||||
$size *= 1024; |
||||
case 'g': |
||||
$size *= 1024; |
||||
case 'm': |
||||
$size *= 1024; |
||||
case 'k': |
||||
$size *= 1024; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
array_push($error_is_required, $lang_i['error_is_writeable'] . $must_writeable . $lang_i['error_is_writeable_2'] ); |
||||
$size = 0; |
||||
} |
||||
return $size; |
||||
} |
||||
} |
||||
|
||||
function clean_db ($name="", $prefix="", $mysql_connect) |
||||
{ |
||||
@mysqli_select_db($mysql_connect, $name); |
||||
$query = @mysqli_query($mysql_connect, "SHOW TABLES FROM " . $name); |
||||
|
||||
while ($row = @mysqli_fetch_array($query, MYSQL_NUM)) |
||||
/** |
||||
* Get GD version |
||||
* @return string |
||||
*/ |
||||
function getGdVersion() |
||||
{ |
||||
if (preg_match("/^" . $prefix . "/", $row[0])) |
||||
if (function_exists('gd_info')) |
||||
{ |
||||
@mysqli_query($mysql_connect ,"DROP TABLE " . $row[0]); |
||||
$gd_info = @gd_info(); |
||||
return preg_replace('/[^0-9\.]/', '', $gd_info['GD Version']); |
||||
} |
||||
|
||||
return NULL; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Convert size from 10M to bytes |
||||
* |
||||
* @param string $str e.g. 10M |
||||
* @return int |
||||
*/ |
||||
function convertSizeToBytes($str) |
||||
{ |
||||
$str = trim($str); |
||||
if (strlen($str) > 0) |
||||
|
||||
/** |
||||
* Get PCRE version |
||||
* @return string |
||||
*/ |
||||
function getPcreVersion() |
||||
{ |
||||
defined('PCRE_VERSION') |
||||
? list($version) = explode(' ', constant('PCRE_VERSION')) |
||||
: $version = NULL; |
||||
|
||||
return $version; |
||||
} |
||||
|
||||
/** |
||||
* Get MySQL version |
||||
* @return string |
||||
*/ |
||||
function getMySQLVersion() { |
||||
$output = mysqli_get_client_info(); |
||||
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version); |
||||
return $version[0]; |
||||
} |
||||
|
||||
function check_param($level, $text) |
||||
{ |
||||
$cLastAlpha = strtolower(substr($str, -1)); |
||||
$size = intval($str); |
||||
switch($cLastAlpha) |
||||
$level = intval($level); |
||||
|
||||
switch ($level) |
||||
{ |
||||
case 't': |
||||
$size *= 1024; |
||||
case 'g': |
||||
$size *= 1024; |
||||
case 'm': |
||||
$size *= 1024; |
||||
case 'k': |
||||
$size *= 1024; |
||||
//Параметр не соответствует. |
||||
case 2: |
||||
$img = 'ico_delete'; |
||||
break; |
||||
//Несоответствие, не влияющее на функционирование системы. |
||||
case 1: |
||||
$img = 'ico_ok'; |
||||
break; |
||||
//Параметр соответствует. |
||||
case 0: |
||||
$img = 'ico_ok_green'; |
||||
break; |
||||
//По умолчанию |
||||
default: |
||||
$img = 'ico_ok_noproblem'; |
||||
break; |
||||
} |
||||
return $img; |
||||
} |
||||
else |
||||
|
||||
|
||||
/** |
||||
* @subpackage install |
||||
*/ |
||||
error_reporting(E_ERROR); |
||||
ini_set('display_errors', 7); |
||||
|
||||
global $config; |
||||
|
||||
ob_start(); |
||||
|
||||
define('SETUP', 1); |
||||
|
||||
define('BASE_DIR', str_replace("\\", "/", dirname(dirname(__FILE__)))); |
||||
|
||||
if (! is_writable(BASE_DIR . '/cache/smarty/')) |
||||
die('Cache folder is not writeable!'); |
||||
|
||||
include(BASE_DIR . '/config/db.config.php'); |
||||
include(BASE_DIR . '/inc/config.php'); |
||||
include(BASE_DIR . '/functions/func.common.php'); |
||||
include(BASE_DIR . '/functions/func.helpers.php'); |
||||
include(BASE_DIR . '/class/class.template.php'); |
||||
|
||||
$AVE_Template = new AVE_Template(BASE_DIR . '/install/tpl/'); |
||||
|
||||
$lang_file = BASE_DIR . '/install/lang/ru.txt'; |
||||
|
||||
$AVE_Template->config_load($lang_file); |
||||
|
||||
$ver = APP_NAME . ' v' . APP_VERSION; |
||||
|
||||
$db_connect = check_db_connect($config['dbhost'], $config['dbuser'], $config['dbpass'], $config['dbname']); |
||||
$check_installed = check_installed($config['dbpref']); |
||||
|
||||
if ((true === $db_connect) && $_REQUEST['step'] != 'finish' && check_installed($config['dbpref'])) { |
||||
echo '<pre>' . $AVE_Template->get_config_vars('installed') . '</pre>'; |
||||
exit; |
||||
}; |
||||
|
||||
$error_is_required = array(); |
||||
|
||||
check_required(); |
||||
check_writable(); |
||||
|
||||
// include_once(BASE_DIR . '/inc/errors.php'); |
||||
|
||||
$count_error = sizeof((array) $error_is_required); |
||||
if (1 == $count_error) |
||||
{ |
||||
$size = 0; |
||||
$AVE_Template->assign('error_header', $AVE_Template->get_config_vars('erroro')); |
||||
} |
||||
return $size; |
||||
} |
||||
|
||||
/** |
||||
* Get GD version |
||||
* @return string |
||||
*/ |
||||
function getGdVersion() |
||||
{ |
||||
if (function_exists('gd_info')) |
||||
elseif ($count_error > 1) |
||||
{ |
||||
$gd_info = @gd_info(); |
||||
return preg_replace('/[^0-9\.]/', '', $gd_info['GD Version']); |
||||
$AVE_Template->assign('error_header', $AVE_Template->get_config_vars('erroro_more')); |
||||
} |
||||
|
||||
return NULL; |
||||
} |
||||
|
||||
/** |
||||
* Get PCRE version |
||||
* @return string |
||||
*/ |
||||
function getPcreVersion() |
||||
{ |
||||
defined('PCRE_VERSION') |
||||
? list($version) = explode(' ', constant('PCRE_VERSION')) |
||||
: $version = NULL; |
||||
|
||||
return $version; |
||||
} |
||||
|
||||
/** |
||||
* Get MySQL version |
||||
* @return string |
||||
*/ |
||||
function getMySQLVersion() { |
||||
$output = mysqli_get_client_info(); |
||||
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version); |
||||
return $version[0]; |
||||
} |
||||
|
||||
function check_param($level, $text) |
||||
{ |
||||
$level = intval($level); |
||||
|
||||
switch ($level) |
||||
if ($count_error > 0 && ! (isset($_REQUEST['force']) && 1 == $_REQUEST['force'])) |
||||
{ |
||||
//Параметр не соответствует. |
||||
case 2: |
||||
$img = 'ico_delete'; |
||||
break; |
||||
//Несоответствие, не влияющее на функционирование системы. |
||||
case 1: |
||||
$img = 'ico_ok'; |
||||
break; |
||||
//Параметр соответствует. |
||||
case 0: |
||||
$img = 'ico_ok_green'; |
||||
break; |
||||
//По умолчанию |
||||
default: |
||||
$img = 'ico_ok_noproblem'; |
||||
break; |
||||
$AVE_Template->assign('error_is_required', $error_is_required); |
||||
$AVE_Template->display('error.tpl'); |
||||
exit; |
||||
} |
||||
return $img; |
||||
} |
||||
|
||||
$_REQUEST['step'] = isset($_REQUEST['step']) ? $_REQUEST['step'] : ''; |
||||
|
||||
// Минимальные требования к системе |
||||
define('PHP_version', '5.6'); |
||||
define('MySQL_version', '5.0.0'); |
||||
define('GD_version', '2.0'); |
||||
define('PCRE_version', '7.0'); |
||||
define('JSON', $AVE_Template->get_config_vars('mess_on')); |
||||
define('MbString', $AVE_Template->get_config_vars('mess_on')); |
||||
define('SimpleXML', $AVE_Template->get_config_vars('mess_on')); |
||||
define('Iconv', $AVE_Template->get_config_vars('mess_on')); |
||||
define('XSLT', $AVE_Template->get_config_vars('mess_supported')); |
||||
define('Data_limit', '2'); // Mb |
||||
define('TIME_limit', '30'); // Sec |
||||
define('DISC_space', '30'); // Mb |
||||
define('RAM_space', '32M'); // Mb |
||||
define('SAFE_MODE', $AVE_Template->get_config_vars('mess_off')); |
||||
define('REGISTER_GLOBALS', $AVE_Template->get_config_vars('mess_off')); |
||||
define('MAGIC_QUOTES_GPC', $AVE_Template->get_config_vars('mess_off')); |
||||
|
||||
switch ($_REQUEST['step']) |
||||
{ |
||||
//Начало |
||||
case '' : |
||||
|
||||
//Шаг 1 |
||||
case '1' : |
||||
$AVE_Template->display('step1.tpl'); |
||||
break; |
||||
|
||||
//Шаг 2 |
||||
case '2' : |
||||
$AVE_Template->display('step2.tpl'); |
||||
break; |
||||
|
||||
//Шаг 3 |
||||
case '3' : |
||||
$test['php_version'] = phpversion(); |
||||
$test['mysql_version'] = getMySQLVersion(); |
||||
$test['gd_version'] = getGdVersion(); |
||||
$test['pcre_version'] = getPcreVersion(); |
||||
$test['json'] = function_exists('json_encode') ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['simplexml'] = function_exists('simplexml_load_string') ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['mbstring'] = function_exists('mb_internal_encoding') ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['iconv'] = function_exists('iconv') ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['xslt'] = (function_exists('xslt_create') || function_exists('domxml_xslt_stylesheet') || (class_exists('DomDocument') && class_exists('XsltProcessor'))) ? XSLT : $AVE_Template->get_config_vars('mess_unsupported'); |
||||
$test['data_limit'] = ini_get('post_max_size') ? ini_get('post_max_size') : $AVE_Template->get_config_vars('mess_undefined'); |
||||
$test['time_limit'] = ini_get('max_execution_time') ? ini_get('max_execution_time') : $AVE_Template->get_config_vars('mess_undefined'); |
||||
$test['disk_space'] = round(@disk_free_space($_SERVER['DOCUMENT_ROOT']) / 1024 / 1024, 2); |
||||
$test['memmory_limit'] = ini_get('memory_limit') ? ini_get('memory_limit') : $AVE_Template->get_config_vars('mess_undefined'); |
||||
$test['s_m'] = (ini_get('safe_mode') == 1) ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['r_g'] = (ini_get('register_globals') == 1) ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['m_q'] = (ini_get('magic_quotes_gpc') == 1 || ini_get('magic_quotes_runtime') == 1 || ini_get('magic_quotes_sybase') == 1) ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
|
||||
$check['php_version'] = check_param(version_compare(phpversion(), PHP_version, ">=") ? 0 : 2, $test['php_version']); |
||||
$check['mysql_version'] = check_param(version_compare(getMySQLVersion(), MySQL_version, ">=") ? 0 : 2, $test['mysql_version']); |
||||
$check['gd_version'] = check_param(version_compare($test['gd_version'], GD_version, ">=") ? 0 : 2, $test['gd_version']); |
||||
$check['pcre_version'] = check_param(version_compare($test['pcre_version'], PCRE_version, ">=") ? 0 : 2, $test['pcre_version']); |
||||
$check['mbstring'] = check_param(function_exists('mb_internal_encoding') ? 0 : 2, $test['mbstring']); |
||||
$check['json'] = check_param(function_exists('json_encode') ? 0 : 2, $test['json']); |
||||
$check['simplexml'] = check_param(function_exists('simplexml_load_string') ? 0 : 2, $test['simplexml']); |
||||
$check['iconv'] = check_param(function_exists('iconv') ? 0 : 2, $test['iconv']); |
||||
$check['xslt'] = check_param(($test['xslt'] == XSLT) ? 0 : 2, $test['xslt']); |
||||
$check['data_limit'] = check_param(($test['data_limit'] != $AVE_Template->get_config_vars('mess_undefined') && version_compare($test['data_limit'], Data_limit, ">=")) ? 0 : 2, $test['data_limit']); |
||||
$check['time_limit'] = check_param(($test['time_limit'] != $AVE_Template->get_config_vars('mess_undefined') && $test['time_limit'] >= TIME_limit) ? 0 : 2, ($test['time_limit'] != $AVE_Template->get_config_vars('mess_undefined')) ? $test['time_limit'] . " " . $AVE_Template->get_config_vars('seconds') : $t_l); |
||||
$check['disk_space'] = check_param(($test['disk_space'] != $AVE_Template->get_config_vars('mess_undefined') && $test['disk_space'] >= DISC_space) ? 0 : 2, ($test['disk_space'] != $AVE_Template->get_config_vars('mess_undefined')) ? $test['disk_space'].$AVE_Template->get_config_vars('megabytes') : $test['disk_space']); |
||||
$check['memmory_limit'] = check_param(($test['memmory_limit'] != $AVE_Template->get_config_vars('mess_undefined') && convertSizeToBytes($test['memmory_limit']) >= convertSizeToBytes(RAM_space)) ? 0 : (($test['memmory_limit'] != $AVE_Template->get_config_vars('mess_undefined')) ? 2 : 1), $test['memmory_limit']); |
||||
$check['s_m'] = check_param(($test['s_m'] == SAFE_MODE) ? 0 : 1, $test['s_m']); |
||||
$check['r_g'] = check_param(($test['r_g'] == REGISTER_GLOBALS) ? 0 : 1, $test['r_g']); |
||||
$check['m_q'] = check_param(($test['m_q'] == MAGIC_QUOTES_GPC) ? 0 : 1, $test['m_q']); |
||||
|
||||
$AVE_Template->assign('check', $check); |
||||
$AVE_Template->assign('test', $test); |
||||
$AVE_Template->display('step3.tpl'); |
||||
break; |
||||
|
||||
//Шаг 4 |
||||
case '4' : |
||||
if (!empty($_POST['dbname']) && !empty($_POST['dbprefix'])) |
||||
{ |
||||
$db_connect = check_db_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']); |
||||
|
||||
/** |
||||
* @subpackage install |
||||
*/ |
||||
error_reporting(E_ERROR); |
||||
ini_set('display_errors', 7); |
||||
|
||||
global $config; |
||||
|
||||
ob_start(); |
||||
|
||||
define('SETUP', 1); |
||||
|
||||
define('BASE_DIR', str_replace("\\", "/", dirname(dirname(__FILE__)))); |
||||
|
||||
if (!is_writable(BASE_DIR . '/cache/smarty/')) die('Cache folder is not writeable!'); |
||||
|
||||
include(BASE_DIR . '/inc/db.config.php'); |
||||
include(BASE_DIR . '/inc/config.php'); |
||||
include(BASE_DIR . '/functions/func.common.php'); |
||||
include(BASE_DIR . '/functions/func.helpers.php'); |
||||
include(BASE_DIR . '/class/class.template.php'); |
||||
|
||||
$AVE_Template = new AVE_Template(BASE_DIR . '/install/tpl/'); |
||||
|
||||
$lang_file = BASE_DIR . '/install/lang/ru.txt'; |
||||
|
||||
$AVE_Template->config_load($lang_file); |
||||
|
||||
$ver = APP_NAME . ' v' . APP_VERSION; |
||||
|
||||
$db_connect = check_db_connect($config['dbhost'], $config['dbuser'], $config['dbpass'], $config['dbname']); |
||||
$check_installed = check_installed($config['dbpref']); |
||||
|
||||
if ((true === $db_connect) && $_REQUEST['step'] != 'finish' && check_installed($config['dbpref'])) { |
||||
echo '<pre>' . $AVE_Template->get_config_vars('installed') . '</pre>'; |
||||
exit; |
||||
}; |
||||
|
||||
$error_is_required = array(); |
||||
|
||||
check_required(); |
||||
check_writable(); |
||||
|
||||
// include_once(BASE_DIR . '/inc/errors.php'); |
||||
|
||||
$count_error = sizeof((array) $error_is_required); |
||||
if (1 == $count_error) |
||||
{ |
||||
$AVE_Template->assign('error_header', $AVE_Template->get_config_vars('erroro')); |
||||
} |
||||
elseif ($count_error > 1) |
||||
{ |
||||
$AVE_Template->assign('error_header', $AVE_Template->get_config_vars('erroro_more')); |
||||
} |
||||
|
||||
if ($count_error > 0 && ! (isset($_REQUEST['force']) && 1 == $_REQUEST['force'])) |
||||
{ |
||||
$AVE_Template->assign('error_is_required', $error_is_required); |
||||
$AVE_Template->display('error.tpl'); |
||||
exit; |
||||
} |
||||
|
||||
$_REQUEST['step'] = isset($_REQUEST['step']) ? $_REQUEST['step'] : ''; |
||||
|
||||
// Минимальные требования к системе |
||||
define('PHP_version', '5.5'); |
||||
define('MySQL_version', '5.0.0'); |
||||
define('GD_version', '2.0'); |
||||
define('PCRE_version', '7.0'); |
||||
define('JSON', $AVE_Template->get_config_vars('mess_on')); |
||||
define('MbString', $AVE_Template->get_config_vars('mess_on')); |
||||
define('SimpleXML', $AVE_Template->get_config_vars('mess_on')); |
||||
define('Iconv', $AVE_Template->get_config_vars('mess_on')); |
||||
define('XSLT', $AVE_Template->get_config_vars('mess_supported')); |
||||
define('Data_limit', '2'); // Mb |
||||
define('TIME_limit', '30'); // Sec |
||||
define('DISC_space', '30'); // Mb |
||||
define('RAM_space', '32M'); // Mb |
||||
define('SAFE_MODE', $AVE_Template->get_config_vars('mess_off')); |
||||
define('REGISTER_GLOBALS', $AVE_Template->get_config_vars('mess_off')); |
||||
define('MAGIC_QUOTES_GPC', $AVE_Template->get_config_vars('mess_off')); |
||||
|
||||
switch ($_REQUEST['step']) |
||||
{ |
||||
//Начало |
||||
case '' : |
||||
|
||||
//Шаг 1 |
||||
case '1' : |
||||
$AVE_Template->display('step1.tpl'); |
||||
break; |
||||
|
||||
//Шаг 2 |
||||
case '2' : |
||||
$AVE_Template->display('step2.tpl'); |
||||
break; |
||||
|
||||
//Шаг 3 |
||||
case '3' : |
||||
$test['php_version'] = phpversion(); |
||||
$test['mysql_version'] = getMySQLVersion(); |
||||
$test['gd_version'] = getGdVersion(); |
||||
$test['pcre_version'] = getPcreVersion(); |
||||
$test['json'] = function_exists('json_encode') ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['simplexml'] = function_exists('simplexml_load_string') ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['mbstring'] = function_exists('mb_internal_encoding') ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['iconv'] = function_exists('iconv') ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['xslt'] = (function_exists('xslt_create') || function_exists('domxml_xslt_stylesheet') || (class_exists('DomDocument') && class_exists('XsltProcessor'))) ? XSLT : $AVE_Template->get_config_vars('mess_unsupported'); |
||||
$test['data_limit'] = ini_get('post_max_size') ? ini_get('post_max_size') : $AVE_Template->get_config_vars('mess_undefined'); |
||||
$test['time_limit'] = ini_get('max_execution_time') ? ini_get('max_execution_time') : $AVE_Template->get_config_vars('mess_undefined'); |
||||
$test['disk_space'] = round(@disk_free_space($_SERVER['DOCUMENT_ROOT']) / 1024 / 1024, 2); |
||||
$test['memmory_limit'] = ini_get('memory_limit') ? ini_get('memory_limit') : $AVE_Template->get_config_vars('mess_undefined'); |
||||
$test['s_m'] = (ini_get('safe_mode') == 1) ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['r_g'] = (ini_get('register_globals') == 1) ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
$test['m_q'] = (ini_get('magic_quotes_gpc') == 1 || ini_get('magic_quotes_runtime') == 1 || ini_get('magic_quotes_sybase') == 1) ? $AVE_Template->get_config_vars('mess_on') : $AVE_Template->get_config_vars('mess_off'); |
||||
|
||||
$check['php_version'] = check_param(version_compare(phpversion(), PHP_version, ">=") ? 0 : 2, $test['php_version']); |
||||
$check['mysql_version'] = check_param(version_compare(getMySQLVersion(), MySQL_version, ">=") ? 0 : 2, $test['mysql_version']); |
||||
$check['gd_version'] = check_param(version_compare($test['gd_version'], GD_version, ">=") ? 0 : 2, $test['gd_version']); |
||||
$check['pcre_version'] = check_param(version_compare($test['pcre_version'], PCRE_version, ">=") ? 0 : 2, $test['pcre_version']); |
||||
$check['mbstring'] = check_param(function_exists('mb_internal_encoding') ? 0 : 2, $test['mbstring']); |
||||
$check['json'] = check_param(function_exists('json_encode') ? 0 : 2, $test['json']); |
||||
$check['simplexml'] = check_param(function_exists('simplexml_load_string') ? 0 : 2, $test['simplexml']); |
||||
$check['iconv'] = check_param(function_exists('iconv') ? 0 : 2, $test['iconv']); |
||||
$check['xslt'] = check_param(($test['xslt'] == XSLT) ? 0 : 2, $test['xslt']); |
||||
$check['data_limit'] = check_param(($test['data_limit'] != $AVE_Template->get_config_vars('mess_undefined') && version_compare($test['data_limit'], Data_limit, ">=")) ? 0 : 2, $test['data_limit']); |
||||
$check['time_limit'] = check_param(($test['time_limit'] != $AVE_Template->get_config_vars('mess_undefined') && $test['time_limit'] >= TIME_limit) ? 0 : 2, ($test['time_limit'] != $AVE_Template->get_config_vars('mess_undefined')) ? $test['time_limit'] . " " . $AVE_Template->get_config_vars('seconds') : $t_l); |
||||
$check['disk_space'] = check_param(($test['disk_space'] != $AVE_Template->get_config_vars('mess_undefined') && $test['disk_space'] >= DISC_space) ? 0 : 2, ($test['disk_space'] != $AVE_Template->get_config_vars('mess_undefined')) ? $test['disk_space'].$AVE_Template->get_config_vars('megabytes') : $test['disk_space']); |
||||
$check['memmory_limit'] = check_param(($test['memmory_limit'] != $AVE_Template->get_config_vars('mess_undefined') && convertSizeToBytes($test['memmory_limit']) >= convertSizeToBytes(RAM_space)) ? 0 : (($test['memmory_limit'] != $AVE_Template->get_config_vars('mess_undefined')) ? 2 : 1), $test['memmory_limit']); |
||||
$check['s_m'] = check_param(($test['s_m'] == SAFE_MODE) ? 0 : 1, $test['s_m']); |
||||
$check['r_g'] = check_param(($test['r_g'] == REGISTER_GLOBALS) ? 0 : 1, $test['r_g']); |
||||
$check['m_q'] = check_param(($test['m_q'] == MAGIC_QUOTES_GPC) ? 0 : 1, $test['m_q']); |
||||
|
||||
$AVE_Template->assign('check', $check); |
||||
$AVE_Template->assign('test', $test); |
||||
$AVE_Template->display('step3.tpl'); |
||||
break; |
||||
|
||||
//Шаг 4 |
||||
case '4' : |
||||
if (!empty($_POST['dbname']) && !empty($_POST['dbprefix'])) |
||||
{ |
||||
$db_connect = check_db_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']); |
||||
|
||||
if (true === $db_connect) { |
||||
$mysql_connect = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']); |
||||
@mysqli_select_db($mysql_connect, $_POST['dbname']); |
||||
} |
||||
if (true === $db_connect) { |
||||
$mysql_connect = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']); |
||||
@mysqli_select_db($mysql_connect, $_POST['dbname']); |
||||
} |
||||
|
||||
// Очищаем бд (по префиксу) |
||||
if (isset($_REQUEST["dbclean"]) && $_REQUEST["dbclean"] == "1") { |
||||
clean_db($_POST['dbname'], $_POST['dbprefix'], $mysql_connect); |
||||
} |
||||
// Очищаем бд (по префиксу) |
||||
if (isset($_REQUEST["dbclean"]) && $_REQUEST["dbclean"] == "1") { |
||||
clean_db($_POST['dbname'], $_POST['dbprefix'], $mysql_connect); |
||||
} |
||||
|
||||
// Создать новую БД |
||||
if(isset($_REQUEST['dbcreat'])){ |
||||
// Создать новую БД |
||||
if(isset($_REQUEST['dbcreat'])){ |
||||
|
||||
$link = check_mysql_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']); |
||||
$link = check_mysql_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']); |
||||
|
||||
if (false === $link) { |
||||
$AVE_Template->assign('warning', 'Ошибка соединения: ' . mysqli_error()); |
||||
} else { |
||||
$mysqli_connect = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']); |
||||
} |
||||
if (false === $link) { |
||||
$AVE_Template->assign('warning', 'Ошибка соединения: ' . mysqli_error()); |
||||
} else { |
||||
$mysqli_connect = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']); |
||||
} |
||||
|
||||
if(false === $db_connect) { |
||||
@mysqli_query($mysqli_connect, "SET collation_server = 'utf8_general_ci'"); |
||||
@mysqli_query($mysqli_connect, "SET character_set_server = 'utf8'"); |
||||
if(false === $db_connect) { |
||||
@mysqli_query($mysqli_connect, "SET collation_server = 'utf8_general_ci'"); |
||||
@mysqli_query($mysqli_connect, "SET character_set_server = 'utf8'"); |
||||
|
||||
$sql = 'CREATE DATABASE ' . $_POST['dbname']; |
||||
$sql = 'CREATE DATABASE ' . $_POST['dbname']; |
||||
|
||||
if (false === check_mysql_query($mysqli_connect, $sql)) { |
||||
$AVE_Template->assign('warning', 'Ошибка при создании базы данных: ' . mysqli_error() . "\n"); |
||||
if (false === check_mysql_query($mysqli_connect, $sql)) { |
||||
$AVE_Template->assign('warning', 'Ошибка при создании базы данных: ' . mysqli_error() . "\n"); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
$check_installed = check_installed($_POST['dbprefix']); |
||||
$check_installed = check_installed($_POST['dbprefix']); |
||||
|
||||
$connect = check_db_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']); |
||||
$connect = check_db_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']); |
||||
|
||||
if (true === $connect && false === $check_installed) |
||||
{ |
||||
if (! @is_writeable(BASE_DIR . '/inc/db.config.php')) |
||||
if (true === $connect && false === $check_installed) |
||||
{ |
||||
$AVE_Template->assign('config_isnt_writeable', 1); |
||||
$AVE_Template->display('error.tpl'); |
||||
exit; |
||||
} |
||||
if (! @is_writeable(BASE_DIR . '/config/db.config.php')) |
||||
{ |
||||
$AVE_Template->assign('config_isnt_writeable', 1); |
||||
$AVE_Template->display('error.tpl'); |
||||
exit; |
||||
} |
||||
|
||||
$fp = @fopen(BASE_DIR . '/inc/db.config.php', 'w+'); |
||||
@fwrite($fp, "<?php\n" |
||||
. "\$config = array();\n" |
||||
. "\$config['dbhost'] = \"" . stripslashes(trim($_POST['dbhost'])) . "\";\n" |
||||
. "\$config['dbuser'] = \"" . stripslashes(trim($_POST['dbuser'])) . "\";\n" |
||||
. "\$config['dbpass'] = \"" . stripslashes(trim($_POST['dbpass'])) . "\";\n" |
||||
. "\$config['dbname'] = \"" . stripslashes(trim($_POST['dbname'])) . "\";\n" |
||||
. "\$config['dbpref'] = \"" . stripslashes(trim($_POST['dbprefix'])) . "\";\n" |
||||
. "\$config['dbport'] = null;\n" |
||||
. "\$config['dbsock'] = null;\n" |
||||
. "?>" |
||||
); |
||||
@fclose($fp); |
||||
|
||||
$filename = BASE_DIR . '/install/structure_base.sql'; |
||||
$fp = @fopen(BASE_DIR . '/config/db.config.php', 'w+'); |
||||
@fwrite($fp, "<?php\n" |
||||
. "\$config = array();\n" |
||||
. "\$config['dbhost'] = \"" . stripslashes(trim($_POST['dbhost'])) . "\";\n" |
||||
. "\$config['dbuser'] = \"" . stripslashes(trim($_POST['dbuser'])) . "\";\n" |
||||
. "\$config['dbpass'] = \"" . stripslashes(trim($_POST['dbpass'])) . "\";\n" |
||||
. "\$config['dbname'] = \"" . stripslashes(trim($_POST['dbname'])) . "\";\n" |
||||
. "\$config['dbpref'] = \"" . stripslashes(trim($_POST['dbprefix'])) . "\";\n" |
||||
. "\$config['dbport'] = null;\n" |
||||
. "\$config['dbsock'] = null;\n" |
||||
. "?>" |
||||
); |
||||
@fclose($fp); |
||||
|
||||
$handle = fopen($filename, 'r'); |
||||
$db_structure = fread($handle, filesize($filename)); |
||||
fclose($handle); |
||||
$filename = BASE_DIR . '/install/structure_base.sql'; |
||||
|
||||
$db_structure = str_replace('%%PRFX%%', $_POST['dbprefix'], $db_structure); |
||||
$handle = fopen($filename, 'r'); |
||||
$db_structure = fread($handle, filesize($filename)); |
||||
fclose($handle); |
||||
|
||||
$mysql_connect = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']); |
||||
@mysqli_select_db($mysql_connect, $_POST['dbname']); |
||||
$db_structure = str_replace('%%PRFX%%', $_POST['dbprefix'], $db_structure); |
||||
|
||||
$ar = explode('#inst#', $db_structure); |
||||
$mysql_connect = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']); |
||||
@mysqli_select_db($mysql_connect, $_POST['dbname']); |
||||
|
||||
foreach ($ar as $in) |
||||
$ar = explode('#inst#', $db_structure); |
||||
|
||||
foreach ($ar as $in) |
||||
{ |
||||
@mysqli_query($mysql_connect, "$in"); |
||||
} |
||||
|
||||
$AVE_Template->display('step5.tpl'); |
||||
exit; |
||||
} |
||||
elseif (true === $connect && true === $check_installed) |
||||
{ |
||||
@mysqli_query($mysql_connect, "$in"); |
||||
$AVE_Template->assign('installed', $AVE_Template->get_config_vars('database_installed')); |
||||
} |
||||
else |
||||
{ |
||||
$AVE_Template->assign('warning', $AVE_Template->get_config_vars('database_not_connect')); |
||||
} |
||||
|
||||
$AVE_Template->display('step5.tpl'); |
||||
exit; |
||||
} |
||||
elseif (true === $connect && true === $check_installed) |
||||
{ |
||||
$AVE_Template->assign('installed', $AVE_Template->get_config_vars('database_installed')); |
||||
} |
||||
else |
||||
{ |
||||
$AVE_Template->assign('warning', $AVE_Template->get_config_vars('database_not_connect')); |
||||
$dbpref = make_random_string(5, 'abcdefghijklmnopqrstuvwxyz0123456789'); |
||||
$AVE_Template->assign('dbpref', $dbpref); |
||||
} |
||||
|
||||
} |
||||
else |
||||
{ |
||||
$dbpref = make_random_string(5, 'abcdefghijklmnopqrstuvwxyz0123456789'); |
||||
$AVE_Template->assign('dbpref', $dbpref); |
||||
} |
||||
|
||||
$AVE_Template->display('step4.tpl'); |
||||
break; |
||||
$AVE_Template->display('step4.tpl'); |
||||
break; |
||||
|
||||
case '5' : |
||||
$_POST['email'] = chop($_POST['email']); |
||||
$_POST['username'] = chop($_POST['username']); |
||||
case '5' : |
||||
$_POST['email'] = chop($_POST['email']); |
||||
$_POST['username'] = chop($_POST['username']); |
||||
|
||||
$regex_username = '/[^\w-]/'; |
||||
$regex_password = '/[^\x20-\xFF]/'; |
||||
$regex_email = '/^[\w.-]+@[a-z0-9.-]+\.(?:[a-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$/i'; |
||||
$regex_username = '/[^\w-]/'; |
||||
$regex_password = '/[^\x20-\xFF]/'; |
||||
$regex_email = '/^[\w.-]+@[a-z0-9.-]+\.(?:[a-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$/i'; |
||||
|
||||
$errors = array(); |
||||
if ($_POST['email'] == '') array_push($errors, $AVE_Template->get_config_vars('noemail')); |
||||
if (! preg_match($regex_email, $_POST['email'])) array_push($errors, $AVE_Template->get_config_vars('email_no_specialchars')); |
||||
if (empty($_POST['pass']) || preg_match($regex_password, $_POST['pass'])) array_push($errors, $AVE_Template->get_config_vars('check_pass')); |
||||
if (strlen($_POST['pass']) < 5) array_push($errors, $AVE_Template->get_config_vars('pass_too_small')); |
||||
if (empty($_POST['username']) || preg_match($regex_username, $_POST['username'])) array_push($errors, $AVE_Template->get_config_vars('check_username')); |
||||
$errors = array(); |
||||
if ($_POST['email'] == '') array_push($errors, $AVE_Template->get_config_vars('noemail')); |
||||
if (! preg_match($regex_email, $_POST['email'])) array_push($errors, $AVE_Template->get_config_vars('email_no_specialchars')); |
||||
if (empty($_POST['pass']) || preg_match($regex_password, $_POST['pass'])) array_push($errors, $AVE_Template->get_config_vars('check_pass')); |
||||
if (strlen($_POST['pass']) < 5) array_push($errors, $AVE_Template->get_config_vars('pass_too_small')); |
||||
if (empty($_POST['username']) || preg_match($regex_username, $_POST['username'])) array_push($errors, $AVE_Template->get_config_vars('check_username')); |
||||
|
||||
$AVE_Template->assign('errors', $errors); |
||||
$AVE_Template->assign('errors', $errors); |
||||
|
||||
if (true === $db_connect && ! sizeof($errors)) |
||||
{ |
||||
if (isset($_POST['demo']) && 1 == $_POST['demo']) |
||||
if (true === $db_connect && ! sizeof($errors)) |
||||
{ |
||||
$filename = BASE_DIR . '/install/data_demo.sql'; |
||||
} |
||||
else |
||||
{ |
||||
$filename = BASE_DIR . '/install/data_base.sql'; |
||||
} |
||||
if (isset($_POST['demo']) && 1 == $_POST['demo']) |
||||
{ |
||||
$filename = BASE_DIR . '/install/data_demo.sql'; |
||||
} |
||||
else |
||||
{ |
||||
$filename = BASE_DIR . '/install/data_base.sql'; |
||||
} |
||||
|
||||
$mysql_connect = @mysqli_connect($config['dbhost'], $config['dbuser'], $config['dbpass']); |
||||
@mysqli_select_db($mysql_connect, $config['dbname']); |
||||
|
||||
$handle = fopen($filename, 'r'); |
||||
$dbin = fread($handle, filesize($filename)); |
||||
fclose($handle); |
||||
|
||||
$salt = make_random_string(); |
||||
$hash = md5(md5($_POST['pass'] . $salt)); |
||||
|
||||
$dbin = str_replace('%%SITENAME%%', $ver, $dbin); |
||||
$dbin = str_replace('%%PRFX%%', $config['dbpref'], $dbin); |
||||
$dbin = str_replace('%%EMAIL%%', $_POST['email'], $dbin); |
||||
$dbin = str_replace('%%SALT%%', $salt, $dbin); |
||||
$dbin = str_replace('%%PASS%%', $hash, $dbin); |
||||
$dbin = str_replace('%%TIME%%', time(), $dbin); |
||||
$dbin = str_replace('%%FIRSTNAME%%', $_POST['firstname'], $dbin); |
||||
$dbin = str_replace('%%LASTNAME%%', $_POST['lastname'], $dbin); |
||||
$dbin = str_replace('%%USERNAME%%', $_POST['username'], $dbin); |
||||
$dbin = str_replace('%%PHONE%%', $_POST['fon'], $dbin); |
||||
$dbin = str_replace('%%FAX%%', $_POST['fax'], $dbin); |
||||
$dbin = str_replace('%%ZIP%%', $_POST['zip'], $dbin); |
||||
$dbin = str_replace('%%TOWN%%', $_POST['town'], $dbin); |
||||
$dbin = str_replace('%%STREET%%', $_POST['street'], $dbin); |
||||
$dbin = str_replace('%%HNR%%', $_POST['hnr'], $dbin); |
||||
|
||||
$ar = explode('#inst#', $dbin); |
||||
|
||||
foreach ($ar as $in) |
||||
{ |
||||
@mysqli_query($mysql_connect, "SET NAMES 'utf8'"); |
||||
@mysqli_query($mysql_connect, "SET COLLATION_CONNECTION = 'utf8_general_ci'"); |
||||
@mysqli_query($mysql_connect, $in); |
||||
} |
||||
/* |
||||
$auth = base64_encode(serialize(array('id' => '1', 'hash'=>$hash))); |
||||
@setcookie('auth', $auth); |
||||
*/ |
||||
$AVE_Template->display('step6.tpl'); |
||||
exit; |
||||
} |
||||
$mysql_connect = @mysqli_connect($config['dbhost'], $config['dbuser'], $config['dbpass']); |
||||
@mysqli_select_db($mysql_connect, $config['dbname']); |
||||
|
||||
$handle = fopen($filename, 'r'); |
||||
$dbin = fread($handle, filesize($filename)); |
||||
fclose($handle); |
||||
|
||||
$salt = make_random_string(); |
||||
$hash = md5(md5($_POST['pass'] . $salt)); |
||||
|
||||
$dbin = str_replace('%%SITENAME%%', $ver, $dbin); |
||||
$dbin = str_replace('%%PRFX%%', $config['dbpref'], $dbin); |
||||
$dbin = str_replace('%%EMAIL%%', $_POST['email'], $dbin); |
||||
$dbin = str_replace('%%SALT%%', $salt, $dbin); |
||||
$dbin = str_replace('%%PASS%%', $hash, $dbin); |
||||
$dbin = str_replace('%%TIME%%', time(), $dbin); |
||||
$dbin = str_replace('%%FIRSTNAME%%', $_POST['firstname'], $dbin); |
||||
$dbin = str_replace('%%LASTNAME%%', $_POST['lastname'], $dbin); |
||||
$dbin = str_replace('%%USERNAME%%', $_POST['username'], $dbin); |
||||
|
||||
$AVE_Template->display('step5.tpl'); |
||||
break; |
||||
} |
||||
$ar = explode('#inst#', $dbin); |
||||
|
||||
foreach ($ar as $in) |
||||
{ |
||||
@mysqli_query($mysql_connect, "SET NAMES 'utf8'"); |
||||
@mysqli_query($mysql_connect, "SET COLLATION_CONNECTION = 'utf8_general_ci'"); |
||||
@mysqli_query($mysql_connect, $in); |
||||
} |
||||
/* |
||||
$auth = base64_encode(serialize(array('id' => '1', 'hash'=>$hash))); |
||||
@setcookie('auth', $auth); |
||||
*/ |
||||
$AVE_Template->display('step6.tpl'); |
||||
exit; |
||||
} |
||||
|
||||
$AVE_Template->display('step5.tpl'); |
||||
break; |
||||
} |
||||
?> |
@ -0,0 +1,48 @@
|
||||
/* == Debug Panel == */ |
||||
#debug-panel { |
||||
font-size: 12px; |
||||
opacity: 0.9; |
||||
position: fixed; |
||||
bottom: 0; |
||||
left: 0; |
||||
z-index: 2000; |
||||
width: 100%; |
||||
} |
||||
#debug-panel .debug-wrapper { |
||||
padding: 0px .875em; |
||||
background-color: #fff; |
||||
border: 1px solid rgba(0,0,0,0.2); |
||||
border-bottom: 0; |
||||
margin: 0px auto 0px auto; |
||||
} |
||||
#debug-panel .items { |
||||
padding: 10px; |
||||
height: 350px; |
||||
padding-top: 1em; |
||||
font-size: 12px; |
||||
color: #888; |
||||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace |
||||
} |
||||
#debug-panel .debug-wrapper .legend { |
||||
background-color: #f9f9f9; |
||||
padding: .25em; |
||||
border: 1px solid rgba(0,0,0,0.2); |
||||
width: auto; |
||||
margin-top: -1.25em; |
||||
} |
||||
#debug-panel .debug-wrapper .legend span { |
||||
color: #999; |
||||
font-weight: 300 |
||||
} |
||||
#debug-panel a { |
||||
text-decoration: none; |
||||
color: rgba(0,0,0,0.5); |
||||
font-size: 12px; |
||||
margin: 0 .25em; |
||||
} |
||||
#debug-panel pre { |
||||
border: 0px; |
||||
} |
||||
#debugArrowMinimize { |
||||
float: right; |
||||
} |
@ -0,0 +1,30 @@
|
||||
function appExpandTabs(act, key) { |
||||
var arrDebugTabs = ["General", "Params", "Globals", "Queries", "SqlTrace"]; |
||||
|
||||
keyTab = (key == null) |
||||
? "General" |
||||
: key; |
||||
|
||||
for (var i = 0; i < arrDebugTabs.length; i++) { |
||||
if (act == "min" || arrDebugTabs[i] != keyTab) { |
||||
$("#content" + arrDebugTabs[i]).css("display", "none"); |
||||
$("#tab" + arrDebugTabs[i]).css("color", "#bbb") |
||||
} |
||||
} |
||||
if (act != "min") { |
||||
$("#content" + keyTab).css("display", ""); |
||||
$("#content" + keyTab).css({ |
||||
"overflow-y": "auto" |
||||
}); |
||||
$("#tab" + keyTab).css("color", "#222") |
||||
} |
||||
|
||||
$("#debug-panel").css("opacity", (act == "min") ? "0.9" : "1"); |
||||
}; |
||||
|
||||
|
||||
function appTabsHide() |
||||
{ |
||||
$('#debug-panel-legend span a').css("color", "#bbb"); |
||||
$("#debug-panel .items").hide(); |
||||
} |
@ -1,360 +0,0 @@
|
||||
<!doctype html> |
||||
|
||||
<title>CodeMirror: C-like mode</title> |
||||
<meta charset="utf-8"/> |
||||
<link rel=stylesheet href="../../doc/docs.css"> |
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css"> |
||||
<script src="../../lib/codemirror.js"></script> |
||||
<script src="../../addon/edit/matchbrackets.js"></script> |
||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css"> |
||||
<script src="../../addon/hint/show-hint.js"></script> |
||||
<script src="clike.js"></script> |
||||
<style>.CodeMirror {border: 2px inset #dee;}</style> |
||||
<div id=nav> |
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
||||
|
||||
<ul> |
||||
<li><a href="../../index.html">Home</a> |
||||
<li><a href="../../doc/manual.html">Manual</a> |
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a> |
||||
</ul> |
||||
<ul> |
||||
<li><a href="../index.html">Language modes</a> |
||||
<li><a class=active href="#">C-like</a> |
||||
</ul> |
||||
</div> |
||||
|
||||
<article> |
||||
<h2>C-like mode</h2> |
||||
|
||||
<div><textarea id="c-code"> |
||||
/* C demo code */ |
||||
|
||||
#include <zmq.h> |
||||
#include <pthread.h> |
||||
#include <semaphore.h> |
||||
#include <time.h> |
||||
#include <stdio.h> |
||||
#include <fcntl.h> |
||||
#include <malloc.h> |
||||
|
||||
typedef struct { |
||||
void* arg_socket; |
||||
zmq_msg_t* arg_msg; |
||||
char* arg_string; |
||||
unsigned long arg_len; |
||||
int arg_int, arg_command; |
||||
|
||||
int signal_fd; |
||||
int pad; |
||||
void* context; |
||||
sem_t sem; |
||||
} acl_zmq_context; |
||||
|
||||
#define p(X) (context->arg_##X) |
||||
|
||||
void* zmq_thread(void* context_pointer) { |
||||
acl_zmq_context* context = (acl_zmq_context*)context_pointer; |
||||
char ok = 'K', err = 'X'; |
||||
int res; |
||||
|
||||
while (1) { |
||||
while ((res = sem_wait(&context->sem)) == EINTR); |
||||
if (res) {write(context->signal_fd, &err, 1); goto cleanup;} |
||||
switch(p(command)) { |
||||
case 0: goto cleanup; |
||||
case 1: p(socket) = zmq_socket(context->context, p(int)); break; |
||||
case 2: p(int) = zmq_close(p(socket)); break; |
||||
case 3: p(int) = zmq_bind(p(socket), p(string)); break; |
||||
case 4: p(int) = zmq_connect(p(socket), p(string)); break; |
||||
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break; |
||||
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break; |
||||
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break; |
||||
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break; |
||||
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break; |
||||
} |
||||
p(command) = errno; |
||||
write(context->signal_fd, &ok, 1); |
||||
} |
||||
cleanup: |
||||
close(context->signal_fd); |
||||
free(context_pointer); |
||||
return 0; |
||||
} |
||||
|
||||
void* zmq_thread_init(void* zmq_context, int signal_fd) { |
||||
acl_zmq_context* context = malloc(sizeof(acl_zmq_context)); |
||||
pthread_t thread; |
||||
|
||||
context->context = zmq_context; |
||||
context->signal_fd = signal_fd; |
||||
sem_init(&context->sem, 1, 0); |
||||
pthread_create(&thread, 0, &zmq_thread, context); |
||||
pthread_detach(thread); |
||||
return context; |
||||
} |
||||
</textarea></div> |
||||
|
||||
<h2>C++ example</h2> |
||||
|
||||
<div><textarea id="cpp-code"> |
||||
#include <iostream> |
||||
#include "mystuff/util.h" |
||||
|
||||
namespace { |
||||
enum Enum { |
||||
VAL1, VAL2, VAL3 |
||||
}; |
||||
|
||||
char32_t unicode_string = U"\U0010FFFF"; |
||||
string raw_string = R"delim(anything |
||||
you |
||||
want)delim"; |
||||
|
||||
int Helper(const MyType& param) { |
||||
return 0; |
||||
} |
||||
} // namespace |
||||
|
||||
class ForwardDec; |
||||
|
||||
template <class T, class V> |
||||
class Class : public BaseClass { |
||||
const MyType<T, V> member_; |
||||
|
||||
public: |
||||
const MyType<T, V>& Method() const { |
||||
return member_; |
||||
} |
||||
|
||||
void Method2(MyType<T, V>* value); |
||||
} |
||||
|
||||
template <class T, class V> |
||||
void Class::Method2(MyType<T, V>* value) { |
||||
std::out << 1 >> method(); |
||||
value->Method3(member_); |
||||
member_ = value; |
||||
} |
||||
</textarea></div> |
||||
|
||||
<h2>Objective-C example</h2> |
||||
|
||||
<div><textarea id="objectivec-code"> |
||||
/* |
||||
This is a longer comment |
||||
That spans two lines |
||||
*/ |
||||
|
||||
#import <Test/Test.h> |
||||
@implementation YourAppDelegate |
||||
|
||||
// This is a one-line comment |
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ |
||||
char myString[] = "This is a C character array"; |
||||
int test = 5; |
||||
return YES; |
||||
} |
||||
</textarea></div> |
||||
|
||||
<h2>Java example</h2> |
||||
|
||||
<div><textarea id="java-code"> |
||||
import com.demo.util.MyType; |
||||
import com.demo.util.MyInterface; |
||||
|
||||
public enum Enum { |
||||
VAL1, VAL2, VAL3 |
||||
} |
||||
|
||||
public class Class<T, V> implements MyInterface { |
||||
public static final MyType<T, V> member; |
||||
|
||||
private class InnerClass { |
||||
public int zero() { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public MyType method() { |
||||
return member; |
||||
} |
||||
|
||||
public void method2(MyType<T, V> value) { |
||||
method(); |
||||
value.method3(); |
||||
member = value; |
||||
} |
||||
} |
||||
</textarea></div> |
||||
|
||||
<h2>Scala example</h2> |
||||
|
||||
<div><textarea id="scala-code"> |
||||
object FilterTest extends App { |
||||
def filter(xs: List[Int], threshold: Int) = { |
||||
def process(ys: List[Int]): List[Int] = |
||||
if (ys.isEmpty) ys |
||||
else if (ys.head < threshold) ys.head :: process(ys.tail) |
||||
else process(ys.tail) |
||||
process(xs) |
||||
} |
||||
println(filter(List(1, 9, 2, 8, 3, 7, 4), 5)) |
||||
} |
||||
</textarea></div> |
||||
|
||||
<h2>Kotlin mode</h2> |
||||
|
||||
<div><textarea id="kotlin-code"> |
||||
package org.wasabi.http |
||||
|
||||
import java.util.concurrent.Executors |
||||
import java.net.InetSocketAddress |
||||
import org.wasabi.app.AppConfiguration |
||||
import io.netty.bootstrap.ServerBootstrap |
||||
import io.netty.channel.nio.NioEventLoopGroup |
||||
import io.netty.channel.socket.nio.NioServerSocketChannel |
||||
import org.wasabi.app.AppServer |
||||
|
||||
public class HttpServer(private val appServer: AppServer) { |
||||
|
||||
val bootstrap: ServerBootstrap |
||||
val primaryGroup: NioEventLoopGroup |
||||
val workerGroup: NioEventLoopGroup |
||||
|
||||
init { |
||||
// Define worker groups |
||||
primaryGroup = NioEventLoopGroup() |
||||
workerGroup = NioEventLoopGroup() |
||||
|
||||
// Initialize bootstrap of server |
||||
bootstrap = ServerBootstrap() |
||||
|
||||
bootstrap.group(primaryGroup, workerGroup) |
||||
bootstrap.channel(javaClass<NioServerSocketChannel>()) |
||||
bootstrap.childHandler(NettyPipelineInitializer(appServer)) |
||||
} |
||||
|
||||
public fun start(wait: Boolean = true) { |
||||
val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel() |
||||
|
||||
if (wait) { |
||||
channel?.closeFuture()?.sync() |
||||
} |
||||
} |
||||
|
||||
public fun stop() { |
||||
// Shutdown all event loops |
||||
primaryGroup.shutdownGracefully() |
||||
workerGroup.shutdownGracefully() |
||||
|
||||
// Wait till all threads are terminated |
||||
primaryGroup.terminationFuture().sync() |
||||
workerGroup.terminationFuture().sync() |
||||
} |
||||
} |
||||
</textarea></div> |
||||
|
||||
<h2>Ceylon mode</h2> |
||||
|
||||
<div><textarea id="ceylon-code"> |
||||
"Produces the [[stream|Iterable]] that results from repeated |
||||
application of the given [[function|next]] to the given |
||||
[[first]] element of the stream, until the function first |
||||
returns [[finished]]. If the given function never returns |
||||
`finished`, the resulting stream is infinite. |
||||
|
||||
For example: |
||||
|
||||
loop(0)(2.plus).takeWhile(10.largerThan) |
||||
|
||||
produces the stream `{ 0, 2, 4, 6, 8 }`." |
||||
tagged("Streams") |
||||
shared {Element+} loop<Element>( |
||||
"The first element of the resulting stream." |
||||
Element first)( |
||||
"The function that produces the next element of the |
||||
stream, given the current element. The function may |
||||
return [[finished]] to indicate the end of the |
||||
stream." |
||||
Element|Finished next(Element element)) |
||||
=> let (start = first) |
||||
object satisfies {Element+} { |
||||
first => start; |
||||
empty => false; |
||||
function nextElement(Element element) |
||||
=> next(element); |
||||
iterator() |
||||
=> object satisfies Iterator<Element> { |
||||
variable Element|Finished current = start; |
||||
shared actual Element|Finished next() { |
||||
if (!is Finished result = current) { |
||||
current = nextElement(result); |
||||
return result; |
||||
} |
||||
else { |
||||
return finished; |
||||
} |
||||
} |
||||
}; |
||||
}; |
||||
</textarea></div> |
||||
|
||||
<script> |
||||
var cEditor = CodeMirror.fromTextArea(document.getElementById("c-code"), { |
||||
lineNumbers: true, |
||||
matchBrackets: true, |
||||
mode: "text/x-csrc" |
||||
}); |
||||
var cppEditor = CodeMirror.fromTextArea(document.getElementById("cpp-code"), { |
||||
lineNumbers: true, |
||||
matchBrackets: true, |
||||
mode: "text/x-c++src" |
||||
}); |
||||
var javaEditor = CodeMirror.fromTextArea(document.getElementById("java-code"), { |
||||
lineNumbers: true, |
||||
matchBrackets: true, |
||||
mode: "text/x-java" |
||||
}); |
||||
var objectivecEditor = CodeMirror.fromTextArea(document.getElementById("objectivec-code"), { |
||||
lineNumbers: true, |
||||
matchBrackets: true, |
||||
mode: "text/x-objectivec" |
||||
}); |
||||
var scalaEditor = CodeMirror.fromTextArea(document.getElementById("scala-code"), { |
||||
lineNumbers: true, |
||||
matchBrackets: true, |
||||
mode: "text/x-scala" |
||||
}); |
||||
var kotlinEditor = CodeMirror.fromTextArea(document.getElementById("kotlin-code"), { |
||||
lineNumbers: true, |
||||
matchBrackets: true, |
||||
mode: "text/x-kotlin" |
||||
}); |
||||
var ceylonEditor = CodeMirror.fromTextArea(document.getElementById("ceylon-code"), { |
||||
lineNumbers: true, |
||||
matchBrackets: true, |
||||
mode: "text/x-ceylon" |
||||
}); |
||||
var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault; |
||||
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete"; |
||||
</script> |
||||
|
||||
<p>Simple mode that tries to handle C-like languages as well as it |
||||
can. Takes two configuration parameters: <code>keywords</code>, an |
||||
object whose property names are the keywords in the language, |
||||
and <code>useCPP</code>, which determines whether C preprocessor |
||||
directives are recognized.</p> |
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code> |
||||
(C), <code>text/x-c++src</code> (C++), <code>text/x-java</code> |
||||
(Java), <code>text/x-csharp</code> (C#), |
||||
<code>text/x-objectivec</code> (Objective-C), |
||||
<code>text/x-scala</code> (Scala), <code>text/x-vertex</code> |
||||
<code>x-shader/x-fragment</code> (shader programs), |
||||
<code>text/x-squirrel</code> (Squirrel) and |
||||
<code>text/x-ceylon</code> (Ceylon)</p> |
||||
</article> |
@ -1,767 +0,0 @@
|
||||
<!doctype html> |
||||
|
||||
<title>CodeMirror: Scala mode</title> |
||||
<meta charset="utf-8"/> |
||||
<link rel=stylesheet href="../../doc/docs.css"> |
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css"> |
||||
<link rel="stylesheet" href="../../theme/ambiance.css"> |
||||
<script src="../../lib/codemirror.js"></script> |
||||
<script src="../../addon/edit/matchbrackets.js"></script> |
||||
<script src="clike.js"></script> |
||||
<div id=nav> |
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
||||
|
||||
<ul> |
||||
<li><a href="../../index.html">Home</a> |
||||
<li><a href="../../doc/manual.html">Manual</a> |
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a> |
||||
</ul> |
||||
<ul> |
||||
<li><a href="../index.html">Language modes</a> |
||||
<li><a class=active href="#">Scala</a> |
||||
</ul> |
||||
</div> |
||||
|
||||
<article> |
||||
<h2>Scala mode</h2> |
||||
<form> |
||||
<textarea id="code" name="code"> |
||||
|
||||
/* __ *\ |
||||
** ________ ___ / / ___ Scala API ** |
||||
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** |
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** |
||||
** /____/\___/_/ |_/____/_/ | | ** |
||||
** |/ ** |
||||
\* */ |
||||
|
||||
package scala.collection |
||||
|
||||
import generic._ |
||||
import mutable.{ Builder, ListBuffer } |
||||
import annotation.{tailrec, migration, bridge} |
||||
import annotation.unchecked.{ uncheckedVariance => uV } |
||||
import parallel.ParIterable |
||||
|
||||
/** A template trait for traversable collections of type `Traversable[A]`. |
||||
* |
||||
* $traversableInfo |
||||
* @define mutability |
||||
* @define traversableInfo |
||||
* This is a base trait of all kinds of $mutability Scala collections. It |
||||
* implements the behavior common to all collections, in terms of a method |
||||
* `foreach` with signature: |
||||
* {{{ |
||||
* def foreach[U](f: Elem => U): Unit |
||||
* }}} |
||||
* Collection classes mixing in this trait provide a concrete |
||||
* `foreach` method which traverses all the |
||||
* elements contained in the collection, applying a given function to each. |
||||
* They also need to provide a method `newBuilder` |
||||
* which creates a builder for collections of the same kind. |
||||
* |
||||
* A traversable class might or might not have two properties: strictness |
||||
* and orderedness. Neither is represented as a type. |
||||
* |
||||
* The instances of a strict collection class have all their elements |
||||
* computed before they can be used as values. By contrast, instances of |
||||
* a non-strict collection class may defer computation of some of their |
||||
* elements until after the instance is available as a value. |
||||
* A typical example of a non-strict collection class is a |
||||
* <a href="../immutable/Stream.html" target="ContentFrame"> |
||||
* `scala.collection.immutable.Stream`</a>. |
||||
* A more general class of examples are `TraversableViews`. |
||||
* |
||||
* If a collection is an instance of an ordered collection class, traversing |
||||
* its elements with `foreach` will always visit elements in the |
||||
* same order, even for different runs of the program. If the class is not |
||||
* ordered, `foreach` can visit elements in different orders for |
||||
* different runs (but it will keep the same order in the same run).' |
||||
* |
||||
* A typical example of a collection class which is not ordered is a |
||||
* `HashMap` of objects. The traversal order for hash maps will |
||||
* depend on the hash codes of its elements, and these hash codes might |
||||
* differ from one run to the next. By contrast, a `LinkedHashMap` |
||||
* is ordered because it's `foreach` method visits elements in the |
||||
* order they were inserted into the `HashMap`. |
||||
* |
||||
* @author Martin Odersky |
||||
* @version 2.8 |
||||
* @since 2.8 |
||||
* @tparam A the element type of the collection |
||||
* @tparam Repr the type of the actual collection containing the elements. |
||||
* |
||||
* @define Coll Traversable |
||||
* @define coll traversable collection |
||||
*/ |
||||
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] |
||||
with FilterMonadic[A, Repr] |
||||
with TraversableOnce[A] |
||||
with GenTraversableLike[A, Repr] |
||||
with Parallelizable[A, ParIterable[A]] |
||||
{ |
||||
self => |
||||
|
||||
import Traversable.breaks._ |
||||
|
||||
/** The type implementing this traversable */ |
||||
protected type Self = Repr |
||||
|
||||
/** The collection of type $coll underlying this `TraversableLike` object. |
||||
* By default this is implemented as the `TraversableLike` object itself, |
||||
* but this can be overridden. |
||||
*/ |
||||
def repr: Repr = this.asInstanceOf[Repr] |
||||
|
||||
/** The underlying collection seen as an instance of `$Coll`. |
||||
* By default this is implemented as the current collection object itself, |
||||
* but this can be overridden. |
||||
*/ |
||||
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]] |
||||
|
||||
/** A conversion from collections of type `Repr` to `$Coll` objects. |
||||
* By default this is implemented as just a cast, but this can be overridden. |
||||
*/ |
||||
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]] |
||||
|
||||
/** Creates a new builder for this collection type. |
||||
*/ |
||||
protected[this] def newBuilder: Builder[A, Repr] |
||||
|
||||
protected[this] def parCombiner = ParIterable.newCombiner[A] |
||||
|
||||
/** Applies a function `f` to all elements of this $coll. |
||||
* |
||||
* Note: this method underlies the implementation of most other bulk operations. |
||||
* It's important to implement this method in an efficient way. |
||||
* |
||||
* |
||||
* @param f the function that is applied for its side-effect to every element. |
||||
* The result of function `f` is discarded. |
||||
* |
||||
* @tparam U the type parameter describing the result of function `f`. |
||||
* This result will always be ignored. Typically `U` is `Unit`, |
||||
* but this is not necessary. |
||||
* |
||||
* @usecase def foreach(f: A => Unit): Unit |
||||
*/ |
||||
def foreach[U](f: A => U): Unit |
||||
|
||||
/** Tests whether this $coll is empty. |
||||
* |
||||
* @return `true` if the $coll contain no elements, `false` otherwise. |
||||
*/ |
||||
def isEmpty: Boolean = { |
||||
var result = true |
||||
breakable { |
||||
for (x <- this) { |
||||
result = false |
||||
break |
||||
} |
||||
} |
||||
result |
||||
} |
||||
|
||||
/** Tests whether this $coll is known to have a finite size. |
||||
* All strict collections are known to have finite size. For a non-strict collection |
||||
* such as `Stream`, the predicate returns `true` if all elements have been computed. |
||||
* It returns `false` if the stream is not yet evaluated to the end. |
||||
* |
||||
* Note: many collection methods will not work on collections of infinite sizes. |
||||
* |
||||
* @return `true` if this collection is known to have finite size, `false` otherwise. |
||||
*/ |
||||
def hasDefiniteSize = true |
||||
|
||||
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
val b = bf(repr) |
||||
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size) |
||||
b ++= thisCollection |
||||
b ++= that.seq |
||||
b.result |
||||
} |
||||
|
||||
@bridge |
||||
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = |
||||
++(that: GenTraversableOnce[B])(bf) |
||||
|
||||
/** Concatenates this $coll with the elements of a traversable collection. |
||||
* It differs from ++ in that the right operand determines the type of the |
||||
* resulting collection rather than the left one. |
||||
* |
||||
* @param that the traversable to append. |
||||
* @tparam B the element type of the returned collection. |
||||
* @tparam That $thatinfo |
||||
* @param bf $bfinfo |
||||
* @return a new collection of type `That` which contains all elements |
||||
* of this $coll followed by all elements of `that`. |
||||
* |
||||
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B] |
||||
* |
||||
* @return a new $coll which contains all elements of this $coll |
||||
* followed by all elements of `that`. |
||||
*/ |
||||
def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
val b = bf(repr) |
||||
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size) |
||||
b ++= that |
||||
b ++= thisCollection |
||||
b.result |
||||
} |
||||
|
||||
/** This overload exists because: for the implementation of ++: we should reuse |
||||
* that of ++ because many collections override it with more efficient versions. |
||||
* Since TraversableOnce has no '++' method, we have to implement that directly, |
||||
* but Traversable and down can use the overload. |
||||
*/ |
||||
def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = |
||||
(that ++ seq)(breakOut) |
||||
|
||||
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
val b = bf(repr) |
||||
b.sizeHint(this) |
||||
for (x <- this) b += f(x) |
||||
b.result |
||||
} |
||||
|
||||
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
val b = bf(repr) |
||||
for (x <- this) b ++= f(x).seq |
||||
b.result |
||||
} |
||||
|
||||
/** Selects all elements of this $coll which satisfy a predicate. |
||||
* |
||||
* @param p the predicate used to test elements. |
||||
* @return a new $coll consisting of all elements of this $coll that satisfy the given |
||||
* predicate `p`. The order of the elements is preserved. |
||||
*/ |
||||
def filter(p: A => Boolean): Repr = { |
||||
val b = newBuilder |
||||
for (x <- this) |
||||
if (p(x)) b += x |
||||
b.result |
||||
} |
||||
|
||||
/** Selects all elements of this $coll which do not satisfy a predicate. |
||||
* |
||||
* @param p the predicate used to test elements. |
||||
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given |
||||
* predicate `p`. The order of the elements is preserved. |
||||
*/ |
||||
def filterNot(p: A => Boolean): Repr = filter(!p(_)) |
||||
|
||||
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
val b = bf(repr) |
||||
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x) |
||||
b.result |
||||
} |
||||
|
||||
/** Builds a new collection by applying an option-valued function to all |
||||
* elements of this $coll on which the function is defined. |
||||
* |
||||
* @param f the option-valued function which filters and maps the $coll. |
||||
* @tparam B the element type of the returned collection. |
||||
* @tparam That $thatinfo |
||||
* @param bf $bfinfo |
||||
* @return a new collection of type `That` resulting from applying the option-valued function |
||||
* `f` to each element and collecting all defined results. |
||||
* The order of the elements is preserved. |
||||
* |
||||
* @usecase def filterMap[B](f: A => Option[B]): $Coll[B] |
||||
* |
||||
* @param pf the partial function which filters and maps the $coll. |
||||
* @return a new $coll resulting from applying the given option-valued function |
||||
* `f` to each element and collecting all defined results. |
||||
* The order of the elements is preserved. |
||||
def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
val b = bf(repr) |
||||
for (x <- this) |
||||
f(x) match { |
||||
case Some(y) => b += y |
||||
case _ => |
||||
} |
||||
b.result |
||||
} |
||||
*/ |
||||
|
||||
/** Partitions this $coll in two ${coll}s according to a predicate. |
||||
* |
||||
* @param p the predicate on which to partition. |
||||
* @return a pair of ${coll}s: the first $coll consists of all elements that |
||||
* satisfy the predicate `p` and the second $coll consists of all elements |
||||
* that don't. The relative order of the elements in the resulting ${coll}s |
||||
* is the same as in the original $coll. |
||||
*/ |
||||
def partition(p: A => Boolean): (Repr, Repr) = { |
||||
val l, r = newBuilder |
||||
for (x <- this) (if (p(x)) l else r) += x |
||||
(l.result, r.result) |
||||
} |
||||
|
||||
def groupBy[K](f: A => K): immutable.Map[K, Repr] = { |
||||
val m = mutable.Map.empty[K, Builder[A, Repr]] |
||||
for (elem <- this) { |
||||
val key = f(elem) |
||||
val bldr = m.getOrElseUpdate(key, newBuilder) |
||||
bldr += elem |
||||
} |
||||
val b = immutable.Map.newBuilder[K, Repr] |
||||
for ((k, v) <- m) |
||||
b += ((k, v.result)) |
||||
|
||||
b.result |
||||
} |
||||
|
||||
/** Tests whether a predicate holds for all elements of this $coll. |
||||
* |
||||
* $mayNotTerminateInf |
||||
* |
||||
* @param p the predicate used to test elements. |
||||
* @return `true` if the given predicate `p` holds for all elements |
||||
* of this $coll, otherwise `false`. |
||||
*/ |
||||
def forall(p: A => Boolean): Boolean = { |
||||
var result = true |
||||
breakable { |
||||
for (x <- this) |
||||
if (!p(x)) { result = false; break } |
||||
} |
||||
result |
||||
} |
||||
|
||||
/** Tests whether a predicate holds for some of the elements of this $coll. |
||||
* |
||||
* $mayNotTerminateInf |
||||
* |
||||
* @param p the predicate used to test elements. |
||||
* @return `true` if the given predicate `p` holds for some of the |
||||
* elements of this $coll, otherwise `false`. |
||||
*/ |
||||
def exists(p: A => Boolean): Boolean = { |
||||
var result = false |
||||
breakable { |
||||
for (x <- this) |
||||
if (p(x)) { result = true; break } |
||||
} |
||||
result |
||||
} |
||||
|
||||
/** Finds the first element of the $coll satisfying a predicate, if any. |
||||
* |
||||
* $mayNotTerminateInf |
||||
* $orderDependent |
||||
* |
||||
* @param p the predicate used to test elements. |
||||
* @return an option value containing the first element in the $coll |
||||
* that satisfies `p`, or `None` if none exists. |
||||
*/ |
||||
def find(p: A => Boolean): Option[A] = { |
||||
var result: Option[A] = None |
||||
breakable { |
||||
for (x <- this) |
||||
if (p(x)) { result = Some(x); break } |
||||
} |
||||
result |
||||
} |
||||
|
||||
def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op) |
||||
|
||||
def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
val b = bf(repr) |
||||
b.sizeHint(this, 1) |
||||
var acc = z |
||||
b += acc |
||||
for (x <- this) { acc = op(acc, x); b += acc } |
||||
b.result |
||||
} |
||||
|
||||
@migration(2, 9, |
||||
"This scanRight definition has changed in 2.9.\n" + |
||||
"The previous behavior can be reproduced with scanRight.reverse." |
||||
) |
||||
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
var scanned = List(z) |
||||
var acc = z |
||||
for (x <- reversed) { |
||||
acc = op(x, acc) |
||||
scanned ::= acc |
||||
} |
||||
val b = bf(repr) |
||||
for (elem <- scanned) b += elem |
||||
b.result |
||||
} |
||||
|
||||
/** Selects the first element of this $coll. |
||||
* $orderDependent |
||||
* @return the first element of this $coll. |
||||
* @throws `NoSuchElementException` if the $coll is empty. |
||||
*/ |
||||
def head: A = { |
||||
var result: () => A = () => throw new NoSuchElementException |
||||
breakable { |
||||
for (x <- this) { |
||||
result = () => x |
||||
break |
||||
} |
||||
} |
||||
result() |
||||
} |
||||
|
||||
/** Optionally selects the first element. |
||||
* $orderDependent |
||||
* @return the first element of this $coll if it is nonempty, `None` if it is empty. |
||||
*/ |
||||
def headOption: Option[A] = if (isEmpty) None else Some(head) |
||||
|
||||
/** Selects all elements except the first. |
||||
* $orderDependent |
||||
* @return a $coll consisting of all elements of this $coll |
||||
* except the first one. |
||||
* @throws `UnsupportedOperationException` if the $coll is empty. |
||||
*/ |
||||
override def tail: Repr = { |
||||
if (isEmpty) throw new UnsupportedOperationException("empty.tail") |
||||
drop(1) |
||||
} |
||||
|
||||
/** Selects the last element. |
||||
* $orderDependent |
||||
* @return The last element of this $coll. |
||||
* @throws NoSuchElementException If the $coll is empty. |
||||
*/ |
||||
def last: A = { |
||||
var lst = head |
||||
for (x <- this) |
||||
lst = x |
||||
lst |
||||
} |
||||
|
||||
/** Optionally selects the last element. |
||||
* $orderDependent |
||||
* @return the last element of this $coll$ if it is nonempty, `None` if it is empty. |
||||
*/ |
||||
def lastOption: Option[A] = if (isEmpty) None else Some(last) |
||||
|
||||
/** Selects all elements except the last. |
||||
* $orderDependent |
||||
* @return a $coll consisting of all elements of this $coll |
||||
* except the last one. |
||||
* @throws `UnsupportedOperationException` if the $coll is empty. |
||||
*/ |
||||
def init: Repr = { |
||||
if (isEmpty) throw new UnsupportedOperationException("empty.init") |
||||
var lst = head |
||||
var follow = false |
||||
val b = newBuilder |
||||
b.sizeHint(this, -1) |
||||
for (x <- this.seq) { |
||||
if (follow) b += lst |
||||
else follow = true |
||||
lst = x |
||||
} |
||||
b.result |
||||
} |
||||
|
||||
def take(n: Int): Repr = slice(0, n) |
||||
|
||||
def drop(n: Int): Repr = |
||||
if (n <= 0) { |
||||
val b = newBuilder |
||||
b.sizeHint(this) |
||||
b ++= thisCollection result |
||||
} |
||||
else sliceWithKnownDelta(n, Int.MaxValue, -n) |
||||
|
||||
def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until) |
||||
|
||||
// Precondition: from >= 0, until > 0, builder already configured for building. |
||||
private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = { |
||||
var i = 0 |
||||
breakable { |
||||
for (x <- this.seq) { |
||||
if (i >= from) b += x |
||||
i += 1 |
||||
if (i >= until) break |
||||
} |
||||
} |
||||
b.result |
||||
} |
||||
// Precondition: from >= 0 |
||||
private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = { |
||||
val b = newBuilder |
||||
if (until <= from) b.result |
||||
else { |
||||
b.sizeHint(this, delta) |
||||
sliceInternal(from, until, b) |
||||
} |
||||
} |
||||
// Precondition: from >= 0 |
||||
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = { |
||||
val b = newBuilder |
||||
if (until <= from) b.result |
||||
else { |
||||
b.sizeHintBounded(until - from, this) |
||||
sliceInternal(from, until, b) |
||||
} |
||||
} |
||||
|
||||
def takeWhile(p: A => Boolean): Repr = { |
||||
val b = newBuilder |
||||
breakable { |
||||
for (x <- this) { |
||||
if (!p(x)) break |
||||
b += x |
||||
} |
||||
} |
||||
b.result |
||||
} |
||||
|
||||
def dropWhile(p: A => Boolean): Repr = { |
||||
val b = newBuilder |
||||
var go = false |
||||
for (x <- this) { |
||||
if (!p(x)) go = true |
||||
if (go) b += x |
||||
} |
||||
b.result |
||||
} |
||||
|
||||
def span(p: A => Boolean): (Repr, Repr) = { |
||||
val l, r = newBuilder |
||||
var toLeft = true |
||||
for (x <- this) { |
||||
toLeft = toLeft && p(x) |
||||
(if (toLeft) l else r) += x |
||||
} |
||||
(l.result, r.result) |
||||
} |
||||
|
||||
def splitAt(n: Int): (Repr, Repr) = { |
||||
val l, r = newBuilder |
||||
l.sizeHintBounded(n, this) |
||||
if (n >= 0) r.sizeHint(this, -n) |
||||
var i = 0 |
||||
for (x <- this) { |
||||
(if (i < n) l else r) += x |
||||
i += 1 |
||||
} |
||||
(l.result, r.result) |
||||
} |
||||
|
||||
/** Iterates over the tails of this $coll. The first value will be this |
||||
* $coll and the final one will be an empty $coll, with the intervening |
||||
* values the results of successive applications of `tail`. |
||||
* |
||||
* @return an iterator over all the tails of this $coll |
||||
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)` |
||||
*/ |
||||
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail) |
||||
|
||||
/** Iterates over the inits of this $coll. The first value will be this |
||||
* $coll and the final one will be an empty $coll, with the intervening |
||||
* values the results of successive applications of `init`. |
||||
* |
||||
* @return an iterator over all the inits of this $coll |
||||
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)` |
||||
*/ |
||||
def inits: Iterator[Repr] = iterateUntilEmpty(_.init) |
||||
|
||||
/** Copies elements of this $coll to an array. |
||||
* Fills the given array `xs` with at most `len` elements of |
||||
* this $coll, starting at position `start`. |
||||
* Copying will stop once either the end of the current $coll is reached, |
||||
* or the end of the array is reached, or `len` elements have been copied. |
||||
* |
||||
* $willNotTerminateInf |
||||
* |
||||
* @param xs the array to fill. |
||||
* @param start the starting index. |
||||
* @param len the maximal number of elements to copy. |
||||
* @tparam B the type of the elements of the array. |
||||
* |
||||
* |
||||
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit |
||||
*/ |
||||
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) { |
||||
var i = start |
||||
val end = (start + len) min xs.length |
||||
breakable { |
||||
for (x <- this) { |
||||
if (i >= end) break |
||||
xs(i) = x |
||||
i += 1 |
||||
} |
||||
} |
||||
} |
||||
|
||||
def toTraversable: Traversable[A] = thisCollection |
||||
def toIterator: Iterator[A] = toStream.iterator |
||||
def toStream: Stream[A] = toBuffer.toStream |
||||
|
||||
/** Converts this $coll to a string. |
||||
* |
||||
* @return a string representation of this collection. By default this |
||||
* string consists of the `stringPrefix` of this $coll, |
||||
* followed by all elements separated by commas and enclosed in parentheses. |
||||
*/ |
||||
override def toString = mkString(stringPrefix + "(", ", ", ")") |
||||
|
||||
/** Defines the prefix of this object's `toString` representation. |
||||
* |
||||
* @return a string representation which starts the result of `toString` |
||||
* applied to this $coll. By default the string prefix is the |
||||
* simple name of the collection class $coll. |
||||
*/ |
||||
def stringPrefix : String = { |
||||
var string = repr.asInstanceOf[AnyRef].getClass.getName |
||||
val idx1 = string.lastIndexOf('.' : Int) |
||||
if (idx1 != -1) string = string.substring(idx1 + 1) |
||||
val idx2 = string.indexOf('$') |
||||
if (idx2 != -1) string = string.substring(0, idx2) |
||||
string |
||||
} |
||||
|
||||
/** Creates a non-strict view of this $coll. |
||||
* |
||||
* @return a non-strict view of this $coll. |
||||
*/ |
||||
def view = new TraversableView[A, Repr] { |
||||
protected lazy val underlying = self.repr |
||||
override def foreach[U](f: A => U) = self foreach f |
||||
} |
||||
|
||||
/** Creates a non-strict view of a slice of this $coll. |
||||
* |
||||
* Note: the difference between `view` and `slice` is that `view` produces |
||||
* a view of the current $coll, whereas `slice` produces a new $coll. |
||||
* |
||||
* Note: `view(from, to)` is equivalent to `view.slice(from, to)` |
||||
* $orderDependent |
||||
* |
||||
* @param from the index of the first element of the view |
||||
* @param until the index of the element following the view |
||||
* @return a non-strict view of a slice of this $coll, starting at index `from` |
||||
* and extending up to (but not including) index `until`. |
||||
*/ |
||||
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until) |
||||
|
||||
/** Creates a non-strict filter of this $coll. |
||||
* |
||||
* Note: the difference between `c filter p` and `c withFilter p` is that |
||||
* the former creates a new collection, whereas the latter only |
||||
* restricts the domain of subsequent `map`, `flatMap`, `foreach`, |
||||
* and `withFilter` operations. |
||||
* $orderDependent |
||||
* |
||||
* @param p the predicate used to test elements. |
||||
* @return an object of class `WithFilter`, which supports |
||||
* `map`, `flatMap`, `foreach`, and `withFilter` operations. |
||||
* All these operations apply to those elements of this $coll which |
||||
* satisfy the predicate `p`. |
||||
*/ |
||||
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p) |
||||
|
||||
/** A class supporting filtered operations. Instances of this class are |
||||
* returned by method `withFilter`. |
||||
*/ |
||||
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] { |
||||
|
||||
/** Builds a new collection by applying a function to all elements of the |
||||
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`. |
||||
* |
||||
* @param f the function to apply to each element. |
||||
* @tparam B the element type of the returned collection. |
||||
* @tparam That $thatinfo |
||||
* @param bf $bfinfo |
||||
* @return a new collection of type `That` resulting from applying |
||||
* the given function `f` to each element of the outer $coll |
||||
* that satisfies predicate `p` and collecting the results. |
||||
* |
||||
* @usecase def map[B](f: A => B): $Coll[B] |
||||
* |
||||
* @return a new $coll resulting from applying the given function |
||||
* `f` to each element of the outer $coll that satisfies |
||||
* predicate `p` and collecting the results. |
||||
*/ |
||||
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
val b = bf(repr) |
||||
for (x <- self) |
||||
if (p(x)) b += f(x) |
||||
b.result |
||||
} |
||||
|
||||
/** Builds a new collection by applying a function to all elements of the |
||||
* outer $coll containing this `WithFilter` instance that satisfy |
||||
* predicate `p` and concatenating the results. |
||||
* |
||||
* @param f the function to apply to each element. |
||||
* @tparam B the element type of the returned collection. |
||||
* @tparam That $thatinfo |
||||
* @param bf $bfinfo |
||||
* @return a new collection of type `That` resulting from applying |
||||
* the given collection-valued function `f` to each element |
||||
* of the outer $coll that satisfies predicate `p` and |
||||
* concatenating the results. |
||||
* |
||||
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B] |
||||
* |
||||
* @return a new $coll resulting from applying the given collection-valued function |
||||
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results. |
||||
*/ |
||||
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { |
||||
val b = bf(repr) |
||||
for (x <- self) |
||||
if (p(x)) b ++= f(x).seq |
||||
b.result |
||||
} |
||||
|
||||
/** Applies a function `f` to all elements of the outer $coll containing |
||||
* this `WithFilter` instance that satisfy predicate `p`. |
||||
* |
||||
* @param f the function that is applied for its side-effect to every element. |
||||
* The result of function `f` is discarded. |
||||
* |
||||
* @tparam U the type parameter describing the result of function `f`. |
||||
* This result will always be ignored. Typically `U` is `Unit`, |
||||
* but this is not necessary. |
||||
* |
||||
* @usecase def foreach(f: A => Unit): Unit |
||||
*/ |
||||
def foreach[U](f: A => U): Unit = |
||||
for (x <- self) |
||||
if (p(x)) f(x) |
||||
|
||||
/** Further refines the filter for this $coll. |
||||
* |
||||
* @param q the predicate used to test elements. |
||||
* @return an object of class `WithFilter`, which supports |
||||
* `map`, `flatMap`, `foreach`, and `withFilter` operations. |
||||
* All these operations apply to those elements of this $coll which |
||||
* satisfy the predicate `q` in addition to the predicate `p`. |
||||
*/ |
||||
def withFilter(q: A => Boolean): WithFilter = |
||||
new WithFilter(x => p(x) && q(x)) |
||||
} |
||||
|
||||
// A helper for tails and inits. |
||||
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = { |
||||
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty) |
||||
it ++ Iterator(Nil) map (newBuilder ++= _ result) |
||||
} |
||||
} |
||||
|
||||
|
||||
</textarea> |
||||
</form> |
||||
|
||||
<script> |
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
||||
lineNumbers: true, |
||||
matchBrackets: true, |
||||
theme: "ambiance", |
||||
mode: "text/x-scala" |
||||
}); |
||||
</script> |
||||
</article> |
@ -1,59 +0,0 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() { |
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c"); |
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } |
||||
|
||||
MT("indent", |
||||
"[type void] [def foo]([type void*] [variable a], [type int] [variable b]) {", |
||||
" [type int] [variable c] [operator =] [variable b] [operator +]", |
||||
" [number 1];", |
||||
" [keyword return] [operator *][variable a];", |
||||
"}"); |
||||
|
||||
MT("indent_switch", |
||||
"[keyword switch] ([variable x]) {", |
||||
" [keyword case] [number 10]:", |
||||
" [keyword return] [number 20];", |
||||
" [keyword default]:", |
||||
" [variable printf]([string \"foo %c\"], [variable x]);", |
||||
"}"); |
||||
|
||||
MT("def", |
||||
"[type void] [def foo]() {}", |
||||
"[keyword struct] [def bar]{}", |
||||
"[type int] [type *][def baz]() {}"); |
||||
|
||||
MT("def_new_line", |
||||
"::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]", |
||||
"[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}") |
||||
|
||||
MT("double_block", |
||||
"[keyword for] (;;)", |
||||
" [keyword for] (;;)", |
||||
" [variable x][operator ++];", |
||||
"[keyword return];"); |
||||
|
||||
MT("preprocessor", |
||||
"[meta #define FOO 3]", |
||||
"[type int] [variable foo];", |
||||
"[meta #define BAR\\]", |
||||
"[meta 4]", |
||||
"[type unsigned] [type int] [variable bar] [operator =] [number 8];", |
||||
"[meta #include <baz> ][comment // comment]") |
||||
|
||||
|
||||
var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src"); |
||||
function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); } |
||||
|
||||
MTCPP("cpp14_literal", |
||||
"[number 10'000];", |
||||
"[number 0b10'000];", |
||||
"[number 0x10'000];", |
||||
"[string '100000'];"); |
||||
|
||||
MTCPP("ctor_dtor", |
||||
"[def Foo::Foo]() {}", |
||||
"[def Foo::~Foo]() {}"); |
||||
})(); |
@ -1,103 +0,0 @@
|
||||
<!doctype html> |
||||
|
||||
<title>CodeMirror: Closure Stylesheets (GSS) mode</title> |
||||
<meta charset="utf-8"/> |
||||
<link rel=stylesheet href="../../doc/docs.css"> |
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css"> |
||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css"> |
||||
<script src="../../lib/codemirror.js"></script> |
||||
<script src="css.js"></script> |
||||
<script src="../../addon/hint/show-hint.js"></script> |
||||
<script src="../../addon/hint/css-hint.js"></script> |
||||
<style>.CodeMirror {background: #f8f8f8;}</style> |
||||
<div id=nav> |
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
||||
|
||||
<ul> |
||||
<li><a href="../../index.html">Home</a> |
||||
<li><a href="../../doc/manual.html">Manual</a> |
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a> |
||||
</ul> |
||||
<ul> |
||||
<li><a href="../index.html">Language modes</a> |
||||
<li><a class=active href="#">Closure Stylesheets (GSS)</a> |
||||
</ul> |
||||
</div> |
||||
|
||||
<article> |
||||
<h2>Closure Stylesheets (GSS) mode</h2> |
||||
<form><textarea id="code" name="code"> |
||||
/* Some example Closure Stylesheets */ |
||||
|
||||
@provide 'some.styles'; |
||||
|
||||
@require 'other.styles'; |
||||
|
||||
@component { |
||||
|
||||
@def FONT_FAMILY "Times New Roman", Georgia, Serif; |
||||
@def FONT_SIZE_NORMAL 15px; |
||||
@def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY; |
||||
|
||||
@def BG_COLOR rgb(235, 239, 249); |
||||
|
||||
@def DIALOG_BORDER_COLOR rgb(107, 144, 218); |
||||
@def DIALOG_BG_COLOR BG_COLOR; |
||||
|
||||
@def LEFT_HAND_NAV_WIDTH 180px; |
||||
@def LEFT_HAND_NAV_PADDING 3px; |
||||
|
||||
@defmixin size(WIDTH, HEIGHT) { |
||||
width: WIDTH; |
||||
height: HEIGHT; |
||||
} |
||||
|
||||
body { |
||||
background-color: BG_COLOR; |
||||
margin: 0; |
||||
padding: 3em 6em; |
||||
font: FONT_NORMAL; |
||||
color: #000; |
||||
} |
||||
|
||||
#navigation a { |
||||
font-weight: bold; |
||||
text-decoration: none !important; |
||||
} |
||||
|
||||
.dialog { |
||||
background-color: DIALOG_BG_COLOR; |
||||
border: 1px solid DIALOG_BORDER_COLOR; |
||||
} |
||||
|
||||
.content { |
||||
position: absolute; |
||||
margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */ |
||||
LEFT_HAND_NAV_WIDTH, |
||||
LEFT_HAND_NAV_PADDING); /* padding right */ |
||||
|
||||
} |
||||
|
||||
.logo { |
||||
@mixin size(150px, 55px); |
||||
background-image: url('http://www.google.com/images/logo_sm.gif'); |
||||
} |
||||
|
||||
} |
||||
</textarea></form> |
||||
<script> |
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
||||
extraKeys: {"Ctrl-Space": "autocomplete"}, |
||||
lineNumbers: true, |
||||
matchBrackets: "text/x-less", |
||||
mode: "text/x-gss" |
||||
}); |
||||
</script> |
||||
|
||||
<p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p> |
||||
<p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p> |
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p> |
||||
|
||||
</article> |
@ -1,17 +0,0 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() { |
||||
"use strict"; |
||||
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss"); |
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); } |
||||
|
||||
MT("atComponent", |
||||
"[def @component] {", |
||||
"[tag foo] {", |
||||
" [property color]: [keyword black];", |
||||
"}", |
||||
"}"); |
||||
|
||||
})(); |
@ -1,75 +0,0 @@
|
||||
<!doctype html> |
||||
|
||||
<title>CodeMirror: CSS mode</title> |
||||
<meta charset="utf-8"/> |
||||
<link rel=stylesheet href="../../doc/docs.css"> |
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css"> |
||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css"> |
||||
<script src="../../lib/codemirror.js"></script> |
||||
<script src="css.js"></script> |
||||
<script src="../../addon/hint/show-hint.js"></script> |
||||
<script src="../../addon/hint/css-hint.js"></script> |
||||
<style>.CodeMirror {background: #f8f8f8;}</style> |
||||
<div id=nav> |
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
||||
|
||||
<ul> |
||||
<li><a href="../../index.html">Home</a> |
||||
<li><a href="../../doc/manual.html">Manual</a> |
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a> |
||||
</ul> |
||||
<ul> |
||||
<li><a href="../index.html">Language modes</a> |
||||
<li><a class=active href="#">CSS</a> |
||||
</ul> |
||||
</div> |
||||
|
||||
<article> |
||||
<h2>CSS mode</h2> |
||||
<form><textarea id="code" name="code"> |
||||
/* Some example CSS */ |
||||
|
||||
@import url("something.css"); |
||||
|
||||
body { |
||||
margin: 0; |
||||
padding: 3em 6em; |
||||
font-family: tahoma, arial, sans-serif; |
||||
color: #000; |
||||
} |
||||
|
||||
#navigation a { |
||||
font-weight: bold; |
||||
text-decoration: none !important; |
||||
} |
||||
|
||||
h1 { |
||||
font-size: 2.5em; |
||||
} |
||||
|
||||
h2 { |
||||
font-size: 1.7em; |
||||
} |
||||
|
||||
h1:before, h2:before { |
||||
content: "::"; |
||||
} |
||||
|
||||
code { |
||||
font-family: courier, monospace; |
||||
font-size: 80%; |
||||
color: #418A8A; |
||||
} |
||||
</textarea></form> |
||||
<script> |
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
||||
extraKeys: {"Ctrl-Space": "autocomplete"} |
||||
}); |
||||
</script> |
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/css</code>, <code>text/x-scss</code> (<a href="scss.html">demo</a>), <code>text/x-less</code> (<a href="less.html">demo</a>).</p> |
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#css_*">normal</a>, <a href="../../test/index.html#verbose,css_*">verbose</a>.</p> |
||||
|
||||
</article> |
@ -1,152 +0,0 @@
|
||||
<!doctype html> |
||||
|
||||
<title>CodeMirror: LESS mode</title> |
||||
<meta charset="utf-8"/> |
||||
<link rel=stylesheet href="../../doc/docs.css"> |
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css"> |
||||
<script src="../../lib/codemirror.js"></script> |
||||
<script src="../../addon/edit/matchbrackets.js"></script> |
||||
<script src="css.js"></script> |
||||
<style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style> |
||||
<div id=nav> |
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
||||
|
||||
<ul> |
||||
<li><a href="../../index.html">Home</a> |
||||
<li><a href="../../doc/manual.html">Manual</a> |
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a> |
||||
</ul> |
||||
<ul> |
||||
<li><a href="../index.html">Language modes</a> |
||||
<li><a class=active href="#">LESS</a> |
||||
</ul> |
||||
</div> |
||||
|
||||
<article> |
||||
<h2>LESS mode</h2> |
||||
<form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … } |
||||
@media screen and (device-aspect-ratio: 1280/720) { … } |
||||
@media screen and (device-aspect-ratio: 2560/1440) { … } |
||||
|
||||
html:lang(fr-be) |
||||
|
||||
tr:nth-child(2n+1) /* represents every odd row of an HTML table */ |
||||
|
||||
img:nth-of-type(2n+1) { float: right; } |
||||
img:nth-of-type(2n) { float: left; } |
||||
|
||||
body > h2:not(:first-of-type):not(:last-of-type) |
||||
|
||||
html|*:not(:link):not(:visited) |
||||
*|*:not(:hover) |
||||
p::first-line { text-transform: uppercase } |
||||
|
||||
@namespace foo url(http://www.example.com); |
||||
foo|h1 { color: blue } /* first rule */ |
||||
|
||||
span[hello="Ocean"][goodbye="Land"] |
||||
|
||||
E[foo]{ |
||||
padding:65px; |
||||
} |
||||
|
||||
input[type="search"]::-webkit-search-decoration, |
||||
input[type="search"]::-webkit-search-cancel-button { |
||||
-webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5 |
||||
} |
||||
button::-moz-focus-inner, |
||||
input::-moz-focus-inner { // Inner padding and border oddities in FF3/4 |
||||
padding: 0; |
||||
border: 0; |
||||
} |
||||
.btn { |
||||
// reset here as of 2.0.3 due to Recess property order |
||||
border-color: #ccc; |
||||
border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25); |
||||
} |
||||
fieldset span button, fieldset span input[type="file"] { |
||||
font-size:12px; |
||||
font-family:Arial, Helvetica, sans-serif; |
||||
} |
||||
|
||||
.rounded-corners (@radius: 5px) { |
||||
border-radius: @radius; |
||||
-webkit-border-radius: @radius; |
||||
-moz-border-radius: @radius; |
||||
} |
||||
|
||||
@import url("something.css"); |
||||
|
||||
@light-blue: hsl(190, 50%, 65%); |
||||
|
||||
#menu { |
||||
position: absolute; |
||||
width: 100%; |
||||
z-index: 3; |
||||
clear: both; |
||||
display: block; |
||||
background-color: @blue; |
||||
height: 42px; |
||||
border-top: 2px solid lighten(@alpha-blue, 20%); |
||||
border-bottom: 2px solid darken(@alpha-blue, 25%); |
||||
.box-shadow(0, 1px, 8px, 0.6); |
||||
-moz-box-shadow: 0 0 0 #000; // Because firefox sucks. |
||||
|
||||
&.docked { |
||||
background-color: hsla(210, 60%, 40%, 0.4); |
||||
} |
||||
&:hover { |
||||
background-color: @blue; |
||||
} |
||||
|
||||
#dropdown { |
||||
margin: 0 0 0 117px; |
||||
padding: 0; |
||||
padding-top: 5px; |
||||
display: none; |
||||
width: 190px; |
||||
border-top: 2px solid @medium; |
||||
color: @highlight; |
||||
border: 2px solid darken(@medium, 25%); |
||||
border-left-color: darken(@medium, 15%); |
||||
border-right-color: darken(@medium, 15%); |
||||
border-top-width: 0; |
||||
background-color: darken(@medium, 10%); |
||||
ul { |
||||
padding: 0px; |
||||
} |
||||
li { |
||||
font-size: 14px; |
||||
display: block; |
||||
text-align: left; |
||||
padding: 0; |
||||
border: 0; |
||||
a { |
||||
display: block; |
||||
padding: 0px 15px; |
||||
text-decoration: none; |
||||
color: white; |
||||
&:hover { |
||||
background-color: darken(@medium, 15%); |
||||
text-decoration: none; |
||||
} |
||||
} |
||||
} |
||||
.border-radius(5px, bottom); |
||||
.box-shadow(0, 6px, 8px, 0.5); |
||||
} |
||||
} |
||||
</textarea></form> |
||||
<script> |
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
||||
lineNumbers : true, |
||||
matchBrackets : true, |
||||
mode: "text/x-less" |
||||
}); |
||||
</script> |
||||
|
||||
<p>The LESS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p> |
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#less_*">normal</a>, <a href="../../test/index.html#verbose,less_*">verbose</a>.</p> |
||||
</article> |
@ -1,54 +0,0 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() { |
||||
"use strict"; |
||||
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-less"); |
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "less"); } |
||||
|
||||
MT("variable", |
||||
"[variable-2 @base]: [atom #f04615];", |
||||
"[qualifier .class] {", |
||||
" [property width]: [variable percentage]([number 0.5]); [comment // returns `50%`]", |
||||
" [property color]: [variable saturate]([variable-2 @base], [number 5%]);", |
||||
"}"); |
||||
|
||||
MT("amp", |
||||
"[qualifier .child], [qualifier .sibling] {", |
||||
" [qualifier .parent] [atom &] {", |
||||
" [property color]: [keyword black];", |
||||
" }", |
||||
" [atom &] + [atom &] {", |
||||
" [property color]: [keyword red];", |
||||
" }", |
||||
"}"); |
||||
|
||||
MT("mixin", |
||||
"[qualifier .mixin] ([variable dark]; [variable-2 @color]) {", |
||||
" [property color]: [atom darken]([variable-2 @color], [number 10%]);", |
||||
"}", |
||||
"[qualifier .mixin] ([variable light]; [variable-2 @color]) {", |
||||
" [property color]: [atom lighten]([variable-2 @color], [number 10%]);", |
||||
"}", |
||||
"[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {", |
||||
" [property display]: [atom block];", |
||||
"}", |
||||
"[variable-2 @switch]: [variable light];", |
||||
"[qualifier .class] {", |
||||
" [qualifier .mixin]([variable-2 @switch]; [atom #888]);", |
||||
"}"); |
||||
|
||||
MT("nest", |
||||
"[qualifier .one] {", |
||||
" [def @media] ([property width]: [number 400px]) {", |
||||
" [property font-size]: [number 1.2em];", |
||||
" [def @media] [attribute print] [keyword and] [property color] {", |
||||
" [property color]: [keyword blue];", |
||||
" }", |
||||
" }", |
||||
"}"); |
||||
|
||||
|
||||
MT("interpolation", ".@{[variable foo]} { [property font-weight]: [atom bold]; }"); |
||||
})(); |
@ -1,157 +0,0 @@
|
||||
<!doctype html> |
||||
|
||||
<title>CodeMirror: SCSS mode</title> |
||||
<meta charset="utf-8"/> |
||||
<link rel=stylesheet href="../../doc/docs.css"> |
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css"> |
||||
<script src="../../lib/codemirror.js"></script> |
||||
<script src="css.js"></script> |
||||
<style>.CodeMirror {background: #f8f8f8;}</style> |
||||
<div id=nav> |
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
||||
|
||||
<ul> |
||||
<li><a href="../../index.html">Home</a> |
||||
<li><a href="../../doc/manual.html">Manual</a> |
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a> |
||||
</ul> |
||||
<ul> |
||||
<li><a href="../index.html">Language modes</a> |
||||
<li><a class=active href="#">SCSS</a> |
||||
</ul> |
||||
</div> |
||||
|
||||
<article> |
||||
<h2>SCSS mode</h2> |
||||
<form><textarea id="code" name="code"> |
||||
/* Some example SCSS */ |
||||
|
||||
@import "compass/css3"; |
||||
$variable: #333; |
||||
|
||||
$blue: #3bbfce; |
||||
$margin: 16px; |
||||
|
||||
.content-navigation { |
||||
#nested { |
||||
background-color: black; |
||||
} |
||||
border-color: $blue; |
||||
color: |
||||
darken($blue, 9%); |
||||
} |
||||
|
||||
.border { |
||||
padding: $margin / 2; |
||||
margin: $margin / 2; |
||||
border-color: $blue; |
||||
} |
||||
|
||||
@mixin table-base { |
||||
th { |
||||
text-align: center; |
||||
font-weight: bold; |
||||
} |
||||
td, th {padding: 2px} |
||||
} |
||||
|
||||
table.hl { |
||||
margin: 2em 0; |
||||
td.ln { |
||||
text-align: right; |
||||
} |
||||
} |
||||
|
||||
li { |
||||
font: { |
||||
family: serif; |
||||
weight: bold; |
||||
size: 1.2em; |
||||
} |
||||
} |
||||
|
||||
@mixin left($dist) { |
||||
float: left; |
||||
margin-left: $dist; |
||||
} |
||||
|
||||
#data { |
||||
@include left(10px); |
||||
@include table-base; |
||||
} |
||||
|
||||
.source { |
||||
@include flow-into(target); |
||||
border: 10px solid green; |
||||
margin: 20px; |
||||
width: 200px; } |
||||
|
||||
.new-container { |
||||
@include flow-from(target); |
||||
border: 10px solid red; |
||||
margin: 20px; |
||||
width: 200px; } |
||||
|
||||
body { |
||||
margin: 0; |
||||
padding: 3em 6em; |
||||
font-family: tahoma, arial, sans-serif; |
||||
color: #000; |
||||
} |
||||
|
||||
@mixin yellow() { |
||||
background: yellow; |
||||
} |
||||
|
||||
.big { |
||||
font-size: 14px; |
||||
} |
||||
|
||||
.nested { |
||||
@include border-radius(3px); |
||||
@extend .big; |
||||
p { |
||||
background: whitesmoke; |
||||
a { |
||||
color: red; |
||||
} |
||||
} |
||||
} |
||||
|
||||
#navigation a { |
||||
font-weight: bold; |
||||
text-decoration: none !important; |
||||
} |
||||
|
||||
h1 { |
||||
font-size: 2.5em; |
||||
} |
||||
|
||||
h2 { |
||||
font-size: 1.7em; |
||||
} |
||||
|
||||
h1:before, h2:before { |
||||
content: "::"; |
||||
} |
||||
|
||||
code { |
||||
font-family: courier, monospace; |
||||
font-size: 80%; |
||||
color: #418A8A; |
||||
} |
||||
</textarea></form> |
||||
<script> |
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
||||
lineNumbers: true, |
||||
matchBrackets: true, |
||||
mode: "text/x-scss" |
||||
}); |
||||
</script> |
||||
|
||||
<p>The SCSS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p> |
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#scss_*">normal</a>, <a href="../../test/index.html#verbose,scss_*">verbose</a>.</p> |
||||
|
||||
</article> |
@ -1,110 +0,0 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() { |
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-scss"); |
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); } |
||||
|
||||
MT('url_with_quotation', |
||||
"[tag foo] { [property background]:[atom url]([string test.jpg]) }"); |
||||
|
||||
MT('url_with_double_quotes', |
||||
"[tag foo] { [property background]:[atom url]([string \"test.jpg\"]) }"); |
||||
|
||||
MT('url_with_single_quotes', |
||||
"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) }"); |
||||
|
||||
MT('string', |
||||
"[def @import] [string \"compass/css3\"]"); |
||||
|
||||
MT('important_keyword', |
||||
"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) [keyword !important] }"); |
||||
|
||||
MT('variable', |
||||
"[variable-2 $blue]:[atom #333]"); |
||||
|
||||
MT('variable_as_attribute', |
||||
"[tag foo] { [property color]:[variable-2 $blue] }"); |
||||
|
||||
MT('numbers', |
||||
"[tag foo] { [property padding]:[number 10px] [number 10] [number 10em] [number 8in] }"); |
||||
|
||||
MT('number_percentage', |
||||
"[tag foo] { [property width]:[number 80%] }"); |
||||
|
||||
MT('selector', |
||||
"[builtin #hello][qualifier .world]{}"); |
||||
|
||||
MT('singleline_comment', |
||||
"[comment // this is a comment]"); |
||||
|
||||
MT('multiline_comment', |
||||
"[comment /*foobar*/]"); |
||||
|
||||
MT('attribute_with_hyphen', |
||||
"[tag foo] { [property font-size]:[number 10px] }"); |
||||
|
||||
MT('string_after_attribute', |
||||
"[tag foo] { [property content]:[string \"::\"] }"); |
||||
|
||||
MT('directives', |
||||
"[def @include] [qualifier .mixin]"); |
||||
|
||||
MT('basic_structure', |
||||
"[tag p] { [property background]:[keyword red]; }"); |
||||
|
||||
MT('nested_structure', |
||||
"[tag p] { [tag a] { [property color]:[keyword red]; } }"); |
||||
|
||||
MT('mixin', |
||||
"[def @mixin] [tag table-base] {}"); |
||||
|
||||
MT('number_without_semicolon', |
||||
"[tag p] {[property width]:[number 12]}", |
||||
"[tag a] {[property color]:[keyword red];}"); |
||||
|
||||
MT('atom_in_nested_block', |
||||
"[tag p] { [tag a] { [property color]:[atom #000]; } }"); |
||||
|
||||
MT('interpolation_in_property', |
||||
"[tag foo] { #{[variable-2 $hello]}:[number 2]; }"); |
||||
|
||||
MT('interpolation_in_selector', |
||||
"[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }"); |
||||
|
||||
MT('interpolation_error', |
||||
"[tag foo]#{[variable foo]} { [property color]:[atom #000]; }"); |
||||
|
||||
MT("divide_operator", |
||||
"[tag foo] { [property width]:[number 4] [operator /] [number 2] }"); |
||||
|
||||
MT('nested_structure_with_id_selector', |
||||
"[tag p] { [builtin #hello] { [property color]:[keyword red]; } }"); |
||||
|
||||
MT('indent_mixin', |
||||
"[def @mixin] [tag container] (", |
||||
" [variable-2 $a]: [number 10],", |
||||
" [variable-2 $b]: [number 10])", |
||||
"{}"); |
||||
|
||||
MT('indent_nested', |
||||
"[tag foo] {", |
||||
" [tag bar] {", |
||||
" }", |
||||
"}"); |
||||
|
||||
MT('indent_parentheses', |
||||
"[tag foo] {", |
||||
" [property color]: [atom darken]([variable-2 $blue],", |
||||
" [number 9%]);", |
||||
"}"); |
||||
|
||||
MT('indent_vardef', |
||||
"[variable-2 $name]:", |
||||
" [string 'val'];", |
||||
"[tag tag] {", |
||||
" [tag inner] {", |
||||
" [property margin]: [number 3px];", |
||||
" }", |
||||
"}"); |
||||
})(); |
@ -1,206 +0,0 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() { |
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "css"); |
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } |
||||
|
||||
// Error, because "foobarhello" is neither a known type or property, but
|
||||
// property was expected (after "and"), and it should be in parentheses.
|
||||
MT("atMediaUnknownType", |
||||
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }"); |
||||
|
||||
// Soft error, because "foobarhello" is not a known property or type.
|
||||
MT("atMediaUnknownProperty", |
||||
"[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }"); |
||||
|
||||
// Make sure nesting works with media queries
|
||||
MT("atMediaMaxWidthNested", |
||||
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }"); |
||||
|
||||
MT("atMediaFeatureValueKeyword", |
||||
"[def @media] ([property orientation]: [keyword landscape]) { }"); |
||||
|
||||
MT("atMediaUnknownFeatureValueKeyword", |
||||
"[def @media] ([property orientation]: [error upsidedown]) { }"); |
||||
|
||||
MT("tagSelector", |
||||
"[tag foo] { }"); |
||||
|
||||
MT("classSelector", |
||||
"[qualifier .foo-bar_hello] { }"); |
||||
|
||||
MT("idSelector", |
||||
"[builtin #foo] { [error #foo] }"); |
||||
|
||||
MT("tagSelectorUnclosed", |
||||
"[tag foo] { [property margin]: [number 0] } [tag bar] { }"); |
||||
|
||||
MT("tagStringNoQuotes", |
||||
"[tag foo] { [property font-family]: [variable hello] [variable world]; }"); |
||||
|
||||
MT("tagStringDouble", |
||||
"[tag foo] { [property font-family]: [string \"hello world\"]; }"); |
||||
|
||||
MT("tagStringSingle", |
||||
"[tag foo] { [property font-family]: [string 'hello world']; }"); |
||||
|
||||
MT("tagColorKeyword", |
||||
"[tag foo] {", |
||||
" [property color]: [keyword black];", |
||||
" [property color]: [keyword navy];", |
||||
" [property color]: [keyword yellow];", |
||||
"}"); |
||||
|
||||
MT("tagColorHex3", |
||||
"[tag foo] { [property background]: [atom #fff]; }"); |
||||
|
||||
MT("tagColorHex4", |
||||
"[tag foo] { [property background]: [atom #ffff]; }"); |
||||
|
||||
MT("tagColorHex6", |
||||
"[tag foo] { [property background]: [atom #ffffff]; }"); |
||||
|
||||
MT("tagColorHex8", |
||||
"[tag foo] { [property background]: [atom #ffffffff]; }"); |
||||
|
||||
MT("tagColorHex5Invalid", |
||||
"[tag foo] { [property background]: [atom&error #fffff]; }"); |
||||
|
||||
MT("tagColorHexInvalid", |
||||
"[tag foo] { [property background]: [atom&error #ffg]; }"); |
||||
|
||||
MT("tagNegativeNumber", |
||||
"[tag foo] { [property margin]: [number -5px]; }"); |
||||
|
||||
MT("tagPositiveNumber", |
||||
"[tag foo] { [property padding]: [number 5px]; }"); |
||||
|
||||
MT("tagVendor", |
||||
"[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }"); |
||||
|
||||
MT("tagBogusProperty", |
||||
"[tag foo] { [property&error barhelloworld]: [number 0]; }"); |
||||
|
||||
MT("tagTwoProperties", |
||||
"[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }"); |
||||
|
||||
MT("tagTwoPropertiesURL", |
||||
"[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }"); |
||||
|
||||
MT("indent_tagSelector", |
||||
"[tag strong], [tag em] {", |
||||
" [property background]: [atom rgba](", |
||||
" [number 255], [number 255], [number 0], [number .2]", |
||||
" );", |
||||
"}"); |
||||
|
||||
MT("indent_atMedia", |
||||
"[def @media] {", |
||||
" [tag foo] {", |
||||
" [property color]:", |
||||
" [keyword yellow];", |
||||
" }", |
||||
"}"); |
||||
|
||||
MT("indent_comma", |
||||
"[tag foo] {", |
||||
" [property font-family]: [variable verdana],", |
||||
" [atom sans-serif];", |
||||
"}"); |
||||
|
||||
MT("indent_parentheses", |
||||
"[tag foo]:[variable-3 before] {", |
||||
" [property background]: [atom url](", |
||||
"[string blahblah]", |
||||
"[string etc]", |
||||
"[string ]) [keyword !important];", |
||||
"}"); |
||||
|
||||
MT("font_face", |
||||
"[def @font-face] {", |
||||
" [property font-family]: [string 'myfont'];", |
||||
" [error nonsense]: [string 'abc'];", |
||||
" [property src]: [atom url]([string http://blah]),", |
||||
" [atom url]([string http://foo]);", |
||||
"}"); |
||||
|
||||
MT("empty_url", |
||||
"[def @import] [atom url]() [attribute screen];"); |
||||
|
||||
MT("parens", |
||||
"[qualifier .foo] {", |
||||
" [property background-image]: [variable fade]([atom #000], [number 20%]);", |
||||
" [property border-image]: [atom linear-gradient](", |
||||
" [atom to] [atom bottom],", |
||||
" [variable fade]([atom #000], [number 20%]) [number 0%],", |
||||
" [variable fade]([atom #000], [number 20%]) [number 100%]", |
||||
" );", |
||||
"}"); |
||||
|
||||
MT("css_variable", |
||||
":[variable-3 root] {", |
||||
" [variable-2 --main-color]: [atom #06c];", |
||||
"}", |
||||
"[tag h1][builtin #foo] {", |
||||
" [property color]: [atom var]([variable-2 --main-color]);", |
||||
"}"); |
||||
|
||||
MT("supports", |
||||
"[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {", |
||||
" [property text-align-last]: [atom justify];", |
||||
"}"); |
||||
|
||||
MT("document", |
||||
"[def @document] [tag url]([string http://blah]),", |
||||
" [tag url-prefix]([string https://]),", |
||||
" [tag domain]([string blah.com]),", |
||||
" [tag regexp]([string \".*blah.+\"]) {", |
||||
" [builtin #id] {", |
||||
" [property background-color]: [keyword white];", |
||||
" }", |
||||
" [tag foo] {", |
||||
" [property font-family]: [variable Verdana], [atom sans-serif];", |
||||
" }", |
||||
"}"); |
||||
|
||||
MT("document_url", |
||||
"[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }"); |
||||
|
||||
MT("document_urlPrefix", |
||||
"[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }"); |
||||
|
||||
MT("document_domain", |
||||
"[def @document] [tag domain]([string blah.com]) { [tag foo] { } }"); |
||||
|
||||
MT("document_regexp", |
||||
"[def @document] [tag regexp]([string \".*blah.+\"]) { [builtin #id] { } }"); |
||||
|
||||
MT("counter-style", |
||||
"[def @counter-style] [variable binary] {", |
||||
" [property system]: [atom numeric];", |
||||
" [property symbols]: [number 0] [number 1];", |
||||
" [property suffix]: [string \".\"];", |
||||
" [property range]: [atom infinite];", |
||||
" [property speak-as]: [atom numeric];", |
||||
"}"); |
||||
|
||||
MT("counter-style-additive-symbols", |
||||
"[def @counter-style] [variable simple-roman] {", |
||||
" [property system]: [atom additive];", |
||||
" [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];", |
||||
" [property range]: [number 1] [number 49];", |
||||
"}"); |
||||
|
||||
MT("counter-style-use", |
||||
"[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }"); |
||||
|
||||
MT("counter-style-symbols", |
||||
"[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }"); |
||||
|
||||
MT("comment-does-not-disrupt", |
||||
"[def @font-face] [comment /* foo */] {", |
||||
" [property src]: [atom url]([string x]);", |
||||
" [property font-family]: [variable One];", |
||||
"}") |
||||
})(); |
@ -1,60 +0,0 @@
|
||||
<!doctype html> |
||||
|
||||
<title>CodeMirror: Html Embedded Scripts mode</title> |
||||
<meta charset="utf-8"/> |
||||
<link rel=stylesheet href="../../doc/docs.css"> |
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css"> |
||||
<script src="../../lib/codemirror.js"></script> |
||||
<script src="../xml/xml.js"></script> |
||||
<script src="../javascript/javascript.js"></script> |
||||
<script src="../css/css.js"></script> |
||||
<script src="../htmlmixed/htmlmixed.js"></script> |
||||
<script src="../../addon/mode/multiplex.js"></script> |
||||
<script src="htmlembedded.js"></script> |
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> |
||||
<div id=nav> |
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
||||
|
||||
<ul> |
||||
<li><a href="../../index.html">Home</a> |
||||
<li><a href="../../doc/manual.html">Manual</a> |
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a> |
||||
</ul> |
||||
<ul> |
||||
<li><a href="../index.html">Language modes</a> |
||||
<li><a class=active href="#">Html Embedded Scripts</a> |
||||
</ul> |
||||
</div> |
||||
|
||||
<article> |
||||
<h2>Html Embedded Scripts mode</h2> |
||||
<form><textarea id="code" name="code"> |
||||
<% |
||||
function hello(who) { |
||||
return "Hello " + who; |
||||
} |
||||
%> |
||||
This is an example of EJS (embedded javascript) |
||||
<p>The program says <%= hello("world") %>.</p> |
||||
<script> |
||||
alert("And here is some normal JS code"); // also colored |
||||
</script> |
||||
</textarea></form> |
||||
|
||||
<script> |
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
||||
lineNumbers: true, |
||||
mode: "application/x-ejs", |
||||
indentUnit: 4, |
||||
indentWithTabs: true |
||||
}); |
||||
</script> |
||||
|
||||
<p>Mode for html embedded scripts like JSP and ASP.NET. Depends on multiplex and HtmlMixed which in turn depends on |
||||
JavaScript, CSS and XML.<br />Other dependencies include those of the scripting language chosen.</p> |
||||
|
||||
<p><strong>MIME types defined:</strong> <code>application/x-aspx</code> (ASP.NET), |
||||
<code>application/x-ejs</code> (Embedded Javascript), <code>application/x-jsp</code> (JavaServer Pages) |
||||
and <code>application/x-erb</code></p> |
||||
</article> |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue