Exemplo n.º 1
0
 public function __construct(&$params = array())
 {
     // reccup le id du module si envoyé en param
     if (isset($_REQUEST->moduleId)) {
         if (isset($_SESSION["modules/" . $_REQUEST->moduleId . "/params"])) {
             $params = $_SESSION["modules/" . $_REQUEST->moduleId . "/params"];
         }
     }
     $this->setParameters($params);
     $id = \Core\Request::getClassUri($this);
     $id = \Core\CString::sanitize($id);
     $this->id = $id . "-" . md5(serialize($params));
     // Sotck une clé unique d'initialisation en session
     if (!isset($_SESSION["modules/" . $this->id()])) {
         $_SESSION["modules/" . $this->id()] = CString::rand(30);
     }
     $this->key = $_SESSION["modules/" . $this->id()];
     $_SESSION["modules/" . $this->id() . "/params"] = $params;
 }
Exemplo n.º 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>
Exemplo n.º 3
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() {
Exemplo n.º 4
0
<?php

if (!isset($titre)) {
    $titre = null;
}
if (!isset($moreLink)) {
    $moreLink = null;
}
if (!isset($content)) {
    $content = null;
}
$titre = \Core\CString::pick($titre, "");
$moreLink = \Core\CString::pick($moreLink, "");
$content = \Core\CString::pick($content, "");
//$faker = Faker\Factory::create(NormalizedLocale());
?>
<!DOCTYPE HTML>
<html>
	<head>
		<title>.:: nOn0n ::.</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
        <?php 
//Bootstrap
echo \Core\View::includeResources("resources/core/bootstrap/bootstrap-3.3.5/css/bootstrap.min.css");
// FA
echo \Core\View::includeResources("resources/core/font-awesome-4.4.0/css/font-awesome.min.css");
echo \Core\View::includeResources("resources/user/demo/demo.css");
?>
	</head>
    <body>
Exemplo n.º 5
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");
     }
 }
Exemplo n.º 6
0
                <?php 
$ligne = 0;
foreach ($self->results as $item) {
    $class = $ligne % 2 === 0 ? "even" : "";
    echo "<tr class=\"{$class}\">";
    // class="even"
    echo "\n                            <td class=\"ck-column\">\n                                <input type=\"checkbox\" name=\"itemId[]\" value=\"" . $item[$self->primaryKey] . "\" />\n                            </td>\n                        ";
    foreach ($self->columns as $table => $conf) {
        if ($conf["showInTable"] === false) {
            continue;
        }
        $celValue = $item[$table];
        $celValue = strip_tags($celValue);
        //$celValue = \Core\CString::utf8decode($celValue);
        // Trim text si long
        if (\Core\CString::strlen($celValue) > 15) {
            $celValue = substr($celValue, 0, 14) . "...";
        }
        if (trim($celValue) === "") {
            $celValue = "&nbsp;--&nbsp;";
        }
        echo "<td>";
        if (isset($conf["link"]) && $conf["link"] === true) {
            echo "<a \n                                        class=\"edit_" . $randId . "\"\n                                        href=\"#\"\n                                        data-form=\"" . $randId . "\"\n                                        data-table=\"" . $table . "\"\n                                        data-value=\"" . $item[$self->primaryKey] . "\"\n                                    >" . $celValue . "</a>";
        } else {
            echo $celValue;
        }
        echo "</td>";
    }
    echo "</tr>";
    $ligne++;
Exemplo n.º 7
0
 /**
 Translate a text
 */
 public static function translateText($str)
 {
     global $PROJECT_TRANSLATION;
     $text = \Core\CString::sanitize($str);
     if (isset($PROJECT_TRANSLATION[$text])) {
         return $PROJECT_TRANSLATION[$text];
     } else {
         if (!empty($PROJECT_TRANSLATION)) {
             \Core\FirePHP::fbLog("warn", "Translation error : " . $str);
         }
     }
     return $str;
 }
Exemplo n.º 8
0
 public function tableManagerBuildItem($randId, $field, $describe, $fieldPrefix = "")
 {
     $name = $field;
     $value = "";
     if (isset($this->results[$field])) {
         $value = $this->results[$field];
     }
     if (!empty($fieldPrefix)) {
         $value = "";
     }
     if ($this->columns[$field]["updateIfNull"] === false) {
         $value = "";
     }
     // TODO escape quote et accent !!!
     $value = htmlspecialchars($value);
     switch ($describe["type"]) {
         case "int":
             $type = "numberfield";
             break;
         case "double":
             $type = "numberfield";
             break;
         case "timestamp":
         case "datetime":
             $type = "datetime";
             break;
         case "date":
             $type = "date";
             break;
         case "time":
             $type = "time";
             break;
         default:
             $type = "text";
             break;
     }
     echo "<label for=\"field_{$name}" . $randId . "\">";
     echo $fieldPrefix . " ";
     if (!empty($this->columns[$field]["alias"])) {
         echo $this->columns[$field]["alias"];
     } else {
         echo $field;
     }
     if ($describe["notNull"]) {
         echo " *";
     }
     echo "</label>";
     // Suffixe name
     if (!empty($fieldPrefix)) {
         $name = $name . "____" . \Core\CString::sanitize($fieldPrefix);
     }
     // Max lenght for input
     $maxLength = "";
     if ($describe["length"] > 0) {
         $maxLength = "maxlength=\"" . $describe["length"] . "\"";
     }
     // PK
     if ($describe["primaryKey"]) {
         // Si AI => id auto
         if ($describe["serial"]) {
             echo "<input type=\"text\" value=\"{$value}\" readonly=\"readonly\" placeholder=\"AUTO\" />";
         } else {
             // si id non renseigné (new) id editable
             if ($value === "") {
                 echo "<input type=\"text\" name=\"tablefield_{$name}\" value=\"{$value}\" {$maxLength} />";
             } else {
                 // si id renseigné id (update) non editable
                 echo "<input type=\"text\" value=\"{$value}\" readonly=\"readonly\" />";
             }
         }
     } else {
         //
         // Fk choix multiple
         //
         if (!empty($describe["foreignKey"])) {
             $sqlFk = "SELECT * FROM " . $this->db->quoteTable($describe["foreignKey"]["table"]);
             $resFk = $this->db->select($sqlFk);
             echo "<select\n                    id=\"field_{$name}" . $randId . "\"\n                    value=\"{$value}\"\n                    name=\"tablefield_{$name}\"\n                    class=\"{$type}\"\n                    type=\"{$type}\"\n                    attr-required=\"" . ($describe["notNull"] ? "required" : "") . "\"\n                >";
             echo "<option value=\"\"></option>";
             foreach ($resFk as $r) {
                 echo "<option\n                        value=\"" . $r[$describe["foreignKey"]["field"]] . "\"\n                        " . ($value == $r[$describe["foreignKey"]["field"]] ? "selected" : "") . "\n                    >";
                 echo implode(" - ", array_values($r));
                 echo "</option>";
             }
             echo "</select>";
         } elseif (!empty($describe["length"]) && (int) $describe["length"] > 255) {
             //
             // Text long
             //
             echo "<textarea\n                    id=\"field_{$name}" . $randId . "\"\n                    name=\"tablefield_{$name}\"\n                    class=\"{$type}\"\n                    type=\"{$type}\"\n                    attr-required=\"" . ($describe["notNull"] ? "required" : "") . "\"\n                    {$maxLength}\n                >{$value}</textarea>";
         } else {
             //
             // TODO bool...
             //
             echo "<input\n                    id=\"field_{$name}" . $randId . "\"\n                    value=\"{$value}\"\n                    name=\"tablefield_{$name}\"\n                    class=\"{$type}\"\n                    type=\"{$type}\"\n                    attr-required=\"" . ($describe["notNull"] ? "required" : "") . "\"\n                    {$maxLength}\n                />";
         }
     }
     // editor
     if (isset($this->columns[$field]["editor"]) && !empty($this->columns[$field]["editor"])) {
         $editor = strtolower($this->columns[$field]["editor"]);
         if ($editor == "tinymce") {
             echo "\n                    <script>\n                        \$(function() {\n                            \$('#field_{$name}" . $randId . "').attr('data-editor', 'tinymce');\n                            \$('#field_{$name}" . $randId . "').tinymce({});\n                        });\n                    </script>\n                ";
         }
     }
 }