Archive for the 'php' Category

MySQL, Source Code, php

MySQLDump 2.0

This is a guest post from Daniele

After a lot of work, I released the new version (2.0) of the MySQLDump class, already introduced by this article.
MySQLDump is a class that allows to do a complete MySQL database backup with php pages.

After the inandrea’s good work there wasn’t too much space for improvements, but I think that these addition can be usefull: now it’s possible to export structures and/or data not only for the selected database but also for a single table.

The following example will explain how to export the structure and the data for the table mytable in the db mydb (the interface to the class is slightly changed from the previous version).

//Include the library
@include_once('lib_dump.php');
//Db connection
$connection = @mysql_connect('127.0.0.1','username','password');
//Create the MySQLDump class instance
//1° parameter: db name
//2° parameter: the exported file that will contain the dump
//3° parameter: create zipped file (true = zipped, false = normal)
//4° parameter: data encode (true = hexadecimal, false = plain text)
$dumper = new MySQLDump('mydb','dumpfile.sql',false,false);
//Structure export of the table 'mytable'
$dumper->getTableStructure('mytable');
//Data export of the table 'mytable'
$dumper->getTableData('mytable');

Continue Reading »

News, Source Code, Wiki-Dashboard, Wordpress, php

Wordpress Plugin: Wiki-Dashboard 0.1

Wiki-Dashboard is a Wordpress plugin that allows to all registered user on a blog to share and edit a text like a wiki, and can be usefull even on mono-author blogs, giving a space to write notes.

Features:

  • Dashboard subpage with the text where to put notes
  • Text shared to all blog authors
  • bbCode parser for text formatting
  • Internationalization support

Installation:
Simply download the Zip-Archive and extract all files into your wp-content/plugins/ directory. Then go into your WordPress administration page, click on Plugins and activate it.
After that you will have a new submenu called “Wiki” under the “Dashboard” menu.

Download Wiki Dashboard 0.1. Downloads: 2694

Screenshots:
Wiki-Dashboard showing the text:

Wiki-Dashboard View

Wiki-Dashboard editing the text:

Wiki-Dashboard Edit
Continue Reading »

MySQL, Source Code, Web, php

MySQLDump backup class interface

MySQLDump class is now at version 2.0 and this article contains obsolete informations about the version 1.0. For information about the new version check this article

After the success of the article PHP backup of a mysql database, I decided to write a short post about a file that can be usefull to download the backup of your db site/wordpress blog directly from your browser.
To use the script, you can simply download it and edit the first lines with the basic configuration:

// DB Configuration
$server = "IP of your server (localhost will work in most cases)";
$username = "Valid username for your mysql db";
$password = "Password";
$dbToDump = "Db to dump";
// password to access the php page. PLEASE change the default password!!!
$backupPassword = "UltraSecretKeyThatYouMUSTInsertHere";
// filename to save
$filename = "backup.sql.gz";

After that you can upload the file to your server, in the same folder where is located the class MySQLDump.
To access the script you have to specify two parameters: the password to access the script (pass), and another parameter (t) that if it’s 1 will separate the SQL inserts every 100 rows.
For example, if you upload the file to the root directory of yoursite, you have to write in the address bar of the browser:

http://www.yoursite.com/backup.php?pass=UltraSecretKeyThatYouMUSTInsertHere&t=1

…and your favorite browser will open the dialog to save the file with the db backup!

Download MySqlDump Interface.php. Downloads: 657

For more info about the MySQLDump class, read the original post, or download the source from here:

Download MySQLDump. Downloads: 4321

MySQL, Source Code, Web, php

PHP backup of a mysql database

MySQLDump class is now at version 2.0 and this article contains obsolete informations about the version 1.0. For information about the new version check this article

I searched a way to do a daily backup of my wordpress blog in my home pc but I didn’t find nothing that completely satisfy me, so I decided to code it.
I separated the problem in two scripts:
The first, that is written in php and runs on the web server, makes the dump of mysql databases from my hosting provider and leaves the dump on the web server.
The other one (written in bash, and running locally) downloads the site and the mysql dump from the web server, via FTP. Unfortunately I discovered that my hosting provider (Aruba.it) didn’t supply with mysqldump its server.

Lamp

First of all, I searched for a php script that makes the direct dump of the database.

Continue Reading »

Wordpress, php

Problems with comments using Redoable theme in WP

If you have problems in the comments using Redoable theme, you can try this trick(i hope that this post can help someone :) ).

Open the file single.php and modify the following lines at the end of the file from:

</div>
<div id=”rightcolumn”>
<?php get_sidebar(); ?>
</div>
<div class=”clear”></div>
</div> <!– .content –>
<?php comments_template(); ?>
<?php get_footer(); ?>

To:

</div>
<?php comments_template(); ?>
<div id=”rightcolumn”>
<?php get_sidebar(); ?>
</div>
<div class=”clear”></div>
</div> <!– .content –>
<?php get_footer(); ?>

I don’t know why, but invoking comments_template() after get_sidebar() the comments will not display right.

php

Random image in php

If you want to show a random image in your site a good method is through a php script.
A random image example is here :)
Immagine random

You prefer the dogs, the cat or the lucky hamster? :D (refresh to randomize another image)
Continue Reading »