コード例 #1
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #2
0
function _inc($inc)
{
    $path = TPL::dir() . $inc . ".php";
    // check for include file in template directory
    if (!file_exists($path)) {
        // check other path
        if (file_exists($inc . ".php")) {
            $path = $inc . ".php";
        } else {
            // log error
            LOGS::write("not_found_template_file");
            // return false
            return false;
        }
    }
    // include file
    extract(TPL::$vars);
    include $path;
}
コード例 #3
0
 switch ($_GET['do']) {
     /*
      * login user
      */
     case "login":
         // check if already logged
         if (USER::is_logged()) {
             redirect(LINKS::get("admin_home"));
         }
         // check if sent data
         if (isset($_POST['username'], $_POST['password'])) {
             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
          */
コード例 #4
0
ファイル: include_user.php プロジェクト: double-web/drawline
 public static function register($username, $email, $password, $fullname, $permission_groups)
 {
     global $db;
     // filter
     $user_username = $db->real_escape($username);
     $user_email = $db->real_escape($email);
     $user_password = $db->real_escape($password);
     $user_fullname = $db->real_escape($fullname);
     $user_groups = $db->real_escape(implode(",", $permission_groups));
     // CHECK FOR ERRORS
     $errors = array();
     // check for uniq username
     $chk = $db->query("SELECT count(*) as tot FROM dl_users WHERE user_username = '******'");
     $chk = $db->fetch_array($chk);
     if ($chk['tot'] == 1) {
         $errors[] = 'not_unique_username';
     }
     // check for uniq email
     $chk = $db->query("SELECT count(*) as tot FROM dl_users WHERE user_email = '" . $user_email . "'");
     $chk = $db->fetch_array($chk);
     if ($chk['tot'] == 1) {
         $errors[] = 'not_unique_email';
     }
     // check if groups exists
     if (empty($errors)) {
         $user_password = password_hash($user_password, PASSWORD_DEFAULT);
         // insert into database
         $ins = $db->query("INSERT INTO dl_users (   user_fullname,\n                                                            user_username,\n                                                            user_email,\n                                                            user_password,\n                                                            user_date_registred,\n                                                            user_groups) \n                                                    VALUES ( '" . $user_fullname . "', \n                                                             '" . $user_username . "', \n                                                             '" . $user_email . "', \n                                                             '" . $user_password . "', \n                                                             NOW(), \n                                                             '" . $user_groups . "'\n                                                            )");
         if (!$ins) {
             // write error [fail]
             LOGS::write("sql_error", true);
             // return false
             return array("sql_error");
         } else {
             // return true
             return true;
         }
     } else {
         return $errors;
     }
 }
コード例 #5
0
ファイル: helper_images.php プロジェクト: double-web/drawline
 /**
  * Load an image
  *
  * @param string        $filename   Path to image file
  *
  * @return SimpleImage
  * @throws Exception
  *
  */
 function load($filename)
 {
     // Require GD library
     if (!extension_loaded('gd')) {
         throw new Exception('Required extension GD is not loaded.');
     }
     // check exists
     if (file_exists($filename)) {
         $this->filename = $filename;
         return $this->get_meta_data();
     } else {
         // write logs
         LOGS::write("I can't load image " . $filename . ". Not found!", true);
         // return false
         return false;
     }
 }
コード例 #6
0
 public static function render($tpl = '')
 {
     if ($tpl == '') {
         return self::$render;
     } else {
         // check if tamplate exists
         if (!self::check_template($tpl)) {
             // write error to log
             LOGS::write("Template not found << " . $tpl . " >> in " . self::dir(), "warning", true);
         }
         // set render
         self::$render = $tpl;
     }
 }
コード例 #7
0
 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;
         }
     }
 }
コード例 #8
0
 public static function set($type, $name, $value, $identifier = 0)
 {
     global $db;
     // filter
     $type = $db->real_escape($type);
     $name = $db->real_escape($name);
     $value = $db->real_escape($value);
     $identifier = $db->real_escape($identifier);
     // check if exists
     $r = self::get($type, $name, $identifier);
     // not found -> insert
     if ($r === false) {
         $ins = $db->query("INSERT INTO dl_options VALUES (  '" . $type . "',\n                                                                    '" . $identifier . "',\n                                                                    '" . $name . "',\n                                                                    '" . $value . "' )");
         // on error
         if (!$ins) {
             // write to log [fail]
             LOGS::write("Error with a sql query. Look in logs and solve sql error.");
             die($db->sql_error());
             // return
             return false;
         }
         // return
         return true;
     } else {
         // skip if the value is same
         if ($r == $value) {
             return true;
         }
         // delete or update option
         // delete
         if ($value === false) {
             // compose query
             $where = "option_type = '" . $type . "' AND option_name = '" . $name . "' AND option_identifier = '" . $identifier . "'";
             // run query
             $del = $db->query("DELETE FROM dl_options WHERE " . $query);
             // on error
             if (!$del) {
                 // write to log [fail]
                 LOGS::write("Error while trying to delete an option.");
                 // return false
                 return false;
             }
             // ok
             return true;
         } else {
             // compose query
             $where = "option_type = '" . $type . "' AND option_name = '" . $name . "' AND option_identifier = '" . $identifier . "'";
             // run query
             $upd = $db->query("UPDATE dl_options SET option_value = '" . $value . "' WHERE " . $where);
             // on error
             if (!$upd) {
                 // write to log [fail]
                 LOGS::write("Error while trying to update an option value.");
                 // return
                 return false;
             }
             // ok
             return true;
         }
     }
 }
コード例 #9
0
ファイル: index.php プロジェクト: double-web/drawline
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());
//TPL::insert( 'head', '<script>alert("Hi! :)");</script>' );
//print_array(TPL::$insert);
コード例 #10
0
ファイル: driver_mysqli.php プロジェクト: double-web/drawline
 /**
  * parsing the data as array - mysql_fetch_array
  *
  * @param resource $rezultat
  * @param bool $type - true for MYSQL_ASSOC, false for MYSQL_NUM, null for MYSQL_BOTH
  *
  * @return array $result
  *
  **/
 public function fetch_array($rezultat = NULL, $type = true)
 {
     if (is_resource($rezultat) || is_object($rezultat)) {
         $result = $rezultat;
     } else {
         $result = $this->result;
     }
     if ($result == true) {
         if ($type == true) {
             $rez = $result->fetch_array(MYSQLI_ASSOC);
         } elseif ($type == false) {
             $rez = $result->fetch_array(MYSQLI_NUM);
         } else {
             $rez = $result->fetch_array(MYSQLI_BOTH);
         }
         if ($this->sql_debug) {
             $this->sql_monitor('fetch_array', 'result', $result, $rez, __LINE__, __FILE__, $this->sql_errno(), $this->sql_error());
         }
         return $rez;
     } else {
         LOGS::write('Trying to fetch results on a boolean resource.', true);
     }
 }
コード例 #11
0
 public static function add_page_type($options)
 {
     // check if $options has all required data
     if (!isset($options['type_name'], $options['type_title'], $options['type_desc'], $options['type_icon'])) {
         LOGS::write("Required [type_name], [type_title], [type_desc], [type_icon] for page type", true);
         return false;
     }
     $c_types = self::get_page_types();
     // check if already exist
     foreach ($c_types as $t) {
         if ($t['type_name'] == $options['type_name']) {
             LOGS::write("Try to add an existing page type.", "notice", true);
             return false;
         }
     }
     // add to current page types
     $c_types[] = $options;
     $new = json_encode($c_types);
     // insert in database
     return OPTIONS::set("website", "page_types", $new) ? true : false;
 }
コード例 #12
0
ファイル: index.php プロジェクト: double-web/drawline
} 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.");
    }
}
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()) {