Пример #1
0
 public function __construct(\Fp\Core\Init $O)
 {
     if ($O->glob('crypt_function')) {
         $this->crypt_function = $O->glob('crypt_function');
     }
     /*
     @TODO delete after Table test validation 
     $tableLoginPassword 	 = $this->table;
     $columnLoginPassword  = array('uid','password','password_tmp');
     $this->tableLoginPassword  = Table::set(Db::get_link(), $tableLoginPassword, $columnLoginPassword);
     $this->tableLoginPassword->setPrimary('uid');
     $this->tableLoginPassword->setUnique(array());
     $this->tableLoginPassword->setSortable(array('uid','password','password_tmp'));
     $this->tableLoginPassword->setSearchable(array (
       'uid' => 'bigint',
       'password' => 'varchar',
       'password_tmp' => 'varchar',
     ));
     $this->tableLoginPassword->setAutoIncrement();	
     */
     $dbLink = Db::get_link();
     $this->table = $O->glob('prefix') . $this->table;
     $shemaPassword = array('table' => $this->table, 'column' => array('uid' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'password' => array('type' => 'varchar', 'sortable' => 1, 'searchable' => 1), 'password_tmp' => array('type' => 'varchar', 'sortable' => 1, 'searchable' => 1)));
     $this->tablePassword = Table::setTable($dbLink, $shemaPassword);
     $this->dbLoginPassword = new Query($this->tablePassword, 'LoginPassword');
 }
Пример #2
0
 public function __construct(\Fp\Core\Init $O)
 {
     $tableLoginFacebook = $O->glob('prefix') . $this->table;
     $columnLoginFacebook = array('uid', 'fb_uid', 'app_id');
     $this->tableLoginFacebook = Table::set(Db::get_link(), $tableLoginFacebook, $columnLoginFacebook);
     $this->tableLoginFacebook->setPrimary('uid');
     $this->tableLoginFacebook->setUnique(array('fb_uid', 'uid'));
     $this->tableLoginFacebook->setSortable(array('uid', 'fb_uid'));
     $this->tableLoginFacebook->setSearchable(array('uid' => 'bigint'));
     $this->tableLoginFacebook->setAutoIncrement();
     $this->dbLoginFacebook = new Table_query($this->tableLoginFacebook, 'LoginFacebook');
 }
Пример #3
0
 public function __construct(\Fp\Core\Init $O)
 {
     $tableLoginMail = $O->glob('prefix') . $this->table;
     $columnLoginMail = array('uid', 'mail', 'tmp_mail', 'status');
     $this->tableLoginMail = Table::set(Db::get_link(), $tableLoginMail, $columnLoginMail);
     $this->tableLoginMail->setPrimary('uid');
     $this->tableLoginMail->setUnique(array('mail'));
     $this->tableLoginMail->setSortable(array('uid', 'mail', 'tmp_mail', 'status'));
     $this->tableLoginMail->setSearchable(array('uid' => 'bigint', 'tmp_mail' => 'varchar', 'status' => 'int'));
     $this->tableLoginMail->setAutoIncrement();
     $this->dbLoginMail = new Table_query($this->tableLoginMail, 'LoginMail');
 }
Пример #4
0
 /**
  * @param string $prefix
  * @return Auth
  */
 public function __construct(\Fp\Core\Init $O)
 {
     $this->O = $O;
     $this->data = array();
     $this->table = $O->glob('prefix') . $this->table;
     $this->session_key = md5($this->salt_session_key);
     $this->session = $O->session();
     $dbLink = Db::get_link();
     $tableLogin = $O->glob('prefix') . $this->table;
     $shemaLogin = array('table' => $tableLogin, 'options' => array('auto_increment' => 1), 'column' => array('uid' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'time' => array('type' => 'datetime', 'sortable' => 1, 'searchable' => 1), 'status' => array('type' => 'int', 'sortable' => 1, 'searchable' => 1)));
     $this->tableLogin = Table::setTable($dbLink, $shemaLogin);
     $this->dbLogin = new Query($this->tableLogin, 'Login');
 }
Пример #5
0
 /**
  * @return Db
  */
 public function db()
 {
     if (!isset($this->db)) {
         require_once __DIR__ . '/../Db/Db.php';
         # initialisation bdd
         $type = array_key_exists('type', $this->global_private['db'][0]) ? $this->global_private['db'][0]['type'] : '';
         Db::connect($this->global_private['db'][0]['id'], $this->global_private['db'][0]['host'], $this->global_private['db'][0]['user'], $this->global_private['db'][0]['pass'], $this->global_private['db'][0]['base'], $type);
         $this->db = Db::get_link($this->global_private['db'][0]['id']);
     }
     return $this->db;
 }
Пример #6
0
 public function parse_console()
 {
     $txt = '';
     $d = array();
     $d['stats'] = Debug::point();
     $d['logSql'] = Db::get_logReq();
     $d['globData'] = $this->global_data;
     $d['data'] = $this->data;
     $d['block'] = array();
     $d['parsed'] = array();
     foreach ($this->block as $k => $block) {
         $v = (array) $block;
         $v['file'] = !empty($block['file']) ? $block['file'] : null;
         $v['file'] = htmlentities(substr($block['file'], 0, 300), null, 'UTF-8');
         if (isset($this->logBlock[$k])) {
             $v['duration'] = $this->logBlock[$k]['duration'];
             $v['memory'] = $this->logBlock[$k]['memory'];
             $v['memory_peak'] = $this->logBlock[$k]['memory_peak'];
         }
         $d['block'][] = $v;
     }
     foreach ($this->parsed as $block) {
         $v = (array) $block;
         $v['file'] = htmlentities(substr($block['file'], 0, 300), null, 'UTF-8');
         $v['current_file'] = htmlentities(substr($block['current_file'], 0, 300), null, 'UTF-8');
         if (isset($this->logBlock[$block['name']])) {
             $v['duration'] = $this->logBlock[$block['name']]['duration'];
             $v['memory'] = $this->logBlock[$block['name']]['memory'];
             $v['memory_peak'] = $this->logBlock[$block['name']]['memory_peak'];
         }
         $d['parsed'][] = $v;
     }
     $d['log'] = Logger::getLog();
     $file = dirname(__FILE__) . '/tpl_console.php';
     $data = new TemplateData($d);
     try {
         $txt = $this->parse($data, $file);
         $txt = json_encode($txt);
         $txt = "<!-- start Console -->                \n                    <iframe style='width:100%;' id='4p_console_content'  ></iframe>\n                    <script>// <!--\n                    var \$4pConsole = document.getElementById('4p_console_content').contentWindow.document;\n                    \$4pConsole.open();\n                    \$4pConsole.write({$txt});\n                    \$4pConsole.close(); \n                    function \$4presizeIframe(obj) {                        \n                        obj.style.height = (obj.contentWindow.document.body.scrollHeight+500) + 'px';\n                    }\n                    \$4presizeIframe(document.getElementById('4p_console_content'));\n                    // -->\n                    </script>\n                    <!-- end Console -->\r\n";
     } catch (\Exception $e) {
         var_dump($e);
         die('parse_console error');
     }
     return $txt;
 }
Пример #7
0
 public function fusionList($id_node_to, array $list_id_node_from = array())
 {
     $tid = \Fp\Db\Db::startTransaction();
     $n = null;
     foreach ($list_id_node_from as $id_node_from) {
         $n = $this->fusion($id_node_to, $id_node_from);
     }
     \Fp\Db\Db::endTransaction($tid);
     return $n;
 }
Пример #8
0
 public static function make_data($msg, $backtrace, $errno, $errfile, $errline, $code)
 {
     try {
         if (!$backtrace) {
             $backtrace = print_r(debug_backtrace(), true);
         }
         $d = array();
         $d[':uid'] = self::get_uid();
         $d[':pid'] = self::sanit(self::get_id());
         $d[':errno'] = self::sanit($errno);
         $d[':msg'] = self::sanit($msg);
         $d[':backtrace'] = self::sanit($backtrace);
         $d[':file'] = self::sanit($errfile);
         $d[':line'] = self::sanit($errline);
         $d[':referer'] = isset($_SERVER['HTTP_REFERER']) ? self::sanit($_SERVER['HTTP_REFERER']) : "''";
         $d[':user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? self::sanit($_SERVER['HTTP_USER_AGENT']) : "''";
         $d[':ip'] = isset($_SERVER['REMOTE_ADDR']) ? self::sanit($_SERVER['REMOTE_ADDR']) : "''";
         $d[':request_uri'] = isset($_SERVER['REQUEST_URI']) ? self::sanit($_SERVER['REQUEST_URI']) : "''";
         $d[':query_string'] = isset($_SERVER['QUERY_STRING']) ? self::sanit($_SERVER['QUERY_STRING']) : "''";
         if (self::$DEBUG >= 3) {
             // on cache les erreurs http banale
             if (!ctype_digit($code) || $code <= 300 && $code >= 499) {
                 echo $code . ': ' . $d[':msg'] . "<br>\r\n <b>" . $d[':file'] . ' </b>  line ' . $d[':line'] . " <br>\r\n";
                 echo "<pre>" . print_r($d[':backtrace'], true) . "</pre> <br>\r\n";
             }
         }
         if (!self::$noSql) {
             if (Db::isConnected()) {
                 $req = 'INSERT INTO ' . self::$TABLE . " \t\n\t\t\t\t\t\t(uid,pid,errno,msg, \n\t\t\t\t\t\tbacktrace,file, \n\t\t\t\t\t\tline, date, \t\n\t\t\t\t\t\treferer, user_agent, \t\n\t\t\t\t\t\tip,request_uri,\tquery_string)\n\t\t\t\t\tVALUES(:uid,:pid,:errno,:msg,:backtrace,:file,:line,NOW(),:referer,:user_agent,:ip,:request_uri,:query_string)";
                 $req = Db::prepare($req)->execute($d);
             }
         }
     } catch (\Exception $e) {
         throw new Exception('Debug Error :' . $e->getMessage(), 666);
     }
 }
Пример #9
0
 protected final function logReqEnd($rid)
 {
     Db::logReqEnd($rid);
 }
Пример #10
0
 /**
  * @param int $uid
  * @param id $group
  */
 public function getUserLevelOnGroup($uid, $gid)
 {
     $key = 'getUserLevelOnGroup_' . $uid . '_' . $gid;
     if (!$this->isInCache($key)) {
         $req = "SELECT gu.permission FROM\n\t\t\t{$this->table_GroupUser} as gu\n\t\t\tWHERE gu.uid='{$uid}' AND gu.gid='{$gid}' ";
         $r = Db::query($req)->fetchColumn();
         $this->setCache($key, $r);
     } else {
         $r = $this->getCache($key);
     }
     return $r;
 }