Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Ok button missing in browseable batch add.  (Read 10500 times)

0 Members and 1 Guest are viewing this topic.

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Ok button missing in browseable batch add.
« on: February 25, 2005, 11:08:06 pm »

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.



« Last Edit: February 27, 2005, 01:59:56 am by donnoman »
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Ok button missing in browseable batch add.
« Reply #1 on: February 25, 2005, 11:28:35 pm »

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

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #2 on: February 26, 2005, 04:18:02 am »

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.

Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Ok button missing in browseable batch add.
« Reply #3 on: February 26, 2005, 04:19:20 am »

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

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Ok button missing in browseable batch add.
« Reply #4 on: February 26, 2005, 12:39:49 pm »

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

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Ok button missing in browseable batch add.
« Reply #5 on: February 26, 2005, 01:30:44 pm »

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
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Ok button missing in browseable batch add.
« Reply #6 on: February 26, 2005, 08:41:20 pm »

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.
« Last Edit: February 26, 2005, 09:22:13 pm by TranzNDance »
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #7 on: February 26, 2005, 10:07:10 pm »

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.

Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #8 on: February 26, 2005, 10:10:38 pm »

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

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Ok button missing in browseable batch add.
« Reply #9 on: February 26, 2005, 11:16:21 pm »

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

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #10 on: February 26, 2005, 11:20:11 pm »

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:
Code: [Select]
<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:
Code: [Select]
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: /

Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Ok button missing in browseable batch add.
« Reply #11 on: February 26, 2005, 11:29:15 pm »

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:
Quote
PHP_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
« Last Edit: February 26, 2005, 11:43:30 pm by TranzNDance »
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #12 on: February 26, 2005, 11:43:47 pm »

I changed the script:
Code: [Select]
    // 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.

Code: [Select]
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
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #13 on: February 26, 2005, 11:47:07 pm »

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

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #14 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.

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

Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #15 on: February 27, 2005, 12:03:35 am »

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.

Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Ok button missing in browseable batch add.
« Reply #16 on: February 27, 2005, 12:14:47 am »

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

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #17 on: February 27, 2005, 12:19:51 am »

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.

Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Ok button missing in browseable batch add.
« Reply #18 on: February 27, 2005, 12:27:53 am »

changing the code that checks filetypes, and adding a strtolower fixes the problem
Code: [Select]
   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

Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Ok button missing in browseable batch add.
« Reply #19 on: February 27, 2005, 01:45:54 am »

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. (http://tu2.net/emoticons/icon_thumbs_up.gif)

DING! DING! DING! DING!

We have a WINNER!.
(http://tu2.net/emoticons/icon_dancecool.gif)
Logged
Pages: [1]   Go Up
 

Page created in 0.033 seconds with 18 queries.