jquery list

  1. .is()
  2. .has()
  3. $.extend(obeject1, obeject2, obejectN );
  4. <script>$("td:gt(4)").css("text-decoration", "line-through");</script>
  5. .delegate()
  6. .clone() 
ajax form plugin  http://www.alajax.com/, [code] <pre>/** * ALAJAX auto sender for jQuery * Create an auto ajax sender from your basic HTML code. * @url http://www.alajax.com/ * @version 1.2 * CopyRight: GNU General Public License v2 * * Developed by: Alaa Badran * http://www.alajax.com/ * Email info@alajax.com * */ $ = jQuery; // Make sure its defined <!--more--> $.fn.alajax = function (options){ // sgObj is a holder for #gallery container.. Cashing it. var aObj = $(this); // contaciner object var aForm = ($(this).is('form') ? $(this):$(this).find('form').eq(0)); // Storing Form object var oid = $(this).attr('id'); // Storing the ID of current Object // Default settings. var settings = { type: 'text', // 'text', 'json' or 'xml' success: function(){}, error: function (){}, beforeSend: function (){}, postType: aForm.attr('method'), // Storing Form method.. POST or GET tourl: aForm.attr('action') // Storing URL to send data to }; settings = $.extend(settings, options); function _sendData(){ // Run AJAX function $.ajax({ type: settings.postType, url: settings.tourl, data: aForm.serialize(), dataType: settings.type, beforeSend: function (){ // add code here if you want to do something before sending the form settings.beforeSend(); }, success: function(data, textStatus, jqXHR){ // Add code here when send is successful. settings.success(data); }, error: function (jqXHR, textStatus, errorThrown){ //alert(errorThrown); settings.error(); } }); } /** * The initializer for this plugin. */ function _init(){ aForm.submit(function (event){ _sendData(); // Processing event.preventDefault(); // To disable form submitting. Submit will be by AJAX only using the function above. }); } return _init(); } // END of Plugin</pre> [/code]

14/01/2015

javascript split() and join() functions epual to the function explode() and implode() in php

[code] var str="How are you doing today?"; var n=str.split(" "); [/code] The result of n will be an array with the values: How,are,you,doing,today? [code] var fruits = ["Banana", "Orange", "Apple", "Mango"]; var energy = fruits.join(); [/code] The result of energy will be: Banana,Orange,Apple,Mango

14/01/2015

Extending phpmailer

Extending phpmailer (inheritance) Extending classes with inheritance is one of the most powerful features of object-oriented programming. It allows you to make changes to the original class for your own personal use without hacking the original classes. Plus, it is very easy to do. I've provided an example: Here's a class that extends the phpmailer class and sets the defaults for the particular site: PHP include file: mail.inc.php [php] require("phpmailer.inc.php"); class my_phpmailer extends phpmailer { // Set default variables for all new objects var $From = "from@email.com"; var $FromName = "Mailer"; var $Host = "smtp1.site.com;smtp2.site.com"; var $Mailer = "smtp"; var $WordWrap = 75; // Replace the default error_handler function error_handler($msg) { print("My Site Error"); print("Description:"); printf("%s", $msg); exit; } // Create an additional function function do_something($something) { // Place your new code here } } [/php] Now here's a normal PHP page in the site: Normal PHP file: mail_test.php [php]</pre> require("mail.inc.php"); // Instantiate your new class $mail = new my_phpmailer; // Now you only need to add the necessary stuff $mail->AddAddress("josh@site.com", "Josh Adams"); $mail->Subject = "Here is the subject"; $mail->Body = "This is the message body"; $mail->AddAttachment("c:/temp/11-10-00.zip"); $mail->Send(); // send message echo "Message was sent successfully"; [/php]

14/01/2015

Php money_format — Formats a number as a currency string

money_format — Formats a number as a currency string

[php]<?php

$number = 1234.56;

// let's print the international format for the en_US locale
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number) . "\n";
// USD 1,234.56
[/php]



[php]
// Italian national format with 2 decimals`
setlocale(LC_MONETARY, 'it_IT');
echo money_format('%.2n', $number) . "\n";
// Eu 1.234,56

// Using a negative number
$number = -1234.5672;

// US national format, using () for negative numbers
// and 10 digits for left precision
setlocale(LC_MONETARY, 'en_US');
echo money_format('%(#10n', $number) . "\n";
// ($        1,234.57)

// Similar format as above, adding the use of 2 digits of right
// precision and '*' as a fill character
echo money_format('%=*(#10.2n', $number) . "\n";
// ($********1,234.57)

// Let's justify to the left, with 14 positions of width, 8 digits of
// left precision, 2 of right precision, withouth grouping character
// and using the international format for the de_DE locale.
setlocale(LC_MONETARY, 'de_DE');
echo money_format('%=*^-14#8.2i', 1234.56) . "\n";
// Eu 1234,56****

// Let's add some blurb before and after the conversion specification
setlocale(LC_MONETARY, 'en_GB');
$fmt = 'The final value is %i (after a 10%% discount)';
echo money_format($fmt, 1234.56) . "\n";
// The final value is  GBP 1,234.56 (after a 10% discount)

?>

[/php]

14/01/2015

Php Math Functions List

floor — Round fractions down [php]<?php echo floor(4.3);   // 4 echo floor(9.999); // 9 echo floor(-3.14); // -4 ?>[/php] [/php]
fmod — Returns the floating point remainder (modulo) of the division of the arguments
[php]<?php
$x = 5.7;
$y = 1.3;
$r = fmod($x, $y);
// $r equals 0.5, because 4 * 1.3 + 0.5 = 5.7
?>

[/php]

ceil — Round fractions up

[php]<?php
echo ceil(4.3);    // 5
echo ceil(9.999);  // 10
echo ceil(-3.14);  // -3
?>

[/php]

round — Rounds a float

[php]<?php
echo round(3.4);         // 3
echo round(3.5);         // 4
echo round(3.6);         // 4
echo round(3.6, 0);      // 4
echo round(1.95583, 2);  // 1.96
echo round(1241757, -3); // 1242000
echo round(5.045, 2);    // 5.05
echo round(5.055, 2);    // 5.06
?>[/php]

number_format — Format a number with grouped thousands

[php]<?php

$number = 1234.56;

// english notation (default)
$english_format_number = number_format($number);
// 1,235

// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56

$number = 1234.5678;

// english notation without thousands separator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57

?>

[/php]
										

14/01/2015

Some php Functions

realpath — Returns canonicalized absolute pathname __DIR__ [php] echo realpath(__FILE__); [/php] output: /home/develop1/public_html/ContactForm.php parse_str parse_url     [php] print(__FILE__); echo '<br>'; echo'PATHINFO_DIRNAME: '. pathinfo(__FILE__, PATHINFO_DIRNAME); echo '<br>'; echo'PATHINFO_BASENAME: '. pathinfo(__FILE__, PATHINFO_BASENAME); echo '<br>'; echo'PATHINFO_EXTENSION: '. pathinfo(__FILE__, PATHINFO_EXTENSION); echo '<br>'; &nbsp; Output: /home/develop1/public_html/folder/example.php PATHINFO_DIRNAME: /home/develop1/public_html/folder PATHINFO_BASENAME: example.php PATHINFO_EXTENSION: php [/php]

14/01/2015

About

################################################ PHP Developer  and Linux Administrator ################################################ Name: Müslüm Çen website : www. webenfo.com Living in: Istanbul /Turkey Study: Computer Education and Instructional Technologies (Computer Science ) Facebook: www.facebook.com/muslum21 Skills: Math, Php- Mysql (OOP), linux (LAMP), python, js&jQuery,html-css Codeigniter , Zend, Smarty, Xtemplate, E-commerce Open Source publish ; Task management, cart21 shopping cart, artcms  coming soon ! ################################################ ################################################

14/01/2015

Php - OOP - method_exists function

method_exists: Checks if the class method exists in the given object. [php]<?php $directory = new Directory('.'); var_dump(method_exists($directory,'read'));  // return   bool(true)  if function exist ?>[/php] func_num_args — Returns the number of arguments passed to the function [php] <?php function foo() { $numargs = func_num_args(); echo "Number of arguments: $numargs\n"; } foo(1, 2, 3); ?> [/php] Output: Number of arguments: 3

14/01/2015

Php Date

[php] &nbsp; echo  mktime;  //  prints now $1day=86400; $1month=86400*30; strtotime — Parse about any English textual datetime description into a Unix timestamp strtotime("06/11/2013 12:30"); // return 12321423423 [/php] Formating Date : [php] echo date("m/d/Y H:i",mktime()); [/php]

14/01/2015

Php - OOP- call_user_func

call_user_func — Call the callback given by the first parameter [php] <?php error_reporting(E_ALL); function increment(&$var) { $var++; } $a = 0; call_user_func('increment', $a); echo $a."\n"; call_user_func_array('increment', array(&$a)); // You can use this instead before PHP 5.3 echo $a."\n"; ?> [/php] call_user_func_array — Call a callback with an array of parameters [php] <?php function foobar($arg, $arg2) { echo __FUNCTION__, " got $arg and $arg2\n"; } class foo { function bar($arg, $arg2) { echo __METHOD__, " got $arg and $arg2\n"; } } // Call the foobar() function with 2 arguments call_user_func_array("foobar", array("one", "two")); // Call the $foo->bar() method with 2 arguments $foo = new foo; call_user_func_array(array($foo, "bar"), array("three", "four")); ?> [/php]

14/01/2015

Cpanel SSL Certificate Configration

Requirement :
  • Unique ip address should be assigned to "www.yourdomain.com"  from WHM 
  • to make sure wheter it is assigned or not   enter ip address to web browser url  if the website opens that means it has been assigned.
  1. First, decide on what URL you'd like to use with your SSL certificate. The most popular choice is:
www.yourdomain.com but some people prefer yourdomain.com It is recommended that the www.yourdomain.com form is used since then the certificate will work with both https://www.yourdomain.com and https://yourdomain.com
  • Next, you need to generate a private key and a CSR (Certificate signing request). This can be done via cPanel. Login to cpanel and go to the section labeled "SSL Manager"
  • Click on the "Private Keys (KEY)" icon.
  • In the "Private Keys" screen, go down to the "Generate a New Key" section of the screen. Type in your URL (or select it from the drop-down) that you picked in Step 1. Remember, www.yourdomain.com is recommended. Make sure you do not include "https://" in the field for your domain name.
  • In the 'KeySize' dropdown, select 2048.
  • Click the 'Generate' button.
  • Go back to the "SSL Manager" screen and click on the icon for "Certificate Signing Requests (CSR)"
  • Use the form labeled "Generate a New Certificate Signing Request" to generate a CSR. Fill in the fields with the appropriate information. The passphrase has to be alpha-numeric. IMPORTANT! Be absolutely sure to create a passphrase you will remember (There is NOTHING we can do to recover this passphrase if forgotten). Fill in the other fields with the appropriate information.
  • Click the 'Generate' button.
  • Now you have a 'CSR' suitable for submission to the signing authority.
  • Click on the link in the email you received titled 'SSL Certificate Configuration Required'.
  • Choose your web server type. For cpanel accounts the webserver type is Apache+ModSSL
  • Paste the CSR you generated into the CSR text box.
  • Complete the Administrative Contact Information and click 'Click to Continue'.
  • On the next page, select the email address that will receive an approval email and click 'Finish'.
  • If the domain you are associating with this SSL Certificate has WHOIS Protection (also called ID Protection or Privacy Protection) the default email address may not be suitable. Please choose an email address that is working and accessible.
  • After completing the above process, your SSL cert will be emailed to you.
  • Go back to the cPanel "SSL Manager" and click on the "Certificates (CRT)" Icon.
  • Paste in your new certificate to the text area under "Upload a new Certificate" and click the "Upload" button.
  • You're almost done -- The SSL Manager stores your SSL info, but it does not install it into the web server. To complete the installation process, go back to the cPanel main screen and click on the "SSL/TLS Manager" Icon. Then choose "Activate SSL on Your Web Site (HTTPS)" (Note: If you don't see an "Activate SSL on Your Web Site (HTTPS)" option, it's probably because your account doesn't have a private IP address. You will need to open a request with our Support department to get a private IP assigned to your account. There is an additional charge for each IP).
  • If there is a currently active SSL host, click the 'Delete Host' button and confirm the deletion.
  • In the "SSL Installer" screen, first select your domain from the drop-down menu, then paste in the contents of your Certificate, Private Key, and your CA Bundle (CA Bundle may also be called Intermediate Certificate). Some of the fields may populate automatically when you select the domain. Pasting in the ones you are sure are correct is the best way to ensure success in this step.
  • Click the "Install Certificate" button to install your SSL certificate.
 

14/01/2015

Smarty - testInstall() Example

Example 14.52. testInstall()
[php] <?php require_once('Smarty.class.php'); $smarty = new Smarty(); $smarty->testInstall(); ?> [/php]
Name testInstall() — checks Smarty installation Description:
void testInstall();This function verifies that all required working folders of the Smarty installation can be accessed. It does output a corresponding protocoll.

14/01/2015

Sendin E-mail with PHPMailer Using Gmail Smtp

Sendin E-mail with  PHPMailer Using Gmail Smtp
Sendin E-mail with  PHPMailer Using Gmail Smtp  [php] require_once('../class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail             = new PHPMailer(); $body             = file_get_contents('contents.html'); $body             = preg_replace('/[\]/','',$body); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host       = "mail.yourdomain.com"; // SMTP server $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth   = true;                  // enable SMTP authentication $mail->SMTPSecure = "tls";                 // sets the prefix to the servier $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server $mail->Port       = 587;                   // set the SMTP port for the GMAIL server $mail->Username   = "yourusername@gmail.com";  // GMAIL username $mail->Password   = "yourpassword";            // GMAIL password $mail->SetFrom('name@yourdomain.com', 'First Last'); $mail->AddReplyTo("name@yourdomain.com","First Last"); $mail->Subject    = "PHPMailer Test Subject via smtp (Gmail), basic"; $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = "whoto@otherdomain.com"; $mail->AddAddress($address, "John Doe"); $mail->AddAttachment("images/phpmailer.gif");      // attachment $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } [/php]

14/01/2015

How to install vQmod and vQmod manager ?

Step1 : Installing vQmod

Step 2 : Installing vQmod Manager

Step1 : Installing vQmod ;

  1. download latest vqmod from following link then upload vqmod folder in the root folder
    http://code.google.com/p/vqmod/downloads/list

  2. after uploading vqmod folder it should looks like screenshot below

3.the go to the url to install vqmod : www.youshop.com/vqmod/install then you will see successful message after correct vqmod installation. Then follow Step2

Step 2 : Installing vQmod Manager ;

vQmod Manager is en opencart extension enable us “to upload vqmod xml file” and “view error logs by xml file ”

    1. Visit following link and download and upload the file to correct folder.
      http://www.opencart.com/index.php?route=extension/extension/info&extension_id=2969&filter_search=%20vqmod%20manager

    2. Then go to admin panel => Extensions => vQmod Manager => install and save . After that the menu under Extension will lookslike screenshot below

referance:  http://octutorial.com/index.php?route=product/product&product_id=47


14/01/2015

Regex quick reference

[abc] A single character of: a, b or c
[^abc] Any single character except: a, b, or c
[a-z] Any single character in the range a-z
[a-zA-Z] Any single character in the range a-z or A-Z
^ Start of line
$ End of line
\A Start of string
\z End of string
. Any single character
\s Any whitespace character
\S Any non-whitespace character
\d Any digit
\D Any non-digit
\w Any word character (letter, number, underscore)
\W Any non-word character
\b Any word boundary
(...) Capture everything enclosed
(a|b) a or b
a? Zero or one of a
a* Zero or more of a
a+ One or more of a
a{3} Exactly 3 of a
a{3,} 3 or more of a
a{3,6} Between 3 and 6 of a

14/01/2015

Smarty Template Control

This class provides a Web interface to create and edit text files.

It was meant to let an user edit Smarty template files but it can be used to edit other types of text files.

The class can generate an interface based on Web page forms to let the user choose and edit text file existing in a given directory or add a new text file.

 

 

Referans:

http://www.phpclasses.org/package/2156-PHP-Web-interface-to-create-and-edit-text-files.html


14/01/2015

Formcat, PHP, Smarty plug-in for client side form validation

Formcat is a class for performing form validation on the client side. Its goal is to generate Javascript code to validate forms before they are submited to the server. It works as a plug-in for the Smarty template engine. It is a good complement SmartyValidate plug-in that performs server side validation. It supports many built-in validation criteria: empty, range, length, checkbox, radio button, integer, float, email, credit card, list menu, date, date comparison, equality between fields, file size, file type, custom validator calls. {formcat ...} tags can be located anywhere in the templates, regardless of where the corresponding fields are located in the form. http://www.phpclasses.org/package/2051-PHP-Smarty-plug-in-for-client-side-form-validation.html

14/01/2015

Smultron Text Editor

Smultron

The Smultron text editor is a program built for Mac OS X and mobile iOS devices. The software has syntax highlighting features which include over 90 different languages. You can also create new documents stored in your iCloud account to retrieve from any computer. This is one rich IDE to grab right off the Mac App Store and it’s great for perfect developers.


14/01/2015

Gumby css framework

http://www.gumbyframework.com/features

 

Multiple, Nestable, Grids fit any project

Gumby Framework includes multiple types of grids with differentcolumn variations which enables you to be flexible throughout an entire project's lifecycle. From concept to deployment, Gumby Framework follows your lead.


14/01/2015

jQuery clear form function

  [code lang="js"] $.fn.clearForm = function() { return this.each(function() { var type = this.type, tag = this.tagName.toLowerCase(); if (tag == 'form') return $(':input',this).clearForm(); if (type == 'text' || type == 'password' || tag == 'textarea') this.value = ''; else if (type == 'checkbox' || type == 'radio') this.checked = false; else if (tag == 'select') this.selectedIndex = -1; }); }; [/code] How to use: $("#formID").clearForm();

14/01/2015