Skip to content

Commit

Permalink
Merge pull request kirillplatonov#6 from KpuTuK/master
Browse files Browse the repository at this point in the history
2.6.1
  • Loading branch information
kirillplatonov committed Jan 10, 2016
2 parents 65ba708 + 0a23e55 commit 021fa2d
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/data_files/config.php
/data_files/config.php
/nbproject/
2 changes: 1 addition & 1 deletion data_files/day.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23
09
8 changes: 4 additions & 4 deletions install/system_dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ CREATE TABLE IF NOT EXISTS `a_ads_manager_links` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
//=====================================//
INSERT INTO `a_ads_manager_links` (`link_id`, `area_id`, `area_ident`, `title`, `url`, `names`, `position`, `count_all`) VALUES
(1, 1, 'all_pages_up', 'Ссылка вверху', 'http://jaze.ru', 'Бесплатная эротика!', 1, 7),
(3, 2, 'all_pages_down', 'Ссылка снизу', 'http://mobilecms.ru', '[red]Первое название[/red]\r\n[green]Второе название[/green]\r\n[blue]Третье название[/blue]', 1, 0);
(3, 2, 'all_pages_down', 'Ссылка снизу', 'https://github.com/KpuTuK/MobileCMS', '[red]MobileCMS download[/red]\r\n[green]MobileCMS repository[/green]\r\n[blue]new MobileCMS[/blue]', 1, 0);
//=====================================//
CREATE TABLE IF NOT EXISTS `a_chat_messages` (
`message_id` int(11) NOT NULL auto_increment,
Expand Down Expand Up @@ -89,6 +88,8 @@ INSERT INTO `a_config` (`id`, `module`, `key`, `value`) VALUES
(8, 'system', 'profiler', 'off'),
(9, 'system', 'display_errors', '1'),
(10, 'system', 'admin_theme', 'admin'),
(11, 'system', 'default_theme', 'default'),
(12, 'system', 'web_theme', 'default'),
(44, 'downloads', 'files_prefix', ''),
(45, 'downloads', 'files_per_page', '7'),
(46, 'downloads', 'directories_per_page', '50'),
Expand All @@ -102,7 +103,6 @@ INSERT INTO `a_config` (`id`, `module`, `key`, `value`) VALUES
(54, 'forum', 'topics_per_page', '7'),
(55, 'forum', 'guests_create_topics', '0'),
(56, 'forum', 'guests_write_messages', '0'),
(11, 'system', 'default_theme', 'default'),
(57, 'downloads', 'allowed_filetypes', 'jpeg;jpg;gif;png;jar;mp3;mid;midi;wav;nth;sis;3gp;mp4;txt;zip;rar'),
(58, 'downloads', 'max_filesize', '5'),
(59, 'ads_manager', 'enable_notice', '0'),
Expand Down Expand Up @@ -321,7 +321,7 @@ CREATE TABLE IF NOT EXISTS `a_news` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
//=====================================//
INSERT INTO `a_news` (`subject`, `text`, `time`) VALUES
('Установка MobileCMS v2.x', 'Здравствуйте. Вы установили на сайт MobileCMS - профессиональную CMS для создания мобильных сайтов. Перед началом работы мы настоятельно рекомендуем ознакомиться с документацией, которая находится по адресу <b>http://ваш_сайт.ру/docs/</b>. Изменить содержимое этой новости вы можете в панеле управления сайтом, раздел <b>новости</b>. Получить техническую поддержку, а также скачать последнюю версию CMS вы всегда можете на официальном сайте <a href="http://mobilecms">http://mobilecms</a>. С уважением, разработчики MobileCMS.', 1307462472);
('Установка MobileCMS v2.6.1', 'Здравствуйте. Вы установили на сайт MobileCMS - профессиональную CMS для создания мобильных сайтов. Перед началом работы мы настоятельно рекомендуем ознакомиться с документацией, которая находится по адресу <b>http://ваш_сайт.ру/docs/</b>. Изменить содержимое этой новости вы можете в панеле управления сайтом, раздел <b>новости</b>. Получить техническую поддержку, а также скачать последнюю версию CMS вы всегда можете на официальном репозитории <a href="https://github.com/KpuTuK/MobileCMS">MobileCMS</a>. С уважением, разработчики MobileCMS.', 1307462472);
//=====================================//
CREATE TABLE IF NOT EXISTS `a_pages` (
`page_id` int(11) NOT NULL auto_increment,
Expand Down
6 changes: 5 additions & 1 deletion kernel/general_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ function error($error_message = '', $link = '') {
function a_notice($message, $link, $timeout = 5) {
$tpl = Registry::get('tpl');

$message = str_safe($message);
$link = str_safe($link);
if (isset($tpl)) {
$tpl->assign(array(
'title' => 'Информация',
Expand All @@ -127,7 +129,9 @@ function a_notice($message, $link, $timeout = 5) {
*/
function a_confirm($message, $link_ok, $link_cancel) {
$tpl = Registry::get('tpl');

$message = str_safe($message);
$link_ok = str_safe($link_ok);
$link_cancel = str_safe($link_cancel);
if (empty($message)) $message = 'Подтверждаете выполнение данного действия?';

if (isset($tpl)) {
Expand Down
30 changes: 15 additions & 15 deletions libraries/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,40 @@ public function __construct($template_dir = '', $cache_dir = ''){
*/
public function parse($filename, $params = array()){
# Если не указано расширение файла, указываем его
if(!strstr($filename, '.tpl')) {
$filename .= '.tpl';
}
if(!strstr($filename, '.tpl')) {
$filename .= '.tpl';
}

# Определение дополнительных параметров
foreach($params AS $var => $var_value) {
$this->vars[$var] = $var_value;
}

if(strpos($this->theme, 'admin') === 0) {
$alternative_theme = 'admin';
} else {
$alternative_theme = 'default';
}
if(strpos($this->theme, 'admin') === 0) {
$alternative_theme = 'admin';
} else {
$alternative_theme = 'default';
}

# Определяем имя файла шаблона
if(strstr($filename, '{THEME}')) {
if(file_exists(ROOT . str_replace('{THEME}', THEME, $filename))) {
$this->template_file = ROOT . str_replace('{THEME}', THEME, $filename);
} elseif(file_exists(ROOT . str_replace('{THEME}', $alternative_theme, $filename))) {
$this->template_file = ROOT . str_replace('{THEME}', $alternative_theme, $filename);
} else {
die('Файл <b>'. $filename .'</b> не является шаблоном или не найден.');
}
} else {
die('Файл <b>'. $filename .'</b> не является шаблоном или не найден.');
}
} else {
if(file_exists(ROOT . 'modules/'. ROUTE_MODULE .'/views/'. $this->theme .'/'. $filename)) {
$this->template_file = ROOT . 'modules/'. ROUTE_MODULE .'/views/'. $this->theme .'/'. $filename;
} elseif(file_exists(ROOT . 'modules/'. ROUTE_MODULE .'/views/'. $alternative_theme .'/'. $filename)) {
$this->template_file = ROOT . 'modules/'. ROUTE_MODULE .'/views/'. $alternative_theme .'/'. $filename;
} elseif(file_exists(ROOT .'/views/'. $this->theme .'/'. $filename)) {
$this->template_file = ROOT .'/views/'. $this->theme .'/'. $filename;
} else {
die('Файл <b>'. $filename .'</b> не является шаблоном или не найден.');
}
} else {
die('Файл <b>'. $filename .'</b> не является шаблоном или не найден.');
}
}

# Создаем ссылки на переменные из общего массива, чтобы они были видны в шаблоне
Expand All @@ -77,7 +77,7 @@ public function parse($filename, $params = array()){

/**
* Вывод кода страницы
* @param string $filename
* @param string $filename
*/
public function display($filename, $params = array()) {
echo $this->parse($filename, $params);
Expand Down
6 changes: 3 additions & 3 deletions modules/ads_manager/controllers/ads_manager_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function action_link_edit() {
$this->db->query("INSERT INTO #__ads_manager_links SET
title = '". a_safe($_POST['title'])."',
url = '". a_safe($_POST['url'])."',
names = '". mysql_real_escape_string($_POST['names'])."',
names = '". mysqli_real_escape_string($this->db_link, $_POST['names'])."',
area_id = '". $area['area_id']."',
area_ident = '". $area['ident']."',
position = '". $position."'
Expand All @@ -166,7 +166,7 @@ public function action_link_edit() {
$this->db->query("UPDATE #__ads_manager_links SET
title = '". a_safe($_POST['title'])."',
url = '". a_safe($_POST['url'])."',
names = '". mysql_real_escape_string($_POST['names'])."',
names = '". mysqli_real_escape_string($this->db_link, $_POST['names'])."',
area_id = '". $area['area_id']."',
area_ident = '". $area['ident']."'
WHERE link_id = '". $link['link_id']."'"
Expand Down Expand Up @@ -287,4 +287,4 @@ public function action_link_down() {
exit;
}
}
?>
?>
4 changes: 2 additions & 2 deletions modules/html/helpers/html_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function setup($widget) {
$code = str_replace("\n", "", $_POST['code']);
$code = str_replace("\r", "", $code);

$config = 'code = "'.mysql_real_escape_string($code).'"';
$config = 'code = "'.mysqli_real_escape_string($this->db->db_link, $code).'"';

$db->query("UPDATE #__index_page_widgets SET
config = '$config'
Expand Down Expand Up @@ -73,4 +73,4 @@ public static function setup($widget) {
}
}
}
?>
?>
2 changes: 1 addition & 1 deletion modules/main/controllers/main_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function action_config() {
foreach ($_config as $key => $value) {
if ($key == 'submit') continue;
$sql = "UPDATE #__config SET \n";
$sql .= "`value` = '".mysql_real_escape_string(stripslashes($value))."'\n";
$sql .= "`value` = '".mysqli_real_escape_string($this->db->db_link, stripslashes($value))."'\n";
$sql .= "WHERE `key` = '".$key."'";
$this->db->query($sql);
}
Expand Down
82 changes: 41 additions & 41 deletions modules/main/helpers/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
class main {
/**
* Конфигурация для модулей
* @param string $module
* @param string $module
*/
public static function config($config_data, $module, $db) {
foreach ($config_data as $key => $value) {
if ($key == 'submit') continue;
$sql = "UPDATE #__config SET \n";
$sql .= "`value` = '".mysql_real_escape_string(stripslashes($value))."'\n";
$sql .= "WHERE `key` = '".mysql_real_escape_string($key)."' AND module = '".mysql_real_escape_string($module)."'";
$sql .= "`value` = '".mysqli_real_escape_string($db->db_link, stripslashes($value))."'\n";
$sql .= "WHERE `key` = '".mysqli_real_escape_string($db->db_link, $key)."' AND module = '".mysqli_real_escape_string($db->db_link, $module)."'";
$db->query($sql);
}
}
Expand Down Expand Up @@ -58,7 +58,7 @@ public static function wtext($text){

/**
* Конвертирование строки в utf-8
* @param string $text
* @param string $text
*/
public static function utext($text){
return iconv('windows-1251', 'utf-8', $text);
Expand All @@ -69,16 +69,16 @@ public static function utext($text){
*/
public static function get_unique_code($length = 0) {
$code = md5(uniqid(rand(), true));
if ($length != 0) {
return substr($code, 0, $length);
} else {
return $code;
}
if ($length != 0) {
return substr($code, 0, $length);
} else {
return $code;
}
}

/**
* Транслитерация латиницы
* @param string $str
* @param string $str
*/
public static function translite($str) {
$table = array('_'=>' ', 'a'=>'а', 'b'=>'б', 'v'=>'в', 'g'=>'г', 'd'=>'д', 'e'=>'е', 'yo'=>'ё', 'zh'=>'ж', 'z'=>'з', 'i'=>'и', 'j'=>'й', 'k'=>'к', 'l'=>'л', 'm'=>'м', 'n'=>'н', 'o'=>'о', 'p'=>'п', 'r'=>'р', 's'=>'с', 't'=>'т', 'u'=>'у', 'f'=>'ф', 'h'=>'х', 'c'=>'ц', 'ch'=>'ч', 'sh'=>'ш', 'sch'=>'щ', 'q'=>'ь', 'x'=>'ы', 'q'=>'ь', 'ye'=>'э', 'yu'=>'ю', 'ya'=>'я',
Expand All @@ -92,9 +92,9 @@ public static function translite($str) {
*/
public static function get_filesize($file_path) {
$headers = get_headers($file_path, 1);
if ((!array_key_exists('Content-Length', $headers))) {
return false;
}
if ((!array_key_exists('Content-Length', $headers))) {
return false;
}
return $headers['Content-Length'];
}

Expand All @@ -110,16 +110,16 @@ public static function detranslite($str){

/**
* Добавление новых правил в роутинг
* @param string $block_name
* @param string $new_rules
* @param string $block_name
* @param string $new_rules
*/
public static function add_route_rules($block_name, $new_rules) {
file_put_contents(ROOT .'data_files/route_rules/'. $block_name .'.rules', $new_rules);
}

/**
* Удаление правил роутинга
* @param string $block_name
* @param string $block_name
*/
public static function delete_route_rules($block_name) {
unlink(ROOT .'data_files/route_rules/'. $block_name .'.rules');
Expand All @@ -129,9 +129,9 @@ public static function delete_route_rules($block_name) {
* Запрет действий в демо версии
*/
public static function is_demo() {
if(file_exists(ROOT .'is_demo')) {
a_error('В демо версии данное действие запрещено!');
}
if(file_exists(ROOT .'is_demo')) {
a_error('В демо версии данное действие запрещено!');
}
}

/**
Expand Down Expand Up @@ -175,7 +175,7 @@ public static function r_copy($source, $dest) {

/**
* Выполнение событий
* @param string $type
* @param string $type
*/
public static function events_exec(&$db, $type) {
$dir = opendir(ROOT.'data_files/events');
Expand All @@ -192,8 +192,8 @@ public static function events_exec(&$db, $type) {

/**
* Добавление события
* @param string $module
* @param string $place
* @param string $module
* @param string $place
*/
public static function add_event($module, $place) {
$filename = ROOT.'data_files/events/'.$module.'.'.$place.'.event';
Expand All @@ -203,7 +203,7 @@ public static function add_event($module, $place) {

/**
* Удаление события
* @param string $module
* @param string $module
*/
public static function delete_event($module) {
$dir = opendir(ROOT.'data_files/events');
Expand Down Expand Up @@ -272,7 +272,7 @@ public static function update_file_counter($file, $number) {

/**
* Обрезание части строки по словам
* @param integer $limit
* @param integer $limit
*/
public static function limit_words($string, $limit) {
$words = explode(' ', $string);
Expand All @@ -288,7 +288,7 @@ public static function limit_words($string, $limit) {

/**
* Рекурсивное удаление папки
* @param string $arg
* @param string $arg
*/
public static function delete_dir($arg, $clear = FALSE) {
$d = opendir($arg);
Expand Down Expand Up @@ -389,11 +389,11 @@ public static function image_resize($path_to_file, $path_to_save, $width, $heigh
$ratio = min($horizontal, $vertical);

// Необходимость пропорционального изменения
if ($horizontal == $ratio) {
$use_horizontal = TRUE;
} else {
$use_horizontal = FALSE;
}
if ($horizontal == $ratio) {
$use_horizontal = TRUE;
} else {
$use_horizontal = FALSE;
}

$new_width = $use_horizontal ? $width : floor($old_width * $ratio);
$new_height = !$use_horizontal ? $height : floor($old_height * $ratio);
Expand Down Expand Up @@ -466,20 +466,20 @@ public static function get_month_name($month_num, $ucfirst = false, $type = 1) {

/**
* Замена <p> на <br />
* @return string
* @return string
*/
public function tinymce_p_br($content) {
$content = preg_replace('/<p[^>]*>/', '', $content);
$content = str_replace('</p>', '<br />', $content);
if(substr(self::wtext($content), self::strlen($content) - 6) == '<br />') {
$content = self::utext(substr(self::wtext($content), 0, -6));
}
if(substr(self::wtext($content), self::strlen($content) - 6) == '<br />') {
$content = self::utext(substr(self::wtext($content), 0, -6));
}
return $content;
}

/**
* Проверка данных регуляркой
* @param string $type
* @param string $type
*/
public static function check_input($value, $type, $mode = 'check'){
$filterinput = array(
Expand All @@ -504,11 +504,11 @@ public static function check_input($value, $type, $mode = 'check'){
"DOMAIN" => array("^[a-z0-9\.\-]{2,50}$","только английские буквы и цифры")
);

if($mode == 'check') {
return preg_match('~'. $filterinput[$type][0] .'~', $value);
} elseif($mode == 'format') {
return $filterinput[$type][1];
}
if($mode == 'check') {
return preg_match('~'. $filterinput[$type][0] .'~', $value);
} elseif($mode == 'format') {
return $filterinput[$type][1];
}
}

/**
Expand Down Expand Up @@ -587,4 +587,4 @@ public function display_time($time = NULL) {
return $data.' в '.$time;
}
}
?>
?>
Loading

0 comments on commit 021fa2d

Please sign in to comment.