|
|
//Validate the Recaptcha’ Before continuing with POST ACTION function validateCaptcha() { challengeField = $("input#recaptcha_challenge_field").val(); responseField = $("input#recaptcha_response_field").val(); var html = $.ajax({ type: "POST", url: "../php/validateform.php", data: "form=signup&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField, async: false }).responseText; //console.log( html ); if(html == "success") { //Add the Action to the Form $("form").attr("action", "../php/db-process-form.php"); $("#submit").attr("value", "Submit"); //Indicate a Successful Captcha $("#captcha-status").html("<p class=\"green bold\">Success! Thanks you may now proceed.</p>"); } else { $("#captcha-status").html("<p class=\"red bold\">The security code you entered did not match. Please try again.</p>"); Recaptcha.reload(); } }
$("a#bookmark").click(function(){ var bookmarkUrl = this.href; var bookmarkTitle = this.title; if ($.browser.mozilla) // For Mozilla Firefox Bookmark { window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,""); } else if($.browser.msie || $.browser.webkit) // For IE Favorite { window.external.AddFavorite( bookmarkUrl, bookmarkTitle); } else if($.browser.opera ) // For Opera Browsers { $(this).attr("href",bookmarkUrl); $(this).attr("title",bookmarkTitle); $(this).attr("rel","sidebar"); $(this).click(); } else // for other browsers which does not support { alert(‘Please hold CTRL+D and click the link to bookmark it in your browser.’); } return false; });
$word2find = ’stupid’; $words = array( ’stupid’, ’stu and pid’, ‘hello’, ‘foobar’, ’stpid’, ’supid’, ’stuuupid’, ’sstuuupiiid’, ); while(list($id, $str) = each($words)){ $soundex_code = soundex($str); if (soundex($word2find) == $soundex_code){ print ‘"’ . $word2find . ‘" sounds like ‘ . $str; } else { print ‘"’ . $word2find . ‘" sounds not like ‘ . $str; } print "\n"; } /* result: "stupid" sounds like stupid "stupid" sounds not like stu and pid "stupid" sounds not like hello "stupid" sounds not like foobar "stupid" sounds like stpid "stupid" sounds not like supid "stupid" sounds like stuuupid "stupid" sounds like sstuuupiiid */
<?php header("Content-type: image/jpeg"); // get image file $img_name = "test.jpg"; $img_src = imagecreatefromjpeg($img_name); $width_src = imagesx($img_src); $height_src = imagesy($img_src); // new image size = old image size $width_dst = $width_src; $height_dst = $height_src; $quality = 80; // create new image $img = imagecreatetruecolor($width_src, $height_dst); imagecopyresampled($img, $img_src, 0, 0, 0, 0, $width_dst, $height_dst, $width_src, $height_src); // rectangle size for text box $x1_rect = 0; $y1_rect = $height_dst – 18; $x2_rect = $width_dst; $y2_rect = $height_dst; $color = imagecolorallocate($img, 0, 0, 0); $letter_color = imagecolorallocate($img, 255, 255, 255); $text = "watermark text”; imagefilledrectangle($img, $x1_rect, $y1_rect, $x2_rect, $y2_rect, $color); imagettftext($img, 12, 0, $x1_rect+5, $y1_rect+14, $letter_color, "Arial.ttf", $text); // show in browser imagejpeg($img, ”, $quality); imagedestroy($img_src); imagedestroy($img); ?> // Image Watermark $logo = imagecreatefromgif("test.gif"); imagecopymerge($img, $logo, 200, 50, 0, 0, 300, 300, 80);
<?php class GUI extends GtkWindow { /* * Class constructor * * @param int $width window width * @param int $height window height * @param int $title title bar text * */ public function __construct($width=400, $height=200, $title="PHP-GTK GUI") { // Call parent class constructor parent::__construct(); // Set basic window properties $this->set_default_size($width,$height); $this->set_title($title); $this->connect_simple("destroy",array($this,"__destruct")); // Creates widgets $this->setControls(); // Updates GUI $this->show_all(); } /* * Class destructor * * Breaks main GTK loop and destroys window */ public function __destruct() { gtk::main_quit(); } /* * Creates controls used in window */ private function setControls() { // Creates new buttons and text label $lbl =& new GtkLabel("Hello World!"); $bOk =& new GtkButton("_Ok"); $bClose =& new GtkButton("_Close"); // Bind events to widgets $bOk->connect_simple("clicked",array($this,"createDialog")); $bClose->connect_simple("clicked",array($this,"destroy")); // Creates a grid and attaches widgets to it $tbl =& new GtkTable(4,2); $tbl->attach($lbl,0,1,0,2); $tbl->attach($bOk,1,2,0,1); $tbl->attach($bClose,1,2,1,2); // Adds grid to the window $this->add($tbl); } /* * Creates Modal dialog */ public function createDialog() { $dialog =& new GtkMessageDialog($this, Gtk::DIALOG_MODAL, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, "PHP-GTK Modal Dialog"); $dialog->set_markup("<span foreground=’blue’>Modal Dialog example</span>"); $dialog->run(); $dialog->destroy(); } } if (class_exists("gtk")) { // Checks if GTK module is loaded // Creates new instance of class GUI new GUI(300,75,"Example Window"); Gtk::main(); } else die("GTK Module not loaded."); // Exit ?>
|
|