Category Archives: PHP and JavaScript

Online Currency Exchange Options

I’d probably go with the Google Calculator to grab the rates and use CURL to grab the contents and supply rates to application. You could setup a cron job which runs a script say every 15 mins to update database which stores latest rates for use with application.

 

Exchangerate-api.com

http://www.exchangerate-api.com/packages

$19 per month
40,000 api calls
Updated every 15mins
Continue reading

A list of Popular PHP Plugins

A list of commonly used PHP plugins. In this post you will find some plugins with its instructions on how to install it manually.. you will have to look up for its download links on the Internet though, they’ve been popular so you should see them easily ;)
1. Clover PHP Plugin – This plugin allows you to capture code coverage reports from PHPUnit.

The following setting is for Phing:

build.xml

<exec dir="."
      command="phpunit --log-junit 'reports/unitreport.xml'
                       --coverage-html 'reports/coverage'
                       --coverage-clover 'reports/coverage/coverage.xml'
                       test/"

/>

Or

build.xml

<phpunit printsummary="true" codecoverage="true">
    <formatter todir="reports" type="xml" outfile="coverage/coverage.xml" />
    <batchtest>
        <fileset dir="test">
            <include name="**/*Test.php" />
        </fileset>
    </batchtest>
</phpunit>

For more information on how to set Clover PHP, look up Template for Jenkins Jobs for PHP Projects.

2. PHPeclipse – PHP Eclipse-Plugin – Support for the Eclipse IDE Framework; Some Features are PHP parser, debugger, code formatter, outline view, templates…(Programming Language: Java).

3. Sonar PHP Plugin – The plugin enables all Sonar built-in features for PHP projects.

How to install:
Step #1. To be able to run PHP analyses with Sonar, you will need:
- A Java Runtime Environment (version > 1.5)
- A database (optional if you’re evaluating the plugin)
- Sonar installed with its PHP plugin
- All the PHP environment (PHP and tools that are required by the plugin)

Step #2. Install a Java Runtime Environment (JRE) – Check the different supported Java virtual machines (see “Supported platforms > Java”) that you can install.

To be sure you have correctly installed a JVM, open a terminal a run “java -version”: you should see the version of Java you’ve just installed.

Step #3. Install a database (optional if you’re evaluating the plugin) – Check the different supported databases (see “Supported platforms > Database”) that you can install.

Step #4. Install Sonar PHP Plugin – Sonar PHP Plugin is very straightforward: once you have installed sonar in

$SONAR_HOME

directory, just copy the

sonar-php-plugin.jar

file inside

$SONAR_HOME/extensions/plugins

directory.

Step #5. Finally, Install PHP environment – This installation section provides a way for installing necessary tools to make the plugin work correctly.If you are familiar with the PHP environment, you may just need to read the “Short way” section.

Short way for PHP experts:

1. Install PHP runtime with the corresponding xdebug extensions. Version 5.2.6 or newer is required.
2. Install PEAR. Version 1.8.0 or newer is required
3. Install the following PEAR packages (check the version list to know which versions to install):

  1. Install PHPUnit
  2. Install phpcpd
  3. Install PHPDepend
  4. Install PHPMD
  5. Install PHP_CodeSniffer

4. Grails – Plugin – PHP Plugin – This plugin installs the Quercus PHP engine in Grails that allows you to run php in any Grails application. Quercus comes with JavaMail and the plugin includes the MySQL JDBC Driver.

See requirements

5. rock-php – RockMongo – This plugin feature allow you to filter data and listen events.

There is only four steps to write a plug-in for RockMongo:

  1. create a plug-in directory under app/plugins
  2. put a init.php in the directory we created
  3. call api to add data filters and event listeners in init.php
  4. enable your plug-in in app/configs/rplugin.php

For instance, you want to create a plug-in named myplugin, so your directory structure will look like this:

   app/
      plugins/
         myplugin/
             init.php

init.php:

<?php

function my_filter($data) {
  //filter data
}

RFilter::add("SUPPORTED FILTER NAME", "my_filter");

?>

rplugin.php:

<?php

$plugins["myplugin"]["enabled"] = 1;
//$plugins["myplugin2"]["enabled"] = 1;
//$plugins["myplugin3"]["enabled"] = 1;

?>

6. PHPEdit – It is the best PHP IDE on the market, dedicated to create dynamic and professional websites more easily and efficiently.

7. PHPSeedy Plugin – It is a script that you can install on your web server to automatically speed up the download time of your web pages.

How to install: via auto-install

In order to install PHP Speedy you should:

  1. Download and unzip the PHP Speedy package into its own directory
  2. Point your browser to the PHP Speedy directory
  3. Follow the installation instructions

8. VS.Php – PHP Plugin for Visual Studio – It is a PHP IDE (Integrated Development Environment) based on Visual Studio IDE. With VS.Php you can design, develop, debug and deploy PHP applications within the Visual Studio IDE.

9. PHP Markdown (Requires PHP version 4.0.5 or later) – It can work as a plugin for WordPress and bBlog, as a modifier for the Smarty templating engine, or as a replacement for textile formatting in any software that support textile.

10. php-maven / maven-php-plugin – A maven plugin for dependency management and quality assurance for PHP projects.

All PHP Scripts on this website are provided by phpscripts4u.com where you can find all the latest PHP code snippets, plugins and libraries.

10 PHP Plugins

The following is a compilation of 10 (executable) PHP Plugins with its codes that are easy to understand and edit. Happy embedding! ;)
1. Embed YouTube Video – With this plugin you can replace all that with a single function call whenever you need to embed a video.

<?php

echo PIPHP_EmbedYouTubeVideo("VjnygQ02aW4", 370, 300, 1, 1, 0);

function PIPHP_EmbedYouTubeVideo($id, $width, $height, $hq,
   $full, $auto)
{
   // Plug-in 27: Embed YouTube Video
   //
   // IMPROVED FROM THE VERSION IN THE BOOK IN WHICH A BUG
   // ALWAYS ALLOWED FULL ZOOM - NOW IT IS PROPERLY AN OPTION.
   //
   // This plug-in accepts the absolute URL of a web page
   // and a link featured within that page. The link is then
   // turned into an absolute URL which can be independently
   // accessed. Only applies to http:// URLs. The arguments
   // required are:
   //
   //    $id:     The YouTube video id
   //    $width:  The display width
   //    $height: The display height
   //             Standard YouTube video is 425 x 344 pixels
   //    $hq:     'true' or 1 for high quality
   //    $full:   'true' if full screen zoom allowed
   //    $auto:   1 to auto start, 0 for no

   if ($hq) $q = "&amp;ap=%2526fmt%3D18";
   else $q = "";

   return <<<_END
<object width="$width" height="$height">
<param name="movie"
   value="http://www.youtube.com/v/$id&amp;fs=1&amp;autoplay=$auto$q">
</param>
<param name="allowFullScreen" value="$full"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/$id&amp;fs=1&amp;autoplay=$auto$q"
   type="application/x-shockwave-flash"
   allowscriptaccess="always" allowfullscreen="$full"
   width="$width" height="$height"></embed></object>
_END;
}

?>
2. Post to Guest Book – A simple plugin to enable you to offer a Guestbook feature in just a few lines of PHP code.

<?php

$name    = "E.Presley";
$email   = "all@shookup.com";
$website = "http://heartbreak.hotel.com";
$message = "Don't you step on my Blue suede shoes.";

echo "Name=<i>$name</i>, Email=<i>$email</i>, Website=<i>" .
   "$website</i>, Message=<i>$message</i><br /><br />";
   
$result = PIPHP_PostToGuestBook('guestbook.txt', $name, $email,
   $website, $message);

if     ($result == 1) echo "<b>Message Posted</b><br />";
elseif ($result == 0) echo "<b>Message Ignored</b><br />";
else                  echo "<b>Message Failed</b><br />";

echo "<br />Name=<i>$name</i>, Email=<i>$email</i>, Website=" .
   "<i>$website</i>, Message=<i>$message</i><br /><br />";

$result = PIPHP_PostToGuestBook('guestbook.txt', $name, $email,
   $website, $message);

if     ($result == 1) echo "<b>Message Posted</b><br />";
elseif ($result == 0) echo "<b>Message Ignored</b><br />";
else                  echo "<b>Message Failed</b><br />";

function PIPHP_PostToGuestBook($datafile, $name, $email,
   $website, $message)
{
   // Plug-in 52: Post To Guest Book
   //
   // This plug-in takes the name of a datafile in which a
   // guestbook is stored and adds a post to it. The plug-in
   // returns 1 if the message has been posted, 0 if the
   // message was already posted and therefore has been
   // ignored, or -1 if the file could not be written to. The
   // arguments required are:
   //
   //    $datafile: File in which to store guestbook data
   //    $name:     User's name
   //    $email:    Their email address
   //    $website:  Their website
   //    $message:  Their message

   $data = $name . '!1!' . $email . '!1!' . $website .
         '!1!' . $message;
   if (file_exists($datafile))
   {
      $lines = explode("\n",
         rtrim(file_get_contents($datafile)));

      if (in_array($data, $lines)) return 0;
   }

   $fh = fopen($datafile, 'a');
   if (!$fh) return -1;

   if (flock($fh, LOCK_EX)) fwrite($fh, $data . "\n");
   flock($fh, LOCK_UN);
   fclose($fh);
   return 1;
}

?>
3. Wrap Text – Using this plugin it’s easy to pass a string of text and have it wrapped using

<br />

tags. What’s more it can also indent the start of a each paragraph by an amount of your choosing.

<?php

$text = "Treats of the place where Oliver Twist was born, and of the circumstances attending his birth.\nAmong other public buildings in a certain town, which for many reasons it will be prudent to refrain from mentioning, and to which I will assign no fictitious name, there is one anciently common to most towns, great or small: to wit, a workhouse; and in this workhouse was born; on a day and date which I need not trouble myself to repeat, inasmuch as it can be of no possible consequence to the reader, in this stage of the business at all events; the item of mortality whose name is prefixed to the head of this chapter.\nFor a long time after it was ushered into this world of sorrow and trouble, by the parish surgeon, it remained a matter of considerable doubt whether the child would survive to bear any name at all; in which case it is somewhat more than probable that these memoirs would never have appeared; or, if they had, that being comprised within a couple of pages, they would have possessed the inestimable merit of being the most concise and faithful specimen of biography, extant in the literature of any age or country.";

echo "<font face='Courier New' size='2'>";
echo PIPHP_WrapText($text, 71, 5);

function PIPHP_WrapText($text, $width, $indent)
{
   // Plug-in 1: Wrap Text
   //
   // This plug-in takes a string variable containing any
   // text and then adds <br /> and &amp;nbsp; tags in the right
   // places to make the text wrap and indent para starts.
   // The arguments required are:
   //
   //    $text: Text to be modified
   //    $width: Number of characters art which to wrap
   //    $indent: Number of chars to indent para start

   $wrapped    = "";
   $paragraphs = explode("\n", $text);

   foreach($paragraphs as $paragraph)
   {
      if ($indent > 0) $wrapped .= str_repeat("&amp;nbsp;", $indent);
     
      $words = explode(" ", $paragraph);
      $len   = $indent;

      foreach($words as $word)
      {
         $wlen = strlen($word);

         if (($len + $wlen) < $width)
         {
            $wrapped .= "$word ";
            $len     += $wlen + 1;
         }
         else
         {
            $wrapped = trim($wrapped);
            $wrapped .= "<br />\n$word ";
            $len     =  $wlen;
         }
      }

      $wrapped = trim($wrapped);
      $wrapped .= "<br />\n";
   }

   return $wrapped;
}

?>
4. Create Captcha – With a Captcha you are asked to re-enter some text displayed in a graphic image.
A bot will not be able to decipher it if the image is complex enough and so only human input is able to get through. This still doesn’t guarantee you will be spam free, but with this plug-in you’ll prevent the majority of it from getting through.

<?php

$result = PIPHP_CreateCaptcha(26, 8, 'captcha.ttf', '',
   '!*a&amp;K', ".fs£!+");
   
$captcha = $result[0];
$token   = $result[1];
$image   = $result[2];

echo "The Captcha is '$captcha', the token is:<br />";
echo "'$token', and the image is in:<br />$image:<br />";
echo "<img src=\"$image\">";

function PIPHP_CreateCaptcha($size, $length, $font,
   $folder, $salt1, $salt2)
{
   // Plug-in 33: Create Captcha
   //
   // This plug-in creates a GIF image containing a word the
   // user must type in to prove they are not a program. The
   // function returns a three element array containing the
   // following:
   //
   //    Element 0: The Captcha word to be entered
   //    Element 1: A unique 32 character token
   //    Element 2: The location of a GIF file with the Captcha
   //               text
   //
   // The function expects a file dictionary.txt to exist in the
   // current folder. This must be a text file of words separated
   // by \r\n carriage return, line feed pairs. The arguments
   // required are:
   //
   //    $size:   Font size for the Captcha
   //    $length: Length of Captcha in letters
   //    $font:   Location of a TrueType font
   //    $folder: Location of a temporary, web-
   //             accessible folder to store the
   //             captcha GIF. Must end with /
   //    $salt1:  A sequence of characters to help
   //             make the Captcha uncrackable
   //    $salt2:  A second sequence to make it even
   //             less crackable

   $file    = file_get_contents('dictionary.txt');
   $temps   = explode("\r\n", $file);
   $dict    = array();

   foreach ($temps as $temp)
      if (strlen($temp) == $length)
         $dict[] = $temp;

   $captcha = $dict[rand(0, count($dict) - 1)];
   $token   = md5("$salt1$captcha$salt2");
   $fname   = "$folder" . $token . ".gif";
   PIPHP_GifText($fname, $captcha, $font, $size, "444444",
      "ffffff", $size / 10, "666666");
   $image   = imagecreatefromgif($fname);
   $image   = PIPHP_ImageAlter($image, 2);
   $image   = PIPHP_ImageAlter($image, 13);
   
   for ($j = 0 ; $j < 3 ; ++$j)
      $image = PIPHP_ImageAlter($image, 3);
   for ($j = 0 ; $j < 2 ; ++$j)
      $image = PIPHP_ImageAlter($image, 5);

   imagegif($image, $fname);
   return array($captcha, $token, $fname);
}

// The plug-ins below are in this file to ensure they
// are available to the main plug-in which uses them

function PIPHP_GifText($file, $text, $font, $size, $fore, $back,
   $shadow, $shadowcolor)
{
   // Plug-in 19: Gif Text
   //
   // This plug-in accepts text input and then turns it into
   // a gif image. Various font sizes and effects are available
   // The arguments are:
   //
   //    $file:        The path and file to save the finished gif
   //    $text:        The text to display
   //    $font:        Filename of a TTF font file
   //    $size:        Font size to use
   //    $fore:        The foreground color
   //    $back:        The background color
   //    $shadow:      0 = None, 1 or more = The offset to use
   //    $shadowcolor: The shadow color (if selected)

   $bound  = imagettfbbox($size, 0, $font, $text);
   $width  = $bound[2] + $bound[0] + 6 + $shadow;
   $height = abs($bound[1]) + abs($bound[7]) + 5 + $shadow;
   $image  = imagecreatetruecolor($width, $height);
   $bgcol  = PIPHP_GD_FN1($image, $back);
   $fgcol  = PIPHP_GD_FN1($image, $fore);
   $shcol  = PIPHP_GD_FN1($image, $shadowcolor);
   imagefilledrectangle($image, 0, 0, $width, $height, $bgcol);
   
   if ($shadow > 0) imagettftext($image, $size, 0, $shadow + 2,
      abs($bound[5]) + $shadow + 2, $shcol, $font, $text);
   
   imagettftext($image, $size, 0, 2, abs($bound[5]) + 2, $fgcol,
      $font, $text);
   imagegif($image, $file);
}

function PIPHP_GD_FN1($image, $color)
{
   return imagecolorallocate($image,
      hexdec(substr($color, 0, 2)),
      hexdec(substr($color, 2, 2)),
      hexdec(substr($color, 4, 2)));
}

function PIPHP_ImageAlter($image, $effect)
{
   // Plug-in 14: Image Alter
   //
   // This plug-in takes a GD image and modifies it
   // according to the selected effect. The arguments are:
   //
   //    $image:  The image source
   //    $effect: The effect to use between 1 and 14:
   //        1 = Sharpen
   //        2 = Blur
   //        3 = Brighten
   //        4 = Darken
   //        5 = Increase Contrast
   //        6 = Decrease Contrast
   //        7 = Grayscale
   //        8 = Invert
   //        9 = Increase Red
   //       10 = Increase Green
   //       11 = Increase Blue
   //       12 = Edge Detect
   //       13 = Emboss
   //       14 = Sketchify

   switch($effect)
   {
      case 1:  imageconvolution($image, array(array(-1, -1, -1),
                  array(-1, 16, -1), array(-1, -1, -1)), 8, 0);
               break;
      case 2:  imagefilter($image,
                  IMG_FILTER_GAUSSIAN_BLUR); break;
      case 3:  imagefilter($image,
                  IMG_FILTER_BRIGHTNESS, 20); break;
      case 4:  imagefilter($image,
                  IMG_FILTER_BRIGHTNESS, -20); break;
      case 5:  imagefilter($image,
                  IMG_FILTER_CONTRAST, -20); break;
      case 6:  imagefilter($image,
                  IMG_FILTER_CONTRAST, 20); break;
      case 7:  imagefilter($image,
                  IMG_FILTER_GRAYSCALE); break;
      case 8:  imagefilter($image,
                  IMG_FILTER_NEGATE); break;
      case 9:  imagefilter($image,
                  IMG_FILTER_COLORIZE, 128, 0, 0, 50); break;
      case 10: imagefilter($image,
                  IMG_FILTER_COLORIZE, 0, 128, 0, 50); break;
      case 11: imagefilter($image,
                  IMG_FILTER_COLORIZE, 0, 0, 128, 50); break;
      case 12: imagefilter($image,
                  IMG_FILTER_EDGEDETECT); break;
      case 13: imagefilter($image,
                  IMG_FILTER_EMBOSS); break;
      case 14: imagefilter($image,
                  IMG_FILTER_MEAN_REMOVAL); break;
   }
   
   return $image;
}

?>
5. Get Tweets – Fetch the (up to) last 20 posts of any Twitter user who’s profile isn’t private with this plugin.

<?php

$user   = 'eminem';
$result = PIPHP_GetTweets($user);

echo "Viewing '$user':<br /><ul>";

if (!$result[0]) echo 'Failed';
else
   for ($j = 0 ; $j < $result[0] ; ++$j)
      echo "<li>" . $result[1][$j] . "</li>";

function PIPHP_GetTweets($user)
{
   // Plug-in 58: Get Tweets
   //
   // This plug-in returns the most recent 20 tweets of a Twitter
   // user. The argument required is:
   //
   //    $user: Twitter username
   //
   // Upon success the plug-in returns a two element array, the
   // first of which contains the number of tweets returned, and
   // the second is an array of the tweets. On failure a single
   // element array is returned with the value FALSE.

   $url  = "http://twitter.com/statuses/user_timeline/$user.xml";
   $file = @file_get_contents($url);
   if (!strlen($file)) return array(FALSE);
   
   $xml  = @simplexml_load_string($file);
   if ($xml == FALSE) return array(FALSE);
   
   $tweets = array();

   foreach ($xml->status as $tweet)
   {
      $timestamp = strtotime($tweet->created_at);
      $tweets[] = "(" . date("M jS, g:ia", $timestamp) . ") " .
         $tweet->text;
   }

   return array(count($tweets), $tweets);
}

?>
6. Spell Check – This plugin provides a reasonably fast spell checker based on a dictionary of over 80,000 words along with the plugins.

<?php //

$text = "It was the best of tmes, it was the wrst of times, it was the age of wisdom, it was the age of foolishnes, it was the epoch of beleif, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despare, we had everything before us, we had nothing before us, we were all going drect to heaven.";

echo "$text<br /><br />";
echo PIPHP_SpellCheck($text, "u");

function PIPHP_SpellCheck($text, $action)
{
   // Plug-in 8: Spell Check
   //
   // This plug-in takes a string of text and then highlights
   // those words it doesn't recognise in the dictionary file.
   // The arguments required are:
   //
   //    $text:    Text to be modified
   //    $action:  What to do with unrecognized words:
   //              "u", "b", "i" = Underline, Bold or Italic

   $dictionary = PIPHP_SpellCheckLoadDictionary("dictionary.txt");
   $text      .= ' ';
   $newtext    = "";
   $offset     = 0;

   while ($offset < strlen($text))
   {
      preg_match('/[^\w]*([\w]+)[^\w]+/',
         $text, $matches, PREG_OFFSET_CAPTURE, $offset);
      $word   = $matches[1][0];
      $offset = $matches[0][1] + strlen($matches[0][0]);
     
      if (!PIPHP_SpellCheckWord($word, $dictionary))
         $newtext .= "<$action>$word</$action> ";
      else $newtext .= "$word ";
   }
   
   return rtrim($newtext);
}

function PIPHP_SpellCheckLoadDictionary($filename)
{
   return explode("\r\n", file_get_contents($filename));
}

function PIPHP_SpellCheckWord($word, $dictionary)
{
   $top = sizeof($dictionary) -1;
   $bot  = 0;
   $word = strtolower($word);

   while($top >= $bot)
   {
      $p =   floor(($top + $bot) / 2);
      if     ($dictionary[$p] < $word) $bot = $p + 1;
      elseif ($dictionary[$p] > $word) $top = $p - 1;
      else   return TRUE;
   }
     
   return FALSE;
}

?>
7. Send Email – You just supply the message and subject lines and the email addresses of all recipients and it gets on with sending the email for you. You can even specify a different Reply-To address if you need to.

<?php

$message = "Hello Fred, I hadn't heard from you recently and " .
           "thought I'd send you a quick note to see how you " .
           "are keeping. - Rick";
$subject = "How are you?";

echo "Sending <i>'$message'</i>: ";
if (PIPHP_SendEmail($message, $subject, 'me@myserver.com', '',
   'rick@otherserver.net', NULL, NULL, ''))
      echo "Mail successful";
else echo "Mail failed";

function PIPHP_SendEmail($message, $subject, $from, $replyto,
   $to, $cc, $bcc, $type)
{
   // Plug-in 38: Send Email
   //
   // This plug-in sends an email to one or more recipients.
   // It returns TRUE on success, otherwise FALSE. The
   // arguments required are:
   //
   //    $message: The message to send - required
   //    $subject: The message's subject - required
   //    $from:    The sender's email address - required
   //    $replyto: The address for replies. This can be set
   //              to NULL or "" if replies should be returned
   //              to the sender.
   //    $to:      The recipient's email address - required
   //    $cc:      An array of email addresses to send copies
   //              to. Can be set to NULL.
   //    $bcc:     An array of email addresses to send hidden
   //              copies to. Can be set to NULL.
   //    $type:    If set to HTML then the message is sent as
   //              HTML.

   $headers = "From: $from\r\n";

   if (strtolower($type) == "html")
   {
      $headers .= "MIME-Version: 1.0\r\n";
      $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
   }
   
   if ($replyto != "") $headers .= "Reply-To: $replyto\r\n";

   if (count($cc))
   {
      $headers .= "Cc: ";
         for ($j = 0 ; $j < count($cc) ; ++$j)
            $headers .= $cc[$j] . ",";
      $headers = substr($headers, 0, -1) . "\r\n";
   }

   if (count($bcc))
   {
      $headers .= "Bcc: ";
         for ($j = 0 ; $j < count($bcc) ; ++$j)
            $headers .= $bcc[$j] . ",";
      $headers = substr($headers, 0, -1) . "\r\n";
   }

   return mail($to, $subject, $message, $headers);
}

?>
8. Validate Email – You can use this plug-in to at least check whether the format of an email address supplied to you is valid.

<?php

$email  = "paul.smith@smithandson.com";
$result = PIPHP_ValidateEmail($email);
echo "The email address: '$email' ";
echo $result ? "validates" : "does not validate";

$email  = "jdoe@usacom";
$result = PIPHP_ValidateEmail($email);
echo "<br />The email address: '$email' ";
echo $result ? "validates" : "does not validate";

function PIPHP_ValidateEmail($email)
{
   // Plug-in 36: Validate Email
   //
   // This plug-in takes an email address and determines whether
   // it appears to be valid. The argument required is:
   //
   //    $email: An email address to validate
   
   $at = strrpos($email, '@');
   
   if (!$at || strlen($email) < 6) return FALSE;
   
   $left  = substr($email, 0, $at);
   $right = substr($email, $at + 1);
   $res1  = PIPHP_ValidateText($left,  1, 64,  "\w\.\+\-",
      "a");
   $res2  = PIPHP_ValidateText($right, 1, 255, "\a-zA-Z0-9\.\-",
      "a");
 
   if (!strpos($right, '.') || !$res1[0] || !$res2[0])
      return FALSE;
   else return TRUE;
}

// The function below is there to ensure that the above function
// (which relies on it) has access it it.

function PIPHP_ValidateText($text, $minlength, $maxlength,
   $allowed, $required)
{
   // Plug-in 35: Validate Text
   // This plug-in takes a string and parameters defining its
   // minimum and maximum length, and the allowed characters.
   // The arguments are:
   //    $text:      The text to be validate
   //    $minlength: The minimum allowed length
   //    $maxlength: The maximum allowed length
   //    $allowed:   The allowed characters. Can include regexp
   //                strings such as a-zA-Z0-9 or \w. Characters
   //                used in regular expressions but which are
   //                to be allowed (such as ( and [ etc) should
   //                be escaped, like this: \( and \[.
   //    $required:  The required characters. This argument
   //                is a string containing one or more of the
   //                letters a, l, u, d, w or p for any letter,
   //                lower case, upper case, digit, word (any
   //                lower, upper, digit or _) or punctuation.
   //                For each of these included, at least one of
   //                that type of character must be in the string
   // The plug-in returns an array of two elements if the string
   // does not validate. The first has the value FALSE and the
   // second is an array of error messages. If it does validate
   // Only one element is returned and its value is TRUE.
   
   $len   = strlen($text);
   $error = array();
   
   if ($len < $minlength)
      $error[] = "The string length is too short " .
         "(min $minlength characters)";
   elseif ($len > $maxlength)
      $error[] = "The string length is too long " .
         "(max $maxlength characters)";
   
   $result = preg_match_all("/([^$allowed])/", $text, $matches);
   $caught = implode(array_unique($matches[1]), ', ');
   $plural = strlen($caught) > 1 ? $plural = "s are" : " is";

   if ($result) $error[] = "The following character$plural " .
      "not allowed: " . $caught;

   for ($j = 0 ; $j < strlen($required) ; ++$j)
   {
      switch(substr(strtolower($required), $j, 1))
      {
         case "a": $regex = "a-zA-Z"; $str = "letter";
                   break;
         case "l": $regex = "a-z";    $str = "lower case";
                   break;
         case "u": $regex = "A-Z";    $str = "upper case";
                   break;
         case "d": $regex = "0-9";    $str = "digit";
                   break;
         case "w": $regex = "\w";     $str = "letter, number or _";
                   break;
         case "p": $regex = "\W";     $str = "punctuation";
                   break;
      }

      if (!preg_match("/[$regex]/", $text))
         $error[] = "The string must include at least one " .
            "$str character";
   }

   if (count($error)) return array(FALSE, $error);
   else return array(TRUE);
}

?>
9. Image Display – Here’s a plugin that will output any GIF, JPEG or PNG image and, if it’s a JPEG or PNG, at whatever quality you choose to achieve the optimum balance between bandwidth use and image quality.

<?php

// You will need an image file called pic.jpg in this folder

PIPHP_ImageDisplay("pic.jpg", "", NULL);

// Try commenting out the above line and uncommenting one below

// PIPHP_ImageDisplay("pic.jpg", "gif",  NULL);
// PIPHP_ImageDisplay("pic.jpg", "png",  50);
// PIPHP_ImageDisplay("pic.jpg", "jpeg", 20);

function PIPHP_ImageDisplay($filename, $type, $quality)
{
   // Plug-in 17: Image Display
   //
   // This plug-in takes an image file name, loads it
   // and displays it to a browser. The image can be
   // converted on the fly to different types and quality.
   // The arguments required are:
   //
   //    $filename: Path and/or name of image to display
   //
   //    $type: Type of file to display:
   //
   //       "":     Output as current type
   //       "gif":  Output as a gif image
   //       "jpeg": Output as a jpeg image
   //       "png":  Output as a png image
   //
   //    $quality: Quality of image (0-99).
   //              Only used if $type is jpeg or png
   //
   //        0 = Lowest quality and smallest size
   //       99 = Best quality and largest size

   $contents = file_get_contents($filename);
   
   if ($type == "")
   {
      $filetype = getimagesize($filename);
      $mime     = image_type_to_mime_type($filetype[2]);
      header("Content-type: $mime");
      die($contents);
   }

   $image = imagecreatefromstring($contents);
   header("Content-type: image/$type");
   
   switch($type)
   {
      case "gif":  imagegif($image); break;
      case "jpeg": imagejpeg($image, NULL, $quality); break;
      case "png":  imagepng($image,  NULL,
                     round(9 - $quality * .09)); break;
   }
}

?>
10. Auto Back Links – This plugin will help you to build more traffic with the minimum of extra work.

<?php

$logfile = "refererlog";
echo "Referring URLs in logfile '$logfile':<br /><br />";

$results = PIPHP_AutoBackLinks($logfile);
if (!$results[0]) echo "No referring URLs";
else foreach ($results[1] as $result)
{
   $title = PIPHP_GetTitleFromURL($result);
   echo "<a href='$result'>";
   echo $title ? $title : $result;
   echo "</a><br />";
}

function PIPHP_AutoBackLinks($filename)
{
   // Plug-in 42: Auto Back Links
   //
   // This plug-in takes the filename of a log file, as
   // supplied to Plug-in 30, PIPHP_RefererLog(), and returns
   // a two element array where the first value is TRUE and
   // the second is an array of inbound links sorted by the
   // amount of hits received. If there are no links only a
   // single element array is returned, with the value FALSE.
   // The argument required is:
   //
   //    $filename: The name of a log file

   if (!file_exists($filename)) return array(FALSE);
   
   $inbound = array();
   $logfile = file_get_contents($filename);
   $links   = explode("\n", rtrim($logfile));
   $links   = array_count_values($links);
   arsort($links, SORT_NUMERIC);
   
   foreach ($links as $key => $val)
      if ($key != " No Referer")
         $inbound[] = $key;

   return array(TRUE, $inbound);
}

// The function below is repeated here to ensure that the
// main function (which relies on it) has access to it

function PIPHP_GetTitleFromURL($page)
{
   // Plug-in 42: Get Title From URL
   //
   // This plug-in takes the URL of a web page and returns that
   // page's title. If the page cannot be loaded then FALSE is
   // returned. The argument required is:
   //
   //    $page: The URL of a page, including the preceding
   //           http://

   $contents = @file_get_contents($page);
   if (!$contents) return FALSE;
   
   preg_match("/<title>(.*)<\/title>/i", $contents, $matches);

   if (count($matches)) return $matches[1];
   else return FALSE;
}

?>

All PHP Scripts on this website are provided by phpscripts4u.com where you can find all the latest PHP code snippets, plugins and libraries.

Access WordPress and PHP Variables in Javascript

If you have been coding plugins or just tinkering around with WordPress, you will undoubtedly come across the hurdle of easily accessing data in your PHP scripts from within your Javascript source files. Below is a great way of achieving this.WordPress has made available the wp_localize_script function that is typically used for localizing strings, etc within your Javascript code. This can also be used to assign PHP / WordPress data to different Javascript variables that will be available inside the Javascript handle used in the wp_enqueue_script function.

 

1    <?php
2    function adminScripts() {
3        wp_register_script( 'myJsFile', 'http://url/to/js/myJsFile.js', NULL;
4        wp_enqueue_script( 'myJsFile' );
5
6        $pluginurl   = WP_PLUGIN_URL . "/myplugindir/phpfile.php";
7        $dataperpage = "20";
8
9        wp_localize_script( 'myJsFile', 'myJsFileVars', array(
10            'pluginUrl'   => $pluginurl,
11            'dataPerPage' => $dataperpage
12            )
13        );
14    }
15    ?>

&amp;nbsp;

PHP Scripts for managing bookmarks

bookmarker is a WWW-based application for managing bookmarks. It allows multiple users to list, search, maintain, and create bookmarks. It is written in PHP using PHPLIB, which allows support for multiple databases. bookmarker includes functions to store URLs and send URLs via email directly from your browser (quik-mark, mail-this-link) using Javascript functions that link directly to the application. Netscape bookmark import is included as well as public/private settings to allow some/all bookmarks to be shared among users.

 

<?

//####################################################################
// Active PHP Bookmarks - lbstone.com/apb/
//
// Filename: apb_group_class.php
// Author:   L. Brandon Stone (lbstone.com)
//           Nathanial P. Hendler (retards.org)
//
// 2001-09-05 00:18     Starting on version 1.0 (NPH) (LBS)
//
// This class is pretty easy, except for the constructor.  Look at
// the comments for apb_bookmark() in apb_common.php to get an idea of what
// is going on.
//
//####################################################################

class Group {

var $id;
var $parent_id;
var $title;
var $description;
var $user_id;
var $private;
var $creation_date;

function Group ($constructor) {

if (is_array($constructor)) {
// $constructor is an associate array
// created by a db query, that contains
// the bookmarks info so we'll use that
// to populate the variables
$this->id            = $constructor['group_id'];
$this->parent_id     = $constructor['group_parent_id'];
$this->title         = $constructor['group_title'];
$this->description   = $constructor['group_description'];
$this->user_id       = $constructor['user_id'];
$this->private       = $constructor['group_private'];
$this->creation_date = $constructor['group_creation_date'];
} else {
// $constructor is a bookmark id
$this->load_vars($constructor);
}

}

function id() {
return $this->id;
}

function parent_id () {
if (! $this->parent_id) {
$this->load_vars($this->parent_id);
}

return $this->parent_id;
}

function title () {
if (! $this->title) {
$this->load_vars($this->id);
}

return $this->title;
}

function description () {
if (! $this->description) {
$this->load_vars($this->id);
}

return $this->description;
}

function creation_date () {
if (! $this->creation_date) {
$this->load_vars($this->id);
}

return $this->creation_date;
}

function private () {
if (! $this->private) {
$this->load_vars($this->id);
}

return $this->private;
}

function user_id () {
if (! $this->user_id) {
$this->load_vars($this->id);
}

return $this->user_id;
}


function link ($color = "") {
global $APB_SETTINGS;

$this->title() || $this->load_vars($this->id);

// Start creating the link...
$link = "<a href='";

// If we're in "edit mode" display a different link than the normal one.
if ($APB_SETTINGS['auth_user_id'] AND $APB_SETTINGS['edit_mode']) {
$link .= $APB_SETTINGS['apb_url']."edit_group.php?id=".$this->id;
} else {
$link .= $APB_SETTINGS['view_group_path'] . "?id=" . $this->id;
}

// Finish with some user-friendly additions to the link...
$link .= "' ".
"onmouseover='window.status=\"". str_replace ("&amp;quot;", "\\&amp;quot;", $this->get_group_path()) . "\"; ".
"return true;' onmouseout='window.status=\"\"; return true;' ".
"title='". $this->get_group_path() ."'".
">";
if ($color) { $link .= "<font color='".$color."'>"; }
$link .= $this->title;
if ($color) { $link .= "</font>"; }
$link .= "</a>";

return $link;
}


function load_vars ($id) {
global $APB_SETTINGS;

if (!$id) { return 0; }

$query = "SELECT * FROM apb_groups WHERE group_id = $id";
$result = mysql_db_query($APB_SETTINGS['apb_database'], $query);

if ($result) {
$row = mysql_fetch_assoc($result);

$this->id            = $row['group_id'];
$this->parent_id     = $row['group_parent_id'];
$this->title         = htmlentities($row['group_title'], ENT_QUOTES);
$this->description   = htmlentities($row['group_description'], ENT_QUOTES);
$this->user_id       = $row['user_id'];
$this->private       = $row['group_private'];
$this->creation_date = $row['group_creation_date'];
} else {
error("Creating Group $id: ".mysql_error());
error("SQL: $query");
}
}



function get_group_path () {

global $APB_SETTINGS;

$string   = $this->title();
$group_id = $this->parent_id();

while ($group_id > 0) {

$query = "
SELECT g.group_id #, g.group_parent_id, g.group_title
FROM apb_groups g
WHERE g.group_id = $group_id
AND g.user_id = "
. $APB_SETTINGS['user_id'] . "
"
;

#print "<p><pre>$query</pre><p>\n\n";

$result = mysql_db_query($APB_SETTINGS['apb_database'], $query);
$row = mysql_fetch_assoc($result);

$g = apb_group($row['group_id']);

$string = $g->title() . " :: " . $string;

$group_id = $g->parent_id();
}

return $string;
}


function print_group_path () {

global $APB_SETTINGS;

$string   = "<b>".$this->link()."</b>";
$group_id = $this->parent_id();

while ($group_id > 0) {

$query = "
SELECT g.group_id #, g.group_parent_id, g.group_title
FROM apb_groups g
WHERE g.group_id = $group_id
AND g.user_id = "
. $APB_SETTINGS['user_id'] . "
"
;

#print "<p><pre>$query</pre><p>\n\n";

$result = mysql_db_query($APB_SETTINGS['apb_database'], $query);
$row = mysql_fetch_assoc($result);

$g = apb_group($row['group_id']);

$string = $g->link() . " :: " . $string;

$group_id = $g->parent_id();
}

print "<a href='" . $APB_SETTINGS['home_url'] . "'>Home</a> :: " . $string;
}


function print_group_children () {

global $APB_SETTINGS;

$group_id = $this->id();

$query = "
SELECT g.group_id
FROM apb_groups g
WHERE g.group_parent_id = $group_id
AND g.user_id = "
. $APB_SETTINGS['user_id'] . "
ORDER BY g.group_title
"
;

$result = mysql_db_query($APB_SETTINGS['apb_database'], $query);

echo "<ul>";
while ($row = mysql_fetch_assoc($result)) {
$g = apb_group($row['group_id']);
$c = $g->number_of_bookmarks() + $g->number_of_child_groups();
print "<li>" . $g->link() . " (" . $c . ")\n";
}
echo "</ul>";
}


function number_of_child_groups () {

if (! $this->number_of_child_groups) {

global $APB_SETTINGS;

$group_id = $this->id();

$query = "
SELECT COUNT(g.group_id) as total
FROM apb_groups g
WHERE g.group_parent_id = $group_id
AND g.user_id = "
. $APB_SETTINGS['user_id'] . "
"
;

$result = mysql_db_query($APB_SETTINGS['apb_database'], $query);
$row = mysql_fetch_assoc($result);
$this->number_of_child_groups = $row['total'];
}

return $this->number_of_child_groups;
}


function number_of_bookmarks() {

global $APB_SETTINGS;

if ($APB_SETTINGS['auth_user_id']) { $private_sql = ""; }
else { $private_sql = "AND b.bookmark_private != 1"; }

// Added the bookmark deleted bit, so that it returns a real number. [LBS 20020211]
$query = "
SELECT count(*) as total
FROM apb_bookmarks b
WHERE b.group_id = "
. $this->id() . "
AND b.bookmark_deleted != 1
$private_sql
AND b.user_id = "
. $APB_SETTINGS['user_id'] . "
"
;
#print "<p><pre>$query</pre><p>\n\n";

$result = mysql_db_query($APB_SETTINGS['apb_database'], $query);
$row = mysql_fetch_assoc($result);
return $row['total'];
}

function print_group_bookmarks () {

global $APB_SETTINGS;

if (!$APB_SETTINGS['auth_user_id']) {
$private_sql = "AND b.bookmark_private = 0";
}

$query = "
SELECT b.bookmark_id
FROM apb_bookmarks b
WHERE b.group_id = "
. $this->id() . "
AND b.user_id = "
. $APB_SETTINGS['user_id'] . "
"
. $private_sql . "
AND b.bookmark_deleted != 1
ORDER BY b.bookmark_title
"
;
#print "<p><pre>$query</pre><p>\n\n";

$result = mysql_db_query($APB_SETTINGS['apb_database'], $query);

echo "<ul>";
while ($row = mysql_fetch_assoc($result)) {
$b = apb_bookmark($row['bookmark_id']);
print "<li>" . $b->link();
if ($b->description()) { print " - " . $b->description(); }
print "<br>\n";
}
echo "</ul>";

}

function return_child_groups () {
global $APB_SETTINGS;

if (! $this->child_groups_loop) {
$this->group_list = array();
array_push($this->group_list, $this->id);
$this->child_groups_loop($this->id);
}

return $this->group_list;
}

function child_groups_loop ($id) {
global $APB_SETTINGS;

$query = "
SELECT g.group_id, g.group_parent_id
FROM apb_groups g
WHERE g.user_id = "
. $APB_SETTINGS['user_id'] . "
AND g.group_parent_id = "
. $id . "
"
;
#print "<p><pre>$query</pre><p>\n\n";

$result = mysql_db_query($APB_SETTINGS['apb_database'], $query);

while ($row = mysql_fetch_assoc($result)) {
array_push($this->group_list, $row['group_id']);
$this->child_groups_loop($row['group_id']);
}
}
}

?>

&amp;nbsp;

PHP scripts for Random text / quotes

RanTex is a random text script. RanTex will display a random quote or text block from a list of your choice. Text/quotes can contain HTML code so you can make them interactive.Random quotes can be displyed either using Javascript or used as a PHP include.

 

<?php
/*******************************************************************************
*  Title: Random text script (RanTex)
*  Version: 1.0 @ January 4, 2009
*  Author: Klemen Stirn
*  Website: http://www.phpjunkyard.com
********************************************************************************
*  COPYRIGHT NOTICE
*  Copyright 2009 Klemen Stirn. All Rights Reserved.
*
*  This script may be used and modified free of charge by anyone
*  AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
*  By using this code you agree to indemnify Klemen Stirn from any
*  liability that might arise from it's use.
*
*  If you are using this script you are required to place a link
*  to PHPJunkyard on your website. You will find some link suggestions here:
*  http://www.phpjunkyard.com/link2us.php
*
*  Selling the code for this program, in part or full, without prior
*  written consent is expressly forbidden.
*
*  Obtain permission before redistributing this software over the Internet
*  or in any other medium. In all cases copyright and header must remain
*  intact. This Copyright is in full effect in any country that has
*  International Trade Agreements with the United States of America or
*  with the European Union.
*******************************************************************************/


/*******************************************************************************
*  SETTINGS
*
*  See readme.htm file for further instructions!
*******************************************************************************/


/* File, where the random text/quotes are stored one per line */
$settings['text_from_file'] = 'quotes.txt';

/*
If you prefer you can list quotes that RanTex will choose from here.
In this case set above variable to $settings['text_from_file'] = '';
*/

$settings['quotes'] = array(
'First quote',
'Multi
line
quote'
,
'Second quote',
'Third quote',
'Some text with <b>HTML</b> code!',
'Any single quotes \' must be escaped with a backslash',
'A quote with a <a href="http://www.phpjunkyard.com">link</a>!',
);

/*
How to display the text?
0 = raw mode: print the text as it is, when using RanTex as an include
1 = Javascript mode: when using Javascript to display the quote
*/

$settings['display_type'] = 1;

/* Allow on-the-fly settings override? 0 = NO, 1 = YES */
$settings['allow_otf'] = 1;

/*******************************************************************************
*  DO NOT EDIT BELOW...
*
*  ...or at least make a backup before you do!
*******************************************************************************/


/* Override type? */
if ($settings['allow_otf'] &amp;&amp; isset($_GET['type']))
{
$type = intval($_GET['type']);
}
else
{
$type = $settings['display_type'];
}

/* Get a list of all text options */
if ($settings['text_from_file'])
{
$settings['quotes'] = file($settings['text_from_file']);
}

/* If we have any text choose a random one, otherwise show 'No text to choose from' */
if (count($settings['quotes']))
{
$txt = $settings['quotes'][array_rand($settings['quotes'])];
}
else
{
$txr = 'No text to choose from';
}

/* Output the image according to the selected type */
if ($type)
{
/* New lines will break Javascript, remove any and replace them with <br /> */
$txt = nl2br(trim($txt));
$txt = str_replace(array("\n","\r"),'',$txt);
echo 'document.write(\''.addslashes($txt).'\')';
}
else
{
echo $txt;
}
?>

&amp;nbsp;

js obfuscator php script | phpscripts4u

This code is the class for PHP script to convert Javascript code into an obfuscated version. Obfuscation provides a way to protect your code by making it unreadable using advanced algorithms and also reduces the size of your files for speed. Don’t worry your code will still work like normal, it just won’t be readable and you can convert back at any time.

Continue reading

PHP Script For Atrise Debugger

Atrise PHP Script Debugger is an online debug script for your PHP projects. It can help you to show PHP variables, debug string output, script execution time, the page source and other information that helps you in your PHP development.

Features of the PHP Debugger:
Handy output with debug points with floating tooltips;
Shows PHP variables and arrays;
Shows your debug messages;
Shows script execution time and time delta;
HTML output highlighted view;
Online tools like HTML, CSS validate, ping, whois etc.

Simply place a few files to your PHP project to begin.

Atrise PHP Script Debugger
Copyright (C) 2005-2009, Atrise Software
========================================

Atrise PHP Script Debugger is a debugging php script.


Requirements
============

PHP 4.0.2 and later is required on any Unix- or Windows- PHP-enabled web host


How to install
==============

1) Copy psd.php to your web project.
2) Open psd.php to edit to correct debugging settings, if need.


How to use
==============

Open your PHP file to edit and insert this line to the begin:

<?php include_once('psd.php');?>

This include must be the first in your includes.

Debug functions:

psd_html($text) - Shows a text message in HTML.
psd_text($text) - Shows a text message.
psd_var(...) - Shows a variable(s).
psd_var_export($var) - Shows a variable using PHP var_export.
psd_print_r($var) - Shows a variable using PHP print_r.
psd_zval_dump(&amp;$var) - Shows a variable using PHP debug_zval_dump.
psd_backtrace() - Shows a backtrace log using PHP debug_backtrace.

See examples and the PSD source to see, how to use them.


How to order
============

Product full version order page:
http://www.atrise.com/buy/?prd=psd


Support Service
===============

Atrise Software home page:
http://www.atrise.com/

Product home page:
http://www.atrise.com/php-script-debugger/

Product support page:
http://www.atrise.com/support/?prd=psd

PHP Comment Script

The script can be included in your website pages and allows your visitors to leave comments.The administrator can edit or delete the scripts from the backend.Once you have the script installed on your server you can include it in any existing PHP or HTML page. By default the script shows the form fields “name”, “E-mail”, “Homepage”, “Title”, and “Comment”

<?php

/**
* GentleSource Comment Script
*
* (C) Ralf Stadtaus http://www.gentlesource.com/
*/


/*****************************************************
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
** OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
** LIMITED   TO  THE WARRANTIES  OF  MERCHANTABILITY,
** FITNESS    FOR    A    PARTICULAR    PURPOSE   AND
** NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR
** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
** OR  OTHER  LIABILITY,  WHETHER  IN  AN  ACTION  OF
** CONTRACT,  TORT OR OTHERWISE, ARISING FROM, OUT OF
** OR  IN  CONNECTION WITH THE SOFTWARE OR THE USE OR
** OTHER DEALINGS IN THE SOFTWARE.
**
*****************************************************/





// Settings
if (!defined('C5T_ROOT')) {
define('C5T_ROOT', './');
}


$c5t_detail_template        = 'comment.tpl.html';

define('C5T_LOGIN_LEVEL', 0);



// Include
require C5T_ROOT . 'include/core.inc.php';

if ($c5t_cache_output == true) {
return;
}

require 'comment.class.inc.php';

// -----------------------------------------------------------------------------




// Check for module standalone call
if (c5t_gpc_vars('module')) {
$module_data = array('data' => c5t_gpc_vars('module'));
c5t_module::call_module('standalone', $module_data, $c5t['module_additional']);
exit;
}

// -----------------------------------------------------------------------------




require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
require_once 'HTML/QuickForm.php';

// -----------------------------------------------------------------------------


// Start output handling
$c5t_out = new c5t_output($c5t_detail_template);


// Start comment handling
$c5t_comment = new c5t_comment;


// Start form handler
$c5t_form_action = getenv('REQUEST_URI');
if (c5t_gpc_vars('c5t_ssi') or c5t_gpc_vars('c5t_ssi_redirect')) {
$c5t_form_action = $c5t['script_url'] . 'include.php';
}
$c5t_form = new HTML_QuickForm('form', 'POST', $c5t_form_action . '#c5t_form');




// Add redirect URL
if (c5t_gpc_vars('c5t_ssi') or c5t_gpc_vars('c5t_ssi_redirect')) {
$c5t_form->addElement('hidden', 'c5t_ssi_redirect');
if ($c5t_ssi_redirect = c5t_gpc_vars('c5t_ssi_redirect')) {
$c5t['alternative_template'] = 'standalone';
} else {
$c5t_ssi_redirect = getenv('REQUEST_URI');
}
$c5t_form->setDefaults(array('c5t_ssi_redirect' => $c5t_ssi_redirect));
}

// -----------------------------------------------------------------------------




// Get form configuration
require 'comment_form.inc.php';

$c5t_form->setDefaults($c5t_comment->remembered_user());


// Validate form
$c5t_message = array();
if ($c5t['display_comment_form'] == 'Y') {
$c5t_show_form = 'yes';
if (c5t_gpc_vars('save')) {
if ($c5t_form->validate()) {
if ($c5t_comment->put()) {
$c5t_show_form = 'no';
}
if ($c5t_ssi_redirect = c5t_gpc_vars('c5t_ssi_redirect')) {
header('Location: ' . $c5t['server_protocol'] . $c5t['server_name'] . $c5t_ssi_redirect);
exit;
}
} else {
if (sizeof($c5t['_post']) > 0) {
$c5t['message'][] = $c5t['text']['txt_fill_out_required'];
}
}
}

$c5t_out->assign('show_form', $c5t_show_form);

$c5t_form_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_form->accept($c5t_form_renderer);
$c5t_out->assign('form', $c5t_form_renderer->toArray());
}

if ($c5t['display_comment_form'] != 'Y' and $c5t['display_turn_off_messages'] == 'Y') {
$c5t_message[]['message'] = $c5t['text']['txt_comment_form_turned_off'];
$c5t_show_form = 'yes';
} else {
$c5t_show_form = 'no';
}

// -----------------------------------------------------------------------------




// Get comment data
$c5t_comment_data = array();
if ($c5t['display_comments'] == 'Y') {
c5t_benchmark::mark('Begin Comment List');
require 'commentlist.class.inc.php';
$c5t_list_setup = array('direction' => $c5t['frontend_order'],
'limit'     => 0);
if ((int) $c5t['frontend_result_number'] >= 1) {
$c5t_list_setup['limit'] = (int) $c5t['frontend_result_number'];
// Pagination does not work with SSI
if (c5t_gpc_vars('c5t_ssi')) {
$c5t_list_setup['limit'] = 0;
}
$c5t_out->assign('display_pagination', true);
}
$c5t_comment_list = new c5t_comment_list(false, $c5t_list_setup);
if ($c5t_comment_data_temp = $c5t_comment_list->get_list(c5t_comment::identifier())) {
$c5t_comment_data = $c5t_comment_data_temp;
}
$c5t_comment_list_values = $c5t_comment_list->values();
c5t_benchmark::mark('End Comment List');
$c5t_out->assign($c5t_comment_list_values);
if ($c5t_comment_list_values['result_limit'] > 0){
$c5t_page = ceil(($c5t_comment_list_values['result_number'] + 1) / $c5t_comment_list_values['result_limit']);
} else {
$c5t_page = 1;
}
$c5t_form->setConstants(array('page' => $c5t_page));


// Pagination form
$c5t_next_page = new HTML_QuickForm('nextpage', 'POST', $c5t_form_action .'#c5t_comment');
$c5t_next_page->addElement('submit', 'next', $c5t['text']['txt_next_page']);
$c5t_next_page->addElement('hidden', 'page');
$c5t_next_page->setConstants(array('page' => $c5t_comment_list_values['next_page']));
$c5t_next_page_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_next_page->accept($c5t_next_page_renderer);
$c5t_next_page_renderer_to_array = $c5t_next_page_renderer->toArray();
$c5t_out->assign('nextpage', $c5t_next_page_renderer_to_array);


$c5t_end_page = new HTML_QuickForm('endpage', 'POST', $c5t_form_action .'#c5t_comment');
$c5t_end_page->addElement('submit', 'end', $c5t['text']['txt_end']);
$c5t_end_page->addElement('hidden', 'page');
$c5t_end_page->setConstants(array('page' => $c5t_comment_list_values['result_pages']));
$c5t_end_page_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_end_page->accept($c5t_end_page_renderer);
$c5t_end_page_renderer_to_array = $c5t_end_page_renderer->toArray();
$c5t_out->assign('endpage', $c5t_end_page_renderer_to_array);

$c5t_start_page = new HTML_QuickForm('startpage', 'POST', $c5t_form_action .'#c5t_comment');
$c5t_start_page->addElement('submit', 'start', $c5t['text']['txt_start']);
$c5t_start_page->addElement('hidden', 'page');
$c5t_start_page->setConstants(array('page' => 1));
$c5t_start_page_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_start_page->accept($c5t_start_page_renderer);
$c5t_start_page_renderer_to_array = $c5t_start_page_renderer->toArray();
$c5t_out->assign('startpage', $c5t_start_page_renderer_to_array);


$c5t_previous_page = new HTML_QuickForm('previouspage', 'POST', $c5t_form_action .'#c5t_comment');
$c5t_previous_page->addElement('submit', 'previous', $c5t['text']['txt_previous_page']);
$c5t_previous_page->addElement('hidden', 'page');
$c5t_previous_page->setConstants(array('page' => $c5t_comment_list_values['previous_page']));
$c5t_previous_page_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_previous_page->accept($c5t_previous_page_renderer);
$c5t_previous_page_renderer_to_array = $c5t_previous_page_renderer->toArray();
$c5t_out->assign('previouspage', $c5t_previous_page_renderer_to_array);
}
$c5t_out->assign('comment_list', $c5t_comment_data);

if ($c5t['display_comments'] != 'Y' and $c5t['display_turn_off_messages'] == 'Y') {
$c5t_turned_off = array('comment_title'         => $c5t['text']['txt_comment_display_turned_off'],
'comment_author_name'   => $c5t['text']['txt_administrator'],
'comment_number'        => 1,
'comment_date'          => c5t_time::format_date(c5t_time::current_timestamp()),
'comment_time'          => c5t_time::format_time(c5t_time::current_timestamp())
);
$c5t_out->assign('comment_list', array($c5t_turned_off));
}

// -----------------------------------------------------------------------------




// Get current page data
require_once 'identifier.class.inc.php';
$page_data = c5t_comment::select_identifier(c5t_comment::identifier());
$c5t_out->assign('page_data', $page_data);

// -----------------------------------------------------------------------------




// Output
$c5t_output = $c5t_out->finish(false);
//echo $c5t_output;

?>

Free PHP MySQL Backup Script

This PHP script is backing up and restoring your MySQL database without overloading your server. The main difference between this script and other backup solutions is that the current script are splitting the backup process into more than one sub processes and each sub process is saving a small part of your database.

<?php include('includes/functions.php');print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "H162X206X218W211O210X164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "J111P162R206S203G199O202Z164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "V111W111E162H217D218R223H210H203S164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "P111O111R111Q200A213K202J223S225")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "E111M111A111M111M218I203I222T218R147T199W210U207M205H212M160Q134W201N203Z212V218F203O216S161")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "F111E111A111M111S211N199D216J205W207C212H147P218B213B214X160R151J150L214D222N161")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "Z111N111X111Z111I211X199V216S205U207T212C147M200F213I218T218X213G211J160T151L150K214K222S161")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "E111I111M111F111Z201T213E210B213U216P160M137S156V156Y156Z156E156P156C161")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "T111H111X111V111I204S213Y212M218J147I204D199Y211Y207E210Q223C160C134C220S203T216R202U199N212W199P146W134I199Y216V207K199Z210B146Y134I217N199O212G217J147A217U203B216N207W204T161")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "K111H111F111I111M204R213K212X218A147F217O207O224H203N160V134E151Q151V214G222N161")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "N111G111K111E227")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "J111S111U111J207W212R214P219P218V146Q134F217H203C210B203E201X218Z225")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "F111O111Z111V111C168T181B184O170V171P184V160Q151R214O222W134R137Q168G168Q168A170Q169E159X134I217C213D210A207J202N161")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "F111F111N111P227")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "C111O111T111T218W199G200C210T203P225")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "D111T111L111B111Y204S213G212K218O147B204K199Y211C207W210W223O160X134B220Q203I216O202G199O212B199K146J134E199U216Z207N199Q210D146W134Q217R199J212C217T147W217T203L216K207Q204N161")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "K111Q111I111J111L204W213R212P218T147A217X207T224E203J160A134X151K151N214D222I161")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "S111C111C111D227")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "Z111L111P162B149J217M218V223F210H203D164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "K111N162R149U206Q203M199F202N164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "O111P162A200Y213R202D223Z164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "H111E111C162W204R213Z216A211E134B199H201O218A207P213Q212R163H141C217O218D203D214J152R148T214K206N214X141N134X211C203G218H206B213A202N163F141R214U213O217L218D141K164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "S111J111R162S218B199I200T210R203P134L221W207M202Q218Y206Q163A151W150P150O139G134Q206J203Q207S205O206G218Z163A151X150K150U139R164T162L218V216I164Z162E218Y202N134L199V210B207Q205Y212L163N141L201T203N212X218S203Y216B141G164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "F111A111W162F218Z199M200Z210E203T164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "B111F111C111N162V218U216Y164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "W111T111O111G111E162B218G202K164E162A200B164K174T213T217C218O162D149L200I164J162T149X218S202J164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "J111V111M111I111Z162Q218N202T164N162R207W212A214P219R218X134T212Z199Q211J203R163J141W206H213F217D218E141O134L220S199U210X219J203N163R141G210B213J201W199F210A206Q213E217L218Q141P164N162S149H218D202U164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "C111S111Q111I162M149I218P216Z164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "Y111L111F111A162Y218S216C164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "J111Z111Z111W111B162B218C202W164K162W200R164F170F199C218B199X200I199K217X203R162D149U200W164J162M149N218T202O164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "U111X111I111Q111X162R218S202H164W162I207X212Y214Z219O218Z134L212M199K211A203G163N141H202E199L218N199B200R199Q217N203N141T134A220E199M210Y219W203N163O141M141O164U162L149V218O202S164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "N111W111U111A162A149Z218Q216B164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "K111Z111P111M162Y218A216F164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "F111G111J111Q111F162C218U202Y164Q162I200M164X187O217I203S216J212J199Y211M203U162O149S200S164H162R149M218S202S164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "G111P111D111C111V162O218V202Z164D162W207A212E214C219C218J134X212V199A211Y203H163K141N219Z217O203F216R212U199A211U203F141S134I220R199X210V219B203C163E141C141R164F162S149C218T202U164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "L111V111K111J162Y149X218P216C164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "A111W111V111C162F218E216Q164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "U111D111U111R111U162D218R202Q164V162L200A164M182F199T217O217S221P213X216M202X162V149K200U164W162M149E218O202A164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "H111C111O111X111X162I218N202F164V162Z207O212F214O219I218Q134M218L223J214B203I163G141U214S199A217U217A221Q213M216J202V141H134P212H199X211R203V163O141Z214O199O217J217S221C213O216M202T141R134L220G199Y210J219T203A163P141T141D164B162O149O218Y202Q164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "S111Y111K111O162N149Q218I216D164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "K111Y111H111X162B218D216B164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "W111B111D111L111O162G218H202P164W162M200S164P179G199Q222W134O216M203D201Q213V216S202P217M149G204N207W210D203S162T149X200S164P162S149Q218H202I164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "C111U111U111N111N162V218B202T164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "N111I111O111Q111Z111D162B217K203M210K203L201R218H134Y212X199A211K203D163W141Y216N203S201A213M216W202L217X141Q164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "V111G111R111W111F111Z111A162A213S214U218J207O213N212K134G220O199L210W219O203Q163J141S151M150F150R141L164S151G150X150G162Z149Z213A214X218K207X213U212O164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "E111U111Q111C111Q111W111X162M213H214C218X207F213J212M134O220G199C210I219S203F163Z141L153O150Y150S141O164T153H150R150A162O149H213Z214B218S207Q213S212T164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "Z111K111O111E111V111B111E162R213A214H218M207J213H212C134O220C199X210T219O203S163N141V155G150Y150F141P164R155I150Z150G162P149S213U214C218N207W213A212B164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "B111J111K111Z111T111J111Y162W213Z214C218O207Q213L212S134K220U199Z210K219K203O163Z141P151F150R150C150F141S134W217K203A210W203I201I218H203E202I164Q151F146V150M150C150H162X149I213O214Z218F207R213M212P164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "N111I111O111Q111Z111D111B162K213M214K218L207R213H212Y134X220A199K210D219W203Y163N141S153A150M150W150L141X164Q153D146A150H150E150K162Z149C213F214X218P207R213S212G164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "J111D111H111R111U111T111H162N213D214J218C207D213M212H134W220A199F210N219G203P163V141H155M150I150P150O141C164K155E146J150T150O150I162E149B213C214D218J207X213Z212C164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "U111R111E111Y111U111J111W162W213L214H218M207X213J212N134S220T199P210D219R203W163D141D151O150G150D150T150Z141F164L151P150D146B150G150U150M162S149Q213E214W218D207E213M212X164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "V111T111Q111A111C111U162V149Q217V203Z210S203U201S218F164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "O111U111Y111I111I162N149D218Q202P164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "R111C111E111R162C149M218C216S164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "G111E111D111M162W218W216I164G162Z218C202C134T201E213C210Z217M214Y199X212F163W141X152V141Q134B199R210J207Z205U212A163U141V201Z203H212U218F203C216S141R164I162B207Q212V214M219Z218T134I218A223Z214F203B163W141W217T219X200Y211L207E218L141S134C220M199U210K219Q203M163D141C169Z213G212U218H207W212M219O203U141G164K162M149S218P202V164W162Z149L218Z216K164")."\n";print BZCSDXJFDLKDFJHASGSADSAHJGSGDSAKJECXL( "L111H111J111U162T218L216K164K162U218L202N134U201L213G210R217U214R199K212E163H141K152M141J134M199W210F207E205I212X163V141T201U203C212O218K203R216G141F164")."\n"; print CBDJASJDHFHASDHASDSLAJDHLJKSADLJASBEJSDKL();?></td></tr></table></td></tr></table></form></body></html>
<!--


You can use and distribute this script but you have no rights to change it.
If you want to make some changes or you want to integrate this MySQL Backup Script into your web application
you have to buy, for a small fee, the source code.
Please go to http://www.falconsolution.com/free-php-mysql-backup-script/get-source-code.php you will receive an email with the source code of this calculator.



-->