<?php if (OPTIONS::website('service_minify') == 1) { EVENTS::add_action("before_render", function () { if (!URL::routed()) { $r = URL::check('^extender/(.*).min.(css|js)$', true); if ($r !== false) { $path = FOLDER_BASE . "extender/" . $r[1] . "." . $r[2]; if (file_exists($path)) { // minify $minify = HELPERS::load("minify"); $minify->addSource($path); $minify->exec(); // redirect to the new file redirect(BASE_URL . $r[0]); } } } }); }
/** * do_action_ref_array Execute functions hooked on a specific action hook, specifying arguments in an array. * @access public * @since 0.1 * @param string $tag The name of the action to be executed. * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt> * @return null Will return null if $tag does not exist in $filter array */ public static function do_action_ref_array($tag, $args) { if (!isset(self::$actions)) { self::$actions = array(); } if (!isset(self::$actions[$tag])) { self::$actions[$tag] = 1; } else { ++self::$actions[$tag]; } // Do 'all' actions first if (isset(self::$filters['all'])) { self::$current_filter[] = $tag; $all_args = func_get_args(); self::_call_all_hook($all_args); } if (!isset(self::$filters[$tag])) { if (isset(self::$filters['all'])) { array_pop(self::$current_filter); } return; } if (!isset(self::$filters['all'])) { self::$current_filter[] = $tag; } // Sort if (!isset($merged_filters[$tag])) { ksort(self::$filters[$tag]); $merged_filters[$tag] = true; } reset(self::$filters[$tag]); do { foreach ((array) current(self::$filters[$tag]) as $the_) { if (!is_null($the_['function'])) { call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); } } } while (next(self::$filters[$tag]) !== false); array_pop(self::$current_filter); }
EVENTS::add_action("edit_page_page_poli_products", function () { /* * on del image btn */ if (isset($_GET['del_img'])) { $n = $_GET['del_img']; $images = explode(",", CONTENT::get("content_attachment")); // if image exists if (isset($images[$n]) && file_exists(FOLDER_pPBUC_CONTENT . $images[$n])) { // delete and unset unlink(FOLDER_pPBUC_CONTENT . $images[$n]); unset($images[$n]); // 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 move image */ if (isset($_GET['move_img'], $_GET['dir']) && in_array(intval($_GET['dir']), array(0, 1))) { $n = intval($_GET['move_img']); $dir = intval($_GET['dir']); $images = explode(",", CONTENT::get("content_attachment")); // if image exists if ($dir == 0) { 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'); $produs_caracteristici = array(); foreach ($produs_caracteristici_arr as $caracter) { $caracter = str_replace("\r", "", $caracter); $produs_caracteristici[] = trim($db->real_escape($caracter)); } // upload imagini $produs_attash = array(); foreach ($produs_imagini['name'] as $n => $name) { if (is_uploaded_file($produs_imagini['tmp_name'][$n]) && is_image($produs_imagini['tmp_name'][$n])) { $file_ext = pathinfo($name, PATHINFO_EXTENSION); $new_name = substr($name, 0, -(strlen($file_ext) + 1)); $new_name = uniqid() . str_replace(array(".", "_", " "), array("", "-", ""), $new_name) . "." . $file_ext; $produs_attash[] = $new_name; move_uploaded_file($produs_imagini['tmp_name'][$n], FOLDER_pPBUC_CONTENT . $new_name); } } if (CONTENT::get("content_attachment") != '') { $produs_attash = CONTENT::get("content_attachment") . "," . implode(",", $produs_attash); } else { $produs_attash = implode(",", $produs_attash); } // create text $produs_text = array("caracteristici" => $produs_caracteristici, "descriere" => $produs_descriere); // create produs $produs = array("content_title" => $produs_denumire, "content_text" => json_encode($produs_text), "content_slug" => $produs_slug, "content_attachment" => $produs_attash); // update if (CONTENT::set_content($produs, CONTENT::get("content_id"))) { TPL::message("Actualizarile au fost efectuate cu success.", "success"); } else { TPL::message("S-au intampinat niste erori. Va rugam reincercati!"); } // update content CONTENT::get_content(CONTENT::get("content_id")); } CONTENT::$current['content_text'] = object2array(json_decode(CONTENT::$current['content_text'])); if (isset(CONTENT::$current['content_text']['caracteristici'])) { CONTENT::$current['content_text']['caracteristici'] = stripslashes(implode("\r\n", CONTENT::$current['content_text']['caracteristici'])); } else { CONTENT::$current['content_text']['caracteristici'] = ''; } if (!isset(CONTENT::$current['content_text']['descriere'])) { CONTENT::$current['content_text']['descriere'] = ''; } else { CONTENT::$current['content_text']['descriere'] = stripslashes(CONTENT::$current['content_text']['descriere']); } if (CONTENT::$current['content_attachment'] == '') { CONTENT::$current['content_attachment'] = array(); } else { CONTENT::$current['content_attachment'] = explode(",", CONTENT::$current['content_attachment']); } // assign TPL::assign("content", CONTENT::get()); // set render TPL::render(FOLDER_pPBUC . "viewers_admin" . DS . "page_produs_edit"); });
public static function uninstall_plugin($plugin_folder) { // check already instaled if (!DRAWLINE::plugin_installed($plugin_folder)) { // write log LOGS::write("Plugin <" . $plugin_folder . "> is not installed."); // return false return false; } else { // check if plugin exists if (!file_exists(FOLDER_PLUGINS . $plugin_folder . DS . "index.php")) { // write error LOGS::write("There is no plugin in " . FOLDER_PLUGINS . $plugin_folder . "."); // return return false; } // call plugin include FOLDER_PLUGINS . $plugin_folder . DS . "index.php"; // check current number of errors, before installing plugin $_b_errors = count(LOGS::get_errors()); // do action for installing plugin EVENTS::do_action("uninstall_plugin_" . $plugin_folder); // check current number of errors, after installed plugin $_a_errors = count(LOGS::get_errors()); // if no errors if (empty(TPL::get_messages('error')) && $_b_errors >= $_a_errors) { // delete from installed plugins $instaled = explode(",", OPTIONS::website('installed_plugins')); if (($key = array_search($plugin_folder, $instaled)) !== false) { unset($instaled[$key]); } OPTIONS::set('website', 'installed_plugins', implode(",", $instaled)); // return success return true; } else { // some problems LOGS::write("Some problems during the plugin uninstall."); // return false return false; } } }
* Description: Our first plugin running on drawline. This is the big success. * Icon: assets/icon.png * Website: http://drawline.org */ if (!defined("pDOC")) { define("pDOC", str_replace(FOLDER_PLUGINS, "", __DIR__)); } if (!defined("FOLDER_pDOC")) { define("FOLDER_pDOC", FOLDER_PLUGINS . pDOC . DS); } /* * install the plugin */ EVENTS::add_action("install_plugin_" . pDOC, function () { }); /* * uninstall the plugin */ EVENTS::add_action("uninstall_plugin_" . pDOC, function () { }); /* * run plugin */ EVENTS::add_action("run_plugin_" . pDOC, function () { if (!on_admin()) { URL::route("^pdo/\$", "index.php?pdoc=super"); if (isset($_GET['pdoc'])) { print_array($_GET); } } });
function show_404() { // do programmed events EVENTS::do_action("on_error_404"); // change header status header("HTTP/1.0 404 Not Found"); // change title if isn't setted if (TPL::thing("head", "title") == '') { TPL::thing("head", "title", "Error 404 | Page not found"); } // set render and draw if (TPL::check_template("page_404")) { TPL::render("page_404"); TPL::draw(true); } else { echo "<h1>Error 404! Not found</h1>"; } }
$page['content_slug'] = $_POST['page_slug'] == '' ? slugify($_POST['page_title']) : $_POST['page_slug']; $page['content_visible'] = $_POST['page_visible']; // update content if (CONTENT::set_content($page, $_GET['id']) !== false) { // show success message TPL::message('Continutul a fost actualizat cu succes!', 'success'); } } // 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");
DRAWLINE::admin_menu('s_seo', array("title" => "SEO", "icon" => "google", "link" => "admin_settings_seo", "parent" => "settings")); DRAWLINE::admin_menu('s_maintenance', array("title" => "Maintenance", "icon" => "code-fork", "link" => "admin_settings_maintenance", "parent" => "settings")); DRAWLINE::admin_menu('s_backend', array("title" => "Backend", "icon" => "paper-plane", "link" => "admin_settings_backend", "parent" => "settings")); DRAWLINE::admin_menu('s_email', array("title" => "E-mail", "icon" => "envelope-o", "link" => "admin_settings_email", "parent" => "settings")); DRAWLINE::admin_menu('s_backup', array("title" => "Backup", "icon" => "cloud", "link" => "admin_settings_backup", "parent" => "settings")); /* * EXTENDER */ DRAWLINE::admin_menu('extender', array("title" => "Extender", "icon" => "bolt", "link" => "admin_extender")); DRAWLINE::admin_menu('users_list', array("title" => "Plugins", "icon" => "plug", "link" => "admin_plugins", "parent" => "extender", "item_separator_bottom" => true)); DRAWLINE::admin_menu('marketplace', array("title" => "Marketplace", "icon" => "shopping-bag", "link" => "admin_marketplace", "parent" => "extender")); /* include template function file */ if (file_exists(FOLDER_ADMIN . "template" . DS . "functions.php")) { include FOLDER_ADMIN . "template" . DS . "functions.php"; } EVENTS::do_action("init"); /* run controller */ if (isset($_GET['c'])) { // path to controller $path = FOLDER_ADMIN . "controllers" . DS . "controller_" . $_GET['c'] . ".php"; if (file_exists($path)) { // include controller include $path; } else { // write to log [fail] LOGS::write("Fail load controller " . $_GET['c'] . "."); // show error 404 die("Error 404"); } } TPL::assign('_admin_ob', ob_get_clean());
include FOLDER_WEBAPP . "services" . DS . "service_minify.php"; // service SITEMAP include FOLDER_WEBAPP . "services" . DS . "service_sitemap.php"; // service THUMBS include FOLDER_WEBAPP . "services" . DS . "service_thumbs.php"; URL::route("/", function () { TPL::render("pages/page_home"); }); if (CONTENT::is_page()) { TPL::thing("head", "title", CONTENT::$current['content_title']); EVENTS::add_action("view_page_page_text", function () { TPL::assign("content", CONTENT::get()); TPL::render("pages/page_text"); }); EVENTS::add_action("before_render", function () { EVENTS::do_action("view_page_" . CONTENT::get("content_type")); }); URL::routed(true); } if (!URL::routed()) { $request = URL::get_request(); if (substr($request, -1) == '/') { $request = substr($request, 0, -1); } $not_allowed = array("home", "text", "404", "maintenance"); if (TPL::check_template("page_" . $request) && !in_array($request, $not_allowed)) { TPL::render("page_" . $request); URL::routed(true); } } //LOGS::export("html", true);
} // 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."); } } EVENTS::do_action("before_render"); // start render if (OPTIONS::website("maintenance_mode") == '1' && !on_admin() && !PERMISSIONS::check("access_admin")) { if (TPL::check_template("page_maintenance")) { TPL::render("page_maintenance"); TPL::draw(true); } else { echo '<h1>This website is in maintenance!</h1>'; } } elseif (TPL::render() != "") { TPL::draw(true); } else { if (!URL::routed()) { show_404(); } } EVENTS::do_action("after_render"); //print_array(LOGS::export("html"));