paypal ipn postback on a custom port.
When we were developping the paypal IPN script for our ecommerce project solidshops.com, we ran into a strange limition.
Apparently paypal does not allow you to post back to a url with a custom port. Only http(80) and https(443) are allowed.
We solved it by using the paypal ipn proxy below. You should put this script on a different server and it will post all the IPN data to your application on port 8080.
The $url should be changed to the webapplication(on custom port) where the paypal data is processed.
PHP:
$url = 'http://www.yourdomain.com:8080/ipnscript.php'; $fields = $_POST; //url-ify the data for the POST foreach ( $fields as $key => $value ) { $fields_string .= $key . '=' . $value . '&'; } //open connection $ch = curl_init (); //set the url, number of POST vars, POST data curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $fields_string ); //execute post $result = curl_exec ( $ch ); //close connection curl_close ( $ch ); }
Popularity: 2% [?]
phpHackChecker: sends you a report of all changed files on your server
This php script will send you a mail with all the files that have been changed within an interval you specify.
I created this script because someone hacked into my shared hosting account and added some hidden spammy link into my templates. And since most shared hosting accounts do not have any kind of logfiles available, it is almost impossible for you to find out how the hacker got in. I could even be, the hacker got acces to your files by hacking another shared hosting account on that server.
With this script you will at least be notified when someone has changed the files on your server.
settings:
PHP:
$from="name@domain.com"; $to="name@domain.com"; $subject="changes on webhosting"; $domain = "yourdomain.com"; wwwname => 'htdocs1', wwwdirectory => '/mounted-storage/home/website1.com' ), wwwname => 'htdocs2', wwwdirectory => '/mounted-storage/home/website2.com' ) );
functions
PHP:
function url_remove_lastslash($url){ }else{ return $url; } } function getfiles($path_start) { global $results; if ($file != "." && $file != "..") { $file_path = url_remove_lastslash($path_start) . "/" . $file; getfiles ($file_path); } //echo $yr .$mnth . $dy."<br>"; if (($now <= $newday) ) { //echo $file_path . " " . $date_mod . " " . $now . " " . $newday. $yr .$mnth . $dy."<br>"; $results[$file_path][0] = $file_path ; $results[$file_path][1] = $date_mod; } } } } }
check all hosting accounts & create mailbody
PHP:
foreach ($settings as $setting){ $date_change = ""; $filename= ""; getfiles($setting['wwwdirectory']); $mail_body .= "<b>".$setting['wwwname']."</b><br/>"; //sort by change date foreach ($results as $key => $row) { $date_change[$key] = $row[0]; $filename[$key] = $row[1]; } //array_multisort($filename, SORT_DESC, $date_change, SORT_ASC, $results); foreach ($results as $result){ } }
mail the changed files
PHP:
$headers=""; $headers .= "X-Sender: $from <$from>\n"; // $headers .="From: $from <$from>\n"; $headers .= "Reply-To: $from <$from>\n"; $headers .= "Subject: $subject\n"; $headers .= "Return-Path: $from <$from>\n"; $headers .= "Delivered-to: $from <$from>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html;charset=ISO-8859-9\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: Mail send from ".$domain."!\n"; //mail to customer echo "job executed succesfully"; }else{ echo "error executing job"; }
You can download a copy of phpHackChecker here. Change the file extension to ".php".
Popularity: 9% [?]
capture the encoding from the main XML file tag
To capture the encoding from the XML tag of the file. We need to read the first line, and pass it to the function to capture the encoding value.
The first line looks like this:
< ?xml version="1.0" encoding="utf-8"? >
The PHP code:
PHP:
function readfirstline($file){ return $firstline; } function get_attr( $line ,$attr) { return $arr_enc [1]; } $path = "home/user/feeds/id.xml"; $line= readfirstline($path);
Popularity: 4% [?]
hot or not wordpress plugin
This wordpress plugins adds a radio button to the comment form so users can tell if a post is hot or not. Depending on the value that is chosen, another css class is added to comment .
- Download the plugin
- Adding the radionbutton group to the comment form.
-
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
- Dynamically add the class to the comment
-
<?php foreach ($comments as $comment) ?>
-
li id="comment-<?php comment_ID() ?>" class="<?php print $comment->css ?>">
- Activate the plugin
- Change the css style of your comments
Download the Hot Or Not plugin here
Unzip this file into the /wp- content/plugins/ folder.
This radiobutton has to be added in the < form > tag of the comments. You can find this somewere at the bottom of your "template/comments.php" file. It looks something like this.
HTML:
You have to paste the code below in that form.
In the beginning of that same file, there is a php foreach statement to print all comments.
HTML:
A bit further in the file you have to add the hotornot class to the listitem:
HTML:
Active the plugin in the admin "Plugins" screen in wordpress.
You can do this in the template/style.css file.
.vote_hot {style.css (line 692)
background-color:#CDEEAB;
border-top:1px dotted #006600;
color:#006600;
}.vote_not {style.css (line 699)
background-color:#FFE0E0;
border-top:1px dotted #F5857E;
color:#AB0000;
}
Popularity: 28% [?]
chmod under safemode
When you would try to change the filepermission with a php script on your hosting, you would probably run into an "Operation not permitted" error.
This is because save mode is enabled. To bypass this limitation you could login unter ftp and change the file permission from there.
-
//settings
-
$ftp_details['ftp_user_name'] = "username";
-
$ftp_details['ftp_user_pass'] = "pw";
-
$ftp_details['ftp_root'] = '/defaultfolder/';
-
$ftp_details['ftp_server'] = 'ftp.domain.com';
-
-
//function to login and change by FTP
-
function chmod_custom($path, $mod, $ftp_details)
-
{
-
// extract ftp details (array keys as variable names)
-
-
// set up basic connection
-
-
// login with username and password
-
-
// try to chmod $path directory
-
$success=TRUE;
-
}
-
else {
-
$success=FALSE;
-
}
-
-
// close the connection
-
return $success;
-
}
-
-
//the actual transaction
-
foreach($folders as $folder){
-
chmod_custom($folder, "0777", $ftp_details);
-
-
}
I found this solution on php.net.
Popularity: 100% [?]


