예제 #1
0
    /**
     * Get content
     */
    public function getContent()
    {
        session("name");
        session_unset();
        if (post("login")) {
            v("message", t("login.1"));
            $user = RDR_User::login(post("username"), post("password"), post("remember"));
            if ($user) {
                if (get("redirect")) {
                    redirect(get("redirect"));
                }
                redirect(l("RDR_Home"), 302);
            }
        }
        ?>

        <div class="center">
            <img src="<?php 
        echo url()->getByAlias("public", "img/logo-1.png");
        ?>
" alt=""/>
        </div>
        <?php 
        $table = new Form_Table($this->getForm());
        $table->addSubmit("Login");
        echo $table->getHtml();
    }
예제 #2
0
 /**
  * Get form
  *
  * @return Form_Form
  */
 public function getForm()
 {
     $form = new Form_Form("user");
     $field = new Form_Field_Hidden("save");
     $field->setDefaultValue(1);
     $form->addField($field);
     $field = new Form_Field_Text("username", t("username"));
     $field->setDefaultValue($this->user->username);
     $field->setDbObjectMember($this->user);
     $form->addField($field);
     $field = new Form_Field_Password("password", t("password"));
     if (!$this->user->getId()) {
         $field->setDbObjectMember($this->user);
     }
     $form->addField($field);
     $field = new Form_Field_Password("password2", t("settings.3"));
     if (!$this->user->getId()) {
         $field->setDbObjectMember($this->user, "password");
     }
     $form->addField($field);
     $field = new Form_Field_Select("role", t("admin.user.5"));
     $field->setDbObjectMember($this->user);
     $field->addOption(RDR_User::ROLE_USER, t("user." . RDR_User::ROLE_USER));
     $field->addOption(RDR_User::ROLE_ADMIN, t("user." . RDR_User::ROLE_ADMIN));
     $field->setDefaultValue($this->user->role);
     $form->addField($field);
     return $form;
 }
예제 #3
0
    /**
     * Get content
     */
    public function getContent()
    {
        $errors = $checkErrors = array();
        $writeableFolders = array(CHOQ_ACTIVE_MODULE_DIRECTORY, CHOQ_ACTIVE_MODULE_DIRECTORY . "/public/static", CHOQ_ACTIVE_MODULE_DIRECTORY . "/public/img/favicons", CHOQ_ACTIVE_MODULE_DIRECTORY . "/tmp");
        foreach ($writeableFolders as $folder) {
            if (!is_dir($folder)) {
                $errors[] = sprintf(t("install.folder.notexist"), $folder);
                break;
            }
            if (!is_writable($folder)) {
                $errors[] = sprintf(t("install.folder.writeable"), $folder);
                break;
            }
        }
        if (!ini_get("allow_url_fopen")) {
            $errors[] = sprintf(t("install.php.feature"), "allow_url_fopen");
        }
        if (!function_exists("fsockopen")) {
            $errors[] = sprintf(t("install.php.feature"), "fsockopen/sockets");
        }
        if (!function_exists("simplexml_load_file")) {
            $errors[] = sprintf(t("install.php.feature"), "SimpleXML");
        }
        if (!CHOQ_DB_Mysql::isAvailable()) {
            $errors[] = sprintf(t("install.php.feature"), "MySQLi");
        }
        if (post("install")) {
            try {
                $connString = "mysql://" . post("mysql-user") . ":" . post("mysql-pass") . "@" . post("mysql-host") . "/" . post("mysql-db");
                CHOQ_DB::add($connString, "test");
                db("test")->query("DROP TABLE IF EXISTS " . db("test")->quote("RDR_test"));
                db("test")->query("CREATE TABLE " . db("test")->quote("RDR_test") . " (" . db("test")->quote("id") . " INT NOT NULL)");
                db("test")->query("DROP TABLE IF EXISTS " . db("test")->quote("RDR_test"));
                $fileData = "<?php\nif(!defined(\"CHOQ\")) die();\n/**\n * Local Configuration\n**/\n\n";
                $fileData .= 'CHOQ_DB::add(\'' . $connString . '\');' . "\n";
                $fileData .= 'v("hash.salt", "' . uniqid(NULL, true) . sha1(microtime() . uniqid(NULL, true)) . '");' . "\n";
                $tmpfile = CHOQ_ACTIVE_MODULE_DIRECTORY . "/tmp/_RDR.local.tmp.php";
                file_put_contents($tmpfile, $fileData);
                include $tmpfile;
                $generator = CHOQ_DB_Generator::create(db());
                $tables = $generator->getExistingTables();
                foreach ($tables as $table) {
                    if ($table == "_choqled_metadata" || substr(strtolower($table), 0, 3) == "rdr_") {
                        db()->query("DROP TABLE " . db()->quote($table));
                    }
                }
                RDR_DBUpdate::run();
                $user = new RDR_User(db());
                $user->username = post("admin-user");
                $user->setPassword(post("admin-pass"));
                $user->role = RDR_User::ROLE_ADMIN;
                $user->store();
                rename($tmpfile, CHOQ_ACTIVE_MODULE_DIRECTORY . "/_RDR.local.php");
                redirect(url()->getByAlias("base"));
            } catch (Exception $e) {
                $checkErrors[] = $e->getMessage();
            }
        }
        ?>
        <div class="center">
            <img src="<?php 
        echo url()->getByAlias("public", "img/logo-1.png");
        ?>
" alt=""/>
        </div>
        <?php 
        if (!$errors) {
            $this->showErrors($checkErrors);
            $form = $this->getForm();
            $formTable = new Form_Table($form);
            $formTable->addSubmit(t("install.finish"));
            echo $formTable->getHtml();
            echo "<div class='center'><br/>" . t("install.warn") . "</div>";
        } else {
            $this->showErrors($errors);
        }
    }
예제 #4
0
 /**
  * Get all categories to this user
  *
  * @return RDR_Category[]
  */
 public function getCategories()
 {
     if (self::$_cache === null) {
         self::$_cache = RDR_Category::getByCondition(db()->quote("user") . " = {0}", array($this), "+name");
     }
     return self::$_cache;
 }
예제 #5
0
 /**
  * On load not implemented
  */
 public function onLoad()
 {
     RDR_User::logout();
     redirect(l("RDR_Home"), 302);
 }
예제 #6
0
    /**
     * Load the View
     */
    public function onLoad()
    {
        # load the view
        $view = $this->getParam("view");
        if (RDR::$isInstalled) {
            if (RDR_DBUpdate::updateRequired()) {
                RDR_User::$user = false;
                $view = new RDR_DBUpdate();
            }
        }
        ob_start();
        $view->getContent();
        $content = ob_get_contents();
        ob_end_clean();
        # some html preparations
        $bodyClasses = array("page-" . slugify(strtolower(get_class($view))));
        $jsVars = array();
        $dir = CHOQ_ACTIVE_MODULE_DIRECTORY . "/view";
        $files = array("css" => array(CHOQ_ROOT_DIRECTORY . "/modules/Form/view/_css/form.css", "{$dir}/_css/default.css"), "js" => array("{$dir}/_js/jquery/jquery.js", "{$dir}/_js/default.js", CHOQ_ROOT_DIRECTORY . "/modules/Form/view/_js/form.js"));
        $name = "default";
        html()->addFileGroupToHead($name, "css", CHOQ_ACTIVE_MODULE_DIRECTORY . "/public/static", "static", $files["css"]);
        html()->addFileGroupToHead($name, "js", CHOQ_ACTIVE_MODULE_DIRECTORY . "/public/static", "static", $files["js"]);
        $jsVars["message"] = v("message");
        if (RDR::$isInstalled) {
            $jsVars["proxyUrl"] = l("RDR_Proxy");
            $jsVars["apiUrl"] = l("RDR_API");
        }
        $userData = array();
        if (user()) {
            $jsVars["ajaxUrl"] = l("RDR_Ajax");
            user()->updateNewsCache();
            $userData = user()->getAjaxData();
        }
        if (isMobile()) {
            $dir = CHOQ_ACTIVE_MODULE_DIRECTORY . "/view";
            $files = array("css" => array("{$dir}/_css/mobile.css"), "js" => array());
            $name = "mobile";
            html()->addFileGroupToHead($name, "css", CHOQ_ACTIVE_MODULE_DIRECTORY . "/public/static", "static", $files["css"]);
            html()->addFileGroupToHead($name, "js", CHOQ_ACTIVE_MODULE_DIRECTORY . "/public/static", "static", $files["js"]);
            $bodyClasses[] = "mobile";
        }
        ?>
<!DOCTYPE html>
        <?php 
        html()->getOpeningHTMLTag();
        ?>
        <head>
        <?php 
        html()->getHeadTag();
        ?>
        <link rel="shortcut icon" href="<?php 
        echo url()->getByAlias("public", "favicon.ico");
        ?>
" type="image/icon" />
        <meta name="generator" content="Choqled PHP Framework" />
        <base href="<?php 
        echo url()->getByAlias("base");
        ?>
"/>
        <script type="text/javascript">
        Global.vars = <?php 
        echo json_encode($jsVars, JSON_FORCE_OBJECT);
        ?>
;
        </script>
        <!--[if lte IE 8]>
        <script type="text/javascript">
        $(document).ready(function(){
            Global.message("<?php 
        echo t("iewarning");
        ?>
")
        });
        </script>
        <![endif]-->
        </head>
        <body class="<?php 
        echo implode(" ", $bodyClasses);
        ?>
">
            <div id="top-message"></div>
            <div class="container a">
                <?php 
        view("RDR_Sidebar", array("content" => 1));
        ?>
            </div><div class="container b">
                <div class="content" id="content">
                    <div class="padd">
                        <?php 
        view("RDR_Sidebar", array("icons" => 1));
        ?>
                        <?php 
        echo $content;
        ?>
                    </div>
                </div>
                <div class="padd" id="content"></div>
            </div><div class="container c"></div>
            <script type="text/javascript">Global.init(<?php 
        echo json_encode($userData);
        ?>
);</script>
        </body>
        </html>
        <?php 
    }