tag:blogger.com,1999:blog-24509224400850911662024-03-13T10:21:39.764+05:30Rubyid10Php & ROR Developerrubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-2450922440085091166.post-46929967154297811052010-09-02T15:33:00.001+05:302010-09-10T17:50:59.021+05:30How to get the distance between to location using the google map?When we calculate the distance between two lat & long the distance would the air to air so distance is wrong,so you have to send both lat & long to google to get the driving distance.<br />
Given below the code for it.<br />
//intiat curl<br />
$ch = curl_init();<br />
//pass the both start and end lat & long<br />
//check google map doc for option<br />
//mode=driving is for driving distance<br />
//sensor=false for site ,for mobile then it is true<br />
//reponse is json<br />
curl_setopt($ch, CURLOPT_URL,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>"http://maps.google.com/maps/api/directions/json?origin=".trim($latitude).",".trim($longitude)."&destination=".$obj->latitude.",".$obj->longitude."&mode=driving&alternatives=false&units=imperial&sensor=false");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$contents = curl_exec ($ch);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$contents=json_decode($contents);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$distance=$contents->routes[0]->legs[0]->distance->text<br />
<div><br />
</div>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-58816018733820108752010-09-02T15:19:00.000+05:302010-09-02T15:19:51.105+05:30Working with php & ffmpeg<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;"><div>This the code for convert video using the ffmpeg.The php use the ffmpeg insstall in Linux system.</div><div>for the option please out the web site of <a href="http://www.ffmpeg.org/">ffmpeg</a></div><div><br />
</div><div><br />
</div></span></span><div><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><div><br />
</div><div>$uploadfile <span class="Apple-tab-span" style="white-space: pre;"> </span>= "t1.3gp";</div><div>$uploadfile_flv = "video.flv";</div><div><br />
</div><div>//shell_exec('ffmpeg -i '.$uploadfile.' -acodec libmp3lame -map_meta_data '.$uploadfile_flv.':'.$uploadfile.' -ar 22050 -ab 64000 -deinterlace -nr 500 -s 320x240 -aspect 4:3 -r 20 -g 500 -me_range 20 -b 200k -f flv -y '.$uploadfile_flv);</div><div><br />
</div><div>shell_exec('ffmpeg -i '.$uploadfile.' -ar 22050 -ab 64000 -deinterlace -nr 500 -s 320x240 -aspect 4:3 -r 20 -g 500 -me_range 20 -b 200k -f flv -y '.$uploadfile_flv);</div><div><br />
</div><div>echo ('ffmpeg -i '.$uploadfile.' -ar 22050 -ab 64000 -deinterlace -nr 500 -s 320x240 -aspect 4:3 -r 20 -g 500 -me_range 20 -b 200k -f flv -y '.$uploadfile_flv);</div><div><br />
</div><div><br />
</div><div>//$flvMetaUpdateCmd = "flvtool2 -U ".$uploadfile_flv;</div><div><br />
</div><div>$uploaddir <span class="Apple-tab-span" style="white-space: pre;"> </span>= "./";</div><div>$png_file_name<span class="Apple-tab-span" style="white-space: pre;"> </span>= "preview";</div><div><br />
</div><div>shell_exec("ffmpeg -i ".$uploadfile." -vcodec png -ss 00:00:05 -vframes 1 -an -f rawvideo -s 320x240 -y ".$uploaddir.$png_file_name.".png");</div><div><br />
</div><div>echo "<br />
<br />
File Converted...";</div><div><br />
</div><div>?></div></span></div>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-7282133404682015102010-09-02T15:14:00.001+05:302010-09-02T15:15:20.975+05:30How to create the application.ini in zend<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;"> The code explain every thing</span></span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//this for all error reporting<br />
error_reporting(E_ALL|E_STRICT);<br />
// Define path to application directory<br />
defined('APPLICATION_PATH')<br />
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));<br />
<br />
// Define application environment<br />
defined('APPLICATION_ENV')<br />
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));<br />
<br />
// Ensure library/ is on include_path<br />
set_include_path(implode(PATH_SEPARATOR, array(<br />
realpath(APPLICATION_PATH . '/../library'),<br />
get_include_path(),<br />
)));<br />
<br />
//database<br />
<br />
<br />
/** Zend_Application */<br />
require_once 'Zend/Application.php'; <br />
<br />
// Create application, bootstrap, and run<br />
$application = new Zend_Application(<br />
APPLICATION_ENV,<br />
APPLICATION_PATH . '/configs/application.ini'<br />
);<br />
//to store the object/array/var in system use the register<br />
require_once 'Zend/Registry.php';<br />
//this for mysql connection<br />
require_once 'Zend/Db/Adapter/Pdo/Mysql.php';<br />
<br />
Zend_Registry::set('varname',"value of var");<br />
//there are two way of setting the database connection<br />
//first by setting the using the Zend_Db_Adapter_Pdo_Mysql<br />
//second using the Zend_Db:factory<br />
/*$params = array('host'<span class="Apple-tab-span" style="white-space: pre;"> </span>=>'localhost',<br />
'username'<span class="Apple-tab-span" style="white-space: pre;"> </span>=>'root',<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'password' =>'password',<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'dbname'<span class="Apple-tab-span" style="white-space: pre;"> </span>=>'zend'<br />
);<br />
<br />
<br />
$db=new Zend_Db_Adapter_Pdo_Mysql($params);<br />
$db->setFetchMode(Zend_Db::FETCH_OBJ);*/<br />
//this for load the application varibles,first parametes is application ini path & second is<br />
//blok in application ini<br />
$config=new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini','general');<br />
$db= Zend_Db::factory($config->db->adapter,$config->db->params->toArray());<br />
Zend_Registry::set('db',$db);<br />
<br />
$application->bootstrap()<br />
->run();rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-24113294095419085092010-06-05T07:49:00.000+05:302010-06-05T07:49:15.091+05:30How to convert base64 string into image with php? First of all create the base64 string<br />
<br />
<i> function encode_img($img)<br />
{<br />
$fd = fopen ($img, 'rb');<br />
$size=filesize ($img);<br />
$cont = fread ($fd, $size);<br />
fclose ($fd);<br />
$encimg = base64_encode($cont);<br />
return $encimg;<br />
} <br />
<br />
$image_base64=encode_img('123.jpg'); // to encode the image <br />
<br />
then convert back to image into some location<br />
<br />
$img = imagecreatefromstring(base64_decode($image_base64));<br />
if($img != false)<br />
{<br />
imagejpeg($img, 'user_images/image.jpg');<br />
} </i><br />
<br />
Have Dream Dayrubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com3tag:blogger.com,1999:blog-2450922440085091166.post-60924156586103261722010-06-05T07:15:00.002+05:302010-06-05T13:33:25.164+05:30Mysql query return the count from multiple table with left joinThis the MySQL query with table where home table has one to many relation with many table,<br />
Here is code that return the count from multiple table.<br />
<br />
<br />
select h.id,h.home_name,count(n.home_id) as ncount,<br />
count(e.home_id) as ecount,count(b.home_id) as bcount,<br />
count(s.home_id) as scount <br />
from home as h left join news as n on (h.id=n.home_club_id)<br />
left join events as e on (h.id=e.home_id)<br />
left join billboard as b on (h.id=b.home_id)<br />
left join store as s on(h.id=s.home_id) where 1<br />
<br />
Have Dream Dayrubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-64318286149220275002010-05-18T19:28:00.000+05:302010-05-18T19:28:19.209+05:30Inline edit using the jQuery/PhpHi,<br />
here code for you,that did not need the any plug-in <br />
<i><span style="color: #444444;"> </span></i><span style="color: #444444;"> Just copy pest the code and add class </span><i><span style="color: #444444;">to element so the it can peek up</span></i><br />
<i><span style="color: #444444;"> </span></i><span style="color: #444444;"> class name "editable"</span><br />
<span style="color: #444444;"> and also give id to the each div or span like</span><i><span style="color: #444444;"> "<span class="editable" id="1">Aesop</span>"</span></i><br />
<span style="color: #444444;"> so that u can fetch the id of the element</span><i><span style="color: #444444;"><br />
</span></i><br />
<i><span style="color: #444444;"> function($) {</span><br style="color: #444444;" /><br style="color: #444444;" /><span style="color: #444444;"> $.fn.inlineEdit = function(options) {</span><br style="color: #444444;" /><span style="color: #444444;"> </span><br style="color: #444444;" /><span style="color: #444444;"> options = $.extend({</span><br style="color: #444444;" /><span style="color: #444444;"> hover: 'hover',</span><br style="color: #444444;" /><span style="color: #444444;"> value: '',</span><br style="color: #444444;" /><span style="color: #444444;"> save: '',</span><br style="color: #444444;" /><span style="color: #444444;"> buttonText: 'Save',</span><br style="color: #444444;" /><span style="color: #444444;"> placeholder: 'Click to edit'</span><br style="color: #444444;" /><span style="color: #444444;"> }, options);</span><br style="color: #444444;" /><br style="color: #444444;" /><span style="color: #444444;"> return $.each(this, function() {</span><br style="color: #444444;" /><span style="color: #444444;"> $.inlineEdit(this, options);</span><br style="color: #444444;" /><span style="color: #444444;"> });</span><br style="color: #444444;" /><span style="color: #444444;"> }</span><br style="color: #444444;" /><br style="color: #444444;" /><span style="color: #444444;"> $.inlineEdit = function(obj, options) {</span><br style="color: #444444;" /><span style="color: #444444;"> </span><br style="color: #444444;" /><span style="color: #444444;"> var self = $(obj),</span><br style="color: #444444;" /><span style="color: #444444;"> placeholderHtml = '<span class="inlineEdit-placeholder">'+ options.placeholder +'</span>';</span><br style="color: #444444;" /><span style="color: #444444;"> </span><br style="color: #444444;" /><span style="color: #444444;"> self.value = function(newValue) {</span><br style="color: #444444;" /><span style="color: #444444;"> if (arguments.length) {</span><br style="color: #444444;" /><span style="color: #444444;"> self.data('value', $(newValue).hasClass('inlineEdit-placeholder') ? '' : newValue);</span><br style="color: #444444;" /><span style="color: #444444;"> }</span><br style="color: #444444;" /><span style="color: #444444;"> return self.data('value');</span><br style="color: #444444;" /><span style="color: #444444;"> }</span><br style="color: #444444;" /><span style="color: #444444;"> self.value($.trim(self.text()) || options.value);</span><br style="color: #444444;" /><br style="color: #444444;" /><span style="color: #444444;"> self.bind('click', function(event) {</span><br style="color: #444444;" /><span style="color: #444444;"> </span><br style="color: #444444;" /><span style="color: #444444;"> var $this = $(event.target);</span><br style="color: #444444;" /><span style="color: #444444;"> </span><br style="color: #444444;" /><span style="color: #444444;"> if ($this.is('button')) {</span><br style="color: #444444;" /><span style="color: #444444;"> var hash = {</span><br style="color: #444444;" /><span style="color: #444444;"> value: $input = $this.siblings('input').val(),</span></i><br />
<i><span style="color: #444444;"> //add more values here </span><br style="color: #444444;" /><span style="color: #444444;"> id :$this.siblings('input').attr('id')</span><br style="color: #444444;" /><span style="color: #444444;"> };</span><br style="color: #444444;" /><span style="color: #444444;"> </span><br style="color: #444444;" /><span style="color: #444444;"> if (($.isFunction(options.save) && options.save.call(self, event, hash)) !== false || !options.save) {</span><br style="color: #444444;" /><span style="color: #444444;"> self.value(hash.value);</span></i><br />
<i><span style="color: #444444;"> //self is the element which is click </span></i><br />
<i><span style="color: #444444;"> //if you want add other var then add here</span><br style="color: #444444;" /><span style="color: #444444;"> self.id = hash.id ;</span><br style="color: #444444;" /><span style="color: #444444;"> }</span><br style="color: #444444;" /><span style="color: #444444;"> </span><br style="color: #444444;" /><span style="color: #444444;"> } else if ($this.is(self[0].tagName) || $this.hasClass('inlineEdit-placeholder')) {</span><br style="color: #444444;" /><span style="color: #444444;"> self</span><br style="color: #444444;" /><span style="color: #444444;"> .html('<input id="'+$this.attr('id')+'" type="text" value="'+ self.value() +'" /> <button>'+ options.buttonText +'</button>')</span><br style="color: #444444;" /><span style="color: #444444;"> .find('input')</span><br style="color: #444444;" /><span style="color: #444444;"> .bind('blur', function() {</span><br style="color: #444444;" /><span style="color: #444444;"> if (self.timer) {</span><br style="color: #444444;" /><span style="color: #444444;"> window.clearTimeout(self.timer);</span><br style="color: #444444;" /><span style="color: #444444;"> }</span><br style="color: #444444;" /><span style="color: #444444;"> self.timer = window.setTimeout(function() {</span><br style="color: #444444;" /><span style="color: #444444;"> self.html(self.value() || placeholderHtml);</span><br style="color: #444444;" /><span style="color: #444444;"> self.removeClass(options.hover);</span><br style="color: #444444;" /><span style="color: #444444;"> }, 200);</span><br style="color: #444444;" /><span style="color: #444444;"> })</span><br style="color: #444444;" /><span style="color: #444444;"> .focus();</span><br style="color: #444444;" /><span style="color: #444444;"> }</span><br style="color: #444444;" /><span style="color: #444444;"> })</span><br style="color: #444444;" /><span style="color: #444444;"> .hover(</span><br style="color: #444444;" /><span style="color: #444444;"> function(){</span><br style="color: #444444;" /><span style="color: #444444;"> $(this).addClass(options.hover);</span><br style="color: #444444;" /><span style="color: #444444;"> },</span><br style="color: #444444;" /><span style="color: #444444;"> function(){</span><br style="color: #444444;" /><span style="color: #444444;"> $(this).removeClass(options.hover);</span><br style="color: #444444;" /><span style="color: #444444;"> }</span><br style="color: #444444;" /><span style="color: #444444;"> );</span><br style="color: #444444;" /><br style="color: #444444;" /><span style="color: #444444;"> if (!self.value()) {</span><br style="color: #444444;" /><span style="color: #444444;"> self.html($(placeholderHtml));</span><br style="color: #444444;" /><span style="color: #444444;"> } else if (options.value) {</span><br style="color: #444444;" /><span style="color: #444444;"> self.html(options.value);</span><br style="color: #444444;" /><span style="color: #444444;"> }</span><br style="color: #444444;" /><span style="color: #444444;"> }</span><br style="color: #444444;" /><br style="color: #444444;" /><span style="color: #444444;">})(jQuery);</span></i><br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="color: #444444;">jQuery(function(){</span><br style="color: #444444;" /><span style="color: #444444;"> </span><br style="color: #444444;" /><span style="color: #444444;"> </span><i style="color: #444444;"> jQuery('.editable').inlineEdit({<br />
buttonText : 'Save',<br />
save: function(e,data) {<br />
//alert(data.id);<br />
var parent_id = jQuery('#cat').val();<br />
e.preventDefault();<br />
//return confirm('You are about to change your name to "'+ data.value +'"\n\nAre you sure?'); </i><br />
<i style="color: #444444;"> //this is ajax call<br />
jQuery.ajax({<br />
type: "GET",<br />
url: ''+data.id+'&name='+data.value+'&parent_id='+parent_id,<br />
success: function(res) <br />
{<br />
<br />
if(res == 0)<br />
{<br />
alert('Category name already exists,please use another name');<br />
jQuery('#'+data.id).html('Edit Category');<br />
}<br />
}<br />
});//ajax end<br />
}//save callback function end<br />
});//inline edit function end<br />
});//jquery function end</i><br />
<br />
Have Dream Dayrubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-43848627933756903062010-04-26T18:56:00.001+05:302010-05-18T19:15:16.035+05:30how to clean the url in php?Hi<br />
This is the code for remove the unwanted charecter from the uploaded file<br />
<br />
<i> $_FILES['image']['name'] = strtolower(trim($_FILES['image']['name']));<br />
$_FILES['image']['name'] = str_replace(array('\'',' ','\#','\$','\&','\!','\@','\#','\$','\%','\^','\&','\*','\(','\)','\_',<br />
'\+','\{','\}'),'', $_FILES['image']['name']);</i><br />
<br />
<br />
have dream dayrubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-12730738889055840402010-04-23T18:31:00.002+05:302010-04-26T18:57:26.603+05:30Zend Framework Tutorials1.first set the bootstrap<br />
<br />
<i style="color: purple;"> protected function _initAppAutoload()<br />
{<br />
$moduleLoad = new Zend_Application_Module_Autoloader(array(<br />
'namespace' => '',<br />
'basePath' => APPLICATION_PATH<br />
));<br />
}</i><br />
<br />
2.set up the database connection in another class file or config.ini<br />
first write code in ini file <br />
<i> <span style="color: purple;">[general]</span><br style="color: purple;" /><span style="color: purple;"> db.adapter = PDO_MYSQL</span><br style="color: purple;" /><span style="color: purple;"> db.config.host = localhost</span><br style="color: purple;" /><span style="color: purple;"> db.config.user = root</span><br style="color: purple;" /><span style="color: purple;"> db.config.password = password</span><br style="color: purple;" /><span style="color: purple;"> db.config.dbname = zend</span></i><br />
<br />
then in public index.php write code<br />
<i> <br style="color: black;" /><span style="color: purple;">$config =new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini','general');</span><br style="color: purple;" /><span style="color: purple;">Zend_Registry::set('config',$config);</span><br style="color: purple;" /><span style="color: purple;">//database</span><br style="color: purple;" /><span style="color: purple;">$db = Zend_Db::factory($config->db->adapter,$config->db->config->toArray());</span><br style="color: purple;" /><span style="color: purple;">Zend_Db_Table::setDefaultAdapter($db);</span></i><br />
<br />
3.create the class in model and give the name of the tablerubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-23864718490937105372010-04-23T11:18:00.000+05:302010-04-23T11:18:32.428+05:30Zend Framework,bootstrap file autoloadHi,<br />
If you want to access the any model or other class then in application folder,the you must auto load the class in bootstrap file,and write the code below<br />
<br />
<i> protected function _initAppAutoload()<br />
{<br />
$moduleLoad = new Zend_Application_Module_Autoloader(array(<br />
'namespace' => '',<br />
'basePath' => APPLICATION_PATH<br />
));<br />
}</i><br />
<br />
Have Dream Dayrubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-34205936953000652872010-03-22T09:54:00.002+05:302010-04-19T18:35:47.840+05:30XMLRPC classHi,<br />
This the class for xmlrpc, <a href="http://sites.google.com/site/rubyid10/Home/classfile.php?attredirects=0&d=1"> download</a><br />
for more details <a href="http://scripts.incutio.com/xmlrpc/basic-server-construction.php">click here</a> <br />
test file<br />
<br />
include_once "classfile.php";<br />
//echo "wp.getUsersBlogs";<br />
$client = new IXR_Client('http://localhost');<br />
echo "method name"."<br />
";<br />
if(!$client->query('method name','param1','param1'))<br />
{<br />
die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());<br />
<br />
}rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-66275167042683081862010-03-20T09:28:00.000+05:302010-03-20T09:28:32.459+05:30Wordpress plug-in that upload image with postHi<br />
I am here to give source code for plug-in that upload image with each post and store the data in post meta.<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code><?php
/*
Plugin Name: artical
Version: 1.0
Plugin URI: http://rubyid10.blogspot.com
Author: Sameer
Author URI: http://rubyid10.blogspot.com
Description: Tool to add custom files to post
*/
define('ARTICAL_FOLDER', dirname(plugin_basename(__FILE__)));
define(DIRECTORY_SEPARATOR,'/');
define('ARTICAL_IMG_WEBSITE_FULLPATH',WP_CONTENT_DIR."/uploads/artical/website/");
define('ARTICAL_IMG_WEBSITE_URL', get_option('siteurl').'/wp-content/uploads/artical/website/');
define('ARTICAL_IMG_IPHONE_FULLPATH',WP_CONTENT_DIR."/uploads/artical/iphone/");
define('ARTICAL_IMG_IPHONE_URL', get_option('siteurl').'/wp-content/uploads/artical/iphone/');
define('THUMB_WIDTH',60);
define('THUMB_HEIGHT',60);
define('ARTICAL_IMG_INTER_FULLPATH',WP_CONTENT_DIR."/uploads/artical/inter/");
define('ARTICAL_IMG_INTER_URL', get_option('siteurl').'/wp-content/uploads/artical/inter/');
define('INTER_WIDTH',150);
define('INTER_HEIGHT',150);
////////////////////////////////
define('GALLERY_IMG_WEBSITE_FULLPATH',WP_CONTENT_DIR."/uploads/gallery/website/");
define('GALLERY_IMG_WEBSITE_URL', get_option('siteurl').'/wp-content/uploads/gallery/website/');
define('GALLERY_IMG_IPHONE_FULLPATH',WP_CONTENT_DIR."/uploads/gallery/iphone/");
define('GALLERY_IMG_IPHONE_URL', get_option('siteurl').'/wp-content/uploads/gallery/iphone/');
define('GALLERY_THUMB_WIDTH',60);
define('GALLERY_THUMB_HEIGHT',60);
define('GALLERY_IMG_INTER_FULLPATH',WP_CONTENT_DIR."/uploads/gallery/inter/");
define('GALLERY_IMG_INTER_URL', get_option('siteurl').'/wp-content/uploads/gallery/inter/');
define('GALLERY_INTER_WIDTH',150);
define('GALLERY_INTER_HEIGHT',150);
//////////////////////////////////////////////////////////
define('BLOG_IMG_WEBSITE_FULLPATH',WP_CONTENT_DIR."/uploads/blog/website/");
define('BLOG_IMG_WEBSITE_URL', get_option('siteurl').'/wp-content/uploads/blog/website/');
define('BLOG_IMG_IPHONE_FULLPATH',WP_CONTENT_DIR."/uploads/blog/iphone/");
define('BLOG_IMG_IPHONE_URL', get_option('siteurl').'/wp-content/uploads/blog/iphone/');
define('BLOG_THUMB_WIDTH',60);
define('BLOG_THUMB_HEIGHT',60);
define('BLOG_IMG_INTER_FULLPATH',WP_CONTENT_DIR."/uploads/blog/inter/");
define('BLOG_IMG_INTER_URL', get_option('siteurl').'/wp-content/uploads/blog/inter/');
define('BLOG_INTER_WIDTH',150);
define('BLOG_INTER_HEIGHT',150);
define('UPLOAD_IMAGE_TYPE','gif,png,jpeg,jpg');
//t
add_action('admin_menu','change_form');
/* Use the admin_menu action to define the custom boxes */
//this will add artical_gallery_blog box
add_action('admin_menu', 'add_artical_gallery_blog');
/* Use the save_post action to do something with the data entered */
add_action('save_post', 'artical_save_postdata');
function change_form()
{
ob_start("modify_buffer");
}
function modify_buffer( $buffer )
{
$buffer = str_replace( '<form name="post"', '<form name="post" enctype="multipart/form-data"',
$buffer );
return $buffer;
}
/* Adds a custom section to the "advanced" Post and Page edit screens */
///////////////////////////////////////////////////////////////////////////
function add_artical_gallery_blog()
{
if( function_exists( 'add_meta_box' ))
{
/////////////////add artical
add_meta_box( 'artical_id', __( 'Image Upload', 'myplugin_textdomain' ),
'artical_custom_box', 'post', 'advanced','high' );
add_meta_box( 'artical_id', __( 'Image Upload', 'myplugin_textdomain' ),
'artical_custom_box', 'page', 'advanced' );
}
}
///////////////////////////////////////////////////////////////////
/* Prints the inner fields for the custom post/page section */
//////////////////this for get the category image,used in xmlrpc response
function get_category_image_names( $cat_id = false, $type = false )
{
$category_image_names = get_option( 'ciii_image_names' );
if ( $cat_id !== false && $type ) {
return $category_image_names[ $cat_id ][ $type ];
}
if ( $cat_id !== false ) {
if ( ! isset( $category_image_names[ $cat_id ] ) ) return false;
return $category_image_names[ $cat_id ];
}
return $category_image_names;
}
////////////////////////////////////////////////////////////////////////////////////
function artical_custom_box()
{
// Use nonce for verification
echo '<input type="hidden" name="myplugin_noncename" id="myplugin_noncename" value="' .
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
// The actual fields for data entry
// $image_meta_data = get_post_meta($_GET['post'], '_artical',true);
if($_GET['action']=='edit'){
$keys = get_post_custom_keys(trim($_GET['post']));
if(in_array('_artical',$keys))
{
$type ="_artical";
}else if(in_array('_gallery',$keys))
{
$type ="_gallery";
}
else
{
$type ="_blog";
}
}
?>
<strong>Note:</strong>
<br/>
<span>Choose "Article" to upload image for Article. </span>
<br/>
<span>Choose "Gallery" to upload image for Gallery. </span>
<br/>
<span>Choose "Blog" to upload image for Blog. </span>
<br/>
<?php
if($_GET['action']=='edit')
{
$div_tag="<div align='center'>";
$image_meta_data = get_post_meta($_GET['post'],$type,true);
switch($type)
{
case '_artical':
$image_path = ARTICAL_IMG_INTER_URL;
break;
case '_gallery':
$image_path = GALLERY_IMG_INTER_URL;
break;
case '_blog':
$image_path = BLOG_IMG_INTER_URL;
break;
}
$div_tag.="<img src='".$image_path.$image_meta_data."'>";
$div_tag.= "</div>";
echo $div_tag;
}
echo "
<script>
jQuery(document).ready(function($){
$('#artical_image').change(function(){
$('#artical_image_edit').attr('value','1');
});
});
</script>
";
echo '<br/><div align=\'center\'><label for="Article Image">' . __("Upload Image for", 'myplugin_textdomain' ) . '</label> ';
echo "<input type='hidden' id='artical_image_edit' name='artical_image_edit' value='0'>";
?>
<select name='image_type'>
<option value="_artical"<?php if($type == '_artical')echo "selected='yes'"?>>Article
</option>
<option value="_gallery"<?php if($type == '_gallery')echo "selected='yes'"?>>Gallery
</option>
<option value="_blog"<?php if($type == '_blog')echo "selected='yes'"?>>Blog
</option>
</select>
<?php
echo '<input type="file" name="artical_image" id=\'artical_image\'/></div>';
?>
<div align="center">
<br/>
<span>File upload limit 2MB. </span>
<br/>
<span>Supported file types: gif, png, jpg . </span>
</div>
<?php
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
/* When the post is saved, saves our custom data */
function artical_save_postdata( $post_id ) {
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) )) {
return $post_id;
}
// verify if this is an auto save routine. If it is our form has not been submitted, so we dont want
// to do anything
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return $post_id;
// Check permissions
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ) )
return $post_id;
} else {
if ( !current_user_can( 'edit_post', $post_id ) )
return $post_id;
}
// OK, we're authenticated: we need to find and save the data
$mydata = $_POST['myplugin_new_field'];
if($_POST['artical_image_edit'] ==1)
{
$file_upload_error="";
/*echo "<pre>";
print_r($_FILES);
exit;*/
$_FILES['artical_image']['name'] = strtolower(trim($_FILES['artical_image']['name']));
if(trim($_FILES['artical_image']['name']) == '')
{
$file_upload_error=1;
wp_redirect(get_option('siteurl').'/wp-content/themes/classic/error.php?cerror='.$file_upload_error);
exit;
}
$image_extesion_array = explode(",",UPLOAD_IMAGE_TYPE);
$image_path = pathinfo($_FILES['artical_image']['name']);
$image_extension = $image_path['extension'];
//image extesion test
if(!in_array($image_extension,$image_extesion_array))
{
$file_upload_error=2;
wp_redirect(get_option('siteurl').'/wp-content/themes/classic/error.php?cerror='.$file_upload_error);
exit;
}
if($file_size >= 2000)
{
$file_upload_error=3;
wp_redirect(get_option('siteurl').'/wp-content/themes/classic/error.php?cerror='.$file_upload_error);
exit;
}
global $wpdb;
if (!empty($_POST["ID"])){
$id = $_POST["ID"];
}
if(trim($_FILES['artical_image']['name']) != '')
{
$post_id=$_POST['post_ID'];
$filename = trim($post_id.'_'.$_FILES['artical_image']['name']);
$filename = strtolower($filename);
$filename = str_replace(' ','_',$filename);
$filename = str_replace("\'",'_',$filename);
$filename = str_replace("\&",'_',$filename);
$filename = str_replace("\$",'_',$filename);
switch(trim($_REQUEST['image_type']))
{
case '_artical':
$meta_key = '_artical';
$meta_value = $filename;
$upload_path = ARTICAL_IMG_WEBSITE_FULLPATH;
$thumbnail_path = ARTICAL_IMG_IPHONE_FULLPATH;
$thumb_width = THUMB_WIDTH;
$thumb_height = THUMB_HEIGHT;
$inter_path = ARTICAL_IMG_INTER_FULLPATH;
$inter_width = INTER_WIDTH;
$inter_height = INTER_HEIGHT;
break;
case '_gallery':
$meta_key = '_gallery';
$meta_value = $filename;
$upload_path = GALLERY_IMG_WEBSITE_FULLPATH;
$thumbnail_path = GALLERY_IMG_IPHONE_FULLPATH;
$thumb_width = GALLERY_THUMB_WIDTH;
$thumb_height = GALLERY_THUMB_HEIGHT;
$inter_path = GALLERY_IMG_INTER_FULLPATH;
$inter_width = GALLERY_INTER_WIDTH;
$inter_height = GALLERY_INTER_HEIGHT;
break;
case '_blog':
$meta_key = '_blog';
$meta_value = $filename;
$upload_path = BLOG_IMG_WEBSITE_FULLPATH;
$thumbnail_path = BLOG_IMG_IPHONE_FULLPATH;
$thumb_width = BLOG_THUMB_WIDTH;
$thumb_height = BLOG_THUMB_HEIGHT;
$inter_path = BLOG_IMG_INTER_FULLPATH;
$inter_width = BLOG_INTER_WIDTH;
$inter_height = BLOG_INTER_HEIGHT;
break;
}
if($_REQUEST['action'] == 'editpost')
{
update_post_meta($post_id,$meta_key,$meta_value);
//for delete the already exists file
/*$image_meta_data = get_post_meta($post_id,$meta_key,true);
if( is_file($upload_path.$image_meta_data))
@unlink($upload_path.$image_meta_data);
@unlink($thumbnail_path.$image_meta_data);
@unlink($inter_path.$image_meta_data);*/
}else
{
add_post_meta($post_id, $meta_key, $meta_value);
}
//file upload move
move_uploaded_file($_FILES['artical_image']['tmp_name'],
$upload_path.$filename);
//for thumbnail image
include_once('thumbnail_class.php');
$image = new Resize_Image;
$image->new_width = $thumb_width ;
$image->new_height = $thumb_height;
$image->image_to_resize = $upload_path.$filename; // Full Path to the file
$image->ratio = true; // Keep Aspect Ratio?
$image->save_folder = $thumbnail_path;
$process = $image->resize();
//fot intermediate image
$image1 = new Resize_Image;
$image1->new_width = $inter_width;
$image1->new_height = $inter_height;
$image1->image_to_resize =$upload_path.$filename; // Full Path to the file
$image1->ratio = true; // Keep Aspect Ratio?
$image1->save_folder =$inter_path;
$process = $image1->resize();
}
}//for file upload checking end
////////////////////////////////////////////////////////////////////
/*echo "<pre>";
print_r($_FILES);
exit;*/
return $mydata;
}
?>
</code></pre>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-14268971157789460182010-03-19T19:01:00.000+05:302010-03-19T19:01:20.968+05:30jquery ajax uploader with progres barI implement the jquery ajax uploader, you find all the details better at <a href="http://blog.stevensanderson.com/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/">here</a>,<br />
I get many problem when I use it,<br />
<br />
For implement in php<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>script type="text/javascript" src='js/jquery-1.4.min.js'>
</script>
<script src="js/swfupload.js"></script>
<script src="js/jquery-asyncUpload-0.1.js"></script>
<script>
$(function() {
$("#yourID").makeAsyncUploader({
upload_url: "../test1.php", // Important! This isn't a directory, it's a HANDLER such as an ASP.NET MVC action method, or a PHP file, or a Classic ASP file, or an ASP.NET .ASHX handler. The handler should save the file to disk (or database).
flash_url: 'js/swfupload.swf',
file_size_limit: '1024 MB',
button_image_url: 'js/blankButton.png'
});
});
</script>
<style>
<!--
DIV.ProgressBar { width: 100px; padding: 0; border: 1px solid black; margin-right: 1em; height:.75em; margin-left:1em; display:-moz-inline-stack; display:inline-block; zoom:1; *display:inline; }
DIV.ProgressBar DIV { background-color: Green; font-size: 1pt; height:100%; float:left; }
SPAN.asyncUploader OBJECT { position: relative; top: 5px; left: 10px; }
-->
<!--
</style>
<input type="file" id="yourID" name="yourID" />
</code></pre>code for php<br />
<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code> require_once 'system/config/configure.php';
$con = mysql_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD);
mysql_select_db(DB_DATABASE);
echo "ok";
define('VIDEO_IMG_FULL_PATH',getcwd()."/upload/");
$uploaddir = VIDEO_IMG_FULL_PATH;
move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadfile)
</code></pre>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-51799318099790021842010-03-16T15:06:00.000+05:302010-03-16T15:06:02.678+05:30how to increment the column value in mysql? We can increment the column value by<br />
<br />
<code>UPDATE images SET counter=counter+1 WHERE image_id=15</code><br />
<code> where counter is the column name </code>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-34435594409350217092010-03-16T15:03:00.000+05:302010-03-16T15:03:50.534+05:30How to get the last insert id in php To get the last id insert in mysql by php by function mysql-insert-id().<br />
This return the last id inserted.<br />
For more details <a href="http://php.net/manual/en/function.mysql-insert-id.php"> click here</a>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-59229787914981585112010-03-06T17:55:00.002+05:302010-03-06T17:55:58.476+05:30To create the frame for code in blogsThis the link where you can create the different frame for code.<br />
http://formatmysourcecode.blogspot.com/rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-3915588830777170142010-02-26T18:45:00.001+05:302010-03-06T17:53:43.450+05:30Create thumbnail image in phpThis function will create the thumbnail image of the source file<br />
other thing explain in function<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
function createthumbimage($source_path,$ext,$filename)
{
//$ext=extension of file
if ($ext == 'jpg' || $ext == 'jpeg')
{
$img = @imagecreatefromjpeg($source_path);
}
else if ($ext == 'png')
{
$img = @imagecreatefrompng($source_path);
# Only if your version of GD includes GIF support
} else if ($ext == 'gif')
{
$img = @imagecreatefromgif($source_path);
}
if ($img)
{
# Get image size and scale ratio
$width = imagesx($img);
$height = imagesy($img);
$scale = min(PRODUCT_MAX_WIDTH/$widthPRODUCT_MAX_WIDTH/$height);
//PRODUCT_MAX_WIDTH and PRODUCT_MAX_WIDTH is predefine width and height of thumbnail image
# If the image is larger than the max shrink it
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
# Create a new temporary image
$tmp_img = imagecreatetruecolor($new_width, $new_height);
# Copy and resize old image into new image
imagecopyresized($tmp_img, $img, 0, 0, 0, 0,
$new_width, $new_height, $width, $height);
imagedestroy($img);
$img = $tmp_img;
// $new_filename="";
imagejpeg($img,PRODUCT_IMG_THUMB_PATH.$filename);
// PRODUCT_IMG_THUMB_PATH.= this the define path that will put thumb file in define path
}
}
</code></pre><div style="text-align: left;"><br />
</div><div style="text-align: left;">Have Dream Day</div>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-60668462013507672872010-02-16T16:43:00.000+05:302010-02-16T16:43:21.271+05:30Get file extension in phpThe file extension with all details can get below given way<br />
<br />
<code><span style="color: black;"><span style="color: #0000bb;"><br />
</span><span style="color: #ff8000;">/*** example usage ***/</span><span style="color: #0000bb;">$filename </span><span style="color: #007700;">= </span><span style="color: #dd0000;">'filename.blah.txt'</span><span style="color: #007700;">;//this is file name or any file also can uploaded<br />
</span><span style="color: #ff8000;">/*** get the path info ***/</span><span style="color: #0000bb;">$info </span><span style="color: #007700;">= </span><span style="color: #0000bb;">pathinfo</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$filename</span><span style="color: #007700;">);//<br />
</span><span style="color: #ff8000;">/*** show the extension ***/</span><span style="color: #007700;">echo </span><span style="color: #0000bb;">$info</span><span style="color: #007700;">[</span><span style="color: #dd0000;">'extenstion'</span><span style="color: #007700;">];//<br />
</span><span style="color: #0000bb;">?></span></span></code>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-14105778004888257312010-02-12T10:27:00.000+05:302010-02-12T10:27:18.102+05:30Mysql dump Table for all countries and statesHi<br />
This the MySQL dump file contains the list of all country and state respectively,<br />
for that just create the database and import the file. <br />
<a href="http://sites.google.com/site/rubyid10/Home/country_state.sql?attredirects=0&d=1">Attechment</a><br />
<br />
Have Dream Dayrubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com5tag:blogger.com,1999:blog-2450922440085091166.post-77362049800274496102009-12-18T17:36:00.003+05:302009-12-18T18:56:39.672+05:30How to return multiple tag with NusoapHow to create web service in php using the nusoap<br />With writting this blog please first read what is web service and how make with nusoap.<br />You can <a href="http://sourceforge.net/projects/nusoap/"> download</a> and for tutorial for basic <a href="http://www.scottnichol.com/soap.htm">http://www.scottnichol.com/soap.htm</a><br /> I am here to write how to send the multiple tag in response<br /> <br /><br /> First we have create the complex data type that you want to send client but little different way.<br /><br /><div style="text-align: justify;"><span style="font-style: italic;">$server->wsdl->addComplexType( 'business','complexType','array','all','',</span><br /><span style="font-style: italic;"> array(</span><br /><span style="font-style: italic;"> 'tagname'=>array('name'=>'tagname','type'=>'xsd:string'));</span><br /><br /> This the code for adding complex data type.<br /><ol><li>$server this the object of NuSOAP .</li><li><span style="font-style: italic;">business</span> is name data type that you want to create.</li><li><span style="font-style: italic;">complexType </span>the type of new data is complex</li><li><span style="font-style: italic;">array</span> there two type of data one struct and another array.we will use array</li><li><span style="font-style: italic;">tagname</span> this the name of tag that you can send inside the array.</li></ol> Then you have create new datatype that contails the array of above data type.<br /> <br /><div style="text-align: left;"><span style="font-style: italic;"> $server->wsdl->addComplexType(</span><span style="font-style: italic;">'array_business',</span><span style="font-style: italic;">'complexType', </span><span style="font-style: italic;">'array', </span><span style="font-style: italic;">'', </span><br /><span style="font-style: italic;"> 'SOAP-ENC:Array', </span>//this tell the ENC is type of array<br /><span style="font-style: italic;"> array(),</span><br /><span style="font-style: italic;"> array(</span><br /><span style="font-style: italic;"> array('ref' => 'SOAP-ENC:arrayType', //now check in WSDL</span><br /><span style="font-style: italic;"> 'wsdl:arrayType' => 'tns:business[]')//the complex data array</span><br /><span style="font-style: italic;"> ),</span><br /><span style="font-style: italic;"> 'tns:</span><span style="font-style: italic;">business</span><span style="font-style: italic;">'</span> //the name of complex data that<br /><span style="font-style: italic;">);</span><br /></div><br /><br /><br /> The above code explain that data array_business contains the array of business that given in "tns:"<br /> Now just one thing to do is set the return type in function is "business".<br /> Each array is an item tag,and each array element is child of item.<br /><br /><br /><br /><br />Thanks.<br />Have Dream Day.<br /> <br /><br /><br /><br /></div>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-32342966578113755902009-12-18T09:45:00.005+05:302009-12-18T10:18:31.102+05:30Image POST with jqueryTo post image to server we can not it directly like set variable name post it, that we do in <span style="font-style: italic;">$.ajax</span><br />for that you need to make iframe then make form tag so that the request contains the header with all file details like name,size,type etc.<br /> Jquery make it simple by plug-in named 'ajax_postup' just download call to your page,<br />you can also find documentation <a href="http://plugins.jquery.com/project/ajax_postup">download</a> but i also write down here.<br /> <br /> <div style="text-align: center;"><span style="font-size:85%;"><span style="font-style: italic;"> $.ajax_postup({url:'imagepost.php',//server url</span></span><br /><span style="font-size:85%;"><span style="font-style: italic;"> file_ele_ids:['x_thumbnailimage'],//just give file name id</span></span><br /><span style="font-size:85%;"><span style="font-style: italic;"> success:function(return_data)</span></span><br /><span style="font-size:85%;"><span style="font-style: italic;"> {</span></span><br /><span style="font-size:85%;"><span style="font-style: italic;"> //write down code for callback</span></span><br /><span style="font-size:85%;"><span style="font-style: italic;"> }</span></span><br /><span style="font-size:85%;"><span style="font-style: italic;"> });</span></span><br /></div><br /><br /> The above code i think explain all things,<br /> you can also pass other variable with code just write down before the <span style="font-style: italic;">'file_ele_ids'</span><br />the syntax is <span style="font-style: italic;">data:{'var_name':'var_value', 'var_name':'var_value'},</span><br /><br /> On server side if you are using the PHP than you can access directly by<br /><ol><li>$_FILE['filename_id']['name'] to access the file name same way<br /></li><li>$_FILE['filename_id']['type']<br /></li><li>$_FILE['filename_id']['size]</li><li>$_FILE['filename_id']['tmp_name'] for server temp location file name.</li></ol><br /> Thanks<br />Have Dream Dayrubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0tag:blogger.com,1999:blog-2450922440085091166.post-11685650149591585632009-12-16T14:55:00.000+05:302009-12-17T09:22:49.271+05:30Zend Error 404I have great problem during installation of Zend Framework into my PC,the Index controller and index action work fine but with the other action it show the error 404 .<br /><br />Solution was that simple just open http.conf and search for <directory> tag just change the<br />AllowOverride None<br />to<br />AllowOverride All<br /><br />please also check to the mod_write module is not commented.<br />I try it in<br />1.Zend Studio 0.7<br />2.Zend Framework 1.9<br />3.Zend Server 4.0<br /><br />Thanks<br />Have Dream Day</directory>rubyid10http://www.blogger.com/profile/01600201976068543726noreply@blogger.com0