Dec 2

Some days ago I run into the following problem with jQuery’s datetime picker.

I have a form that contain a input field that I populate with a date/time picker.  If you populate the form on the server with some default values, the jQuery’s hidden fields wont get set unless you do some action on the calendar.

The  solution  is to add inline:true to its options like this:

$(“#myDate”).datepicker({

inline: true,
dateFormat: ‘yy-mm-dd’

});

Dec 6

This guide aims to familiarize you with some of the basic concepts of online security and teach you how to write more secure PHP scripts.

http://php.robm.me.uk/

Mar 1

cURL is a tool for transferring files and data with URL syntax, supporting many protocols including HTTP, FTP, TELNET and more. Initially, cURL was designed to be a command line tool. Lucky for us, the cURL library is also supported by PHP. In this article, we will look at some of the advanced features of cURL, and how we can use them in our PHP scripts.

Source : here

Feb 2

Mai intai setam header pentru formatul UTF-8

$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Content-type: application/x-www-form-urlencoded';
$headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
$headers[] = 'Accept-Charset: utf-8;';
$headers[] = 'Keep-Alive: 300';

dupa setarea aray-ului cu header-ele, acesta trebuie integrat in CURL

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://www.google.ro/search?&q='.urlencode($val['keywords']));
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFilenameLogin);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFilenameLogin);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
$data = curl_exec($ch);
curl_close($ch);
Jan 26

Editing Methods

Editing functionality is applied to selected page content through scripts that apply the document.execCommand() method. Parameters are passed to this method giving the edit command to apply. The general format for the execCommand() method is shown below. It is applied through the document object.

document.execCommand("command" [,0] [,"value"])
<button title="Bold"
  onclick="document.execCommand('Bold')">
  <img src="Bold.gif"/>
</button>

Editing Commands

All of the available editing commands are too numerous to list here. The following table gives a sampling of what types of editing can be applied to selected text a page.

Command Description

document.execCommand(“BackColor“,0,”color“)
Sets the background color of the selected element; color
is a color name or hexadecimal value.

document.execCommand(“Bold“)
Sets the current selection to bold style.

document.execCommand(“Copy“)
Copies the current selection to the clipboard.

document.execCommand(“CreateLink“)
Displays a dialogue box for entering a URL which is applied to the selected text.

document.execCommand(“Cut“)
Cuts the current selection to the clipboard.

document.execCommand(“Delete“)
Deletes the current selection.

document.execCommand(“FontName“,0,”name“)
Sets the font face of the current selection; name
is a font name.

document.execCommand(“FontSize“,0,”size“)
Sets the font size of the current selection; size
is an integer from 1 (smallest) to 7 (largest).

document.execCommand(“ForeColor“,0,”color“)
Sets the text (foreground) color of the selected element; color
is a color name or hexadecimal value.

document.execCommand(“Indent“)
Increases the indent of the selected text by one indentation increment.

document.execCommand(“InsertImage“,1)
Displays a dialogue box for selecting and positioning a graphic image.

document.execCommand(“InsertMarquee“)
Inserts an empty marquee for entering displayed text.

document.execCommand(“InsertOrderedList“)
Formats an ordered list of current selection.

document.execCommand(“InsertUnorderedList“)
Formats an unordered list of current selection.

document.execCommand(“Italic“)
Sets the current selection to italic style.

document.execCommand(“JustifyCenter“)
Centers the text block in which the current selection is located.

document.execCommand(“JustifyFull“)
Justifies the text block in which the current selection is located.

document.execCommand(“JustifyLeft“)
Left justifies the text block in which the current selection is located.

document.execCommand(“JustifyRight“)
Right justifies the text block in which the current selection is located.

document.execCommand(“Outdent“)
Decreases the indent of the selected text by one indentation increment.

document.execCommand(“Paste“)
Pastes the current clipboard contents to current selection.

document.execCommand(“Print“)
Opens the print dialog box so the user can print the current page.

document.execCommand(“RemoveFormat“)
Removes all formatting from current selection.

document.execCommand(“SelectAll“)
Selects the entire document.

document.execCommand(“StrikeThrough“)
Sets the current selection to strike-through style.

document.execCommand(“Subscript“)
Sets the current selection to subscript style.

document.execCommand(“Superscript“)
Sets the current selection to superscript style.

document.execCommand(“Underline“)
Sets the current selection to underline style.

document.execCommand(“Unlink“)
Removes any hyperlink from the current selection.

document.execCommand(“Unselect“)
Clears the current selection.
Dec 7

Va propun o metoda de a pune un watermark pe o imagine in PHP. In principiu functia primeste ca parametrii imaginea sursa (locatie), locatia destinatie, watermarkul (locatie imagine), si calitatea jpeg.

Va returna Boolean, iar in cazul TRUE va salva un jpeg cu watermark din imaginea initiala. Functia se foloseste de libraria GD inclusa in php si accepta orice fel de tip de imagine pe care o poate recunoaste aceasta.

Watermarkul este pus in coltul din dreapta jos, dar asta se paote modifica dupa bunul plac.

function set_watermark($source, $dest, $watermark, $quality = 80)
{
  if (func_num_args() < 3)
  {
    $set_watermark_error = "Insufficient parameters supplied!";
  }
  else
  {
    if (file_exists($source))
    {
      if ($src = imagecreatefromstring(file_get_contents($source)))
      {
        $info = getimagesize($source);
        imageantialias($src, true);
        if ($wm = imagecreatefromstring(file_get_contents($watermark)))
        {
          $wm_info = getimagesize($watermark);
          imagealphablending($src, true);
          imagecopy($src, $wm, $info[0]-$wm_info[0]-5, $info[1]-$wm_info[1]-5, 0, 0, $wm_info[0], $wm_info[1]);
          if (imagejpeg($src, $dest, $quality))
          {
            if (file_exists($dest))
            {
              chmod($dest, 0777);
              return true;
            }
            else
            {
              $set_watermark_error = 'Unable tosaveimage! ';
            }
          }
          else
          {
            $set_watermark_error = 'Unable tosaveimage! ';
          }
        }
      }
      else
      {
        $set_watermark_error = 'Unrecognized imageformat! ';
      }
    }
    else
    {
      $set_watermark_error = 'Source filedoesnotexist! ';
    }
  }
  return false;
}

Functia mai poate fi customizata pentru a intoarce si alte tipuri de imagine, dar lasam asta la alegerea fiecaruia.

Powered By Wordpress - Theme Provided By Wordpress Theme - Credit Loan