Sub buckets is very tricky task to create on Amazon S3 service…

<?php

include(“S3.php”); // class for REST based S3 manager

$s3 = new S3(‘accessKey’, ‘secretKey’);
$s3->putBucket(‘bucketname’, S3::ACL_PUBLIC_READ);

/* function to upload phpsolutions.txt file to subfolders p/h/p/s/o/l/u/t/i/o/n/s on S3 bucketname */
$s3->putObjectFile(‘phpsolutions.txt’, ‘bucketname’, ‘p/h/p/s/o/l/u/t/i/o/n/s/phpsolutions.txt’, S3::ACL_PUBLIC_READ);

/* function to delete phpsolutions.txt file to subfolders p/h/p/s/o/l/u/t/i/o/n/s on S3 bucketname */
//$s3->deleteObject(‘bucketname’, ‘p/h/p/s/o/l/u/t/i/o/n/s/phpsolutions.txt’);

?>

Public URL for this file:
http://bucketname.s3.amazonaws.com/p/h/p/s/o/l/u/t/i/o/n/s/phpsolutions.txt

Source: http://undesigned.org.za/2007/10/22/amazon-s3-php-class

wget – server to server files transfer

On October 2, 2009, in Fedora, Linux, Tips, Tricks, by phpsolutions

wget is powerful utility in linux. We can use “wget” to download files of any folder on any server to our server.

wget will download files on local server in current folder, we can use

# pwd (for current directory)

# wget -H -r –level=1 -k -p http://www.domain.com/folder/

here level is folder’s level

Keep downloading files 🙂

float: left – anchor's height

On September 28, 2009, in Javascript, PHP, Tips, Tricks, by phpsolutions

Today I faced a strange problem …. I have to add drop-down menu by javascript.

<a href=”http://www.phpsolutions.co.in” style=”border:2px dotted #0000FF”><img src=”phpsolutions.gif” border=”0″ style=”border:2px solid #009966″ /></a>

this is the code where I have to add a menu but menu dancing on this image.. when I mouse over the image menu appeared to bottom of the image…

anchor height

here you can see output of above html code… I have marked a border around image in green and on anchor with blue color.

I think now you got the problem 🙂

Yes, now we have to apply height and width to anchor in blue color below is the code for this….

<a href=”http://www.phpsolutions.co.in” style=”border:2px dotted #0000FF; float:left; width:70px; height:80px;”><img src=”dateblock.gif” border=”0″ style=”border:2px solid #009966″ /></a>

This is the magic for “float: left” of CSS .. here you can use “float: right” as well to apply height/width to anchor tags…..

height of anchor
Here you can see the output of above code the blue border with width/height of anchor tag.

MVC-model-view-controller component

On September 26, 2009, in Joomla, PHP, by phpsolutions

General definition:

Input      => Processing => Output
Controller => Model      => View

Model

The model is the part of the component that encapsulates the application’s data. It will often provide routines to manage and manipulate this data in a meaningful way in addition to routines that retrieve the data from the model. In our case, the model will contain methods to add, remove and update information about the books in the database. It will also contain methods to retrieve the list of books from the database. In general, the underlying data access technique should be encapsulated in the model. In this way, if an application is to be moved from a system that utilizes a flat file to store its information to a system that uses a database, the model is the only element that needs to be changed, not the view or the controller.

View

The view is the part of the component that is used to render the data from the model in a manner that is suitable for interaction. For a web-based application, the view would generally be an HTML page that is returned to the data. The view pulls data from the model (which is passed to it from the controller) and feeds the data into a template which is populated and presented to the user. The view does not cause the data to be modified in any way, it only displays data retrieved from the model.

Controller

The controller is responsible for responding to user actions. In the case of a web application, a user action is a page request. The controller will determine what request is being made by the user and respond appropriately by triggering the model to manipulate the data appropriately and passing the model into the view. The controller does not display the data in the model, it only triggers methods in the model which modify the data.

Source:
http://www.vojtechovsky.net/joomla/component-helloworld-2-create-tutorial-guide-en.html

HTMLDOC – html2image

On September 22, 2009, in Fedora, Linux, PHP, Tips, Tricks, Web Application, by phpsolutions

htmldoc is a powerful simple-to-use tool/utility, which converts HTML to Postscript, PDF or indexed HTML output.

# convert /var/www/html/html2img/grid.ps -crop 280×300+40+9 -modulate 100 -geometry 530×480 /var/www/html/html2img/grid.png

here convert is ImageMagick tool for manipulating images..

Tagged with:  

txt2img

On September 22, 2009, in PHP, Tips, Tricks, by phpsolutions

Here is the code to convert text to image or simply write text on image….

<?php
$img=ImageCreate (100,20);
$background_color=ImageColorAllocate($img,255,205,255);
$textcolor=ImageColorAllocate ($img,203,14,91);
ImageString($img,3,5,5,”phpsolutions.co.in!”,$textcolor);
ImagePNG ($img, “phpsolutions.png”);
$img2 = imagerotate ($img, 100, 0);
ImagePNG($img2,”phpsolutions.png”);
ImageDestroy($img);
ImageDestroy($img2);
?>

DIV – Overflow Hidden

On September 22, 2009, in PHP, Tips, Tricks, by phpsolutions

Today I got a problem to show product title in 2 lines on product’s detail page…..

After some R&D………………..

I got solution by CSS to style a DIV with height for 2 line text and then overflow: hidden 🙂

I also used wordpress to wrap the text in next line for product’s description in 5 lines.

Amazing “DIV – Overflow Hidden” is great solution for making site symmetric 🙂

TinyMCE load ajax

On September 13, 2009, in Javascript, PHP, Tips, Tricks, Web Application, by phpsolutions

Today I got problem to load TinyMCE as dynamic loaded textareas by Ajax?

Solution:

<a href=”javascript:void(0)” onclick=”ajaxEdit(); showEditor();”>Edit Content</a>

here ajaxEdit() is ajax function where textarea loaded by ajax as html response.

here we have use showEditor(); to load TinyMCE editor … page loaded by Ajax

<script>

function showEditor()
{

setTimeout(“initEditor(‘newsdesc’)”,4000);

}

tinyMCE.init({………………………
…………………………………………………});

function initEditor(id)
{

tinyMCE.execCommand(‘mceAddControl’, false, id);

}

</script>

tiny

Hindi Text Editor

On September 10, 2009, in PHP, Tips, Tricks, Web Application, by phpsolutions

akIndicPlugin is very useful for Indian language like Hindi, Marathi, Bengoli, Gujarati, Malyalam, Telugu and Punjabi….

1

2

Source:
http://amiworks.co.in/talk/akindicplugin-for-tinymce-and-joomla/
http://www.vishalon.net/IndicResources/IndicIME/tabid/244/Default.aspx