예제 #1
0
").append(tmp);

        // Set driver combo
        if(options.driver) {
            $("#databasedriver_" + rnd).val(options.driver);
        }
        // Remove item
        $("#deletedatabase_" + rnd).click(function() {
            var id = $(this).attr("data-parent");
            $("div." + id).remove();
        });

    }
    <?php 
foreach ($config as $key => $db) {
    $rnd = \Core\CString::rand();
    ?>
        Module_Admin_Configuration_Database_SetItem("<?php 
    echo $rnd;
    ?>
", "<?php 
    echo $key;
    ?>
", <?php 
    echo json_encode($db);
    ?>
);
        <?php 
}
?>
    $(function() {
예제 #2
0
<?php

$randId = \Core\CString::rand();
?>
<div class="sortable">
    <i class="fa fa-arrows"></i>
    &nbsp;&nbsp;
    <input type="checkbox" value="<?php 
echo $value;
?>
" <?php 
echo $checked;
?>
 id="<?php 
echo $randId;
?>
" />
    <label for="<?php 
echo $randId;
?>
"><?php 
echo $label;
?>
</label>
</div>
예제 #3
0
 protected function loginAction($options = array())
 {
     // Default option value
     // passwordEncrypt = true
     $options["passwordEncrypt"] = isset($options["passwordEncrypt"]) ? $options["passwordEncrypt"] : true;
     // force l'envoi de la clé
     $this->testKey(true);
     if (empty($_REQUEST->login) || empty($_REQUEST->password)) {
         throw new \Core\CException("Login failed");
     }
     $db = \Core\Db::create($this->getParams("database"));
     $userTable = $db->quoteTable($this->getParams("userTable", "table"));
     $idField = $db->quoteField($this->getParams("userTable", "idField"));
     $loginField = $db->quoteField($this->getParams("userTable", "loginField"));
     $passwordField = $db->quoteField($this->getParams("userTable", "passwordField"));
     $passwordFn = $this->getParams("userTable", "passwordFn");
     $nameField = $db->quoteField($this->getParams("userTable", "nameField"));
     $roleTable = $db->quoteTable($this->getParams("roleTable", "table"));
     $roleId = $db->quoteField($this->getParams("roleTable", "idField"));
     $roleField = $db->quoteField($this->getParams("roleTable", "roleField"));
     $linkTable = $db->quoteTable($this->getParams("linkTable", "table"));
     $linkUser = $db->quoteField($this->getParams("linkTable", "userId"));
     $linkRole = $db->quoteField($this->getParams("linkTable", "roleId"));
     //if(! \Core\CString::isValidMd5($_REQUEST->password)) {
     if ($options["passwordEncrypt"] === true && !empty($passwordFn)) {
         $_REQUEST->password = call_user_func($passwordFn, $_REQUEST->password);
     }
     $randId = strtolower(\Core\CString::rand(5));
     $sql = "\n            SELECT\n                {$idField} as userid_{$randId},\n                {$loginField} as userlogin_{$randId},\n                {$nameField} as username_{$randId},\n                u.*\n            FROM\n                {$userTable} u\n            WHERE\n                u.{$loginField} = :user\n                AND u.{$passwordField} = :Login\n        ";
     $res = $db->selectRow($sql, array(":user" => $_REQUEST->login, ":Login" => $_REQUEST->password));
     if (!empty($res)) {
         \Core\Security::setUserId($res["userid_" . $randId]);
         \Core\Security::setUserLogin($res["userlogin_" . $randId]);
         \Core\Security::setUserName($res["username_" . $randId]);
         $resUser = $res;
         unset($resUser["userid_" . $randId]);
         unset($resUser["userlogin_" . $randId]);
         unset($resUser["username_" . $randId]);
         \Core\Security::setUser($resUser);
         // Reccup role
         $sql = "\n                SELECT \n                    r.{$roleField} as role\n                FROM\n                    {$roleTable} r\n               JOIN\n                    {$linkTable} l\n                        ON r.{$roleId} = l.{$linkRole}\n               JOIN\n                    {$userTable} u\n                        ON u.{$idField} = l.{$linkUser}\n               WHERE\n                    u.{$idField} = :userid\n            ";
         $resRole = $db->select($sql, array(":userid" => $res["userid_" . $randId]));
         if (!empty($resRole)) {
             foreach ($resRole as $role) {
                 \Core\Security::AddRole($role["role"]);
             }
         }
         // St cookie for Autologin
         if (isset($_REQUEST->autologin) && $_REQUEST->autologin == "1") {
             $c = array($_REQUEST->login, $_REQUEST->password);
             $c = serialize($c);
             $c = \Core\CString::encrypt($c, $this->cookieName);
             setcookie($this->cookieName, $c, time() + $this->cookieTime, "/");
         }
     } else {
         $this->logout(new \Core\Request());
         throw new \Core\CException("Login failed");
     }
 }