News:

Wondering if this will always be free?  See why free is better.

Main Menu

SimplePortal

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

Previous topic - Next topic

Angelina Belle

My version of the code works fine for me. I'm not sure why it does not work fine for you. Perhaps we are using different versions of php?
Perhaps if ( isset($_FILES) && isset($_FILES['uploadedfile']) && isset($_FILES['uploadedfile']['name']) ) would work better for you?

The "<>" appear on your page because they are are in the code. For the code I posted, I simply showed how the code you posted would look with the one line changed. You are in no way required to use the version of code you posted here, or to use the change I suggested.

I can see that you are a little lost in the customization discussion. If you desire to use custom php in your blocks, you may feel more comfortable if you go through a simple php tutorial, like the one at w3schools.org. Then, you might like to look up the php function isset at php.net, in order to understand the change I suggested.

Good Luck!
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

#3881
I tried again, and this time it worked.   :D 

THANKS for all the help, now to fix about 10 more pages.

EDIT: I found something weird.....if I click "Edit Page" just under the code it gives the error, but if I go all the way to the bottom "Edit Page" it works.




ACAMS

I changed the code in all my uploaders and they all work fine, but this one still gives me the error in my error log.


It is a little different than the others as it gives users the link to the file.


I hope you can see what is throwing the error.






<?
$target_path = "../uploads/files/"; /// upload folder
$allowedExtentions = "rar,zip,7Z,7z"; // allowed extentions
// Upload File
if( isset($_FILES['uploadedfile']['name']) ){
// Check file extention
$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, Please use ($allowedExtentions)");}

// See if filename exists
// if it exists rename it
if (file_exists($target_path.$_FILES['uploadedfile']['name'])) {
    $random_digit=rand(0000,9999);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path.$random_digit.basename( $_FILES['uploadedfile']['name']))) {
    echo "The file ".  $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">
    <input name="textfield" type="text" id="textfield" value="[url=<?=$fileurl?>]<?=$fileurl?>[/url]" size="105"  />
    <? } else{
    echo "There was an error uploading the file, please try again!";
}

// other wise just upload
} else {
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path.basename( $_FILES['uploadedfile']['name']))) {
echo "The file ".  $random_digit.basename( $_FILES['uploadedfile']['name']). " has been uploaded <br>";
$fileurl= "http://".$_SERVER['SERVER_NAME']. "/".$target_path.$random_digit.basename( $_FILES['uploadedfile']['name']);?>
    <input name="textfield" type="text" id="textfield" value="[url=<?=$fileurl?>]<?=$fileurl?>[/url]" size="105"  />
    <? } 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=page4749" method="POST">
              <div align="center">
                <p>
            <input type="hidden" name="MAX_FILE_SIZE" value="5000000000" />
            <BR />
          Choose a file to upload .zip, 7Zip or .rar ONLY<BR />
          <BR />
          <input name="uploadedfile" type="file" />
           <input type="submit" value="Upload File" />
                </p>
              <>
</form>
            <div align="center"><br />
                <? } ?>             
            <>
           <BR><div align="center">
<BR><strong>TERMS OF SERVICE</strong><><BR>
<div align="center">
gametechmods.com file host is a free file hosting service, we allow you to upload your files onto our server for free.<BR>
These files can be linked to forums or friends and can not be seen by anyone without the file name.<BR>
We reserve the right to ban any individual  or website from using our services for any reason.<BR>
<strong>Do not upload copywrited or illegal content.</strong><>

Bigguy

What is the error in the error log. ???

ACAMS

Quote from: Bigguy on April 21, 2011, 11:14:25 PM
What is the error in the error log. ???



Quote from: ACAMS on April 12, 2011, 08:33:58 PM

I have SMF 2.0 RC3 with the RC4 security patch and Simpleportal 2.3.2

I am getting an error in my error log whenever anybody clicks a link to one of my PHP pages, it does not give an error for BBC, or HTML.


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

8: Undefined index: uploadedfile

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


you will see that line 5 has nothing to do with anything.


Angelina Belle

Isn't line 5 of your eval'd code
if( isset($_FILES['uploadedfile']['name']) ){
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

#3886

Quote from: AngelinaBelle on April 22, 2011, 09:23:52 AM
Isn't line 5 of your eval'd code
if( isset($_FILES['uploadedfile']['name']) ){

Yes, it is.



EDIT: it is...


if( isset($_FILES['uploadedfile']['name']) ){

Angelina Belle

Then that is your problem.

Perhaps you can see if isset($_FILES) works better for you, and/or you can try one of my earlier suggestions, to see if that works:
Quote from: AngelinaBelle on April 21, 2011, 08:00:02 AM
Perhaps if ( isset($_FILES) && isset($_FILES['uploadedfile']) && isset($_FILES['uploadedfile']['name']) ) would work better for you?
Quote

At this point, I think we are confident that this is not a SimplePortal-specific problem. I feel that I am not solving your problem quickly and efficiently.  You might find more and better help than I have been able to provide in a custom coding board. You can ask there about the correct way to check this php Variable without creating php errors.
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

ACAMS

I am having trouble again......I have a page linking to another page, here is the code
<p><a href="index.php?page=page4106"" target="_blank" >Play your uploaded MP3's</a></p>
<p><a href="index.php?page=page4107"" target="_blank" >Classic Rock Player</a></p>
<p><a href="index.php?page=page4108"" target="_blank" >Country Music Player</a></p>

The line ---  <p><a href="index.php?page=page4106"" target="_blank" >Play your uploaded MP3's</a></p> works just fine in my block linking to my player, but when I make a page linking the player, it ends up with an extra /index.php
http://gametechmods.com/forums/index.php/index.php?page=page4106

I have changed it to EVERYTHING I can think of, and cleared my cache a thousand times....is this a bub, or am I stupid?
I even tried <p><a href="page=page4106"" target="_blank" >Play your uploaded MP3's</a></p>....BUT it still came out http://gametechmods.com/forums/index.php/index.php?page=page4106


What do I do, how can I link to my player without it adding the extra index.php



ACAMS

#3889
OK, I changed my code to this...AND IT STILL wont work......it keeps adding the extra index.php.....and pisssssssing me offfffff!




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MP3 Players</title>
</head>


<body>
<table width="23%" height="178" border="2" align="center" cellpadding="4px" bordercolor="#000000">
<tr>
       <td width="57%" height="170" valign="top">
       <p><a href="index.php?page=page4106">Play your uploaded MP3's</a></p>
       <p><a href="index.php?page=page4107">Classic Rock Player</a></p>
       <p><a href="index.php?page=page4108">Country Music Player</a></p>
   </td></tr></table>
<br />
</body>
</html>





EDIT:  The only way it will take the code is HTML, php gives an error


An Error Has Occurred!

Syntax error in block code. Please check the code.

Chen Zhen

#3890
.. so do not include index.php in your code. Also only include what is in the body of the html you just posted.

QuoteEDIT:  The only way it will take the code is HTML, php gives an error


echo '<table width="23%" height="178" border="2" align="center" cellpadding="4px" bordercolor="black">
<tr>
       <td width="57%" height="170" valign="top">
       <p><a href="index.php?page=page4106">Play your uploaded MP3s</a></p>
       <p><a href="index.php?page=page4107">Classic Rock Player</a></p>
       <p><a href="index.php?page=page4108">Country Music Player</a></p>
   </td></tr></table>
<br />';


.. it gave an error because of the apostrophe. If you want it to show you can use a character code

ie.

echo '<table width="23%" height="178" border="2" align="center" cellpadding="4px" bordercolor="black">
<tr>
       <td width="57%" height="170" valign="top">
       <p><a href="index.php?page=page4106">Play your uploaded MP3&#39;s</a></p>
       <p><a href="index.php?page=page4107">Classic Rock Player</a></p>
       <p><a href="index.php?page=page4108">Country Music Player</a></p>
   </td></tr></table>';


\\Edit -> I change to character code.

My SMF Mods & Plug-Ins

WebDev

"Either you repeat the same conventional doctrines everybody is saying, or else you say something true, and it will sound like it's from Neptune." - Noam Chomsky

ACAMS

#3891
I removed the apostrophe and another page linking the player and saved as php and IT WORKS  :D


THANKS!!!

teos55

Running SMF 1.1.13  default theme  Simple Portal 2.3.3

  As mentioned in topic :http://www.simplemachines.org/community/index.php?topic=434341.0

this is a clean system with no errors systemwise.

I'm not sure when this error happened but the problem is:

- Create a BBC custom block and put :

[img]https://picasaweb.google.com/teos1955/Cambodia?authkey=Gv1sRgCOWM-5PfuqS0lgE#5607733418829291538[/img]

Result :  image not shown  and [/img] tag is sticked to the link data and blue.

    Consequently 404 not found error.  picasaweb album is public not private. In fact it doesnt matter which link
you put there, always [/img] is sticked to the link

Any guidance ?

nb.  After posting noticed that, same failure happens here in code path of the topic. Strange !!

Angelina Belle

In http://www.simplemachines.org/community/index.php?topic=434341.0 you mentioned that you re-installed SMF 1.1.13 from scratch, then began re-installing mods.

I don't think I understand the problem. I'd like to start with an image that ought to work, instead of an HTML page. How about
[img width=300]https://lh4.googleusercontent.com/_se0aqm-n1iA/TdKr1VhoIBI/AAAAAAAAGL4/JV_DOCz3EyQ/s720/_MG_3162.jpg[/img]

Please show a picture of what it looks like to edit this block, like this:
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

teos55


teos55

#3895
And this is output of your recommendation. I'm not familiar but can it related to hotlinks ?
Previously it was working with no hassle.

This is same error in topic : http://www.simplemachines.org/community/index.php?topic=433264.0

teos55

  I dont know whether it is clue or not but when I logged out, I can see the photos on main page of
guest screen :-)  The blocks permission includes guest view. Not only as admin user also tested with
a regular member.

  I tested this with opera, firefox and chrome. As soon as the users logs in, the problem starts.

Angelina Belle

But [img] tag works OK in topics? Do you have any errors in your SMF error log?
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

teos55

Yes AngelinaBelle,  [img] tag in topics works as designed. It's only fails when used in BBC custom block.
No erros in the errorlog unfortunately. Even this happens if I put an image from my site.

Angelina Belle

It looks like the BBC parser has gotten confused and included the [/img] tag in the URL. Could you provide me a link to your site?

This is a puzzling little problem. What other mods do you have installed? What other mods have you uninstalled?
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

Advertisement: