Exemplo n.º 1
0
function showDebugInfo()
{
    if (!is_devel()) {
        return;
    }
    require_once common_class('sql_highlighter');
    global $engine_errors, $sql_queries, $sql_errors, $timers;
    $high = new TSqlHighlighter();
    $time_sum = 0;
    if (!empty($sql_queries)) {
        foreach ($sql_queries as $k => $v) {
            $time_sum += $v['time'];
            $sql_queries[$k]['sql'] = $high->highlight($v['sql']);
        }
    }
    if (!empty($sql_errors)) {
        foreach ($sql_errors as $k => $v) {
            $sql_errors[$k]['sql'] = $high->highlight($v['sql']);
        }
    }
    $tpl =& Registry::get('TRusoft_View');
    $tpl->template_dir = find_dir("../templates");
    $ret = array('timers' => $timers, 'sql' => array('count' => count($sql_queries), 'time' => $time_sum), 'engine_errors' => $engine_errors, 'sql_queries' => $sql_queries, 'sql_errors' => $sql_errors);
    $tpl->assign($ret);
    return $tpl->render($tpl->template_dir . 'debug.tpl');
}
Exemplo n.º 2
0
 function TCEd_base()
 {
     global $str, $actions;
     TTable::TTable();
     $this->window_icons = array();
     if (is_devel()) {
         $this->window_icons['show']['source'] =& $GLOBALS['window_icons']['source'];
     }
     $this->window_icons['show']['help'] =& $GLOBALS['window_icons']['help'];
     $this->window_icons['show']['close'] =& $GLOBALS['window_icons']['close'];
     $actions[$this->name] = array('save' => array('Сохранить', 'Save', 'link' => 'cnt.document.forms.editform.submit()', 'img' => 'icon.save.gif', 'display' => 'block', 'show_title' => true), 'versions' => array('Версии текста', 'Versions', 'link' => 'cnt.frames[0].versions()', 'img' => 'icon.versions.gif', 'display' => 'none', 'show_title' => true), 'delete' => array('Удалить', 'Delete', 'link' => 'if (cnt.document.forms.delform.onsubmit()) cnt.document.forms.delform.submit()', 'img' => 'icon.delete.gif', 'display' => 'none', 'show_title' => true), 'moveup' => array('Выше', 'Up', 'link' => 'cnt.frames[\'tmp\'+cnt.TABLE+cnt.ID].location=\'page.php?page=' . $this->name . '/\'+cnt.TABLE+\'&do=EditPriority&id[\'+cnt.ID+\']=\'+cnt.ID+\'&move=-1&bars=\'+cnt.document.forms.editform.bars.value', 'img' => 'icon.moveup.gif', 'display' => 'none', 'show_title' => true), 'movedown' => array('Ниже', 'Down', 'link' => 'cnt.frames[\'tmp\'+cnt.TABLE+cnt.ID].location=\'page.php?page=' . $this->name . '/\'+cnt.TABLE+\'&do=EditPriority&id[\'+cnt.ID+\']=\'+cnt.ID+\'&move=1&bars=\'+cnt.document.forms.editform.bars.value', 'img' => 'icon.movedown.gif', 'display' => 'none', 'show_title' => true), 'close' => array('Закрыть', 'Close', 'link' => 'if (window.top.opener && window.top.opener.focusItem) window.top.opener.focusItem(); window.top.close()', 'img' => 'icon.close.gif', 'display' => 'block', 'show_title' => true), 'add_to_list' => array('Добавить в список', 'Add To List', 'link' => 'cnt.document.forms.editform.submit()', 'img' => 'icon.save.gif', 'display' => 'none', 'show_title' => true), 'changes' => array('Сохранить изменения', 'Save Changes', 'link' => 'cnt.document.forms.editform.submit()', 'img' => 'icon.save.gif', 'display' => 'none', 'show_title' => true), 'add' => array('Добавить', 'Add', 'link' => 'cnt.editItem()', 'img' => 'icon.new.gif', 'display' => 'none', 'show_title' => true));
     # базовые константы
     $str[$this->name] = array('title' => array('Редактирование страницы', 'Page editing'), 'basic' => array('Основные поля', 'Basic fields'), 'basic_icon' => 'box.page.gif', 'basic_caption' => array('Страница', 'Page'));
     # языковые константы
     $str[get_class_name($this)] = array_merge($str[get_class_name($this)], array('name' => array('Заголовок', 'Title'), 'type' => array('Тип', 'Type'), 'page' => array('Страница', 'Page'), 'url' => array('URL', 'URL'), 'visible' => array('Показывать в меню', 'Visible in menu'), 'published' => array('Опубликован', 'Published'), 'restricted' => array('Ограниченный показ', 'Restricted'), 'saved' => array('Страница успешно сохранена', 'Page saved successfully'), 'loading' => array('Загрузка...', 'Loading...'), 'layout' => array('Размещение', 'Layout'), 'l_no_menu_with_banners' => array('Без меню с баннерами', 'Without menu, with banners'), 'l_no_menu_no_banners' => array('Без меню и баннеров', 'Without menu and banners'), 'l_txt_menu_with_banners' => array('С текстовым меню и баннерами', 'With text menu and banners'), 'l_txt_menu_no_banners' => array('С текстовым меню без баннеров', 'With text menu and no banners'), 'l_g_menu_with_banners' => array('С графическим меню и баннерами', 'With graphic menu and banners'), 'l_g_menu_no_banners' => array('С графическим меню без баннеров', 'With graphic menu and no banners')));
 }
Exemplo n.º 3
0
 function TStrings()
 {
     global $actions, $str;
     TTable::TTable();
     if (DEV_MODE) {
         $actions[$this->name] = array('create' => &$actions['table']['create'], 'edit' => &$actions['table']['edit'], 'delete' => &$actions['table']['delete']);
     } else {
         $actions[$this->name] = array('edit' => &$actions['table']['edit']);
     }
     $actions[$this->name . '.editform'] = array('apply' => array('title' => array('ru' => 'Сохранить', 'en' => 'Save'), 'onclick' => 'document.forms[\'editform\'].elements[\'do\'].value=\'apply\'; document.forms[\'editform\'].submit(); return false;', 'img' => 'icon.save.gif', 'display' => 'block', 'show_title' => true), 'save_close' => array('title' => array('ru' => 'Сохранить и закрыть', 'en' => 'Save'), 'onclick' => 'document.forms[\'editform\'].elements[\'do\'].value=\'save\'; document.forms[\'editform\'].submit(); return false;', 'img' => 'icon.save.gif', 'display' => 'block', 'show_title' => true), 'cancel' => array('title' => array('ru' => 'Отмена', 'en' => 'Cancel'), 'onclick' => 'window.location=\'/admin/?page=' . $this->name . '\'', 'img' => 'icon.close.gif', 'display' => 'block', 'show_title' => true));
     unset($actions[$this->name . '.editform'][is_devel() ? 'restore' : 'copy']);
     if (!empty($_GET['id'])) {
         $temp = sql_getValue("SELECT name FROM " . $this->table . " WHERE id=" . $_GET['id']);
     } else {
         $temp = "Новая константа";
     }
     $str[get_class_name($this)] = array_merge($str[get_class_name($this)], array('title' => array('Строковые константы', 'Strings'), 'title_editform' => array("Строковая константа : " . $temp, 'String : ' . $temp), 'add' => array('Добавление новой строки', 'Add string'), 'edit' => array('Редактирование строки', 'Edit string'), 'module' => array('Модуль сайта', 'Site module'), 'name' => array('Название', 'Name'), 'def' => array('Значение по умолчанию', 'Default value'), 'value' => array('Текущее значение', 'Current value'), 'description' => array('Описание', 'Description'), 'copy_clipboard' => array('Скопировать в буфер', 'Copy to clipboard'), 'make_default' => array('Восстановить значение по умолчанию', 'Restore default value'), 'saved' => array('Даные были успешно сохранены', 'Data has been saved successfully'), 'all' => array('-- Все --', '-- All --'), 'deleted' => array('Удалено', 'Deleted'), 'is_default' => array('Берется по умолчанию', 'Default')));
 }
Exemplo n.º 4
0
<?php

/* hati-hati dengan file ini !!!
 * pemanggilan semua controller dimulai dari file ini 
 * file ini berubah, aplikasi tidak berjalan :-)
 */
define('APP_CONTROLLER', CODEKIR_APPPATH . 'controller/');
define('APP_VIEW', CODEKIR_APPPATH . 'view/theme/');
define('APP_MODELS', CODEKIR_APPPATH . 'model/');
require_once CODEKIR_COREPATH . 'loader.php';
is_devel(debug);
if (is_array($CONFIG)) {
    if ($CONFIG['default']['app_underdevelopment'] == TRUE) {
        under_development();
    }
}
/* load halaman berdasarkan parameter 
 * yang diminta dari browser dengan method GET
 */
$setPage = NULL;
$setFunction = NULL;
$getURI = array();
/* Get page berdasarkan method GET 
$baseURI = ($_GET);
*/
// $baseURI = strip_tags($_SERVER['SCRIPT_NAME'].$_SERVER['REDIRECT_QUERY_STRING']);
$baseURI = strip_tags($_SERVER['QUERY_STRING']);
/* 	Ini untuk membuat path app menjadi dinamic, bukan statis lagi
	jadi app ini bisa ditaroh dimana aja gk harus di document root apache
	yeah.... :-)
*/
Exemplo n.º 5
0
 function ElemEdit($id, $row)
 {
     $id = get('id', 0, 'p');
     $this->table = $this->elem_table;
     # получаем значение для записи с индексом  id
     $exist_row = sql_getRow('SELECT * FROM ' . $this->elem_table . ' WHERE id=' . $id);
     if (!$row['lang'] && $row['root_id']) {
         // заполнение поля lang
         $row['lang'] = $this->getLang($row['root_id']);
         if (!$row['lang']) {
             $row['lang'] = LANG_DEFAULT;
         }
     }
     $req_fields = array();
     if (defined('LANG_SELECT') && LANG_SELECT) {
         foreach ($this->elem_req_fields as $key => $val) {
             // Проверяем, это многоязыковое поле или нет
             if (isset($this->elem_fields['columns'][$val]['lang_select']) && $this->elem_fields['columns'][$val]['lang_select']) {
                 $req_fields[] = $val . "_" . $row['lang'];
             } else {
                 $req_fields[] = $val;
             }
         }
     } else {
         $req_fields = $this->elem_req_fields;
     }
     # запись такая есть?
     if (!isset($exist_row['id'])) {
         // если создается новая запись на не основном языке, нужно еще создать такую же на основном (если не создана ранее)
         $main_root_id = getMainRootID();
         if ($row['root_id'] != $main_root_id || $row['lang'] != LANG_DEFAULT) {
             $exist_row_default_lang = sql_getRow('SELECT * FROM ' . $this->elem_table . ' WHERE name="' . $row['name'] . '" AND module="' . $row['module'] . '" AND lang="' . LANG_DEFAULT . '" AND root_id="' . $main_root_id . '"');
             if (!$exist_row_default_lang) {
                 $def_row = array('module' => $row['module'], 'name' => $row['name'], 'value' => $row['value'], 'description' => $row['description'], 'def' => $row['value'], 'root_id' => $main_root_id, 'lang' => LANG_DEFAULT);
                 $this->EditorCommit($req_fields, true, $def_row, $this->elem_fields['id_field'], 0);
             }
         }
     } else {
         # запись для текущего языка или для текущего домена ?
         if ($exist_row['lang'] != $row['lang'] || $exist_row['root_id'] != $row['root_id']) {
             # значит запись для нового языка
             $row['id'] = '';
             # для новой записи значение устанавливается по умолчанию
             $row['def'] = $row['value'];
             $row['lang'] = $this->getLang($row['root_id']);
         }
     }
     if (!is_devel()) {
         # поля были disabled... следовательно их нет в $_POST
         $row['module'] = $exist_row['module'];
         $row['name'] = $exist_row['name'];
     } else {
         # разработчик изменяет также и значение по умолчанию
         $row['def'] = $row['value'];
     }
     $ret = $this->EditorCommit($req_fields, true, $row, $this->elem_fields['id_field'], $row['id']);
     return $ret;
 }
Exemplo n.º 6
0
 function Edit()
 {
     $id = get('id', 0, 'p');
     if (is_devel() && (int) $id) {
         $row = sql_getRow("SELECT allowed, required FROM " . $this->table . " WHERE id=" . (int) $id);
         $_POST['fld'] = array_merge($row, $_POST['fld']);
     }
     $required = is_devel() ? array('pid', 'name', 'display_ru', 'display_en', 'type') : array();
     $res = $this->Commit($required);
     $reload = mysql_affected_rows() ? "window.parent.location.reload()" : "";
     if (is_int($res)) {
         if ($this->update_modules_conf()) {
             $update = $this->str('write_conf');
         } else {
             $update = $this->str('e_write_conf');
         }
         return "<script>alert('" . $this->str('saved') . "\\n" . $update . "'); {$reload}</script>";
     }
     return $this->Error($res);
 }
Exemplo n.º 7
0
 function Save($unique)
 {
     $fld = get('fld', array(), 'p');
     $id = get('id', '', 'p');
     /*
         [recipient] => admin
         [types] => Array
             (
                 [email] => on
                 [sms] => on
             )
     
         [admins] => Array
             (
                 [email] => Array
                     (
                         [0] => 1
                         [1] => 3
                     )
     
                 [sms] => Array
                     (
                         [0] => 2
                         [1] => 1
                         [2] => 3
                     )
     
             )*/
     //Проверяем уникальные поля
     $query = '';
     foreach ($unique as $k => $field) {
         if (!empty($fld[$field])) {
             $query .= " `" . $field . "`='" . $fld[$field] . "' OR";
         }
     }
     if (!empty($query)) {
         //обрезаем последний OR
         $query = substr($query, 0, -2);
         //запрашиваем id
         $uid = sql_getValue("SELECT id FROM " . $this->table . " WHERE " . $query);
         if ($uid && $id != $uid) {
             return "<script>alert('" . $this->str('error_name') . "');</script>";
         }
     }
     // добавляем новую запись
     if (!$id) {
         $sql = sql_query("INSERT INTO " . $this->table . " (`name`,`description`,`comments`,`recipient`) VALUES('" . htmlspecialchars($fld['name']) . "', '" . htmlspecialchars($fld['description']) . "', '" . htmlspecialchars($fld['comments']) . "', '" . $fld['recipient'] . "')");
         if (!$sql) {
             trigger_error(sql_getError(), E_USER_ERROR);
         } else {
             $id = sql_getLastId();
         }
     } else {
         if (is_devel()) {
             $sql = sql_query("UPDATE " . $this->table . " SET name='" . htmlspecialchars($fld['name']) . "', description='" . htmlspecialchars($fld['description']) . "', comments='" . htmlspecialchars($fld['comments']) . "',recipient='" . $fld['recipient'] . "' WHERE id=" . $id);
             if (!$sql) {
                 trigger_error(sql_getError(), E_USER_ERROR);
             }
         } elseif (isset($fld['description']) & !empty($fld['description'])) {
             $sql = sql_query("UPDATE " . $this->table . " SET description='" . htmlspecialchars($fld['description']) . "' WHERE id=" . $id);
             if (!$sql) {
                 trigger_error(sql_getError(), E_USER_ERROR);
             }
         }
     }
     //удаляем всех админов для данного события
     $root = domainRootId();
     sql_query("DELETE FROM notify_admins WHERE event=" . $id . " AND root_id=" . $root);
     $types = $fld['types'];
     if ($fld['recipient'] == 'admin') {
         unset($fld['types']);
         if (isset($fld['admins'])) {
             foreach ($fld['admins'] as $plugin => $it) {
                 if (isset($types[$plugin])) {
                     foreach ($it as $k => $admin_id) {
                         sql_query("INSERT INTO notify_admins(`event`,`admin_id`,`type`,`root_id`) VALUES(" . $id . "," . $admin_id . ",'" . $plugin . "'," . $root . ")");
                     }
                     $fld['types'][$plugin] = 'on';
                 }
             }
         }
     }
     $sql = sql_query("DELETE FROM notify_compare WHERE event=" . $id);
     if (!$sql) {
         trigger_error(sql_getError(), E_USER_ERROR);
     }
     if (isset($fld['types']) & !empty($fld['types'])) {
         foreach ($fld['types'] as $k => $v) {
             $sql = sql_query("INSERT INTO notify_compare(`event`,`plugin`) VALUES ('" . $id . "', '" . $k . "')");
             if (!$sql) {
                 trigger_error(sql_getError(), E_USER_ERROR);
             }
         }
     }
     return $id;
 }