<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
 "http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">

<channel>
<title>PHP4IT</title>
<link>http://www.php4it.com/</link>
<description>PHP4IT</description>
<language>en-us</language>
<image>
 <title>PHP4IT</title>
 <url>http:/www.php4it.com/images/themes/php4it/images/php4it.gif</url>
 <link>http://www.php4it.com/</link>
</image>
<item>
<title>Guide to Getting PHP 5 to work with IIS 6 with custom identity</title>
<link>http://www.php4it.com/a-8.html</link>
<description>When you want PHP running in IIS to be able to read/write files on a Windows network share, you could run into a myriad of errors and problems.  Hopefully this article will help you get everything working smoothly.

Here what we want is to have IIS run as a Domain user who has the proper access to the network share.  After you have installed PHP (in ISAPI mode), go to the IIS Manager, Application Pools, right-click on DefaultAppPool (or the name of your application pool), and select Properties.  Go to the Identity tab and type in the User name and Password for the Domain user.  Don't forget to prefix the username with the Domain.  For instance (and for our example's sake):

MY_DOMAIN\my-user

Click OK and you will be asked to confirm the password again.

Now you'll want to make sure that you go to the server that has the target directory share and make sure all the permissions are set so that that MY_DOMAIN\my-user has the proper read or read/write permissions to that share.

Now back on the IIS server, go to Administrative Tools, Computer Management, expand Local Users and 
Groups, go to Groups, and double-click on IIS_WPG (IIS Worker Process Group).  You must add MY_DOMAIN\my-user to the group or else you may end up with the &quot;Service Unavailable&quot; message when you try to load the website.

Next go to Administrative Tools, Local Policies, and User Rights Assignment.  Add MY_DOMAIN\my-user to the following policies of &quot;Access this computer from the network&quot;, &quot;Act as part of the operating system&quot;, and &quot;Log on as a service&quot;.

Now go to the Properties of your website (&quot;Default Web Site&quot;), go to the Directory Security tab, and click on the Edit button for &quot;Authentication and access control&quot;.  If you have enabled anonymous access, make sure that the user name is set to MY_DOMAIN\my-user and the password is inputted correctly.

Restart IIS and voila, everything should work.  If not make sure you check the Event Viewer on the destination server and see if the error messages there give you any clue as to why it's not working.  If it doesn't work and you see Microsoft Authentication Security Account Logon Failure, then it's an issue with the user name and password specified there.

In your PHP script make sure that you escape backslashes for the network share you're trying to get to.  For instance if you're tring to do a &quot;opendir&quot; on &quot;\\my_server\my_files&quot;, you would do:

$dh = opendir(&quot;\\\\my_server\\my_files&quot;);

If you get PHP undefined function errors such as:

Fatal error: Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\your_script.php

make sure you enabled the module (in this case extension=php_mysql.dll) in php.ini.  If you did, it could well be that PHP is not reading the php.ini for some reason.  You can make sure by looking at the output of php_info() and look for &quot;Loaded Configuration File&quot;.  If it says &quot;(none)&quot;, then there's a problem.  Make sure that &quot;MY_DOMAIN\my-user&quot; (in our example) has read permissions to the php.ini file AND the directory in which it resides- whether it be C:\PHP or C:\Windows.

If you have trouble executing commands using exec(), passthru(), etc, and the script seems to hang, make sure you have given the proper permissions to cmd.exe.  So make sure that c:\windows, c:\windows\system32, and cmd.exe all can be read and executed by, in our example, MY_DOMAIN\my-user.

Good luck and I hope this guide helps.  These instructions could work for other PHP and Microsoft Internet Information Server (IIS) versions as well, though I used PHP 5.2 and IIS 6.</description>
</item>
<item>
<title>Securing the Recommend Us feature in PostNuke/PHP Nuke</title>
<link>http://www.php4it.com/a-7.html</link>
<description>I've noticed some oddball email bounces stemming from the Recommend_Us module trying to send email to non-existent email addresses.  A lot of them would contain spam words which I won't list here.  I came to the conclusion that this is a malicious attack on a PostNuke/PHP Nuke site trying to blacklist the server hosting the site as a source of spam. Therefore I think it is important that if you run a PostNuke or PHPNuke site that you take steps to secure the &quot;Recommend Us&quot; module.  Since I am running PostNuke, the solution here is based for that CMS, but the same concepts apply for PHP Nuke.  

Basically we want to make sure that a user is logged in before he/she can recommend the site/story from the site.

Here are the steps:

head over to your root PostNuke directory, go to modules, and Recommend_Us. 
Make a backup copy of index.php
Edit the file index.php.
Look for instances of:

  if (pnUserLoggedIn()) {

and in the else portion, put in something like the following:

die(&quot;You must be a member and logged in to send a recommendation.&quot;);

Note that some already have the &quot;else&quot; and some you will have to add yourself.

Next I would recommend changing the text input boxes for &quot;Your name&quot; and &quot;Your email&quot; into hidden inputs instead.  For instance, change:

    echo &quot;
    &amp;lt;table&amp;gt;
      &amp;lt;tr&amp;gt;
        &amp;lt;td&amp;gt;&amp;lt;span class=\&quot;pn-normal\&quot;&amp;gt;&amp;lt;label for=\&quot;YOURNAME\&quot;&amp;gt;&quot;._FYOURNAME.&quot;&amp;lt;/label&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;td&amp;gt;&amp;lt;input type=\&quot;text\&quot; name=\&quot;yname\&quot; value=\&quot;$yn\&quot; SIZE=\&quot;25\&quot; maxlength=\&quot;25\&quot; id=\&quot;YOURNAME\&quot; tabindex=\&quot;0\&quot; /&amp;gt;&amp;lt;/td&amp;gt;
      &amp;lt;/tr&amp;gt;
      &amp;lt;tr&amp;gt;
        &amp;lt;td&amp;gt;&amp;lt;span class=\&quot;pn-normal\&quot;&amp;gt;&amp;lt;label for=\&quot;YOUREMAIL\&quot;&amp;gt;&quot;._FYOUREMAIL.&quot;&amp;lt;/label&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;td&amp;gt;&amp;lt;input type=\&quot;text\&quot; name=\&quot;ymail\&quot; value=\&quot;$ye\&quot; size=\&quot;25\&quot; id=\&quot;YOUREMAIL\&quot; tabindex=\&quot;0\&quot; /&amp;gt;&amp;lt;/td&amp;gt;
      &amp;lt;/tr&amp;gt;


to

echo &quot;&amp;lt;table&amp;gt;
&amp;lt;input type=hidden name=\&quot;yname\&quot; value=\&quot;$yn\&quot;&amp;gt; &amp;lt;input type=hidden name=\&quot;ymail\&quot; value=\&quot;$ye\&quot;&amp;gt;


And voila you have just secured the recommendation feature from anonymous malicious users.</description>
</item>
<item>
<title>Adding the DBF dbase extensions in Red Hat Linux/Fedora</title>
<link>http://www.php4it.com/a-6.html</link>
<description>
The previous two articles showed how to convert and import data from DBF files into MySQL.  It's simple enough to enable the dbase extension for PHP for Windows, but if you're using Red Hat/Fedora, this is not as simple.  There's no rpm that you can simply install to enable the extension, so you have to recompile and build the PHP Redhat/Fedora RPM.  Here are the steps to do this (note that this can work with other extensions that you can't find the rpm for):


1) download the source rpm for PHP, usually it'll have the word &quot;src&quot; in the file name
2) install it - e.g. &quot;rpm -Uvh php_src.rpm&quot;
3) edit the php.spec file, usually located in /usr/src/redhat/SPECS/php.spec, and add &quot;--enable-dbase&quot;
4) run rpmbuild - &quot;rpmbuild -ba php.spec&quot;
5) Go to the directory of the newly created RPMs (e.g. /usr/src/redhat/RPMS/i386/) and install them (note the --force):



rpm -Uvh --force php-4.3.8-1.1.i386.rpm php-devel-4.3.8-1.1.i386.rpm php-imap-4.3.8-1.1.i386.rpm php-ldap-4.3.8-1.1.i386.rpm php-mysql-4.3.8-1.1.i386.rpm php-pgsql-4.3.8-1.1.i386.rpm php-odbc-4.3.8-1.1.i386.rpm php-snmp-4.3.8-1.1.i386.rpm php-domxml-4.3.8-1.1.i386.rpm php-xmlrpc-4.3.8-1.1.i386.rpm php-mbstring-4.3.8-1.1.i386.rpm php-debuginfo-4.3.8-1.1.i386.rpm



That should get the job done!
</description>
</item>
<item>
<title>Import/Convert DBF files into MySQL - Part 2</title>
<link>http://www.php4it.com/a-5.html</link>
<description>Here in part 2 we focus on reading from the DBF file (addresses.dbf) and then inserting the data into the MySQL table (in this case a table called &quot;addresses&quot;) created from the CREATE TABLE statement generated in part 1.

Before continuing note that you will need the DBase extensions compiled/loaded.  In Windows you simply uncomment out the line:

;extension=php_dbase.dll

In Linux and other *nix you will have to compile PHP with the &quot;--enable-dbase&quot; option.


The code will look for matching field names as it loops through the entire file and generate &amp; execute INSERT statements in MySQL.  Note that I start with record 1 as record 0 doesn't seem to contain actual data when using the dbase_get_record_with_names() function.  Here it goes:

</description>
</item>
<item>
<title>Import/Convert DBF files into MySQL - Part 1</title>
<link>http://www.php4it.com/a-4.html</link>
<description>If you've been presented with the task of having to import a Dbase/DBF - here's a two step way to approach the problem.  First the Mysql table structure needs to be created, and then the DBF is then read and inserted into the table.

I'll present step 1 today, which involves the conversion the output from the &quot;disp stru&quot; command in FoxPro into a MySQL create table statement.

Consider a DBF file called &quot;addresses.dbf&quot;- and the &quot;DISP STRU&quot; of the file looks like this:

   1  HNAME1      Character     30
   2  ADDRESS     Character     30
   3  EXTRA       Character     30
   4  CITY        Character     28
   5  STATE       Character      2
   6  ZIP         Character     10

The convert function would convert that to this:

HNAME1 char (30)
ADDRESS char (30)
EXTRA char (30)
CITY char (28)
STATE char (2)
ZIP char (10)

Here's the script:

</description>
</item>
<item>
<title>Workaround Solution for the 10 User Windows XP Pro Maximum Connections Limit</title>
<link>http://www.php4it.com/a-3.html</link>
<description>If you're using Windows XP Pro as a file server and often run into problems where users can't connect to because the 10 maximum simulaneous connections have been reached (or 5 maximum connections for XP Home) - here's a quick and simple solution via PHP.    The script basically uses &quot;net session&quot;, parses the output and looks for idle connections and disconnects them- in this case if they've been idle for a second or don't have any open files.  Combine this with some sort of cron app for Windows (I recommend PyCron), and it works terrifically:




Here's the sample crontab entry to run the script, which we're calling disconnect_idle_sessions.php, to run every minute:


* * * * * c:\php\php c:\php\disconnect_idle_sessions.php
</description>
</item>
<item>
<title>PHP-based cron script for Windows</title>
<link>http://www.php4it.com/a-2.html</link>
<description>You can easily create your own php cron-like script for Windows.  The basic gist of it is you create a database table (or you can simply create a text file) that will hold the information about the application to execute- i.e. command, switch, executed flag column, date, &amp; duration.  I propose a 2 script solution- cron.php &amp; cron_exec.php.

Cron.php would basically just call cron_exec.php every designated X seconds (or minutes, e.g.):



----

Here's cron_exec.php:

</description>
</item>
<item>
<title>Printing a form directly to a PCL printer (Linux)</title>
<link>http://www.php4it.com/a-1.html</link>
<description>
Let's say that you've built a web application with neat html tables &amp; forms, and you want your users to be able to click on a button and send the page directly to a PCL printer from your app.  Or you want the web application to automatically print the html form to a PCL printer.  Here's how to do it with PHP:

Output the html to a temporary file, e.g. fopen($tmp_file, &quot;w+&quot;) or die (&quot;Print error: Can't write file $tmp_file.&quot;);
convert the html file into a postscript file using the perl command line utility &quot;html2ps&quot; (download html2ps) - e.g. exec(&quot;html2ps /tmp/form.html &gt; /tmp/form.ps&quot;);    
convert the postscript file to PC using ghostscript, e.g. exec(&quot;gs -sDEVICE=laserjet -sPAPERSIZE=letter -sOutputFile=/tmp/form.pcl -dNOPAUSE -q /tmp/form.ps -c quit&quot;);  In this case you are converting the file form.ps into form.pcl
simply use lpr -P$name_of_your_print_queue to print the file - e.g. exec(&quot;lpr -Pmy_laserjet /tmp/form.pcl&quot;);  Now this is assuming that you've already have the print queue setup - voila!</description>
</item>
</channel>
</rss>
