Пример #1
0
function page_admin_menu_edit($parent_id = "", $act = "", $id = "")
{
    requires_admin();
    set_lang("other");
    use_template("admin");
    if (!$parent_id) {
        $parent_id = 0;
    }
    $o = "";
    if ($act == "del") {
        $rec = db_object_get("menu", $id);
        if ($rec->fixed == 'Y') {
            $act = "-";
            $o .= '<script>alert("Эту запись нельзя удалить.")</script>';
        }
    }
    global $tables;
    $tables['menu']['fields'][] = "title";
    $tables['menu']['fields'][] = "link";
    $tables['menu']['weight'] = true;
    if ($parent_id) {
        $o .= menu_path($parent_id);
    }
    $o .= table_edit("menu", "admin/menu/edit/{$parent_id}", $act, $id, "parent_id", $parent_id, "", "on_menu");
    return $o;
}
Пример #2
0
function page_admin_edit($table, $field, $id)
{
    use_layout("admin");
    requires_admin();
    global $tables;
    if (!isset($tables[$table]['liveedit'])) {
        die("can't edit this table tables[{$table}]['liveedit'] not set");
    }
    if (isset($_POST['editor1'])) {
        $html = form_post("editor1");
        $html = str_replace('\\"', '"', $html);
        $html = str_replace("\\'", "'", $html);
        $html = str_replace("\\\\", "\\", $html);
        $f = "on_{$table}_{$field}_update";
        if (function_exists($f)) {
            $f($id, $html);
        }
        db_query("UPDATE %s SET %s='%s' WHERE id=%d", $table, $field, $html, $id);
        if (CLOSE_ON_SAVE) {
            die("<script> window.close();</script>");
        }
        flash("message", "Изменения сохранены");
    }
    $content = db_result(db_query("SELECT %s FROM %s WHERE id=%d", $field, $table, $id));
    $o = "";
    if (form_post("back")) {
        $back = form_post("back");
        $o .= "<a href={$back}><<Назад</a>";
    }
    $o .= template("tinymce", "content", $content);
    return $o;
}
Пример #3
0
function page_admin_news($act = "", $id = "")
{
    requires_admin();
    use_template("admin");
    $o = table_edit("news", "admin/news", $act, $id);
    return $o;
}
Пример #4
0
function page_admin_images($act = "", $id = "")
{
    requires_admin();
    use_template("admin");
    if ($act == "add") {
        if (form_file_uploaded("file")) {
            $fname = $_FILES["file"]['name'];
            db_query("INSERT INTO images (link) VALUES ('')");
            $id = db_last_id();
            $fname = $id . "." . fileext($fname);
            form_file_uploaded_move("file", "img/" . $fname);
            db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
            redir("admin/images");
        }
        form_start("", "post", " enctype='multipart/form-data' ");
        form_file("Файл", "file");
        form_submit("Загрузить", "submit");
        form_end();
        $o = form();
        return $o;
    }
    if ($act == "del") {
        $im = db_object_get("images", $id);
        @unlink("../{$im->link}");
    }
    $o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
    return $o;
}
Пример #5
0
function page_admin_menu_edit($parent_id = "", $act = "", $id = "")
{
    requires_admin();
    set_lang("other");
    use_layout("admin");
    if (!$parent_id) {
        $parent_id = 0;
    }
    $o = "";
    if ($act == "del") {
        $rec = db_object_get("menu", $id);
        if ($rec->fixed == 'Y') {
            $act = "-";
            $o .= '<script>alert("Эту запись нельзя удалить.")</script>';
        }
    }
    global $tables;
    $tables['menu']['fields'][] = "title";
    $tables['menu']['fields'][] = "link";
    $tables['menu']['weight'] = true;
    if ($parent_id) {
        $o .= menu_path($parent_id);
    }
    global $table_edit_props;
    $table_edit_props->use_rename_icon_for_edit = true;
    $o .= table_edit("menu", "admin/menu/edit/{$parent_id}", $act, $id, "parent_id", $parent_id, "", "on_menu");
    $o .= "<style> input[type='submit'] { padding: 5px 10px; width: auto;}\r\n\t  input{ width:400px; }\r\n\t</style>";
    return $o;
}
Пример #6
0
function page_admin_edit($table, $field, $id)
{
    use_template("admin");
    requires_admin();
    global $tables;
    if (!isset($tables[$table]['liveedit'])) {
        die("can't edit this table tables[{$table}]['liveedit'] not set");
    }
    if (form_post("editor1")) {
        $html = form_post("editor1");
        $html = str_replace('\\"', '"', $html);
        $html = str_replace("\\'", "'", $html);
        $f = "on_{$table}_{$field}_update";
        if (function_exists($f)) {
            $f($id, $html);
        }
        db_query("UPDATE %s SET %s='%s' WHERE id=%d", $table, $field, $html, $id);
        if (CLOSE_ON_SAVE) {
            die("<script> window.close();</script>");
        }
    }
    $content = db_result(db_query("SELECT %s FROM %s WHERE id=%d", $field, $table, $id));
    $o = template("tinymce", "content", $content);
    return $o;
}
Пример #7
0
function page_search_prepare()
{
    requires_admin();
    echo "updating content_search value<Br>";
    $rr = db_fetch_objects(db_query("SELECT * FROM pages"));
    foreach ($rr as $r) {
        echo "page p/{$r->id} " . strlen($r->content) . " bytes <br>";
        on_pages_content_update($r->id, $r->content);
    }
    die("DONE");
}
Пример #8
0
function page_admin_catalog_images($catalog_id = "", $act = "", $id = "")
{
    requires_admin();
    use_template("admin");
    global $tables;
    $tables['catalog_images']['weight'] = 1;
    $o = "";
    if ($act == "edit") {
        $o .= "<a href=admin/catalog/images/{$catalog_id}><<Назад</a><br>";
    } else {
        $catalog = db_object_get("catalog", $catalog_id);
        $o .= "<a href=admin/catalog/edit/{$catalog->parent_id}/edit/{$catalog_id}><<Назад</a><br>";
    }
    if ($act == "del") {
        $fname = db_object_get("catalog_images", $id)->image_file;
        @unlink("img/upload/catalog/{$fname}");
    }
    if ($act == "edit") {
        form_start("", "post", " enctype='multipart/form-data' ");
        form_file("Файл", "file");
        form_submit("Загрузить картинку", "submit");
        form_end();
        $upload = form();
        $upload .= "<script>\r\n             \$(function() {\r\n\t\t\t\t \$('input[name=submit]').remove();\r\n                 \$('input[name=file]').change( function() {\r\n\t\t\t\t\t \$('form').submit();\r\n\t              });\r\n\t  });\r\n\t\t  </script>";
        $o .= $upload;
        if (form_file_uploaded("file")) {
            $fname = $_FILES["file"]['name'];
            $ext = strtolower(fileext($fname));
            if (!($ext == "swf" || $ext == "jpg" || $ext == "gif" || $ext == "png" || $ext == "bmp" || $ext == "jpeg" || $ext == "pdf")) {
                $o = "Данный тип файла не является картинкой";
                return $o;
            } else {
                @unlink("img/upload/catalog/" . db_result(db_query("SELECT image_file FROM catalog_images WHERE id=%d", $id)));
                $fname = $id . "." . fileext($fname);
                form_file_uploaded_move("file", "img/upload/catalog/" . $fname);
                db_query("UPDATE catalog_images SET image_file='{$fname}' WHERE id=%d", $id);
                redir("admin/catalog/images/{$catalog_id}");
            }
        }
    }
    if ($act == "add") {
        $_REQUEST['add'] = true;
    }
    global $table_edit_props;
    $table_edit_props->add_redir = false;
    $o .= table_edit("catalog_images", "admin/catalog/images/{$catalog_id}", $act, $id, "catalog_id", $catalog_id, "", "on_catalog_image");
    if ($act == "add") {
        $id = db_last_id();
        redir("admin/catalog/images/{$catalog_id}/edit/" . $id);
        die;
    }
    return $o;
}
Пример #9
0
function page_admin_images($act = "", $id = "")
{
    requires_admin();
    use_layout("admin");
    form_start("", "post", " enctype='multipart/form-data' ");
    form_file("Файл", "file");
    $caption = "Загрузить картинку";
    if ($act == "edit") {
        $caption = "Изменить картинку";
    }
    form_submit($caption, "submit");
    form_end();
    $upload = form();
    if (form_file_uploaded("file")) {
        $fname = $_FILES["file"]['name'];
        $ext = strtolower(fileext($fname));
        if (!($ext == "swf" || $ext == "jpg" || $ext == "gif" || $ext == "png" || $ext == "bmp" || $ext == "jpeg" || $ext == "pdf")) {
            $o = "Данный тип файла не является картинкой";
            return $o;
        } else {
            if ($act == "add") {
                db_query("INSERT INTO images (link) VALUES ('')");
                $id = db_last_id();
            } else {
                @unlink(db_result(db_query("SELECT link FROM images WHERE id=%d", $id)));
            }
            $fname = $id . "." . fileext($fname);
            form_file_uploaded_move("file", "img/" . $fname);
            db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
            redir("admin/images/edit/{$id}");
        }
    }
    if ($act == "add") {
        $o = $upload;
        return $o;
    }
    if ($act == "del") {
        $im = db_object_get("images", $id);
        @unlink("{$im->link}");
    }
    $o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
    if ($act == 'edit') {
        $im = db_object_get("images", $id);
        $o .= "<img width=100px src={$im->link}><br>{$upload}";
    }
    return $o;
}
Пример #10
0
function page_admin_pages($act = "", $id = "")
{
    requires_admin();
    use_template("admin");
    $o = "";
    if ($act == "del") {
        $p = db_object_get("pages", $id);
        if ($p->fixed == 'Y') {
            $act = "-";
            $o .= '<script>alert("Эту страницу нельзя удалить.")</script>';
        }
    }
    global $table_edit_props;
    $table_edit_props->col_title_show = false;
    //	$table_edit_props->new_record_show = false;
    //   $table_edit_props->del_record_show = false;
    //    $table_edit_props->edit_record_show = false;
    global $base_url;
    $o .= table_edit("pages", "admin/pages", $act, $id, "", "", "", "<a href=admin/edit/pages/content/[id]><img src=images/text_edit.png atl='Редактировать' title='Редактировать'></a> <a href={$base_url}p/[id]>{$base_url}p/[id]</a>");
    return $o;
}
Пример #11
0
function page_admin_pages($act = "", $id = "")
{
    requires_admin();
    use_layout("admin");
    $o = "";
    if ($act == "del") {
        $p = db_object_get("pages", $id);
        if ($p->fixed == 'Y') {
            $act = "-";
            $o .= '<script>alert("Эту страницу нельзя удалить.")</script>';
        }
    }
    global $table_edit_props;
    $table_edit_props->col_title_show = false;
    //	$table_edit_props->new_record_show = false;
    //   $table_edit_props->del_record_show = false;
    //    $table_edit_props->edit_record_show = false;
    $table_edit_props->use_rename_icon_for_edit = true;
    global $base_url;
    $o .= table_edit("pages", "admin/pages", $act, $id, "category", "null", "weight", "admin_on_page");
    return $o;
}
Пример #12
0
function page_admin_settings()
{
    requires_admin();
    use_layout("admin");
    global $tables;
    $o = "";
    if (form_post("save")) {
        $set = "";
        foreach ($tables['settings']['fields'] as $field) {
            if ($set) {
                $set .= ",";
            }
            $set = "{$field}='" . form_post($field) . "'";
        }
        db_query("UPDATE settings SET {$set}");
        $o .= "<font color=green>changes saved</font>";
    }
    $vals = db_fetch_object(db_query("SELECT * FROM settings LIMIT 1"));
    form_start();
    foreach ($tables['settings']['fields'] as $field) {
        form_input($field, $field, $vals->{$field});
    }
    form_submit("Save", "save");
    form_end();
    $o .= form();
    return $o;
}
Пример #13
0
function page_all_vars()
{
    requires_admin();
    global $modules;
    $mods = $modules;
    $mods[] = "app";
    $_REQUEST['q'] = '/vars';
    foreach ($mods as $mod) {
        $func_name = "page_" . $mod . "_vars";
        if (function_exists($func_name)) {
            ln("----");
            ln("<font color=red>{$func_name}</font>");
            $func_name();
        }
    }
}