opless / phpliteadmin

Automatically exported from code.google.com/p/phpliteadmin
0 stars 0 forks source link

Is my directory scanned for databases instead of manual settings? #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Is my directory scanned for databases instead of manual settings?

I changed variable $directory from "." to "../../databases, but here is what I 
get after authorization.
http://www.imageup.ru/img150/2011-05-30-030234_851x597_scrot669083.png

I checked twice that $directory is not "." anymore 

Original issue reported on code.google.com by owl.brai...@gmail.com on 29 May 2011 at 11:07

GoogleCodeExporter commented 9 years ago
Click "logout", and then log back in. See what happens. Does it work when you 
use "." as the directory?

Original comment by daneirac...@gmail.com on 30 May 2011 at 4:00

GoogleCodeExporter commented 9 years ago
After logout and login again nothing happened.
http://www.imageup.ru/img153/2011-05-30-160527_851x597_scrot669419.png

After I changed $directory to "." that appears
http://www.imageup.ru/img153/2011-05-30-160331_851x597_scrot669415.png
It is because I dont have any databases in current directory, in 
"../../databases" I do.

Original comment by owl.brai...@gmail.com on 30 May 2011 at 12:06

GoogleCodeExporter commented 9 years ago
It seems that your phpliteadmin.php script is stuck with dot (".") as directory 
value, no matter that I change it.

Original comment by owl.brai...@gmail.com on 30 May 2011 at 8:39

GoogleCodeExporter commented 9 years ago
I am not seeing this problem. I created a directory and then changed the 
$directory variable to point to it, and it worked as it should. It found all 
the databases in that directory and used them in the application. I don't know 
what to tell you. 

Original comment by daneirac...@gmail.com on 31 May 2011 at 7:55

GoogleCodeExporter commented 9 years ago
I have warning
"The database, 'qwerty.db', does not exist and cannot be created because the 
containing directory, '.', is not writable. The application is unusable until 
you make it writable."

Interesting facts.
1. I read from screen " 'qwerty.db', does not exist and cannot be created ". 
What does it mean? It wrote the name of the base - qwerty.db. So why does it 
say that database does not exist and cannot be created, if it can access it and 
even type its name? Strange caption.

2. My database 'qwerty.db' really located in ../../databases (it is my value of 
$directory). Thus, phpliteadmin.php really reads directory I indicated. BUT, 
this directory has 0777 permissions, and so it IS writable.

3. If script reads directory I indicated, why it complains about current 
directory '.' Why script stuck with that directory? It is true that my curreny 
directory ('.') IS NOT writable, because its permissions are 0755. BUT AGAIN, 
why on earth it refer to it. 

Screenshot
http://www.imageup.ru/img190/2011-05-31-163140_851x597_scrot670244.png

Original comment by owl.brai...@gmail.com on 31 May 2011 at 12:34

GoogleCodeExporter commented 9 years ago
I don't have an answer for you. I have recreated your exact situation, and the 
script works fine for me. 

Original comment by daneirac...@gmail.com on 31 May 2011 at 4:06

GoogleCodeExporter commented 9 years ago
OK, I am tired of this. Now I am looking into your code.
I commented some commands

if($directory!==false)

{

   if(is_dir($directory)) //make sure the directory is valid

   {

      $arr = scandir($directory);
 // !!! ARR IS LIST OF FILENAMES, NOT THEIR PATHS !!!

      $databases = array();

      $j = 0;

      for($i=0; $i<sizeof($arr); $i++) //iterate through all the files in the databases

      {

         $file = pathinfo($arr[$i]);

         $ext = strtolower($file['extension']);

         if($ext=="sqlite" || $ext=="db" || $ext=="sqlite3" || $ext=="db3") //make sure the file is a valid SQLite database by checking its extension

            {

               $databases[$j]['path'] = $arr[$i];
  // !!! JUST FILENAME, i.e. qwerty.db, USED AS PATH !!!
               $databases[$j]['name'] = $arr[$i];

               $j++;

            }

         }

      }

Original comment by owl.brai...@gmail.com on 31 May 2011 at 7:50

GoogleCodeExporter commented 9 years ago
Nice work. I think you need to replace the line, $databases[$j]['path'] = 
$arr[$i] with this:

$databases[$j]['path'] = $directory."/".$arr[$j];

Try that and tell me if it works.

Original comment by daneirac...@gmail.com on 31 May 2011 at 8:30

GoogleCodeExporter commented 9 years ago
I changed the line, OF COURSE EVERYTHING WORKS NOW! 

:D :D :D 
Guys, do you have special "scandir" ??? :D 
scandir is scandir. Read manual. 
http://www.php.net/manual/en/function.scandir.php

I wonder how, on earth, it works for you :D

Original comment by owl.brai...@gmail.com on 31 May 2011 at 8:56

GoogleCodeExporter commented 9 years ago
Awesome! I think it was working for me because I wasn't referencing the parent 
directory, but rather, a subdirectory. Nice work on debugging. How would you 
like to become a developer for the project? 

This fix has been implemented in v1.8.6. Get it from SVN.

Original comment by daneirac...@gmail.com on 31 May 2011 at 9:03

GoogleCodeExporter commented 9 years ago
Developer? :) No, thanks. I looked through about 30 lines to find a bug from 
3113 :)

I currently have work. I try to move data from my previous DB in MySQL format 
to something lite and simple, and I found... TA-DA... sqlite.
I am photographer (kind of amateur :) ) but also programmer. And now I want to 
renew my website (photo gallery). I am trying to rewrire old scripts and switch 
to new database engine, as you can see.

Original comment by owl.brai...@gmail.com on 31 May 2011 at 9:47