Posts

Showing posts from August, 2012

how to clean link using php

function clickable_link($var) { $text = $var; $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); $ret = ' ' . $text; $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1 \\2 ", $ret); $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1 \\2 ", $ret); $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1 \\2@\\3 ", $ret); $ret = substr($ret, 1); return $ret; } ------------------------------------------------------------- if you helpful my code please donate some few amount to developing and free to post. -------------------------------------------------------------

how to check ban-word user in put using php

function banned_words_chk($phrase) { global $conn, $config; $query = "SELECT word from bans_words"; $executequery = $conn->Execute($query); $bwords = $executequery->getarray(); $found = 0; $words = explode(" ", $phrase); foreach($words as $word) { foreach($bwords as $bword) { if($word == $bword[0]) { $found++; } else { $pos2 = strpos($word, $bword[0]); if($pos2 !== false) { $found++; } } } } if($found > 0) { return true; } else { return false; } } ------------------------------------------------------------- if you helpful my code please donate some few amount to developing and free to post. -------------------------------------------------------------

how to send mail html using php with example

function mailme($sendto,$sendername,$from,$subject,$sendmailbody,$bcc="") { global $SERVER_NAME; $subject = nl2br($subject); $sendmailbody = nl2br($sendmailbody); $sendto = $sendto; if($bcc!="") { $headers = "Bcc: ".$bcc."\n"; } $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=utf-8\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: PHP/"."MIME-Version: 1.0\n"; $headers .= "From: " . $from . "\n"; $headers .= "Content-Type: text/html\n"; mail("$sendto","$subject","$sendmailbody","$headers"); } ------------------------------------------------------------- if you helpful my code please donate some few amount to developing and free to post. -------------------------------------------------------------

how to get htmlenties tag value in joomla

//in controller page function store() { $row =& $this->getTable(); $data = JRequest::get( 'post'); /* Get proper HTML-code for your HTML-encoded field now by using JREQUEST_ALLOWHTML*/ $data['fielsd']=JRequest::getVar( 'fielsd', '', 'post', 'string', JREQUEST_ALLOWHTML ); /* now proceed as suggested */ $row->bind($data); ------------------------------------------------------------- if you helpful my code please donate some few amount to developing and free to post. -------------------------------------------------------------

you tube url parsing uisng php and play on web page

/* * YoutubeParser() PHP class * @author: takien * @version: 1.0 * @date: June 16, 2012 * URL: http://takien.com/864/php-how-to-parse-youtube-url-to-get-video-id-thumbnail-image-or-embed-code.php * * @param string $source content source to be parsed, eg: a string or page contains youtube links or videos. * @param boolean $unique whether the return should be unique (duplicate result will be removed) * @param boolean $suggested whether show suggested video after finished playing * @param boolean $https whether use https or http, default false ( http ) * @param string $width width of embeded video, default 420 * @param string $height height of embeded video, default 315 * @param boolean $privacy whether to use 'privacy enhanced mode or not', * if true then the returned Youtube domain would be youtube-nocookie.com */ class YoutubeParser{ var $source = ''; var $unique = false; var $suggested = false; var $https = false; var $privacy = false; var $width = 354; var $height = 2

mvc explanation simply

1).    Model:   The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser.   2).   View :   The view represents the presentation of the application. The view object refers to the model. It uses the query methods of the model to obtain the contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view's to maintain the consistency in its presentation when the model changes. 3).   Controller:   Whenever the user sends a request for something then it always go through the cont

how to url rewrite in open cart working good

step -1-> root index.php comment the default (common/seo_url) example below //$controller->addPreAction(new Action('common/seo_url'));    change to below code Step -2 create automatic_seo_url.php under catalog/controller/common/automatic_seo_url.php step3-> paste the class code into automatic_seo_url.php ----------------------------------------------------------------------------- <?php class ControllerCommonAutomaticSeoUrl extends Controller {     var $_products;     var    $_categories;     var $_tmp_cat_path = array();     var    $_manufacturers;     var    $_infos;     var $product_identifier = 'p';     var $category_identifier = 'c';     var $manufacturer_identifier = 'm';     var $info_identifier = 'i';     var $route_identifier = 'r';     var $_sep = '-';     var $_url_ext = ''; // .html, .php etc.         public function index() {         global $request;         // Add rewrite to url class         if (

how to dynamic url rewrite in htaccess using php

# paste below these code to htaccess and generate url you php link RewriteEngine On RewriteBase /opencart/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA] ------------------------------------------------------------- if you helpful my code please donate some few amount to developing and free to post. -------------------------------------------------------------

how to clean request string in php for prevent sql injection

function cleanit($text) { return htmlentities(strip_tags(stripslashes($text)), ENT_COMPAT, "UTF-8"); }

how to get country name through ip using php

<?php function countrynameFromIP($ipAddr) { ip2long($ipAddr)== -1 || ip2long($ipAddr) === false ? trigger_error("Invalid IP", E_USER_ERROR) : ""; $ipDetail=array(); //initialize a blank array $xml = file_get_contents("http://api.hostip.info/?ip=".$ipAddr); preg_match("@(\s)*(.*?)@si",$xml,$match); $ipDetail['city']=$match[2]; preg_match("@(.*?)@si",$xml,$matches); $ipDetail['country']=$matches[1]; //get the country name inside the node and preg_match("@(.*?)@si",$xml,$cc_match); $ipDetail['country_code']=$cc_match[1]; //assing the country code to array //return the array containing city, country and country code return $ipDetail; } echo $IPDetail=countrynameFromIP($_SERVER['REMOTE_ADDR']); ?> ------------------------------------------------------------- if you helpful my code please donate some few amount to developing and free to post. ------------------------------------------------

simple curl using php example

1- create post.php curl value paste below code --------------------------------------------------------- $Curl_Session = curl_init('http://127.0.0.1/test/getvalue.php');  curl_setopt ($Curl_Session, CURLOPT_POST, 1);  curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "Name=hari");  curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);  $ss=curl_exec ($Curl_Session);  curl_close ($Curl_Session); --------------------------------------------------- 2-create getvalue.php value paste below code --------------------------------------------------- if(isset($_REQUEST['Name'])){  echo $_REQUEST['Name']; }

how to create file using php and write some thing

$filename="bikash.txt"; $fx=fopen($filename,a); $string="heloo bikash"; fwrite($fx,$string); fclose($fx);

how to export into csv and xml using php and mysql query

SELECT * INTO OUTFILE "D:/bikash.csv" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\n" FROM bikash_tble http://127.0.0.1/test/test.php <?php $mysql=mysql_connect('localhost','root',''); mysql_select_db('test'); $select = "SELECT * FROM bikash_tbls"; $export = mysql_query ( $select ) or die ( "Sql error : " . mysql_error( ) ); $fields = mysql_num_fields ( $export ); for ( $i = 0; $i < $fields; $i++ ) {     $header .= mysql_field_name( $export , $i ) . "\t"; } while( $row = mysql_fetch_row( $export ) ) {     $line = '';     foreach( $row as $value )     {                                                    if ( ( !isset( $value ) ) || ( $value == "" ) )         {             $value = "\t";         }         else         {             $value = str_replace( '"' , '""' , $value );             $value

how to find number of parameter of function in php

<?php function bikash_args() { echo "Number of arguments: " . func_num_args() . "<br />"; for($i = 0 ; $i < func_num_args(); $i++) { echo "Argument $i = " . func_get_arg($i) . "<br />"; $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) { echo "Argument $i is: " . $arg_list[$i] . " \n"; }  } bikash_args("a1", "b2", "c3", "d4", "e5"); ?>

you tube url parsing uisng php

/* step-1 create class YoutubeParserbybikash.php and include your page this class file and create obeject  and pass your youtube url  class YoutubeParserbybikash{ var $source = ''; var $unique = false; var $suggested = false; var $https = false; var $privacy = false; var $width = 354; var $height = 234; function __construct(){ } function set($key,$val){ return $this->$key = $val; } function playyoutube(){ $return = Array(); $domain = 'http'.($this->https?'s':'').'://www.youtube'.($this->privacy?'-nocookie':'').'.com'; $size = 'width="'.$this->width.'" height="'.$this->height.'"'; preg_match_all('/(youtu.be\/|\/watch\?v=|\/embed\/)([a-z0-9\-_]+)/i',$this->source,$matches); if(isset($matches[2])){ if($this->unique){ $matches[2] = array_values(array_unique($matches[2])); } foreach($matches[2] as $key=>$id) { $return[$key]['id'] = $id; $return[

how to assign ip and create user in mysql

setp 1-  > CREATE USER 'bikash'@'localhost' IDENTIFIED BY 'password'; step 2--> GRANT ALL PRIVILEGES ON demo . * TO bikash@localhost IDENTIFIED BY '123456' GRANT ALL PRIVILEGES ON bikash_db. * TO 'bikash'@'%' IDENTIFIED BY 'tt@12345'; remote access- GRANT ALL PRIVILEGES ON *.* TO 'bikash'@'%' IDENTIFIED BY 'tt@12345'; FLUSH PRIVILEGES;

htaccess dynamic url rewrite

root/.htaccess profile.php?uname=bikash it will show /bikash ------------------------------------ RewriteEngine On RewriteBase / RewriteRule ^confirmemail/(.*) confirmemail.php?code=$1 RewriteRule ^resetpassword/(.*) resetpassword.php?code=$1 RewriteRule ^resendconfirmation/(.*) resendconfirmation.php?userid=$1 RewriteRule ^widget$ widget.php RewriteRule ^profile/(.*)/(.*) redirect.php?id=$1&username=$2 RewriteRule ^([^/.]+)(\/)?$ profile.php?uname=$1 # Turn off mod_security filtering. SecFilterEngine Off # The below probably isn't needed, # but better safe than sorry. SecFilterScanPOST Off ------------------------------------------------------------- if you helpful my code please donate some few amount to developing and free to post. -------------------------------------------------------------

how to swapping update query table row 0 to 1 and 1 to 0

mysql update query 1 to 0 and 0 to 1 single statement using query update users set banned= case  when banned= "0"  then 1 when banned= "1"  then 0 end

Load Data while Scrolling Page Down with jQuery and PHP

<script type="text/javascript">     var page = 1;     function getFeedItems() {         $('.loading').show();         $.ajax({             url : 'loadmore.php',             data : 'page=' + page,             type : 'GET',             success: function(a) {                 if (a == '') {                     $('#feed-list').append('<li>No more records found.</li>');                     $(window).scroll(function() {});                     $('.loading').hide();                 } else {                     $('#feed-list').append(a);                     $('.loading').hide();                 }                             }         });     }     $(document).ready(function() {         getFeedItems();         $(window).scroll(function() {     if($(window).scrollTop() == $(document).height() - $(window).height())     {         page = page+1;     getFeedItems();     } });     }); </script

paypal subscriber form with html

<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">                               <input type="hidden" name="cmd" value="_xclick-subscriptions">                         <input type="hidden" name="business" value=" me@mybusiness.com ">                         <input type="hidden" name="cmd" value="_xclick-subscriptions">                         <input type="hidden" name="item_name" value="ESP 365 - Extreme. Dally" />                         <input type="hidden" name="currency_code" value="USD">                         <input type="hidden" name="no_shipping" value="1">                                              <input type="hidden" name="a1" value="0">            

multiple retaltional query using 4 table mysql

UserID | Name ———————— 1 | John 2 | Mike 3 | Tom Teams: TeamID | Name ——————————- 1 | FC Barcelona 2 | Real Madrid 3 | Manchester United 4 | Liverpool Permissions: PermissionsID | Name ——————————- 1 | Read Comments 2 | Write Comments 3 | Send Email 4 | Admin UserTeams: ID | UserID | TeamID | PermissionID ——————————————– 1 | 1 | 1 | 1 2 | 3 | 1 | 2 3 | 2 | 1 | 4 4 | 4 | 2 | 1 4 | 1 | 4 | 3 SELECT p.Name AS Permission, u.pseudo AS User_name, t.Name AS Team, u.id AS User_id FROM userteams AS ut INNER JOIN users AS u ON (ut.UserId = u.id) INNER JOIN teams AS t ON (ut.TeamId = t.TeamId) INNER JOIN permissions AS p ON (ut.PermissionId = p.permissionsId) WHERE u.id= ut.userId ------------------------------------------------------------- if you helpful my code please donate some few amount to developing and free to post. ----------------------------------

Explain the difference between abstract class and interfaces with an example for each.

Explain the difference between abstract class and interfaces with an example for each. The differences between abstract class and interface are as follows: Abstract Class Interface Can have abstract methods and concrete methods Can have only method signatures and static final members All methods are not by default public All methods by default abstract and public An abstract class can extend another abstract class An interface can extend another interface but not a class The extended class can override the methods of its super class and its hierarchy An implementing class can implement multiple interfaces All abstract methods must have abstract access modifier All methods in an interface must not have abstract access modifier The following examples illustrate the differences: abstract class Shape {        abstract void area();        abstract void perimeter();        void someMethod() // concrete method        {               ..       

Android Interview Questions and Answers

Image
Android Interview Questions and Answers Describe Android Application Architecture. Android Application Architecture has the following components: • Services – like Network Operation • Intent – To perform inter-communication between activities or services • Resource Externalization – such as strings and graphics • Notification signaling users – light, sound, icon, notification, dialog etc. • Content Providers – They share data between applications Describe a real time scenario where android can be used? Imagine a situation that you are in a country where no one understands the language you speak and you can not read or write. However, you have mobile phone with you. With a mobile phone with android, the Google translator translates the data of one language into another language by using XMPP to transmit data. You can type the message in English and select the language which is understood by the citizens of the country in order to reach the message to the citizens. What’s the difference