Sometimes users need to send outgoing e-mails with external SMTP servers. Most popular example is PHPMailer with its ability to use free SMTP servers, for example Gmail. Here is the short piece of code, that allows to do this: If you have a Directadmin server with csf firewall installed, most probably you will get this message on execution:… Read More »
Sometimes you need to avoid using cURL for getting external web content for any reasons. You’re lucky that PHP has some built-in functions that allow you to get data from the Web without cURL. But if you are using default values, there is no option to set the timeout for a operation and it’s sometimes annoying. In order… Read More »
If you have used Hesk before, you must have mentioned that all links that were posted by users at the time of ticlet creation/reply were opening in new tabs. If you decide to update to 2.5.2 (I was using version 2.3 before), you will notice that all links will be opening in the current tab. If you want… Read More »
After another PHP recompilation I’ve started getting the following error while trying to access SSL websites with cURL: 56 SSL read: error:140940E5:SSL routines:SSL3_READ_BYTES:ssl handshake failure, errno 0 What does this mean and how to solve this issue? This means your cURL installation is trying to use the wrong number of SSL protocol. All you need to resolve this… Read More »
If you have an array with duplicate values, sometimes you might need to show only non-unique elements. Here is a short code in PHP that will allow you to do this. <? $arr=array_map(“trim”, file(“file.txt”)); $nonuniq=array_unique(array_diff_assoc($arr, array_unique($arr))); ?> This will return unique array of duplicates. If you need to show all duplicated values, use this code. <? $arr=array_map(“trim”, file(“file.txt”));… Read More »
Just wanted to paste a PHP solution for a Paypal refund. It was found on Paypal official site, but I spent some time to get it.
You can count the number of substring occurrences using Regexp-based functions, but if you don’t want to deal with them, that seems to be the fastest option for case insensitive substr_count.
Today I had to fix a script that sends an e-mail using PHPMailer. Here is the intital code: I had to send 2 different mails: one to the buyer and another one to administrator. If I tried to send another mail by using the same code, I got 2 recipients for e-mail. I’ve searched for the way in… Read More »
Since cookies are small files that are stored on user computers, you don’t have the ability to remove them as files. But you can delete them using a simple PHP script.
Recently I had to deal with Twitter avatar upload for a Twitter application. Everything went very well, but when I have prepared everything for the upload query, the only server response I got was Error 417. Since I used cURL, I tried to deal with different headers, but with no luck at all. I found the solution at… Read More »