Is my directory scanned for databases instead of manual settings?

Issue #26 resolved
Former user created an issue

Originally reported on Google Code with ID 26 ``` 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 ```

Reported by `owl.brainworker` on 2011-05-29 23:07:02

Comments (11)

  1. Dane Iracleous

    ``` Click "logout", and then log back in. See what happens. Does it work when you use "." as the directory? ```

    Reported by `diracleo` on 2011-05-30 04:00:48 - Status changed: `Started`

  2. Former user Account Deleted

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

    Reported by `owl.brainworker` on 2011-05-30 20:39:40

  3. Dane Iracleous

    ``` 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. ```

    Reported by `diracleo` on 2011-05-31 07:55:16

  4. Former user Account Deleted

    ``` 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 ```

    Reported by `owl.brainworker` on 2011-05-31 12:34:51

  5. Dane Iracleous

    ``` I don't have an answer for you. I have recreated your exact situation, and the script works fine for me. ```

    Reported by `diracleo` on 2011-05-31 16:06:34

  6. Former user Account Deleted

    ``` 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++;

    }

    }

    } ```

    Reported by `owl.brainworker` on 2011-05-31 19:50:05

  7. Dane Iracleous

    ``` 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. ```

    Reported by `diracleo` on 2011-05-31 20:30:14

  8. Dane Iracleous

    ``` 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. ```

    Reported by `diracleo` on 2011-05-31 21:03:31 - Status changed: `Fixed`

  9. Former user Account Deleted

    ``` 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. ```

    Reported by `owl.brainworker` on 2011-05-31 21:47:47

  10. Log in to comment