<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Georgi Mitev &#124; Learn Scripts Tutorials &#124; PHP Cron Mysql Flash</title>
	<atom:link href="http://georgi-mitev.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://georgi-mitev.com</link>
	<description>Georgi Mitev&#039;s blog for scripts tutorials and something else</description>
	<lastBuildDate>Sun, 02 May 2010 22:00:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>regular updates of this blog</title>
		<link>http://georgi-mitev.com/2010/05/03/regular-updates-of-this-blog/</link>
		<comments>http://georgi-mitev.com/2010/05/03/regular-updates-of-this-blog/#comments</comments>
		<pubDate>Sun, 02 May 2010 22:00:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=241</guid>
		<description><![CDATA[Hello everybody,
I&#8217;m sorry that the blog wasn&#8217;t very active last year. This year will be different  . I&#8217;m going to add a new category (SEO &#38; Marketing) &#8211; because my current interests are in this direction.
I&#8217;ll to add a couple of posts regarding google analytics and adsence in the next weeks. The blog will [...]]]></description>
			<content:encoded><![CDATA[<p>Hello everybody,</p>
<p>I&#8217;m sorry that the blog wasn&#8217;t very active last year. This year will be different <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I&#8217;m going to add a new category (SEO &amp; Marketing) &#8211; because my current interests are in this direction.</p>
<p>I&#8217;ll to add a couple of posts regarding google analytics and adsence in the next weeks. The blog will be updated every Monday and Thursday.</p>
<p>If you want to have a post on specific topic in the field of SEO or advertising you can contact me and i could do some research on the subject, and comeback with a post about it.</p>
<p>Greetings</p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2010/05/03/regular-updates-of-this-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Full backup of website’s mysql database using cron job</title>
		<link>http://georgi-mitev.com/2010/04/29/full-backup-mysql-database-db-using-cron-job/</link>
		<comments>http://georgi-mitev.com/2010/04/29/full-backup-mysql-database-db-using-cron-job/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 09:00:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Web Developing]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=226</guid>
		<description><![CDATA[The MySql database backup website backup is very similar to the previous backup that I showed you 2 days ago. We are going to create a php file that is going to dump our database into filename with the current date and time.
Ok so let’s get going:
1.	Create the file “backup_database.php” and input the following code [...]]]></description>
			<content:encoded><![CDATA[<p>The MySql database backup website backup is very similar to the previous backup that I showed you 2 days ago. We are going to create a php file that is going to dump our database into filename with the current date and time.</p>
<p>Ok so let’s get going:<br />
<strong>1.	Create the file “backup_database.php” and input the following code into it:</strong><br />
&lt;?php exec(&#8216;cd /home/your_user/backup/db/;mysqldump &#8211;add-drop-table -h localhost &#8211;user=your_user &#8211;password=your_pass database_name &gt; `date +%y-%m-%d_%H-%M`.sql&#8217;); ?&gt;</p>
<p>Sometimes the path to your home dir looks different than ‘/home/your_user/’, so execute the ‘pwd’ command like explained in <a href="http://georgi-mitev.com/2010/04/26/schedule-website-file-system-backup-php-cron-job/#more-215">my previous post</a></p>
<p>Here we use the command mysqldump in a tutorial that I wrote previously about the dumping the sql database from one host to another. Now the database will be saved directly on the server that is hosting your website</p>
<p><span id="more-226"></span></p>
<p><strong>2. Create /backup/ and /backup/db/ directories via SSH or  FTP if not created.</strong></p>
<p>Of course you can use any names. But better<strong> do not </strong>create the /backup/ directory in the /public_html/ directory for security reasons <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>3. Upload </strong><strong>“backup_database.php” to the /home/your_user/backup  directtory<br />
</strong></p>
<p>If you upload backup_database.php to www.yoursite.com/backup_database.php by accessing it directly in your browser you will create a backup of your database.  However I do not recommend doing this <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  First because someone can overload your space quota by accessing the backup_database.php many times and second because you probably don’t want to enter the URL in your browser every time you want to perform database backup.</p>
<p><strong>4.	Go to CPanel -&gt; Cron Jobs and input the path to backup_database.php:</strong></p>
<p><img src="http://georgi-mitev.com/images/posts/4.2010/bdb1.jpg" alt="Cron Job DataBase backup" /><br />
Click on the `Add new Cron Job` button…     and you are pimped out. In my case I added the option this cron job to be executed twice a day. In case you database is updated more often/rarely you can modify this setting to suit your needs.<br />
You can also add option to save the dump of the database in tar format to save some space in your hdd quota by changing the script a bit.<br />
Full database backup in tar format (save more space):<br />
backup_database.php:<br />
<strong>&amp;lt;?php exec(&#8216;FILE=`date +%y-%m-%d_%H-%M`;cd /home/ps3igri/backup/db/;mysqldump &#8211;add-drop-table -h localhost &#8211;user=your_mysql_user &#8211;password=your_pass db_name &gt; $FILE.sql;tar czpf $FILE.tar $FILE.sql;rm -f $FILE.sql&#8217;); ?&gt;</strong><br />
As you see here we use the ‘FILE’ variable to store information about the filename. We create a SQL Dump, then we archive it, and after that we delete the original file to save some disk space.<br />
Good luck with the backup and see you next time <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2010/04/29/full-backup-mysql-database-db-using-cron-job/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Website file system backup using php and cron job</title>
		<link>http://georgi-mitev.com/2010/04/26/schedule-website-file-system-backup-php-cron-job/</link>
		<comments>http://georgi-mitev.com/2010/04/26/schedule-website-file-system-backup-php-cron-job/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 14:00:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[backup cron job]]></category>
		<category><![CDATA[backup filesystem]]></category>
		<category><![CDATA[cpanel cron job]]></category>
		<category><![CDATA[execute backup]]></category>
		<category><![CDATA[php file system backup]]></category>
		<category><![CDATA[schedule backup]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=215</guid>
		<description><![CDATA[Hello guys and ladies,
Long time no see  . Today I&#8217;m going to show you how to make a php script to perform full website backup the script can be executed via http request or via ssh shell or like a cron job .
We all know about the most standard way to add backup for [...]]]></description>
			<content:encoded><![CDATA[<p>Hello guys and ladies,<br />
Long time no see <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Today I&#8217;m going to show you how to make a php script to perform full website backup the script can be executed via http request or via ssh shell or like a cron job .<br />
We all know about the most standard way to add backup for your website maintenance for example using  the Cron Jobs in the CPanel. If you already don’t know this – if your hosting provider does support CPanel you should be able to access it via this URL:  www.yourwebsite.com/cpanel<br />
<img src="http://georgi-mitev.com/images/posts/4.2010/bf1.jpg" alt="Cron Job CPanel" /><br />
<span id="more-215"></span><br />
After you login into you CPanel and choose ‘Cron jobs’  you can enter there manually script to fully backup your database or file system. For example a script for full file system backup should look like this:<br />
tar -cvpzf my_backup_file.tar /home/your_user/public_html<br />
we could make the script more interesting when instead of ‘my_backup_file’ we include the date and time in the filename:<br />
<strong>tar -cvpzf `date +%y-%m-%d_%H-%M`.tar /home/ your_user/public_html</strong><br />
of course you should change `/home/your_user/public_html` to whatever your home directory is. You can find out what your home directory is by executing ‘pwd’ (print working directory) in the ssh shell or creating the file `exec.php` with the code:<br />
<strong>&lt;?php echo exec(‘pwd’); ?&gt;</strong></p>
<p>and after that executing the code by opening http://www.yoursite.com/exec.php in your browser.<br />
So we can add this line directly into the Curl command field:<br />
<img src="http://georgi-mitev.com/images/posts/4.2010/bf2.jpg" alt="Cron Job CPanel Command field" /><br />
But now I am going to tell you better way to do it, because very often the commands directly typed at the cron’s `Command:` field are ignored because of some stupid quote convention etc.<br />
Full website filesystem backup using php file and cron job:<br />
1.	First we are going to create the file backup_filesystem.php and put this code into it :<br />
<strong>&lt;?php echo exec(&#8216;cd /home/your_user/backup/files;tar -cvpzf `date +%y-%m-%d_%H-%M`.tar /home/ your_user /public_html&#8217;); ?></strong></p>
<p>2.	After that we’ll access the website via the FTP and put the backup_filesystem.php file into the /home/your _user/backup/.  Make sure that you create “backup” and “backup/files” directories  if they are not already created. Better don’t put backup_filesystem.php file into the /public_html/ folder because we don’t want the users to have direct access to the file.</p>
<p>3.	Now we are going back to the CPanel -&gt; Cron Jobs. On the common settings we enter Once a day (so the Command will be executed once a day)  and on the Command field we enter:<br />
php ‘the path to backup_filesystem.php’<br />
<img src="http://georgi-mitev.com/images/posts/4.2010/bf3.jpg" alt="Cron Job CPanel enter Command " /><br />
After that click on the ‘Add new cron job’ button and Voila !! – the Cron Job for backup of your database is ready.<br />
The archive is created using low tar compression, so if needed you can archive your site using stronger bzip2 compression by replacing: “tar –cvpzf filename.tar” with “tar –cjf tarname.bz2”.<br />
<img src="http://georgi-mitev.com/images/posts/4.2010/bf4.jpg" alt="Cron Job CPanel enter Command" /><br />
The full backup of your website is created in the /backup/files directory and can be downloaded via FTP if necessarily – as you see the filename include the date and time of the moment it has been created, so it won’t be hard for you to guess which is the latest version of the backup if needed.<br />
Thank you for your time, next time I’m going to show you how to perform similar backup, but this time full database backup instead of filesystem backup.<br />
Cheers <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2010/04/26/schedule-website-file-system-backup-php-cron-job/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>HTTP, HTTPS, and SSL via PHP</title>
		<link>http://georgi-mitev.com/2009/05/10/http-https-and-ssl-via-php/</link>
		<comments>http://georgi-mitev.com/2009/05/10/http-https-and-ssl-via-php/#comments</comments>
		<pubDate>Sun, 10 May 2009 07:08:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[https and php]]></category>
		<category><![CDATA[https via php]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[sockets]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[ssl and php]]></category>
		<category><![CDATA[ssl via php]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=81</guid>
		<description><![CDATA[Today i found this very cool tutorial regarding the using of using ssl with PHP.
I&#8217;ll copy here the most interesting of it.
HTTP with PHP Sockets
// don&#8217;t need to specify http, it&#8217;s the default protocol
$hostname = &#8220;www.google.com&#8221;;
$port     = 80;
// create and configure the client socket
$fp = fsockopen($hostname, $port); // optional: $error_number, $error_string, [...]]]></description>
			<content:encoded><![CDATA[<p>Today i found this very cool tutorial regarding the using of using ssl with PHP.</p>
<p>I&#8217;ll copy here the most interesting of it.</p>
<h2><a name="http-sockets">HTTP with PHP Sockets</a></h2>
<p>// don&#8217;t need to specify http, it&#8217;s the default protocol<br />
$hostname = &#8220;www.google.com&#8221;;<br />
$port     = 80;</p>
<p>// create and configure the client socket<br />
$fp = fsockopen($hostname, $port); // optional: $error_number, $error_string, $connect_timeout<br />
if ($fp) {<br />
    stream_set_timeout($fp, 30); // seconds to wait for i/o operations</p>
<p>    // send request headers<br />
    fwrite($fp, &#8220;GET / HTTP/1.1\r\n&#8221;);<br />
    fwrite($fp, &#8220;Host: $hostname\r\n&#8221;);<br />
    fwrite($fp, $additional_headers); // Accept, User-Agent, Referer, etc.<br />
    fwrite($fp, &#8220;Connection: close\r\n&#8221;);</p>
<p>    // read response<br />
	$response = &#8220;&#8221;;<br />
    while (!feof($fp)) {<br />
        $response .= fgets($fp, 128);<br />
    }<br />
	echo $response;</p>
<p>    // close the socket<br />
    fclose($fp);<br />
}<br />
<span id="more-81"></span></p>
<h2><a name="raw-ssl-sockets">Direct SSL Sockets in PHP</a></h2>
<p>You don&#8217;t have to send request headers in the above example. You can actually connect to some servers and send raw text with <code>fwrite</code>. Because you have to implement the HTTP/HTTPS protocol yourself if you want it, sockets are considered &#8220;clean&#8221; connections.<br />
You don&#8217;t have to send request headers in the above example. You can actually connect to some servers and send raw text with fwrite. Because you have to implement the HTTP/HTTPS protocol yourself if you want it, sockets are considered &#8220;clean&#8221; connections.</p>
<p>// note that &#8220;ssl&#8221; is the protocol, NOT &#8220;https&#8221;<br />
$hostname  = &#8220;ssl://your-secure-site.com&#8221;;<br />
$port      = 443;</p>
<p>// create and configure the client socket<br />
$fp = fsockopen($hostname, $port);<br />
if ($fp) {<br />
    stream_set_timeout($fp, 30);</p>
<p>	// send data (or build HTTPS headers similar to first example)<br />
	fwrite($fp, &#8220;your message goes here&#8221;);</p>
<p>    // read response<br />
    while (!feof($fp)) {<br />
        echo fgets($fp, 128);<br />
    }</p>
<p>    // close the socket<br />
    fclose($fp);<br />
}</p>
<h2><a name="https-curl">HTTPS via cURL</a></h2>
<p>PHP doesn&#8217;t directly support attaching client certificates to web requests with <code>fsockopen</code>, so  you have to use the <code>cURL</code> library.<br />
$url = &#8220;https://your-secure-site.com/secure-service.php&#8221;;<br />
$port = 443;</p>
<p>// POST data, formatted just like a GET query string<br />
$request = &#8220;name=hb&amp;age=27&amp;site=arguments.callee.info&#8221;;</p>
<p>// the client certificate path MUST be a physical path, not url<br />
$certificate = &#8220;C:\\certificates\\test.crt&#8221;; // windows example<br />
$certificate = &#8220;/etc/pki/tls/private/test.crt&#8221;; // unix/linux example<br />
$password = &#8216;mypassword&#8217;; // client certificate&#8217;s key</p>
<p>// more details at http://php.net/curl<br />
$ch = curl_init();<br />
curl_setopt($ch, CURLOPT_POST, 1);<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />
curl_setopt($ch, CURLOPT_URL, $url);<br />
curl_setopt($ch, CURLOPT_PORT, $port);<br />
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);<br />
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);<br />
curl_setopt($ch, CURLOPT_SSLCERT, $certificate);<br />
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $password);</p>
<p>// fetch response and close the socket<br />
$response = curl_exec($ch);<br />
curl_close($ch);</p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/05/10/http-https-and-ssl-via-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>mysql copy entire database to remote host</title>
		<link>http://georgi-mitev.com/2009/04/17/mysql-copy-entire-database-to-remote-host/</link>
		<comments>http://georgi-mitev.com/2009/04/17/mysql-copy-entire-database-to-remote-host/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 12:27:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[backup remote host]]></category>
		<category><![CDATA[copy database]]></category>
		<category><![CDATA[copy database to remote host]]></category>
		<category><![CDATA[db backup mysql]]></category>
		<category><![CDATA[mysqldump command]]></category>
		<category><![CDATA[mysqldump remote host]]></category>
		<category><![CDATA[remote database backup]]></category>
		<category><![CDATA[remote db backup]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=203</guid>
		<description><![CDATA[I needed to create a backup on my mysql database on remote host. I found out that there is a way that you can actually do that with mysqldump  . I didn&#8217;t believe that it will be so easy but i decided to give it a try. After all the stuff i read on [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to create a backup on my mysql database on remote host. I found out that there is a way that you can actually do that with mysqldump <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I didn&#8217;t believe that it will be so easy but i decided to give it a try. After all the stuff i read on the net about it there was&#8217;nt a single working example of it &#8211; so after some testing i managed to do it <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
so here it is:</p>
<p>first i will show you how to use mysqldump to backup your database on your harddrive on your local computer under windows. Go to your command prompt -> Start -> Run -> write &#8220;cmd&#8221; -> hit enter<br />
go to your mysql bin directory, in case that you use xampp, and it&#8217;s installed on c:\xampp, it should be in c:\xampp\mysql\bin<br />
you can do that by typing &#8220;cd \&#8221; and then &#8220;cd xampp\mysql\bin&#8221; (i&#8217;m trying to write this tutorial as simple as possible so that everybody will get it <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) </p>
<p>after that, to backup your database on local mashine you should write:<br />
mysqldump &#8211;add-drop-table -h localhost &#8211;user=root &#8211;password=yourpass yourDBname > OutputFile.sql</p>
<p>voilla <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>so if you want to backup your database to remote host the command gets a bit more sophisticated <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
here we go:</p>
<p>copy databse and it&#8217;s data from one server to another:<br />
mysqldump &#8211;user=root &#8211;password=yourPassword &#8211;opt localDB | mysql -h 192.168.1.35 &#8211;user=root &#8211;password=remotePassword remoteDB</p>
<p>In our case we copy our local database &#8220;localDB&#8221; into the database &#8220;remoteDB&#8221; on the machine with 192.168.1.35</p>
<p>we can also do the command like this:<br />
mysqldump -h 192.168.1.17 &#8211;user=test &#8211;password=12345 &#8211;opt remoteDB<br />
 | mysql -h 192.168.1.51 &#8211;user=root &#8211;password=bg_820918 remoteDB</p>
<p>in this case we copy the database &#8220;remoteDB&#8221; from remote host to another remote host in the database &#8220;remoteDB&#8221;</p>
<p>now you see how powerfull mysqldump really is, and that&#8217;s only few of the things it&#8217;s capable of <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I hope this will was usefull for someone <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/04/17/mysql-copy-entire-database-to-remote-host/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Simple script to feed your site with some RSS that you like ;)</title>
		<link>http://georgi-mitev.com/2009/04/08/simple-script-to-feed-your-site-with-some-rss/</link>
		<comments>http://georgi-mitev.com/2009/04/08/simple-script-to-feed-your-site-with-some-rss/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 12:10:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[import feed]]></category>
		<category><![CDATA[include feed]]></category>
		<category><![CDATA[php script]]></category>
		<category><![CDATA[put feed]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[xml rss]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=193</guid>
		<description><![CDATA[Hello fellas,  because these days i had a case where i had to include some RSS feed on my site and i needed a very simple and fast solution in php how to do it i was very dissapointed from what i&#8217;ve found on the web. There are all kind of widgets, tools PHP scripts [...]]]></description>
			<content:encoded><![CDATA[<p>Hello fellas,  because these days i had a case where i had to include some RSS feed on my site and i needed a very simple and fast solution in php how to do it i was very dissapointed from what i&#8217;ve found on the web. There are all kind of widgets, tools PHP scripts using the xml-reader class, whatever &#8211; but i just needed some very simple solution. So ofcourse i had to write it myself at the end <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>in this example i&#8217;m going to import feed from yahoo&#8217;s technology news rss:</p>
<p><span id="more-193"></span></p>
<p>first i&#8217;m going to use the &#8220;simplexml_load_file&#8221; to check what we got in this yahoo url</p>
<p>&lt;?php<br />
$xmlobj = simplexml_load_file(&#8220;http://rss.news.yahoo.com/rss/tech&#8221;);<br />
print header(&#8220;Content-type: text/plain&#8221;);<br />
print_r($xmlobj);<br />
?&gt;</p>
<p>my output on the browser looks like this</p>
<pre>SimpleXMLElement Object
(
    [@attributes] =&gt; Array
        (
            [version] =&gt; 2.0
        )

    [channel] =&gt; SimpleXMLElement Object
        (
            [title] =&gt; Yahoo! News: Technology News
            [copyright] =&gt; Copyright (c) 2009 Yahoo! Inc. All rights reserved.
            [link] =&gt; http://news.yahoo.com/i/738
            [category] =&gt; technology
            [description] =&gt; Technology News
            [language] =&gt; en-us
            [lastBuildDate] =&gt; Wed, 08 Apr 2009 12:02:30 GMT
            [ttl] =&gt; 5
            [image] =&gt; SimpleXMLElement Object
                (
                    [title] =&gt; Yahoo! News
                    [width] =&gt; 142
                    [height] =&gt; 18
                    [link] =&gt; http://news.yahoo.com/i/738
                    [url] =&gt; http://l.yimg.com/a/i/us/nws/th/main_142b.gif
                )

            [item] =&gt; Array
                (
                    [0] =&gt; SimpleXMLElement Object
                        (
                            [title] =&gt; Cable's answer to online's ad success: targeting
    (AP)

                            [link] =&gt; http://us.rd.yahoo.com/dailynews/rss/tech/*http://news.yahoo.com/s/ap/20090407/ap_on_hi_te/cable_targeted_advertising

                            [category] =&gt; technology
                            [pubDate] =&gt; Tue, 07 Apr 2009 20:37:20 GMT
                            [description] =&gt; &lt;p&gt;&lt;a href="http://us.rd.yahoo.com/dailynews/rss/tech/*http://news.yahoo.com/s/ap/20090407/ap_on_hi_te/cable_targeted_advertising"&gt;&lt;img src="http://d.yimg.com/a/p/ap/20090407/capt.0d1190bc652444d0b0f4eb9bb9f0836c.cable_targeted_advertising_nybz175.jpg?x=130&amp;y=86&amp;q=85&amp;sig=52xM5q9qwuq.Eq2_2pqO3A--" align="left" height="86" width="130" alt="FILE - In this April 2, 2009 file photo, a view of the user interface for Tru2way technology is seen on display inside the Broadband Nation exhibit at The Cable Show at the Washington Convention Center in Washington. Cable's efforts to standardize their systems around Tru2way will make it easier to deploy so-called 'addressable' ads regardless of operator, said Dallas Clement, senior vice president of strategy and development at Cox Communications. (AP Photo/Gerald Herbert, file)" border="0" /&gt;&lt;/a&gt;AP - You're watching Jon Stewart's "The Daily Show," when suddenly you see a commercial for the Mustang convertible you've been eyeing Â— with a special promotion from Ford, which knows you just ended your car lease.&lt;/p&gt;&lt;br clear="all"/&gt;
                        )

so i won't be needing the RSS's channel news, i want only the items in that -&gt; so i do:
&lt;?php
$xmlobj = simplexml_load_file("http://rss.news.yahoo.com/rss/tech");
print header("Content-type: text/plain");
print_r($xmlobj-&gt;channel-&gt;item);
?&gt;

after that i can remove the "print header("Content-type: text/plain");" ( i used it just not to show the images but to be able to see all the site just like a raw text <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )

<strong>so all the code that i'm going to need for my RSS Feed importer will be :</strong>

&lt;?php
$xmlobj = simplexml_load_file("http://rss.news.yahoo.com/rss/tech");

foreach($xmlobj-&gt;channel-&gt;item as $item){
	echo "&lt;a href='".$item-&gt;link."'&gt;".$item-&gt;title."&lt;/a&gt;&lt;br /&gt;";
	echo $item-&gt;description."&lt;br /&gt;";
}
?&gt;
and here is the result:

<a rel="lightbox" href="http://georgi-mitev.com/images/posts/4.2009/rss.jpg"><img title="including rss from yahoo feeder using php" src="http://georgi-mitev.com/images/posts/4.2009/rss.jpg" alt="including rss from yahoo feeder using php" width="600" height="340" /></a>

<strong>so 4 rows in php and voilla( i hope that's the way to spell it <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )
</strong>we gotta fully working RSS(xml) importer for our shiny site -)</pre>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/04/08/simple-script-to-feed-your-site-with-some-rss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Object Oriented aspects PHP</title>
		<link>http://georgi-mitev.com/2009/03/30/simple-object-oriented-aspects-php/</link>
		<comments>http://georgi-mitev.com/2009/03/30/simple-object-oriented-aspects-php/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 05:44:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[database link]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[mysqli]]></category>
		<category><![CDATA[object oriented php]]></category>
		<category><![CDATA[php class]]></category>
		<category><![CDATA[__constructor]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=171</guid>
		<description><![CDATA[I&#8217;m going to talk about some good object oriented practices for small/medium projects. The object oriented programming itself will save you enourmous amount of time. The inheritance is part of the Object Oriented Programming (OOP) and is very good thing that is going to save you even more time when you start to use some [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to talk about some good object oriented practices for small/medium projects. The object oriented programming itself will save you enourmous amount of time. The inheritance is part of the Object Oriented Programming (OOP) and is very good thing that is going to save you even more time when you start to use some object oriented model in your programming. </p>
<p>Let&#8217;s say we need to have some root class &#8211; lets say &#8220;Base&#8221;, with the __construct() (the class&#8217;s constructor) &#8211; notice that since PHP 5.0 the constructor of a class is defined in __constructs(), instead of &#8220;the-name-of-your-class&#8221;(). Anyway you can define the constructor information in Base() as well, but better do it in __construct, because you don&#8217;t know if there will be support for the old PHP 4 constructors in PHP 6 <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>so let&#8217;s get on business..<br />
<span id="more-171"></span><br />
In our Base class we are going to add some protected variables (they are going to be viewed from all delivered classes, and from the Base itself)<br />
In our case we add a constructor that creates a mysqli connection to our host, and that&#8217;s all we are going to use this class for &#8211; for the connection with the DataBase.</p>
<p>Class Base {<br />
    protected $host = &#8220;localhost&#8221;;<br />
    protected $user = &#8220;root&#8221;;<br />
    protected $pass = &#8220;&#8221;;<br />
    protected $name = &#8220;MerchantsDB;<br />
    protected $char = &#8220;utf-8&#8243;;<br />
    protected $table = &#8220;merchants&#8221;;</p>
<p>		function __construct(){<br />
		if(($this->link = new mysqli($this->host, $this->user, $this->pass, $this->name)) === false){ $this->error(&#8220;cant login&#8221;);</p>
<p>      }else{<br />
		  //echo &#8220;logged<br />&#8220;;<br />
         $this->link->set_charset($this->char) or $this->error(&#8220;set charset&#8221;);</p>
<p>		}<br />
	}<br />
}</p>
<p><?php</p>
<p>Class Merchant extends Base {</p>
<p>    function AddMerchant($mName, $mURL, $mAgent, $mUID, $mDate, $mManager, $mStatus, $mComment){</p>
<p>     $q = mysqli_query($this->link, &#8220;INSERT INTO &#8220;.$this->table.&#8221; (`MerchantName`, `MerchantURL`, `MerchantAgent`, `MerchantUserID`, `MerchantReceivedDate`, `MerchantManager`, `MerchantStatus`, `MerchantComment`) VALUES (&#8216;$mName&#8217;, &#8216;$mURL&#8217;, &#8216;$mAgent&#8217;, &#8216;$mUID&#8217;, &#8216;$mDate&#8217;, &#8216;$mManager&#8217;, &#8216;$mStatus&#8217;, &#8216;$mComment&#8217;)&#8221;);</p>
<p>      if($q){<br />
      	 echo &#8220;Merchant Successfully added !!&#8221;;<br />
      	return true;<br />
      }else{<br />
      	 echo &#8220;Invalid input data or duplicated URL !!&#8221;;<br />
      	return false;<br />
      }</p>
<p>    }</p>
<p>	function RemoveByID($id){<br />
			if(mysqli_query($this->link,&#8221;Delete from &#8220;.$this->table.&#8221; where MerchantID = &#8220;.$id)){<br />
				//echo &#8220;entry $id successfully removed&#8221;;<br />
			}<br />
		}<br />
	}</p>
<p>    function GetAll($order){<br />
      $q = mysqli_query($this->link,&#8221;select * from &#8220;.$this->table.&#8221; ORDER BY &#8220;.$order.&#8221; desc&#8221;);<br />
      $count = 1;</p>
<p>          while($row = mysqli_fetch_assoc($q)){<br />
			include(&#8220;Merchants.table.inc.php&#8221;);</p>
<p>            $count++;<br />
          }<br />
      }</p>
<p>}</p>
<p>So we have a class Merchant that is delivered from Base and so we inherit $link variable from the Base&#8217;s constructor. So when we call $this->link we have a fully working mysqli connection (that is more secure than the standard mysql).</p>
<p>As you see we have created 3 very simple functions of the Merchant class GetAll, RemoveByID, and AddMerchant<br />
in all of them we use $this->link delivered from our base class, which is very cool, because we can have a bunch of other classes &#8211; like Product, Car, Student&#8230; whatever and we don&#8217;t have to specify a single connection for each of them &#8211; we just inherit it from the Base class &#8211; with &#8220;extends Base&#8221; at the class declaration <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>that&#8217;s it for now i hope this example was useful for you <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/03/30/simple-object-oriented-aspects-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use local script to login to remote web site (modify Header)</title>
		<link>http://georgi-mitev.com/2009/03/20/login-locally-to-remote-host/</link>
		<comments>http://georgi-mitev.com/2009/03/20/login-locally-to-remote-host/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 07:41:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[fgets]]></category>
		<category><![CDATA[fputs]]></category>
		<category><![CDATA[fsockopen]]></category>
		<category><![CDATA[Login remotely]]></category>
		<category><![CDATA[PHP modify POST]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=153</guid>
		<description><![CDATA[I don&#8217;t know if this will be interesting for you, but it was very interesting for me when i found that it is very easy to modify header information and send POST/GET variables through header using php. Anyway with CURL you are able to do much more that just modify the header information etc., but [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know if this will be interesting for you, but it was very interesting for me when i found that it is very easy to modify header information and send POST/GET variables through header using php. Anyway with CURL you are able to do much more that just modify the header information etc., but we wont have that time-frame <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I will give you simple example where i login through script on localhost on some site &#8211; in this example: &#8220;gametrailers.com&#8221; &#8211; without actually enter any username and password <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , i think this will be the easiest way to understand it.</p>
<p>so here is the example:<br />
<span id="more-153"></span></p>
<p>on your localhost create php file &#8211; &#8220;loadUrl.php&#8221;</p>
<p>&lt;base href=&#8221;http://www.gametrailers.com/&#8221; /&gt;<br />
&lt;!&#8211; we use base href to be able to load the css and the js paths correctly on the site &#8211;&gt;</p>
<p>$port = 80;<br />
//usually this is default http port so probably u won&#8217;t have to change this</p>
<p>$server= &#8216;www.gametrailers.com&#8217;;<br />
//i tested thet with this host, but i guess it will work on many other URLs as well</p>
<p>$url = &#8216;/index.php?&#8217;;  //this is the index file of the url</p>
<p>$content = &#8216;userlog&#8217;;<br />
//these are custom variables especially for gametrailers &#8211; probably you won&#8217;t have to use them<br />
$content .= &#8216;&amp;try=1&#8242;;<br />
//these are custom variables especially for gametrailers &#8211; probably you won&#8217;t have to use them</p>
<p>//enter your site login name<br />
$content .= &#8216;&amp;username=your_username&#8217;;<br />
//enter your site pass<br />
$content .= &#8216;&amp;password=your_pass&#8217;;<br />
$content_length = strlen($content);<br />
//don&#8217;t touch this one &#8211; the header has to have valid lenght</p>
<p>$headers = &#8220;POST $url HTTP/1.0\r\n&#8221;;<br />
$headers.= &#8220;Content-type: application/x-www-form-urlencoded\r\n&#8221;;<br />
$headers.= &#8220;Host: $server\r\n&#8221;;<br />
$headers.= &#8220;Content-length: $content_length\r\n\r\n&#8221;;</p>
<p>$fp = fsockopen($server, $port, $errno, $errstr);<br />
//we open connection to our URL<br />
if (!$fp) return false;</p>
<p>fputs($fp, $headers);</p>
<p>fputs($fp, $content);<br />
$ret = &#8220;&#8221;;<br />
while (!feof($fp)) {<br />
$ret.= fgets($fp, 1024);<br />
//we get the content of the URL<br />
}<br />
fclose($fp);</p>
<p>print &#8220;&lt;pre style=&#8221;position:absolute;z-index:100;&#8221;&gt;&#8221;.$ret.&#8221;&lt;/pre&gt;&#8221;;</p>
<p>//we print the actual content of the website, and finally we are logged as user <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
?&gt;</p>
<p>You see &#8211; succeed to login on this URL (gametrailers), but on for some other URL you will have to make some more custom solution. For example you will have to check the login form &#8211; what are the &#8220;name&#8221; properties for the html input elements, and to change that in the script, but after that everything should be fine <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/03/20/login-locally-to-remote-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamically (on request) Resize Images with PHP</title>
		<link>http://georgi-mitev.com/2009/03/19/resize-image-using-php/</link>
		<comments>http://georgi-mitev.com/2009/03/19/resize-image-using-php/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 07:51:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[joomla resize image]]></category>
		<category><![CDATA[php resize image]]></category>
		<category><![CDATA[resize image]]></category>
		<category><![CDATA[resize image script]]></category>
		<category><![CDATA[resize script]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=142</guid>
		<description><![CDATA[Hello   today i&#8217;m going to talk about resizing your the images in your site.
So let&#8217;s say for example that you have a CMS system &#8211; like Joomla for example. In the administration you usually have functionality like &#8211; uploading images and linking them in your content.
But often the problem with that is that [...]]]></description>
			<content:encoded><![CDATA[<p>Hello <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  today i&#8217;m going to talk about resizing your the images in your site.<br />
So let&#8217;s say for example that you have a CMS system &#8211; like Joomla for example. In the administration you usually have functionality like &#8211; uploading images and linking them in your content.<br />
But often the problem with that is that usually the customers will upload too large images (copied in raw jpeg directly from their cameras) and when they link them to the content of their website, it get&#8217;s really messy.<br />
Anyway you can fix this by writing some script that directly resize the image to some resolution like 500px/* for example, but what will happen if you want to put <a href="http://www.huddletogether.com/projects/lightbox/">lightbox </a>or something other to show the image in large resolution, or you just want to put some function to download the original file etc. You simply can&#8217;t because the image was resized at the moment it was uploaded on the server.</p>
<p><strong>How about dinamically resize the image at the very  moment that client requests it? </strong></p>
<p>So that way we wont have a big image that the client has to download, and at the same time we will still have the original, good resolution copy of the image, in case that we need it. We can also use the following PHP script for creating thumbnails.</p>
<p>Well &#8211; as you will see below it&#8217;s not hard at all to do it,  i mean not hard at all <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-142"></span>So what we are about to do is create a PHP file that we are going to use for resize of the image.</p>
<p>We are going to pass the images to it like $_GET parameters, for example:</p>
<p>resizeImage.php?image=/images/file.jpg</p>
<p>and the image on our site will look like &lt;img src=&#8221;resizeImage.php?image=/images/file.jpg&#8221; alt=&#8221;#&#8221; /&gt;</p>
<p>so let&#8217;s get to the script:<br />
filename: resizeImage.php<br />
<code>$f = htmlspecialchars($_GET['image']);</code></p>
<p>$im = imagecreatefromjpeg($f);<br />
//we create the image from the $_GET path<br />
$a  = getimagesize($f);</p>
<p>$newwidth = 400;<br />
//we decide to make the picture 400px width and depends on the width/height ratio we calculate what should be the height<br />
if ($a[0] &gt; $a[1]) {<br />
$percentage = $a[0] / $a[1];<br />
$newheight = 400 / $percentage;<br />
} else {<br />
$percentage = $a[1] / $a[0];<br />
$newheight = 400 * $percentage;<br />
}</p>
<p>$d=imagecreatetruecolor($newwidth,$newheight);</p>
<p>imagecopyresized($d, $im, 0, 0, 0, 0, $newwidth, $newheight, $a[0], $a[1]);</p>
<p>header(&#8220;Content-type: image/jpeg&#8221;);<br />
//we modify the header to treat resizeImage.php as image </p>
<p>imagejpeg($d, null, 90 );<br />
//here we show our modified image at quality 90</p>
<p>imagedestroy($im);<br />
//we free the memory (not necessary, but it&#8217;s good practic)<br />
imagedestroy($d);<br />
?&gt;</p>
<p>So that&#8217;s about it <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I hope it was useful for you.<br />
Anyway i wrote another script that replaces all the content from your site ( for example joomla site)<br />
and basically does the following: when we have <img src="file.jpg" alt="" /> it uses regular expression to replace it like this <img src="imageResize.php?img=file.jpg" alt="" /> and basically it does all the work for you with the replacing <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
if you need it i can post it here as well <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>have a nice one -)</p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/03/19/resize-image-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alien Hominid &#124; flash arcade game</title>
		<link>http://georgi-mitev.com/2009/03/12/alien-booya-flash-game-arcade/</link>
		<comments>http://georgi-mitev.com/2009/03/12/alien-booya-flash-game-arcade/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 23:38:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[alien]]></category>
		<category><![CDATA[alien booya]]></category>
		<category><![CDATA[arcade]]></category>
		<category><![CDATA[flash game]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[metal gear]]></category>
		<category><![CDATA[metal gear alternative]]></category>
		<category><![CDATA[nice game]]></category>
		<category><![CDATA[shoot]]></category>
		<category><![CDATA[shooting game]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=135</guid>
		<description><![CDATA[This is metal gear solid kind-a game W. i highly recommend it if you have&#8217;nt tried it before. You come in the role of the bad alien  that kills FBI agents, and in the same time unknown why you must have to kill all sorts of weird robots etc. This is very classic game [...]]]></description>
			<content:encoded><![CDATA[<p>This is metal gear solid kind-a game W. i highly recommend it if you have&#8217;nt tried it before. You come in the role of the bad alien  that kills FBI agents, and in the same time unknown why you must have to kill all sorts of weird robots etc. This is very classic game so don&#8217;t miss it ;D</p>
<p><a rel="lightbox" href="http://georgi-mitev.com/images/posts/3.2009/alien.jpg"><img src="http://georgi-mitev.com/images/posts/3.2009/alien.jpg" alt="alien arcade flash game" width="50%" height="50%" /></a></p>
<p>if you want to play the game &#8211; click <strong>Continue reading</strong></p>
<p><span id="more-135"></span></p>
<p><!--<br />
<object width="550" height="400" data="http://georgi-mitev.com/files/games/alien_booya.swf" type="application/x-shockwave-flash"><param name="src" value="http://georgi-mitev.com/files/games/alien_booya.swf" /></object> &#8211;></p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/03/12/alien-booya-flash-game-arcade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
