PHP Script

Using CURL follow redirects to get final url

This example code shows you how to use curl to follow redirects and get final url. [code] <?php function get_final_url( $url, $timeout = 5 ) { $url = str_replace( "&amp;", "&", urldecode(trim($url)) ); $cookie = tempnam ("/tmp", "CURLCOOKIE"); $ch = curl_init(); curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" ); curl_setopt( $ch, ...

ThinkPHP中forward和redirect的区别

ThinkPHP中forward和redirect的区别在那里呢? 首先看代码注释: forward: 执行某个Action操作(隐含跳转) 支持指定模块和延时执行 redirect: Action跳转(URL重定向) 支持指定模块和延时跳转 其次看代码组织,二者的行为是不同的: forward: [code] if(is_array($action)) { //通过类似 array(&$module,$action)的方式调用 call_user_func($action); }else { if(empty($module)) { $module = defined('C_MODULE_NAME')?C_MODULE_NAME:MODULE_NAME; } if( MODULE_NAME!= $module) { ...

How do I add a new currency in opencart?

Adding a new currencies in opencart is very simple. 1. Login to the admin panel of your store 2. Goto Admin->Configuration->Localisation->Currency 3. Click on the "Insert" icon at the top 4. Here we can enter the details of our new currency. For this example, I will use "Canadian Dollars" Currency Title: Canadian Dollar Currency Code: CAD Symbol Left: $ Symbol Right: Decimal places: 2 Value: 1.000000 5. Click "Save" icon at the top. Now you should see this currency...

How to fix prestashop mailalert no voucher code display?

My prestashop Version 1.1.0.5. I have a problem with mailalert module before, which is the Voucher code and voucher value do not display in the email 'New Order'. If you have same problem, you can fix it in a minute. Open file '/modules/mailalerts/mailalerts.php'. Find line #106 [code] $itemsTable .= '<tr style="background-color:#EBECEE;"> <td colspan="4" style="padding:0.6em 0.4em; text-align:right;">'.$this->l('Voucher code:...

如何用php编写注册后Email激活的验证代码

通过使用Email验证激活的方法,可以有效的帮你阻止恶意的Spam和注册机器人的访问。 用php编写注册后Email验证激活的步骤非常简单,相信几分钟之内你就能学会。 总共需两个页面,register.php 和 verify.php 1. 用户注册表格 register.php [code] <html> <body> <form action="register.php" method="post" name="register"> 用户名:<input type="text" name="username" /> 密码:<input type="password" name="password" /> 电子邮件:<input type="text" name="email" /&...

开源的PDF工具

FPDF FPDF 这个PHP Class允许你采用纯PHP(更确切地说就是不需要使用PDFlib)来生成PDF文件。它所具有的特点包括:可选择的unit大小,页面格式和页边距;页眉和页脚管理;自动分页;自动换行与文本自动对齐;支持JPEG与PNG图片格式;支持着色和文件超链接;支持TrueType,Type1与 encoding;支持页面压缩。 HTML2PDF HTML2PDF能够把一个HTML文本转换成一个打印机友好的PDF文件。这个PHP脚本构建在FPDF PHP脚本之上。 TCPDF TCPDF是一个用于快速生成PDF文件的PHP5函数包。TCPDF基于FPDF进行扩展和改进。支持UTF-8,Unicode,HTML和XHTML。 html2ps html2ps 能够把带有图片,复杂表格(包含rowspan/colspan) ,layer/div和css样式的HTML转换成Postscript与PDF。 html2ps对CSS2.1支持非常好,并且很好地兼容不正确的HMTL。它甚至能够转换几乎是采用CSS设计的网站如msn.com。 HTML_ToPDF...

Tracking the user’s browsing history with PHP and cookie

Here is a sample code to show how using php and cookie to tracking the user's browsing history. The code is used on a shopping website. Hope it helpful to you. [code] /* browsing history */ if (!empty($_COOKIE['ECS']['history'])) { $history = explode(’,', $_COOKIE['ECS']['history']); array_unshift($history, $goods_id); $history = array_unique($history); while (count($history) > $_CFG['history_number']) { array_pop($history); } setcookie(’ECS[hi...

How To Find The Current URL In PHP

In your valiant conquest of the web development industry, you will notice that some scripts will require that you know the current URL the user is browsing to provide certain services. A prime example would be in user management- where we make use of query strings to keep track of users. More practical solutions may even demand that we find the current URL to display relevant ads and increase conversion rates. PHP has set forth certain global variables that makes this process painfully easy. ...

Auto post into Blogspot using php code?

The following code will help to auto post into blogspot using php code. [php] <?php session_start(); $email = “blogger_email@gmail.com”; $pass = “password”; $blogID= urlencode(“blogger_id”); // like 6304924319904337556 // Do Not Modify Below Code if(!isset($_SESSION['sessionToken'])) { $ch = curl_init(“https://www.google.com/accounts/ClientLogin?Email=$email&Passwd=$pass&service=blogger&accountType=GOOGLE”); curl_setopt($ch, CURLOPT_POS...

php5.3 and mysqlnd old authentication issue

After upgrading to php5.3, i got this problem: [sourcecode] SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using old authentication [/sourcecode] Here is what i found: * php 5.3 now use a native extension to use mysql : mysqlnd * my database credential was old (4 years old maybe) and still use the old mysql authentication * mysqlnd needs the new 41bytes password The problem was easy to solve: First, open '/etc/my.cnf' in Linux or 'my.ini' in Windows, ...