Пользователь
Покинул форум
Сообщений всего: 615
Дата рег-ции: Июль 2006
Откуда: Оттуда !
Помог: 0 раз(а)
|
Начнем пожалуй с
PHP:
скопировать код в буфер обмена
<?PHP class Encryption { static $cypher = 'blowfish'; static $mode = 'cfb'; static $key = 'Тут пишем ключ для кодировки'; public static function encrypt( $plantext ) { return $iv.$crypttext; } public static function decrypt( $crypttext ) { $iv = substr( $crypttext, 0 , $ivsize ); $crypttext = substr( $crypttext, $ivsize ); $plaintext = ""; if ( $iv ) { } return $plaintext; } } ?>
(Добавление)
PHP:
скопировать код в буфер обмена
<?PHP class CURL { private $curl = NULL; private $url = NULL; function __construct( $url ) { $this->url = $url; } function __destruct() { } /** * This function use's for installing CURL * parameters. If You need to use other * params you can modify this function. * * All function You can see below. */ private function setOptions() { $this->setParams(); $this->showHeader(); $this->followLocation(); $this->setTimeOut(0); } public function setParams() { } public function showHeader( $show = false ) { if ( $show ) { } else { } } public function followLocation( $follow = false ) { if ( $follow ) { } else { } } public function setPost( $row ) { $postdata = self::parse( $row ); curl_setopt ($this->curl, CURLOPT_POSTFIELDS , $postdata); } public function setTimeOut( $time ) { } public function getUrl() { return $this->url; } public function getResource() { return $this->curl; } public function send() { return $html; } private static function parse( $row ) { $str = ""; foreach ( $row as $key => $value ) { $str .= $key."=".$value."&"; } return $str; } } ?>
(Добавление)
PHP:
скопировать код в буфер обмена
<?PHP class Database { public $_dbLocation = "localhost"; public $_dbUser = "user"; public $_dbPass = "pass"; public $_dbName = "dbname"; public $_dbr = null; public $_sql = ""; public $_sql_res = null; public $_resource = null; public $_error = null; public function __construct( $new = false ) { if ($this->_resource = @mysql_connect($this->_dbLocation , $this->_dbUser , $this->_dbPass , $new)) { $this->_error = " Could not connect to database !"; return NULL; } } $this->_error = NULL; } public function __destruct() { } public function haveError() { if ( $this->_error == NULL ) { return FALSE; } return TRUE; } public function getLastId() { $rows = null; return $rows; } /** * selecting database * * @param string $database */ public function selectDb ($database) { } private function escape( $var ) { } else { //$var = @mysql_real_escape_string($var); } return $var; } /** * Enter description here... * * @param SQL query $strQuery * @param Database (optional) $database * @return Error massage if exist */ public function query($strQuery, $database = '') { $strQuery = $this->escape($strQuery); $this->_sql_res = $strQuery; $sql = false; } $this->_error = null; return TRUE; } else { $this->_sql = null; return FALSE; } } public function gerErrorMsg() { return $this->_error; } /** * Enter description here... * * @return Rows of query function ($this->query) */ public function fetchRow() { if ( !$this->_sql || $this->_sql == null ) { return null; } $rows = null; return $rows; } /** * Enter description here... * * @return List Array */ public function fetchArrayList() { if ( !$this->_sql || $this->_sql == null ) { return null; } $array[] = $row; } return $array; } /** * Enter description here... * * @return Array of query function */ public function fetchArray() { if ( !$this->_sql || $this->_sql == null ) { return null; } return $row; } /** * Enter description here... * * @return One value of query function */ public function fetchOne() { if ( !$this->_sql || $this->_sql == null ) { return null; } $res = null; $res = $row[0]; } return $res; } /** * Enter description here... * * @return Object array of query function */ public function fetchObjectList() { if ( !$this->_sql || $this->_sql == null ) { return null; } $array[] = $row; } return $array; } public function fetchObject() { if ( !$this->_sql || $this->_sql == null ) { return null; } return $row; } /** * Enter description here... * * @return String of query yau have set if query function */ public function returnSql() { } } ?>
(Добавление)
PHP:
скопировать код в буфер обмена
<?PHP class Cookie { private $created; private $userid; private $version; static $coockiename = 'USERAUTH'; static $myversion = '1'; static $expiration = '600'; static $resettime = '300'; static $warning = '300'; static $glue = '|'; function __construct( $userid = false ) { if ( $userid ) { $this->userid = $userid; return ; } else { $buffer = $this->_unpackage( $_COOKIE[ self::$coockiename ]); } else { throw new Exception(); } } } public function set() { $cookie = $this->_package(); } public function validate() { if (!$this->version || !$this->created || !$this->userid ) { throw new Exception("Неверный cookie фаил !"); } if ( $this->version != self::$myversion ) { throw new Exception("Неверная версия cookie фаила !"); } if ( time() - $this->created > self::$expiration ) { throw new Exception("Истекло время действия cookie фаила !"); } elseif ( time() - $this->created > self::$resettime ) { $this->set(); } } private function _package() { $parts = array( self::$myversion, time(), $this->userid ); $coockie = implode( self::$glue, $parts ); return Encryption::encrypt( $coockie ); } private function _unpackage( $cookie ) { $buffer = Encryption::decrypt( $cookie ); list( $this->version, $this->created, $this->userid ) = explode( self::$glue, $buffer ); if ( $this->version != self::$myversion || !$this->created || !$this->userid ) { throw new Exception(); } } private function _reissue() { } } ?>
(Добавление)
Сори, документация неочень написана, чуть позже примеры напишу как какой класс юзается
|