if (isset($images[$n - 1])) { $c = $images[$n - 1]; $images[$n - 1] = $images[$n]; $images[$n] = $c; } } else { if (isset($images[$n + 1])) { $c = $images[$n + 1]; $images[$n + 1] = $images[$n]; $images[$n] = $c; } } // update CONTENT::set_content(array("content_attachment" => implode(",", $images)), CONTENT::get("content_id")); // redirect back redirect(LINKS::get("admin_pages_edit", CONTENT::get("content_id"))); } /* * on submit to edit product */ if (isset($_POST['edit_produs_btn'])) { global $db; // filter $produs_denumire = trim($db->real_escape($_POST['produs_denumire'])); $produs_caracteristici = trim($_POST['produs_caracteristici']); $produs_descriere = trim($db->real_escape($_POST['produs_descriere'])); $produs_slug = trim($db->real_escape($_POST['produs_slug'])); $produs_imagini = $_FILES['produs_imagini']; // get caraceristici $produs_caracteristici_arr = explode("\n", $produs_caracteristici); $produs_caracteristici_arr = array_filter($produs_caracteristici_arr, 'trim');
if (USER::login($_POST['username'], $_POST['password'])) { TPL::message("Perfect! You'll be redirected in 2 seconds..", "success"); redirect(isset($_GET['redirect']) ? urldecode($_GET['redirect']) : LINKS::get("admin_home"), 2); } else { switch (LOGS::get_error()['log_text']) { case "wrong_username": TPL::message("You entered a wrong username.."); break; case "wrong_password": TPL::message("You entered a wrong password.."); break; } } } // set render TPL::render("v_login/login"); break; /* * logout user */ /* * logout user */ case "logout": // sign out user USER::logout(); // redirect redirect(LINKS::get("admin_login")); break; } }
} } // assign data TPL::assign("content", CONTENT::get()); TPL::assign('categories', CONTENT::get_categories()); // set render TPL::render('v_pages/page_types/page_text'); }); EVENTS::add_action("before_render", function () { EVENTS::do_action("edit_page_" . CONTENT::get('content_type')); }); break; /* * delete page */ /* * delete page */ case "delete": $page_id = $db->real_escape($_GET['id']); $del = $db->query("DELETE FROM dl_content WHERE content_id = '{$page_id}'"); redirect(LINKS::get("admin_pages")); break; default: die("Undefined action"); break; } } else { // redirect redirect(ADMIN_URL); }
function generate_link($str) { $type = explode("::", $str); $link = ''; switch ($type[0]) { case "baseurl": if ($type[1] == 'website') { $link = LINKS::get("base_home"); } else { $link = LINKS::get("admin_home"); } break; case "link": $link = substr($str, 6); break; } if ($link == '') { $link = "#"; } $link = str_replace("%base_home%", LINKS::get("base_home"), $link); return $link; }
<?php // check if logged if (!USER::is_logged() && !LINKS::on_link("admin_login")) { $link = LINKS::get("admin_login") . (LINKS::on_link("admin_home") ? '' : '?redirect=' . urlencode(URL::get_full_url())); redirect($link); } // check if has permission to access Admin Panel if (USER::is_logged() && !PERMISSIONS::check("access_admin") && !LINKS::on_link("admin_login") && !LINKS::on_link("admin_logout")) { redirect(LINKS::get("base_home")); } /* REWRITING */ if (file_exists(FOLDER_ADMIN . "routes.php")) { include FOLDER_ADMIN . "routes.php"; } ob_start(); /* * Set default admin menu */ /* * CONTENT */ DRAWLINE::admin_menu('content', array("title" => "Content", "icon" => "book", "link" => "admin_content")); DRAWLINE::admin_menu('add_page', array("title" => "Add page", "icon" => "plus", "link" => array("admin_pages_add"), "item_active_on_link" => "admin_pages_add", "parent" => "content")); DRAWLINE::admin_menu('pages_list', array("title" => "Pages list", "icon" => "list", "link" => "admin_pages", "parent" => "content")); DRAWLINE::admin_menu('categories', array("title" => "Categories", "icon" => "tags", "link" => "admin_categories", "parent" => "content", "item_separator_bottom" => true)); DRAWLINE::admin_menu('media', array("title" => "Media", "icon" => "picture-o", "link" => "admin_media", "parent" => "content")); DRAWLINE::admin_menu('menus', array("title" => "Menus", "icon" => "plane", "link" => "admin_menus", "parent" => "content", "item_separator_bottom" => true)); DRAWLINE::admin_menu('trash', array("title" => "Trash", "icon" => "trash", "link" => "admin_trash", "parent" => "content")); /* * DESIGN
$link = 'link::' . str_replace(LINKS::get("base_home"), "%base_home%", $link); // update $upd = $db->query("UPDATE dl_menus_items SET item_title = '{$titlu}', item_value = '{$link}' WHERE item_id = '{$item_id}'"); if (!$upd) { die($db->sql_error()); } // redirect redirect(LINKS::get("admin_menus_view", $menu_id)); } /* * daca se vrea stergerea unui element */ if (isset($_POST['btn_delete_item'])) { $del = $db->query("DELETE FROM dl_menus_items WHERE item_id = '{$item_id}'"); $upd = $db->query("UPDATE dl_menus_items SET item_parent = '0' WHERE item_parent = '{$item_id}'"); redirect(LINKS::get("admin_menus_view", $menu_id)); } // select all menus $current_menus = $db->query_fetch("SELECT * FROM dl_menus ORDER BY menu_title ASC"); // select current menu infos $menu = $db->query_fetch("SELECT * FROM dl_menus WHERE menu_id = '{$menu_id}'")[0]; $menu['items'] = $db->query_fetch("SELECT * FROM dl_menus_items WHERE item_menu = '{$menu_id}' ORDER BY item_parent, item_sort ASC"); $c_item = $db->query_fetch("SELECT * FROM dl_menus_items WHERE item_id = '{$item_id}' LIMIT 1")[0]; $c_item['item_link'] = generate_link($c_item['item_value']); // generate tree $menu['items'] = generate_tree($menu['items']); //print_array($c_item); // assign data TPL::assign("current_menus", $current_menus); TPL::assign("c_menu", $menu); TPL::assign("c_item", $c_item);
<?php URL::route(LINKS::get("admin_home", true), 'index.php?c=index'); URL::route(LINKS::get("admin_accounts_users", true), 'index.php?c=users&do=users_list'); URL::route(LINKS::get("admin_accounts_users_add", true), 'index.php?c=users&do=add_user'); URL::route(LINKS::get("admin_accounts_users_edit", true), 'index.php?c=users&do=edit_user&user_id=$1'); URL::route(LINKS::get("admin_accounts_groups", true), 'index.php?c=users&do=groups_list'); URL::route(LINKS::get("admin_accounts_groups_add", true), 'index.php?c=users&do=groups_add'); URL::route(LINKS::get("admin_accounts_groups_edit", true), 'index.php?c=users&do=groups_edit&group_id=$1'); URL::route(LINKS::get("admin_pages", true), 'index.php?c=pages&do=list'); URL::route(LINKS::get("admin_pages_add", true), 'index.php?c=pages&do=add&type=$1'); URL::route(LINKS::get("admin_pages_edit", true), 'index.php?c=pages&do=edit&id=$1'); URL::route(LINKS::get("admin_pages_delete", true), 'index.php?c=pages&do=delete&id=$1'); URL::route(LINKS::get("admin_categories", true), 'index.php?c=categories'); URL::route(LINKS::get("admin_media", true), 'index.php?c=content&do=media'); URL::route(LINKS::get("admin_menus", true), 'index.php?c=content&do=menus'); URL::route(LINKS::get("admin_menus_view", true), 'index.php?c=content&do=menu_view&id=$1'); URL::route(LINKS::get("admin_menus_item_edit", true), 'index.php?c=content&do=menu_item_edit&id=$1&item=$2'); URL::route(LINKS::get("admin_templates", true), 'index.php?c=design&do=templates_list'); URL::route(LINKS::get("admin_template_install", true), 'index.php?c=design&do=template_install&package=$1'); URL::route(LINKS::get("admin_login", true), 'index.php?c=login&do=login'); URL::route(LINKS::get("admin_logout", true), 'index.php?c=login&do=logout'); URL::route(LINKS::get("admin_settings_general", true), 'index.php?c=settings&do=general'); URL::route(LINKS::get("admin_settings_backend", true), 'index.php?c=settings&do=backend'); URL::route(LINKS::get("admin_settings_maintenance", true), 'index.php?c=settings&do=maintenance'); URL::route(LINKS::get("admin_plugins", true), 'index.php?c=extender&do=plugins'); URL::route(LINKS::get("admin_plugin_install", true), 'index.php?c=extender&do=plugin_install&package=$1'); URL::route(LINKS::get("admin_plugin_uninstall", true), 'index.php?c=extender&do=plugin_uninstall&package=$1');
<?php if (!defined("DRAWLINE_RUN_FROM_INDEX")) { die; } define("ADMIN_URL", LINKS::get("admin_home")); /* * load BACKend or FRONTend */ if (on_admin()) { // set template path to admin TPL::dir(FOLDER_ADMIN . "template" . DS); // run admin include FOLDER_ADMIN . "index.php"; } else { // set template path to admin TPL::dir(FOLDER_EXTENDER . "templates" . DS . OPTIONS::website('frontend_template') . DS); // run frontend include FOLDER_FRONTEND . "index.php"; } // general assign TPL::assign("admin_url", ADMIN_URL); TPL::assign("base_url", BASE_URL); // run plugins foreach (DRAWLINE::plugins_list(true) as $plugin) { if (file_exists(FOLDER_PLUGINS . $plugin . DS . "index.php")) { include_once FOLDER_PLUGINS . $plugin . DS . "index.php"; EVENTS::do_action("run_plugin_" . $plugin); } else { LOGS::write("Not found plugin " . $plugin . " on the server."); }
} // if base url is not defined in config file if (!defined("BASE_URL")) { define("BASE_URL", URL::get_base_url()); } /* CONNECT TO DATABASE */ $db = new MYSQLI_DB(CONFIG_DATABASE_HOST, CONFIG_DATABASE_PORT, CONFIG_DATABASE_USERNAME, CONFIG_DATABASE_PASSWORD, CONFIG_DATABASE_DBNAME); if (DEBUG_MODE == true) { $db->sql_debug = true; $db->sql_query_monitor = true; } if ($db->conn === false) { if (DEBUG_MODE == true) { die('Error initializing the database connection.'); } else { die; } } /* INITIALIZATIONS */ URL::init(); USER::init(); LINKS::init(BASE_URL, ADMINISTRATOR_URL_PATH); CONTENT::init(); DRAWLINE::init(); // set cache folder CACHE::config("cache_folder", FOLDER_CACHE); // remove $path variable if (isset($path)) { $path = NULL; unset($path); }