News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SimplePortal

Started by SimplePortal Team, March 10, 2008, 11:16:07 PM

Previous topic - Next topic

Angelina Belle

Yes. many users are using it with 1.1.13
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

Quote from: AngelinaBelle on April 14, 2011, 10:48:18 AM
This piece of code depends on $_FILES['uploadedfile']['name']) being set. But, in the context of this SimplePortal page, it doesn't appear that the value has been set.

http://www.php.net/manual/en/reserved.variables.files.php
The $_FILES php variable is supposed to be an array of items uploaded to the current script via the HTTP POST method.
But if you are not getting to that page via an HTTP post that uploaded items, then that variable will not have been set.




What do I need to do to fix it?

Angelina Belle

I don't have enough information about what you are trying to do.

But, basically, this part of the code needs to be on a page that is receiving the result of a form that uploaded a file.
Instead, it is hitting that part of the code (the part that affects $_FILE to have been set) without having had that php superglobal variable set.

I don't know more because I have not seen the code.
If I were trying to track down this problem, I would start with a very simple example of form handling, from your favorite php tutorial. The one at w3schools.com, for example. I would make sure that it is possible to handle a simple form in a SimplePortal php block. I have never tried this. I don't know what other parts of the page might be competing for the contents of the php variables.

I might also have a look through QueryString.php, in function cleanRequest. It doesn't look like anything bad happens to $_FILES in there. But I am not an expert on SMF coding.

This is definitely a bit of an advanced topic. You'll need the help of someone good handling forms in php, and preferably some experience modding SMF.
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

Thanks for the reply, but I usually get THOUSANDS of errors a day and have now stopped most. Every time I fix one error problem another pops up, and now I am only getting about 50 a day......I can live with that!
I thought maybe it would be a simple fix, like maybe adding a line to Sources/Subs.php


Thanks anyway.

Alyen

error in database in SimplePortal 2.3.3 on SMF 2.0 RC5

Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'ifnull'
Arquivo: .../httpdocs/Sources/Subs-Portal.php
Linha: 1266

My Forum: www.xpzone.net

Biology Forums

"
Fatal error: Cannot redeclare sp_topposter() (previously declared in /home/biologyf/public_html/Sources/Load.php:2539) in /home/biologyf/public_html/Sources/PortalBlocks.php on line 605"

I get this error after I install it, what should I do?

Suki

Quote from: Alyen on April 15, 2011, 05:00:56 PM
error in database in SimplePortal 2.3.3 on SMF 2.0 RC5

Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'ifnull'
Arquivo: .../httpdocs/Sources/Subs-Portal.php
Linha: 1266


You need to change your tables collation to use either utf8_unicode or utf8_general all,  sometimes even columns needs to be changed.


Quote from: shuban on April 16, 2011, 10:41:33 PM
"
Fatal error: Cannot redeclare sp_topposter() (previously declared in /home/biologyf/public_html/Sources/Load.php:2539) in /home/biologyf/public_html/Sources/PortalBlocks.php on line 605"

I get this error after I install it, what should I do?


You most likely install SP twice,  you will need to see the parser for SP and make sure you do not have any duplicate code in your files.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Alyen

Quote from: Miss All Sunday on April 16, 2011, 10:54:38 PM
Quote from: Alyen on April 15, 2011, 05:00:56 PM
error in database in SimplePortal 2.3.3 on SMF 2.0 RC5

Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'ifnull'
Arquivo: .../httpdocs/Sources/Subs-Portal.php
Linha: 1266


You need to change your tables collation to use either utf8_unicode or utf8_general all,  sometimes even columns needs to be changed.

how I can change that, not much of DB?  :P

My Forum: www.xpzone.net

Angelina Belle

@ACAMS
Your problem could be fixed by doing something to the code that is causing the problem -- the code you added to the php block.
I cannot know exactly what, because I haven't seen the code.
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

Well I will show it to you if you don't mind looking at it for me.

Angelina Belle

I can promise to look at it. I cannot promise I will be able to solve the problem, though!
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

This is one of my uploaders, it is a PHP page in Simple Portal




<?
$target_path = "../Robot_Exchange/AW/"; /// upload folder
$allowedExtentions = "bot"; // allowed extentions
// Upload File
if($_FILES['uploadedfile']['name']){
$ext = substr($_FILES['uploadedfile']['name'], strrpos($_FILES['uploadedfile']['name'], '.') + 1);
$chechextentions = explode(",", $allowedExtentions);
$isallowed = 0;
foreach($chechextentions as $key => $name){
if($name==$ext){$isallowed = 1;}
}
if($isallowed == 0){ die("Sorry that filetype [$ext] is not allowed. We allow ($allowedExtentions)");}

    if (trim($_POST['user']) == '')
    {
        echo "Please put your name in the box";
    }
elseif (file_exists($target_path.$_FILES['uploadedfile']['name'])) {
    $bad_stuff = array("..", ".", "/", "\\");
        $random_digit = str_replace($bad_stuff, "", $_POST['user']) . "_DUPLICATE";
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path.$random_digit.basename( $_FILES['uploadedfile']['name']))) {
    echo "Your Bot ".  $random_digit.basename( $_FILES['uploadedfile']['name']). " has been uploaded <br>";
$fileurl= "http://".$_SERVER['SERVER_NAME']. "/".$target_path.$random_digit.basename( $_FILES['uploadedfile']['name']);?>
  <>
<div align="center">
  Thanks for sharing your bot<br>
  <? } else{
    echo "There was an error uploading the file, please try again!";
}
// other wise just upload
} else {
        $bad_stuff = array("..", ".", "/", "\\"); 
        $random_digit = str_replace($bad_stuff, "", $_POST['user']). "_";$random_digit = ($random_digit  !="" ? $random_digit : die("empty name"));
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path.$random_digit.basename( $_FILES['uploadedfile']['name']))) {
echo 'Your Bot '.$random_digit.basename( $_FILES['uploadedfile']['name']). " has been uploaded <br>";
$fileurl= "http://".$_SERVER['SERVER_NAME']. "/".$target_path.$random_digit.basename( $_FILES['uploadedfile']['name']);?>
<br><div align="center">Thanks for sharing your bot<br>
<>
  <? } else{
    echo "There was an error uploading the file, please try again!";
}
}
// Ask for upload info
}else{ ?>
<>
<form enctype="multipart/form-data" action="index.php?page=page4971" method="POST">
              <div align="center"><p>
  <BR><strong>YOUR FORUM NAME</strong><br />
<input type="text" name="user" />
            <input type="hidden" name="MAX_FILE_SIZE" value="5000000000" />
            </p>
                <p><BR />
          Upload AW bots ONLY 125.0 KG or less<BR />
          <BR />
          <input name="uploadedfile" type="file" />
           <input type="submit" value="Upload File" />
                </p>
  <>
</form>
            <div align="center"><br />
                <? } ?>             
            <>
           <BR><div align="center">
<><br><br><br>

Angelina Belle

Right. I don't see the part where you actually upload the files.
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

It works, just gives error when somebody looks at the page.....don't have to upload, just look!

Angelina Belle

@ACAMS -- The reason you get the error is that you are trying to check the value of something that does not exist.
To avoid the error message, you can avoid doing that. You might like to test the following, to see if it works properly for you:
if ( isset($_FILES['uploadedfile']['name'] )
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

Where would I put that?....in my code somewhere?

Angelina Belle

Code (find) Select
if($_FILES['uploadedfile']['name'])
Code (replace) Select
if ( isset($_FILES['uploadedfile']['name'] )
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

I get this error...


Syntax error in block code. Please check the code.

Angelina Belle

#3878
If your code works, then this one should work, too.

$target_path = "../Robot_Exchange/AW/"; /// upload folder
$allowedExtentions = "bot"; // allowed extentions
// Upload File
if( isset($_FILES['uploadedfile']['name']) ){
$ext = substr($_FILES['uploadedfile']['name'], strrpos($_FILES['uploadedfile']['name'], '.') + 1);
$chechextentions = explode(",", $allowedExtentions);
$isallowed = 0;
foreach($chechextentions as $key => $name){
if($name==$ext){$isallowed = 1;}
}
if($isallowed == 0){ die("Sorry that filetype [$ext] is not allowed. We allow ($allowedExtentions)");}

    if (trim($_POST['user']) == '')
    {
        echo "Please put your name in the box";
    }
elseif (file_exists($target_path.$_FILES['uploadedfile']['name'])) {
    $bad_stuff = array("..", ".", "/", "\\");
        $random_digit = str_replace($bad_stuff, "", $_POST['user']) . "_DUPLICATE";
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path.$random_digit.basename( $_FILES['uploadedfile']['name']))) {
    echo "Your Bot ".  $random_digit.basename( $_FILES['uploadedfile']['name']). " has been uploaded <br>";
$fileurl= "http://".$_SERVER['SERVER_NAME']. "/".$target_path.$random_digit.basename( $_FILES['uploadedfile']['name']);?>
  <>
<div align="center">
  Thanks for sharing your bot<br>
  <? } else{
    echo "There was an error uploading the file, please try again!";
}
// other wise just upload
} else {
        $bad_stuff = array("..", ".", "/", "\\"); 
        $random_digit = str_replace($bad_stuff, "", $_POST['user']). "_";$random_digit = ($random_digit  !="" ? $random_digit : die("empty name"));
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path.$random_digit.basename( $_FILES['uploadedfile']['name']))) {
echo 'Your Bot '.$random_digit.basename( $_FILES['uploadedfile']['name']). " has been uploaded <br>";
$fileurl= "http://".$_SERVER['SERVER_NAME']. "/".$target_path.$random_digit.basename( $_FILES['uploadedfile']['name']);?>
<br><div align="center">Thanks for sharing your bot<br>
<>
  <? } else{
    echo "There was an error uploading the file, please try again!";
}
}
// Ask for upload info
}else{ ?>
<>
<form enctype="multipart/form-data" action="index.php?page=page4971" method="POST">
              <div align="center"><p>
  <BR><strong>YOUR FORUM NAME</strong><br />
<input type="text" name="user" />
            <input type="hidden" name="MAX_FILE_SIZE" value="5000000000" />
            </p>
                <p><BR />
          Upload AW bots ONLY 125.0 KG or less<BR />
          <BR />
          <input name="uploadedfile" type="file" />
           <input type="submit" value="Upload File" />
                </p>
  <>
</form>
            <div align="center"><br />
                <? } ?>             
            <>
           <BR><div align="center">
<><br><br><br>

---
edit: removed opening '<?'
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

I copy/pasted all in your reply and it did work, but I still get my original error....



http://gametechmods.com/forums/index.php?/page,page4971.html

8: Undefined index: uploadedfile

File: /home/gametechmods/gametechmods.com/forums/Sources/Subs-Portal.php(1155) : eval()'d code
Line: 5




I also get this on the bottom of my page


<> <>
<>

Advertisement: