Exemple #1
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;
}
Exemple #2
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;
}
Exemple #3
0
function page_admin_news($act = "", $id = "")
{
    requires_admin();
    use_template("admin");
    $o = table_edit("news", "admin/news", $act, $id);
    return $o;
}
Exemple #4
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;
}
Exemple #5
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;
}
Exemple #6
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;
}
Exemple #7
0
function page_admin_settings()
{
    requires_admin();
    use_template("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;
}