Posts Tagged ‘ class ’
utf8 substr <?php function utf8_substr($str,$from,$len){ return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'. '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s', '$1',$str); } echo utf8_substr('người đi xa mãi',0,10); ?> loadt2player(333)[ READ MORE ]
Login and Logout using Sessions and Cookies. 1. Tại file functions.php với nội dung: <?php function createsessions($username,$password) { //Add additional member to Session array as per requirement session_register(); $_SESSION["gdusername"] = $username; $_SESSION["gdpassword"] = md5($password); if(isset($_POST['remme'])) { //Add additional member to cookie array as per requirement setcookie("gdusername", $_SESSION['gdusername'], time()+60*60*24*100, "/"); setcookie("gdpassword", $_SESSION['gdpassword'], time()+60*60*24*100, "/"); return; } } function clearsessionscookies() { unset($_SESSION['gdusername']); unset($_SESSION['gdpassword']); session_unset(); session_destroy(); setcookie ("gdusername", "",time()-60*60*24*100, "/"); setcookie ("gdpassword", "",time()-60*60*24*100, "/"); } function confirmUser($username,$password) { // $md5pass = md5($password); // Not needed any [ READ MORE ]
Bài viết này là Level 2 khóa học Zend tại wWw.Zend.Vn Phần I: Tổng quan về lập trình hướng đối tượng 1. Lập trình hướng đối tượng là gì? Lập trình hướng đối tượng (gọi tắt là OOP, từ chữ Anh ngữ object-oriented programming), hay còn gọi là lập trình định hướng đối tượng, là [ READ MORE ]
Đây là class đăng nhập vào Yahoo và lấy sổ địa chỉ, list messenger , số mail chưa đọc, lịch. Demo Download loadt2player(225)[ READ MORE ]
Đây là class login vào yahoo, set status và gửi tin nhắn cho 1 nick. Tôi sưu tầm trên mạng mà giờ chẳng biết bài viết gốc nó nằm mô rồi. Hix! loadt2player(218)[ READ MORE ]
Cách 1: Xài file htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)?domain\.com/ [NC] RewriteCond %{HTTP_USER_AGENT} !(googlebot-image|msnbot|psbot|yahoo-mmcrawler) [NC] RewriteRule \.(bmp|gif|jpe?g|png)$ - [NC,F] </IfModule> Với cách này thì khi site nào chôm link ảnh sẽ không thấy được ảnh Cách 2: Cũng xài htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)?domain\.com/ [NC] RewriteCond %{HTTP_USER_AGENT} !(googlebot-image|msnbot|psbot|yahoo-mmcrawler) [NC] RewriteCond %{REQUEST_URI} !^/hotlink\.png$ RewriteRule \.(bmp|gif|jpe?g|png)$ /hotlink.png [L] </IfModule> Với cách này thì site nào chôm link ảnh sẽ [ READ MORE ]
<?php /************************************** seesaw associates | http://seesaw.net client: file: description: Copyright (C) 2008 Matt Kenefick(.com) **************************************/ class zipArch { /** * Unzip the source_file in the destination dir * * @param string The path to the ZIP-file. * @param string The path where the zipfile should be unpacked, if false the directory of the zip-file [ READ MORE ]
class Auth { var $user_id; var $username; var $password; var $ok; var $salt = "34asdf34"; var $domain = ".domain.com"; function Auth() { global $db; $this->user_id = 0; $this->username = "Guest"; $this->ok = false; if(!$this->check_session()) $this->check_cookie(); return $this->ok; } function check_session() { if(!empty($_SESSION['auth_username']) && !empty($_SESSION['auth_password'])) return $this->check($_SESSION['auth_username'], $_SESSION['auth_password']); else return false; } function check_cookie() { if(!empty($_COOKIE['auth_username']) && !empty($_COOKIE['auth_password'])) return $this->check($_COOKIE['auth_username'], $_COOKIE['auth_password']); else return false; } function login($username, $password) { global $db; $db->query("SELECT user_id FROM users WHERE username = '$username' AND password = '$password'"); if(mysql_num_rows($db->result) == 1) { $this->user_id = mysql_result($db->result, 0, 0); $this->username = [ READ MORE ]
<? //@class CURL //@author sans_amour //@copyright TVPHP.NET //@date 12/15/2007 class CURL{ var $contents; var $_header; var $headers=array(); var $body; var $url=""; function exec($method, $url, $vars="",$h=1,$cookie="",$referer="",$ua="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0") { $ch = curl_init(); //$ip = rand(0,255).".".rand(0,255).".".rand(0,255).".".rand(0,255); //$header =array("REMOTE_ADDR: $ip"); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, ($h==2) ? 0:1); if($ua) curl_setopt($ch, CURLOPT_USERAGENT, $ua); if($referer || $this->url) curl_setopt($ch, CURLOPT_REFERER,$referer?$referer:$this->url); //curl_setopt($ch, CURLOPT_HTTPHEADER,$header); @curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if(strncmp($url,"https",6)) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); } curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); if ($method [ READ MORE ]
<?php /* * PHP Email Class * * Class to deal with sending emails in PHP * Makes it easy to send emails in PHP with attachments and such. * * Written By Jacob Wyke - jacob@redvodkajelly.com - www.redvodkajelly.com * * LICENSE * --- * Feel free to use this as you wish, just give me credit where credits due and drop me an email telling [ READ MORE ]
Bad Behavior has blocked 49 access attempts in the last 7 days.