Ok button missing in browseable batch add. Ok button missing in browseable batch add.
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Ok button missing in browseable batch add.

Started by donnoman, February 25, 2005, 11:08:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

donnoman

I've seen this on both of my installs, and both of my installs use IIS. I don't know if thats a key problem.




Tranz

On a linux apache server, the OK button shows up.

donnoman

I've had a pretty consistent problem with it, I thought it was just something on that one server, but its now happening on my work server.


Tranz

Well, on my windows apache server, the folders don't even show up let alone the OK button. :D

kegobeer

On my Windows/Apache box, everything works as advertised.  This looks suspiciously like a server setup issue.  Donnoman and I ran into this before with certain $_SERVER variables not available to him that I was using.  There must be something slightly amiss in mine, Donnoman's, Thu's, or all of our setups.
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

Joachim Müller

hm, works as expected on my (older) IIS setup (on the intranet of the company server). I'll check on monday when I get back to work.

Joachim

Tranz

#6
It has something to do with $_REQUEST, which Andi pointed out before. When I replaced it with FILES and POST, the folders and the OK button showed up.

Since I didn't know which superglobals to use in the correct places, I put back REQUEST. I turned on magic_quotes_gpc and the minibrowser worked.

donnoman

I was just reading up on $_REQUEST for fixing one of Andi's other posts;

In php 4.3.0 $_FILES information was removed from $_REQUEST.

Quote
Request variables: $_REQUEST
Note: Introduced in 4.1.0. There is no equivalent array in earlier versions.

Note: Prior to PHP 4.3.0, $_FILES information was also included in $_REQUEST.

An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE.

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_REQUEST; to access it within functions or methods.

If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_REQUEST array. For related information, see the security chapter titled Using Register Globals. These individual globals are not autoglobals.


donnoman

Thu, update your CVS I just added $_REQUEST to be stripslashed as are _GET and _POST in int.php.inc for the other work I was doing. Magic Quotes won't have an effect on the _REQUEST vars now.

I'll test my config as well.

Tranz

I updated files. Turned off magic quotes and the folders disappeared. :-\\ Turned them back on and they reappeared.

donnoman

same here:

I've tracked it back to: cpg_get_webroot_path()

I've moved its code to a standalone page so I could comment it and see whats happening:

<html>
<head>
<title>Testing</title>
</head>
<body>

<?php
    
//global $PHP_SELF;
    // get the webroot folder out of a given PHP_SELF of any coppermine page

    // what we have: we can say for sure where we are right now: $PHP_SELF (if the server doesn't even have it, there will be problems everywhere anyway)
echo "PHP_SELF: $PHP_SELF <br>";

    
// let's make those into an array:
    
$path_from_serverroot[] = $_SERVER["SCRIPT_FILENAME"];
    if (isset(
$_SERVER["PATH_TRANSLATED"])) {
       
$path_from_serverroot[] = $_SERVER["PATH_TRANSLATED"];
    }
    
$path_from_serverroot[] = $HTTP_SERVER_VARS["SCRIPT_FILENAME"];
    
$path_from_serverroot[] = $HTTP_SERVER_VARS["PATH_TRANSLATED"];

    
// we should be able to tell the current script's filename by removing everything before and including the last slash in $PHP_SELF
    
$filename ltrim(strrchr($_SERVER['PHP_SELF'], '/'), '/');
echo 
"path_from_serverroot : ";
echo 
"<pre>";
print_r($path_from_serverroot);
echo 
"</pre>";
echo 
"filename: $filename <br>";
    
// let's eliminate all those vars that don't contain the filename (and replace the funny notation from windows machines)
    
foreach($path_from_serverroot as $key) {
        
$key str_replace('\\\\''/'$key); // replace the windows notation
        
if(strstr($key$filename) != FALSE) { // eliminate all that don't contain the filename
            
$path_from_serverroot2[] = $key;
        }
    }
echo 
"path_from_serverroot2 : ";
echo 
"<pre>";
print_r($path_from_serverroot2);
echo 
"</pre>";

    
// remove double entries in the array
    
$path_from_serverroot3 array_unique($path_from_serverroot2);

echo 
"path_from_serverroot3 : ";
echo 
"<pre>";
print_r($path_from_serverroot3);
echo 
"</pre>";

    
// in the best of all worlds, the array is not empty
    
if (is_array($path_from_serverroot3)) {
        
$counter 0;
        foreach(
$path_from_serverroot3 as $key) {
            
// easiest possible solution: $PHP_SELF is contained in the array - if yes, we're lucky (in fact we could have done this before, but I was going to leave room for other checks to be inserted before this one)
            
if(strstr($key$_SERVER['PHP_SELF']) != FALSE) { // eliminate all that don't contain $PHP_SELF
                
$path_from_serverroot4[] = $key;
                
$counter++;
            }
        }
    } else {
        
// we're f***ed: the array is empty, there's no server var we could actually use
echo "It thinks there's no server var we could use <br>";
        
$return '';
    }

    if (
$counter == 1) { //we have only one entry left - we're happy
        
$return $path_from_serverroot4[0];
echo 
"path_from_serverroot4 : ";
echo 
"<pre>";
print_r($path_from_serverroot4);
echo 
"</pre>";
    } elseif (
$counter == 0) { // we're f***ed: the array is empty, there's no server var we could actually use
echo "Second spot it thinks theres no server var <br>";
        
$return '';
    } else { 
// there is more than one entry, and they differ. For now, let's use the first one. Maybe we could do some advanced checking later
        
$return $path_from_serverroot4[0];
echo 
"path_from_serverroot4 : ";
echo 
"<pre>";
print_r($path_from_serverroot4);
echo 
"</pre>";
echo 
"thinks there is more than one entry and they differ <br>";
    }

    
// strip the content from $PHP_SELF from the $return var and we should (hopefully) have the absolute path to the webroot
    
$return str_replace($_SERVER['PHP_SELF'], ''$return);
echo 
"Supposedly absolute path to the webroot: $return <br>";
    
// the return var should at least contain a slash - if it doesn't, add it (although this is more or less wishfull thinking)
    
if ($return == '') {
        
$return '/';
    }
echo 
"What is finally returned: $return <br>";
?>


</body></html>


this is what I'm getting as output:

Notice: Undefined variable: PHP_SELF in c:\inetpub\wwwroot\webroot.php on line 12
PHP_SELF:

Notice: Undefined index: SCRIPT_FILENAME in c:\inetpub\wwwroot\webroot.php on line 15

Notice: Undefined index: SCRIPT_FILENAME in c:\inetpub\wwwroot\webroot.php on line 19
path_from_serverroot :
Array
(
   [0] =>
   [1] => c:\inetpub\wwwroot\webroot.php
   [2] =>
   [3] => c:\inetpub\wwwroot\webroot.php
)

filename: webroot.php
path_from_serverroot2 :
Array
(
   [0] => c:\inetpub\wwwroot\webroot.php
   [1] => c:\inetpub\wwwroot\webroot.php
)

path_from_serverroot3 :
Array
(
   [0] => c:\inetpub\wwwroot\webroot.php
)

Second spot it thinks theres no server var
Supposedly absolute path to the webroot:
What is finally returned: /



Tranz

#11
I tried your script with magic quotes off:
Quote
Notice: Undefined variable: PHP_SELF in C:\wamp\websites\cpg-dev\phpself.php on line 12
PHP_SELF:

Notice: Undefined index: PATH_TRANSLATED in C:\wamp\websites\cpg-dev\phpself.php on line 20
path_from_serverroot :

Array
(
   
  • => C:\\wamp\\websites\\cpg-dev\\phpself.php
        [1] => C:\\wamp\\websites\\cpg-dev\\phpself.php
        [2] =>
    )

    filename: phpself.php
    path_from_serverroot2 :

    Array
    (
       
  • => C:/wamp/websites/cpg-dev/phpself.php
        [1] => C:/wamp/websites/cpg-dev/phpself.php
    )

    path_from_serverroot3 :

    Array
    (
       
  • => C:/wamp/websites/cpg-dev/phpself.php
    )

    path_from_serverroot4 :

    Array
    (
       
  • => C:/wamp/websites/cpg-dev/phpself.php
    )

    Supposedly absolute path to the webroot: C:/wamp/websites/cpg-dev
    What is finally returned: C:/wamp/websites/cpg-dev

Using {$_SERVER['PHP_SELF']} I got this:
QuotePHP_SELF: /phpself.php

Notice: Undefined index: PATH_TRANSLATED in C:\wamp\websites\cpg-dev\phpself.php on line 20
path_from_serverroot :

Array
(
   
  • => C:\\wamp\\websites\\cpg-dev\\phpself.php
        [1] => C:\\wamp\\websites\\cpg-dev\\phpself.php
        [2] =>
    )

    filename: phpself.php
    path_from_serverroot2 :

    Array
    (
       
  • => C:/wamp/websites/cpg-dev/phpself.php
        [1] => C:/wamp/websites/cpg-dev/phpself.php
    )

    path_from_serverroot3 :

    Array
    (
       
  • => C:/wamp/websites/cpg-dev/phpself.php
    )

    path_from_serverroot4 :

    Array
    (
       
  • => C:/wamp/websites/cpg-dev/phpself.php
    )

    Supposedly absolute path to the webroot: C:/wamp/websites/cpg-dev
    What is finally returned: C:/wamp/websites/cpg-dev

donnoman

I changed the script:

    // let's eliminate all those vars that don't contain the filename (and replace the funny notation from windows machines)
    foreach($path_from_serverroot as $key) {
        $key = str_replace('\\', '/', $key); // replace the windows notation
        $key = str_replace('//', '/', $key); // replace duplicate forwardslashes
        if(strstr($key, $filename) != FALSE) { // eliminate all that don't contain the filename
            $path_from_serverroot2[] = $key;
        }
    }


Now I've got something that resembles a decent return value.


Notice: Undefined variable: PHP_SELF in c:\inetpub\wwwroot\webroot.php on line 12
PHP_SELF:
SERVER_PHP_SELF: /webroot.php

Notice: Undefined index: SCRIPT_FILENAME in c:\inetpub\wwwroot\webroot.php on line 16

Notice: Undefined index: SCRIPT_FILENAME in c:\inetpub\wwwroot\webroot.php on line 20
path_from_serverroot :
Array
(
    [0] =>
    [1] => c:\inetpub\wwwroot\webroot.php
    [2] =>
    [3] => c:\inetpub\wwwroot\webroot.php
)

filename: webroot.php
path_from_serverroot2 :
Array
(
    [0] => c:/inetpub/wwwroot/webroot.php
    [1] => c:/inetpub/wwwroot/webroot.php
)

path_from_serverroot3 :
Array
(
    [0] => c:/inetpub/wwwroot/webroot.php
)

counter: 1
path_from_serverroot4 :
Array
(
    [0] => c:/inetpub/wwwroot/webroot.php
)

Supposedly absolute path to the webroot: c:/inetpub/wwwroot
What is finally returned: c:/inetpub/wwwroot

donnoman

I used those changes in coppemrine, and I've got folders now.... but still no OK button.

donnoman

wiith those changes, I get a valid webroot with magic quotes on or off.

So I think thats a good fix.

Now still need to work on why no OK button LOL.


donnoman

I just realised something important.

the "ok" button isn't missing on all the folders, only some. (I'd say its missing on more than not)

I haven't figured out the ryhme or reason for it yet.


Tranz

crazy guess... could it be due to uppercase extensions?

donnoman

DING! DING! DING! DING!

We have a WINNER!.

I threw a file that had a lowercase extension in those directories and I now have an OK button.


donnoman

changing the code that checks filetypes, and adding a strtolower fixes the problem

   if (is_array($filename)) {
       foreach ($filename as $value) {
         if(in_array(ltrim(strrchr(strtolower($value),'.'),'.'), $filetypes)) {
             $allowed_file_counter++;
         } // end if in_array
       } // end foreach
   } // end is_array



Tranz

Quote from: donnoman on February 26, 2005, 11:51:17 PM
wiith those changes, I get a valid webroot with magic quotes on or off.

So I think thats a good fix.
minibrowser now works with magic quotes on or off. (https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Ftu2.net%2Femoticons%2Ficon_thumbs_up.gif&hash=f845a31009dafd4285db67da2f3f39ffbaaab71c)

Quote from: donnoman on February 27, 2005, 12:19:51 AM
DING! DING! DING! DING!

We have a WINNER!.
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Ftu2.net%2Femoticons%2Ficon_dancecool.gif&hash=fc7cd9e3843ca4f747ea71e7cc3390ae72f1ad8a)