Tuesday, April 16, 2013

How to Fix PhpMyPrepaid 0.4.rc3

 Phpmyprepaid in fedora
This is story of my experiment, when install phpmyprepaid 0.4.rc3, on fedora 18. And another "friends" who been installed, were FreeRADIUS version: 2.2, Chillispot version: 1.1, Mysql Server version: 5.5.30. and Apache/2.4.4 (Fedora). It was very difficult to install. A lot of errors that I got. Probably, phpmyprepaid is too old, has long been abandoned, and no support with new things.
let's see list error, so if you find the error again, you know how to fix that…

Can't open configuration file !
After phpmyprepaid downloaded, and extracted, I placed it in / var / www /, and created links for easy configuration.
# cd /var/www/
# tar zxvf phpmyprepaid
# ln -s /var/www/phpmyprepaid/www /var/www/html/hotspot

Then browsing to http://10.10.10.250/hotspot ( 10.10.10.250 is my ip address lancard)
welcome to phpmyprepaid setup

And I continue to follow the instructions, for the configuration. Until the step 8,  I got  an error, as shown below.
creating database error in phpmyprepaid

How to fix.
Edit the file step7.php on install folder. Find the line
die ("<center><span class='stop'>Can't open configuration file !</span></center><br><br>");
Delete  or comment  the line. Then add some variable, like below…
# mcedit /var/www/html/hotspot/install/step7.php
if ($fd = fopen("../phpmyprepaid.conf.php", "w+"))      {
                                for ($i = 0; $i <= 20; $i++)
                                        fwrite ($fd, $file[$i]);
                                fclose ($fd);
                        } else {
//  die ("<center><span class='stop'>Can't open configuration file !</span></center><br><br>");
                            for ($i = 0; $i <= 20; $i++)
                                        fwrite ($fd, $file[$i]);
                                fclose ($fd);
                        }

I tried again, and then I found status done, like this..
phpmyprepaid - creating database done

After installation and configuration of phpmyprepaid, then browsing again to 10.10.10.250/hotspot,
Installation step would normally appear again . what happened .... ?? there seems to be missing... After I check, the problem in index.html
if (!file_exists("./phpmyprepaid.conf.php"))
                header("Location: ./install/setup.php");
        else {
        include('config.inc.php');

How to fix
Make a file with name "phpmyprepaid.conf.php"
vim /var/www/html/phpmyrepaid/www/phpmyprepaid.conf.php
and this is content of  phpmyprepaid.conf.php file.
<?
/*
PhpMyPrepaid is developped with GPL Licence 2.0 :
http://www.gnu.org/licenses/gpl.txt or read LICENSE file.

We are using Oreon for base code: http://www.oreon-project.org. Dialup Admin fo
 user management and many more things: http://www.freeradius.org.
*/
// database
$conf_pra['host'] = "localhost";
$conf_pra['user'] = "phpmyprepaid";
$conf_pra['password'] = " phpmyprepaidpasswd";
$conf_pra['db'] = "phpmyprepaiddb";
$conf_pra['dbtype'] = "mysql";
$conf_pra['sqlport'] = "3306";

// path to classes
$classdir='./class';
?>

Save, and when browsing, phpmyprepaid appear with user and password.
phpmyprepaid - login administrator

Remove installation directory, so there's no warning again.
# rm -Rf /var/www/html/hotspot/install
# chmod 755 /var/www/phpmyprepaid/www

ORDER BY priority: Table ' phpmyprepaiddb.radusergroup' doesn't exist
We turn to the error in the radius server. To test the radius server I use a radtest tool.
#radtest jvxumn pnpn 127.0.0.1 1 testing123
And this is result,
rlm_sql_mysql: MYSQL check_error: 1146 received
[sql] database query error, SELECT groupname           FROM radusergroup           WHERE username = 'hsanlw'           ORDER BY priority: Table 'phpmyprepaiddb.radusergroup' doesn't exist
[sql] Error retrieving group list
[sql] Error processing groups; rejecting user

How to fix
In phpmyprepaid database, no radusergroup table, is this table missing or does not exist? Ok. Make radusergroup, by copying an existing radusergroup table in FreeRADIUS. I used phpmyadmin to do that.

Database query error - Unknown column 'username' in 'field list'
I found another error when running radtest
#radtest jvxumn pnpn 127.0.0.1 1 testing123
rlm_sql (sql): Reserving sql socket id: 3
rlm_sql_mysql: MYSQL check_error: 1054 received
rlm_sql (sql) in sql_postauth: Database query error - Unknown column 'username' in 'field list'
rlm_sql (sql): Released sql socket id: 3
++[sql] returns fail
Using Post-Auth-Type REJECT

How to fix.
The cause is on the table, the database does not recognize the "username" column of data input, which is on the table radpostauth, is a "user" column, So?? Change the name. On "user" Column changed to "username".

Database query error - Unknown column 'authdate' in 'field list'
Another error, when running radtest
#radtest jvxumn pnpn 127.0.0.1 1 testing123
rlm_sql_mysql: MYSQL check_error: 1054 received
rlm_sql (sql) in sql_postauth: Database query error - Unknown column 'authdate' in 'field list'
rlm_sql (sql): Released sql socket id: 1
++[sql] returns fail
Using Post-Auth-Type REJECT

How to fix
The database does not recognize the "authdate" column of data input, which is on the table radpostauth, is a "date" column. Then change name column of table. At last, "authenticated successfully".
#radtest jvxumn pnpn 127.0.0.1 1 testing123
….
+- entering group PAP {...}
[pap] login attempt with password "pnpn"
[pap] Using clear text password "pnpn"
[pap] User authenticated successfully
….

Error when query the database: unknown column 'user'
I thought it was all over, When I clicked View accounts - accounts timed - (username) - the minus sign, delete user, User erased, but there was warning ...
phpmyprepaid - error when query database

How to fix.
Error, due, no user column. Ok, then add a line for the "user" column
phpmyprepaid - Error, due, no user column

Done. When delete user, there's no warning again.
phpmyprepaid - success delete user

No more bugs of phpmyprepaid that I found. If you find a bug, please submit to me. Phpmyprepaid 0.4rc3, which has made improvements, you can download at link below.

Link Download  : phpmyprepaid that have been fixed.

Licence : PhpMyprepaid is under GNU General Public License (GPL)

No comments:

Post a Comment