Friday, April 24, 2009

Problems In Smarty Template

some times i found a problem in smarty template that whenever i do some changes in my template coding and refresh html page the changes do not applied.i was wondering what is the problem in it.after having so much research i found that smarty creates obj templates every time you do some changes in template.
then i delete all obj templates and then refresh the page.the changes are now applied in the page

Preg_Match PHP Function













The
Preg_Match PHP function is used to search a string, and return a 1 or 0. If the search was successful a 1 will be returned, and if it was not found a 0 will be returned. Although other variables can be added, it is most simply phrased as: preg_match(search_pattern, your_string).

There are two scripts which validates the format of a url text string and domain. It might be used to check the url submitted from a form. The format of the url is expected to be of the form: domain-name.co.uk for example.

  • First script validates a url. This make use of regular expression pattern matching.



//url validation

$url = 'teSTgjhgj.co.uk';

if (preg_match ("/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i", $url)) {

print "$url url OK.";

} else {

print "$url url not valid!";

}

?>
  
  • Second script validates a domain.
  


//domain validation

$domain = 'teSTgjhgj';

if (preg_match ("/^[a-z0-9][a-z0-9\-]+[a-z0-9]$/i", $domain)) {

print "$domain Domain OK.";

} else {

print "$domain Domain not valid!";

}

?>

Wednesday, April 22, 2009

Digital Clock in PHP


This is a PHP script for displaying the current time in a digital clock on your web page. It uses individual digit images for the clock, and does not require any special library.

You can download the zip format of code file from
http://www.hotscripts.com/listing/digital-clock-6741/

Monday, April 20, 2009

Change Mysql root password

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop
Output:

Stopping MySQL database server: mysqld.

Step # 2: Start to MySQL server w/o password:

# mysqld_safe --skip-grant-tables &
Output:

[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client:

# mysql -u root
Output:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop
Output:

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+ Done mysqld_safe --skip-grant-tables

Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p

Installing Skype on Ubunto

If you’re interested in running Skype on Ubuntu then follow these steps.

From the Ubuntu System menu select:
Administration –> Synaptic Package Manager

synaptic.png

Inside Synaptic Package Manager select the Tools –> Repositories menu option. Make sure all the checkboxes are checked. Then close the Synaptic Package Manager.

screenshot-software-sources.png

Next you need to add the Medibuntu repository. Full details about this repository, including installation instructions, can be found on the Medibuntu home page.

To install Medibuntu you need to run a Terminal window session. From the Ubuntu Applications –> Accessories menu select Terminal

ubuntu-terminal.png

Assuming you’re running Ubuntu 7.04 Feisty Fawn you need to enter the following into a command window. If you’re using an earlier version of Ubuntu then refer to the Medibuntu home page for installation instructions.

sudo wget http://www.medibuntu.org/sources.list.d/feisty.list -O /etc/apt/sources.list.d/medibuntu.list

wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add - && sudo apt-get update

sudo aptitude install skype

That’s it!

Skype should now be available from the Applications –> Internet menu.

skype.png

Saturday, April 11, 2009

HTML DOM Parsing

If you want to extract data from a webpage and not getting the exact data using different patterns and "PHP String Positions" techniques, then here is the suggestion for you.

This is Simple HTML DOM Parser written in PHP5+ by a Developer on Sourceforge.net

Developer Profile:
http://sourceforge.net/users/me578022/

Download Link:
http://sourceforge.net/projects/simplehtmldom/

Documentions:
http://simplehtmldom.sourceforge.net/



How to Use:

First of all download the simple_html_dom.php File from download link.


// Include the downloded file in your own php file.
include('../simple_html_dom.php');

// Create a DOM First:
$html = file_get_html('http://www.google.com/'); // Create DOM from URL or file
$html = str_get_html($str, $lowercase=true); // Create DOM from String of HTML Script


// find all links
foreach($html->find('a') as $element)
echo $element->href;

// find all images
foreach($html->find('img') as $element)
echo $element->src;

// find all images with full tag
foreach($html->find('img') as $element)
echo $element->outertext;

// find all div tags with id=gbar
foreach($html->find('div#gbar') as $element)
echo $element->innertext;

// find all span tags with class=gb1
foreach($html->find('span.gb1') as $element)
echo $element->outertext;

// find all td tags with attribite align=center
foreach($html->find('td[align=center]') as $element)
echo $element->innertext;

// extract text from table
echo $html->find('td[align="center"]', 1)->plaintext;

// extract text from HTML
echo $html->plaintext;



Read documents for more example.

Friday, April 10, 2009

Installation Problem in UBUNTU





After installing Ubuntu, i was installing system application
jre-1_6_0_02-linux-i586-rpm.bin. Every thing was going right
suddenly a message of service agreement appeared and the
installation was stopped. I closed the terminal and tried to reinstall
the application. Then i received the message,

"E: dpkg was interrupted, you must manually run
'dpkg --configure -a' to correct the problem."

I couldn't install anything through my terminal or my synaptic manager.
Then i found the solution of this problem.

Solution:

On terminal, execute the following commands:

sudo dpkg --configure -a
sudo dpkg --update -a


Thursday, April 9, 2009

Accedently Replace / Remove Directory From SVN

Problem
I have replace a directory from 'trunk' at revision 977 & now i want to rollback to revision 974 .....!

Solution
Simply follow these steps mentioned below:
1- $ svn merge -r 977:974 https://som_one.com/repos/home/trunk
2- $ svn commit -m "Recover Lost Directory"
3- $ svn update

Tuesday, April 7, 2009

SOAP

Introduction:

SOAP is an XML-based messaging protocol. It defines a set of rules for structuring messages that can be used for simple one-way messaging but is particularly useful for performing RPC-style (Remote Procedure Call) request-response dialogues. It is not tied to any particular transport protocol though HTTP is popular. Nor is it tied to any particular operating system or programming language so theoretically the clients and servers in these dialogues can be running on any platform and written in any language as long as they can formulate and understand SOAP messages. As such it is an important building block for developing distributed applications that exploit functionality published as services over an intranet or the internet.

Server Side:

As is the case with any client-server paradigm, in the world of web services there are web service providers and web service consumers. Server-Side SOAP is a tutorial which deals with how to build and provide web services using Apache SOAP. We will cover the details of the technology for consuming web services when we work through SOAP on the Client-Side.

Client Side:

Client-Side SOAP is a multi-part tutorial with the aim of introducing you to some of the technologies available for writing clients that consume web services using SOAP.

For detail information:
Follow the link http://www.soapuser.com/index.html

Document Comparisons


Compare Files with 'Diff Doc'
(The Comprehensive Document Comparison Tool)
Some times more than one person( lets, you & your partner ) are working on the same file that may on ( MS Word/Excel/PowerPoint, PDF, RTF, Text, HTML, XML, Wordperfect ), and suppose you need to check the modifications that have been made by your partner then either you'll request him to inform you about those changes made by him or review the whole file to justify the changes, but it may takes more time & may be you could not correctly justify .

I was also passed through that experience & i faced much problems, so i thought that their must be utility tools to solve such problems & at last i found an excellent
utility tool " Diff Doc ", but its a trial version. Following are its features i have test it is really a nice one ....

Diff Doc Features
  • Compare documents of MS Word (DOC, DOCX etc), Excel, PDF, Rich Text (RTF), Text, HTML, XML, PowerPoint, or Wordperfect and retain formatting
  • Choose any portion of any document (file) and compare it against any portion of the same or different document (file).
  • Word to word or letter to letter comparisons. See to the letter what changed in a sentence.
  • Compare files of any type against any file type (i.e. An MS Word compared against a. Wordperfect document)
  • Integrated into the Windows Explorer Shell (Windows Explorer, Desktop, Find in Files, etc.) for quick comparisons
  • Navigate easily through the file differences with the Next (F7), Previous (Shift+F7) etc. navigation buttons. Or use the drop down list box to jump to a specific difference
  • Paragraph differences are highly detailed
  • Compares text from any application by cutting and pasting into 'Diff Doc'.
  • Both 'Side By Side' and the red-lined 'All In One' difference views are supported
  • Save any of the views as DOC, Text, RTF or HTML format
  • Text and Comma Delimited reports also available
  • Compare folders first, then quickly see what files are different and compare with a mouse click
  • Compatible with WORLDOX, and any other document management software that supports 3rd party file comparison applications through the command line. Click here for details
  • Run it from the Command Line or build your own solutions by using the ActiveX COM interface (available upon request)
Download Link for Diff Doc
http://www.softinterface.com/DL/DL_UserData_Proc.ASP