Tuesday, 29 March 2011

Know the status of your email in php

This is my requesting php file

This is my response php file


Thursday, 17 March 2011

CRON Path and settings in server


@minute - * * * * *


And paths that you need to try

/web/cgi-bin/php5 "$HOME/html/public_html/my.php"

php /home/*******/public_html/my.php

/home/*******/public_html

/web/cgi-bin/php5 -q /home/*******/public_html/my.php

/web/cgi-bin/php5 -q /home/*******/public_html/my.php

/web/cgi-bin/php5 $HOME/html/home/*******/public_html/html/my.php

/web/cgi-bin/php5 “$HOME/*******/public_html/my.php?

------------------------------------------------------------------------------
/usr/bin/php /home/*******/public_html/my.php
-----------------------------------------------------------------------------

Monday, 7 March 2011

Creating multiple like in a dynamic php page

Creating multiple like in a dynamic php page

1) Create the FB like code

2) Two formats

<.script src="http://connect.facebook.net/en_US/all.js#xfbml=1"><.fb:like href="http://*****/fb_like.php" show_faces="true" width="450" font="verdana">

<.iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2F*******%2F******%2Ffb_like.php&layout=standard&show_faces=true&width=450&action=like&font=verdana&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true">

3) I just used the first method

<.script src="http://connect.facebook.net/en_US/all.js#xfbml=1">

<.fb:like href="http://*****/fb_like.php?id=1" show_faces="true" width="450" font="verdana">

<.fb:like href="http://*****/fb_like.php?id=2" show_faces="true" width="450" font="verdana">

<.fb:like href="http://*****/fb_like.php?id=3" show_faces="true" width="450" font="verdana">

<.fb:like href="http://*****/fb_like.php?id=4" show_faces="true" width="450" font="verdana">



=========================

the above one is a XFBML (script code) that is non iframe code

Tuesday, 1 March 2011

group by order by

select * from ".DB_table." Where id IS NOT NULL GROUP BY blog_date ORDER BY id DESC

Tuesday, 22 February 2011

Add Search form in wordpress

have the code where ever you want

<...........form method='get' id='searchform' action='<.....?php bloginfo('home'); ........?..>/'>
<......div>
<........input type='text' size='18' value=' ' name='s' id='s' />
<.....input type='submit' id='searchsubmit' value='Search' class='btn' />
<....../div>

Wordpress add small description in the index page or the page you want to show

This is the function in your template function.php

if(!function_exists('getPageContent'))
{
function getPageContent($pageId,$max_char)
{
if(!is_numeric($pageId))
{
return;
}
global $wpdb;
$nsquery = 'SELECT DISTINCT * FROM ' . $wpdb->posts .
' WHERE ' . $wpdb->posts . '.ID=' . $pageId;
$post_data = $wpdb->get_results($nsquery);
if(!empty($post_data))
{
foreach($post_data as $post)
{
$text_out=nl2br($post->post_content);
$text_out=str_replace(']]>', ']]>', $text_out);
$text_out = strip_tags($text_out);
return substr($text_out,0,$max_char);

}
}
}
}


and just have the code where ever you want to have

<....?php echo getPageContent(39,65); .....?>
39 is the page ID

and 65 is the character set

Monday, 1 February 2010

Scribd Max page settings

Have the below settings:

while uploading we have to make the paid_content=1; and
have the scribd->changeSettings function open and pass the below
$doc_ids=$data['doc_id'];
$page_restriction_type="max_pages";
$max_pages=2;

Have the full code here:
examples.php
upload($file, $doc_type, $access, $rev_id, $paid_content);
$doc_ids=$data['doc_id'];
$page_restriction_type="max_pages";
$max_pages=2;
$data = $scribd->changeSettings($doc_ids, $page_restriction_type, $max_pages);
// returns Array ( [doc_id] => 1026598 [access_key] => key-23nvikunhtextwmdjm2i )
?>

scribd.php

api_key = $api_key;
$this->secret = $secret;
$this->url = "http://api.scribd.com/api?api_key=" . $api_key;
}


/**
* Upload a document from a file
* @param string $file : relative path to file
* @param string $doc_type : PDF, DOC, TXT, PPT, etc.
* @param string $access : public or private. Default is Public.
* @param int $rev_id : id of file to modify
* @return array containing doc_id, access_key, and secret_password if nessesary.
*/
public function upload($file, $doc_type = null, $access = null, $rev_id = null, $paid_content){
$method = "docs.upload";
$params['doc_type'] = $doc_type;
$params['access'] = $access;
$params['file'] = "@".$file;
$params['paid_content'] = $paid_content;
echo $method;
//print_r($params);
$result = $this->postRequest($method, $params);
//print_r($result);
return $result;
}


/**
* Upload a document from a Url
* @param string $url : absolute URL of file
* @param string $doc_type : PDF, DOC, TXT, PPT, etc.
* @param string $access : public or private. Default is Public.
* @return array containing doc_id, access_key, and secret_password if nessesary.
*/
public function uploadFromUrl($url, $doc_type = null, $access = null, $rev_id = null){
$method = "docs.uploadFromUrl";
$params['url'] = $url;
$params['access'] = $access;
$params['rev_id'] = $rev_id;
$params['doc_type'] = $doc_type;

$data_array = $this->postRequest($method, $params);
return $data_array;
}
/**
* Get a list of the current users files
* @return array containing doc_id, title, description, access_key, and conversion_status for all documents
*/
public function getList(){
$method = "docs.getList";

$result = $this->postRequest($method, $params);
return $result['resultset'];
}
/**
* Get the current conversion status of a document
* @param int $doc_id : document id
* @return string containing DISPLAYABLE", "DONE", "ERROR", or "PROCESSING" for the current document.
*/
public function getConversionStatus($doc_id){
$method = "docs.getConversionStatus";
$params['doc_id'] = $doc_id;

$result = $this->postRequest($method, $params);
return $result['conversion_status'];
}
/**
* Get settings of a document
* @return array containing doc_id, title , description , access, tags, show_ads, license, access_key, secret_password
*/
public function getSettings($doc_id){
$method = "docs.getSettings";
$params['doc_id'] = $doc_id;

$result = $this->postRequest($method, $params);
return $result;
}
/**
* Change settings of a document
* @param array $doc_ids : document id
* @param string $title : title of document
* @param string $description : description of document
* @param string $access : private, or public
* @param string $license : "by", "by-nc", "by-nc-nd", "by-nc-sa", "by-nd", "by-sa", "c" or "pd"
* @param string $access : private, or public
* @param array $show_ads : default, true, or false
* @param array $tags : list of tags
* @return string containing DISPLAYABLE", "DONE", "ERROR", or "PROCESSING" for the current document.
*/
public function changeSettings($doc_ids, $page_restriction_type, $max_pages){
$method = "docs.changeSettings";
$params['doc_ids'] = $doc_ids;
$params['page_restriction_type'] = $page_restriction_type;
$params['max_pages'] = $max_pages;

$result = $this->postRequest($method, $params);
return $result;
}
/**
* Delete a document
* @param int $doc_id : document id
* @return 1 on success;
*/
public function delete($doc_id){
$method = "docs.delete";
$params['doc_id'] = $doc_id;

$result = $this->postRequest($method, $params);
return $result;
}
/**
* Search the Scribd database
* @param string $query : search query
* @param int $num_results : number of results to return (10 default, 1000 max)
* @param int $num_start : number to start from
* @param string $scope : scope of search, "all" or "user"
* @return array of results, each of which contain doc_id, secret password, access_key, title, and description
*/
public function search($query, $num_results = null, $num_start = null, $scope = null){
$method = "docs.search";
$params['query'] = $query;
$params['num_results'] = $num_results;
$params['num_start'] = $num_start;
$params['scope'] = $scope;

$result = $this->postRequest($method, $params);

return $result['result_set'];
}
/**
* Login as a user
* @param string $username : username of user to log in
* @param string $password : password of user to log in
* @return array containing session_key, name, username, and user_id of the user;
*/
public function login($username, $password){
$method = "user.login";
$params['username'] = $username;
$params['password'] = $password;

$result = $this->postRequest($method, $params);
$this->session_key = $result['session_key'];
return $result;
}
/**
* Sign up a new user
* @param string $username : username of user to create
* @param string $password : password of user to create
* @param string $email : email address of user
* @param string $name : name of user
* @return array containing session_key, name, username, and user_id of the user;
*/
public function signup($username, $password, $email, $name = null){
$method = "user.signup";
$params['username'] = $username;
$params['password'] = $password;
$params['name'] = $name;
$params['email'] = $email;

$result = $this->postRequest($method, $params);
return $result;
}
private function postRequest($method, $params){
$params['method'] = $method;
$params['session_key'] = $this->session_key;
$params['my_user_id'] = $this->my_user_id;


$post_params = array();
foreach ($params as $key => &$val) {
if(!empty($val)){

if (is_array($val)) $val = implode(',', $val);
if($key != 'file' && substr($val, 0, 1) == "@"){
$val = chr(32).$val;
}

$post_params[$key] = $val;
}
}
$secret = $this->secret;
$post_params['api_sig'] = $this->generate_sig($params, $secret);
$request_url = $this->url;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params );
$xml = curl_exec( $ch );
$result = simplexml_load_string($xml);
curl_close($ch);

if($result['stat'] == 'fail'){

//This is ineffecient.
$error_array = (array)$result;
$error_array = (array)$error_array;
$error_array = (array)$error_array['error'];
$error_array = $error_array['@attributes'];
$this->error = $error_array['code'];

throw new Exception($error_array['message'], $error_array['code']);

return 0;

}
if($result['stat'] == "ok"){

//This is shifty. Works currently though.
$result = $this->convert_simplexml_to_array($result);
if(urlencode((string)$result) == "%0A%0A" && $this->error == 0){
$result = "1";
return $result;
}else{
return $result;
}
}
}

public static function generate_sig($params_array, $secret) {
$str = '';

ksort($params_array);
// Note: make sure that the signature parameter is not already included in
// $params_array.
foreach ($params_array as $k=>$v) {
$str .= $k . $v;
}
$str = $secret . $str;

return md5($str);
}

public static function convert_simplexml_to_array($sxml) {
$arr = array();
if ($sxml) {
foreach ($sxml as $k => $v) {
if($arr[$k]){
$arr[$k." ".(count($arr) + 1)] = self::convert_simplexml_to_array($v);
}else{
$arr[$k] = self::convert_simplexml_to_array($v);
}
}
}
if (sizeof($arr) > 0) {
return $arr;
} else {
return (string)$sxml;
}
}
}
?>




NA NA NIGAAA ... I code this