예제 #1
0
<?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]);
                }
            }
        }
    });
}
예제 #2
0
 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");
 });
예제 #3
0
             $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");
예제 #4
0
 * 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);
        }
    }
});
예제 #5
0
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);