TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,994
  • Total Topics: 21,325
  • Online today: 777
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 129
  • Total: 129

TP prefixing absolute paths in php scripts?

Started by Inge Jones, January 29, 2007, 06:00:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Inge Jones

Am I going mad, or did TP prefix a path variable in my php code with the domain name?

I am trying to get round the .htaccess in either the attachments or tp-downloads folders so that I can display pictures from the in a block.   I don't understand why a TP block doesn't have access to a TP folder!

akulion

You will have to eloborate more on your problem with examples of codes if possible.

There are no hard edited url in TP - all of them are pretty much calling the url through the site_url and default_theme_url etc strings

as for blocks, it only shows what you tell it to show

Inge Jones

If I put this code into a phpbox block:

$patth = "/home/simlo2/public_html/ffss/FFSSForum/attachments";

$featuredsite = array (
"<a href='http://sims2noir.blogspot.com/' target='_blank'><img src=$patth . '/featuredjudfernoir.jpg'></a>",
"<a href='http://bluemooner.com/primrose/' target='_blank'><img src=$patth . '/featuredprimrosegardens.jpg'></a>",
"<a href='http://www.freewebs.com/t2suggas/' target='_blank'><img src=$patth . '/featuredt2suggas.jpg'></a>",
"<a href='http://minena.prismbaby.com/sims/' target='_blank'><img src=$patth . '/featuredminiroll.jpg'></a>",
"<a href='http://www.catandsusims.com/' target='_blank'><img src=$patth . '/featuredcatandsusims200x200.jpg'></a>",
"<a href='http://www.strawberry-patch.net/' target='_blank'><img src=$patth . '/featuredpurplepaws.jpg'></a>",
"<a href='http://inlimite.com/' target='_blank'><img src=$patth . '/featured_mickeyinlimite.gif'></a>",
);

shuffle($featuredsite);

echo $featuredsite[0];


The picture does not display which is not that much of a surprise because as we know, attachments has a .htaccess

But when I right-click over the picture placeholder, and do properties, it tells me it is trying to display http://ffss.simlogical.com/home/simlo2/public_html/ffss/FFSSForum/attachments
which is definitely not the path I created in the string!

I also still need to know why php code inserted into a block does not run with SMF's permissions or cookies or whatever it needs and therefore be allowed into the attachments folder.

jacortina

Properties show an address, a URL. That IS the URL version of what you typed in. Of course an image source should also be a URL and not a file path.

Php (TP or not) will usually run as the user 'nobody'.

What kind of .htaccess settings are you using that the directory can't be read from the local domain?

niko

Well you use path variable in url which is /home...ments

jacortina

But the URL will not be the (server) full file path.

The URL path to his forum is: http://ffss.simlogical.com/FFSSForum/
To the attachment directory: http://ffss.simlogical.com/FFSSForum/attachments

jacortina

Note that this appears to be a subdomain which has been set up to be rooted at /home/simlo2/public_html/ffss/. This means that the URL http://ffss.simlogical.com will resolve to the specific directory location /home/simlo2/public_html/ffss/ (and look for an index.? file there).

Any further URL specifications within that subdomain have to use THAT as the root.

Ianedres

Shouldn't the img src tag have a quotation mark (directly after the equal sign) before the $pathh string?

When echoed out in the script, the HTML should look like this:

<img src="/home/simlo2/public_html/ffss/FFSSForum/attachments/featuredjudfernoir.jpg">

but it appears in your code not to have the first quote being sent.

Since you're using an array string, I believe you have to declare it inside your text string with a special leading slash or something like that.

jacortina

Quote from: Ianedres on January 30, 2007, 02:56:41 PM
Shouldn't the img src tag have a quotation mark (directly after the equal sign) before the $pathh string?

In fact, the same goes for the links (<a href=).

Generally, this is more like it should be (pulling in the SMF-defined $boardurl to build off of):
global $boardurl;

$patth = $boardurl . '/attachments/';

$featuredsite = array (
'<a href="http://sims2noir.blogspot.com/" target="_blank"><img src="' . $patth . 'featuredjudfernoir.jpg"></a>',
'<a href="http://bluemooner.com/primrose/" target="_blank"><img src="' . $patth . 'featuredprimrosegardens.jpg"></a>',
'<a href="http://www.freewebs.com/t2suggas/" target="_blank"><img src="' . $patth . 'featuredt2suggas.jpg"></a>',
'<a href="http://minena.prismbaby.com/sims/" target="_blank"><img src="' . $patth . 'featuredminiroll.jpg"></a>',
'<a href="http://www.catandsusims.com/" target="_blank"><img src="' . $patth . 'featuredcatandsusims200x200.jpg"></a>',
'<a href="http://www.strawberry-patch.net/" target="_blank"><img src="' . $patth . 'featuredpurplepaws.jpg"></a>',
'<a href="http://inlimite.com/" target="_blank"><img src="' . $patth . 'featured_mickeyinlimite.gif"></a>',
);

shuffle($featuredsite);

echo $featuredsite[0];

Inge Jones

#9
Ok well I obviously have some syntax errors in that particular script, I just posted that to show what my eventual goal was.  In fact I have tried just using the single line, <a href='http://sims2noir.blogspot.com/' target='_blank'><img src="https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fffss.simlogical.com%2FFFSSForum%2Fattachments%2Ffeaturedjudfernoir.jpg&hash=db37f6c506a08e64f7564b5caf5af931"></a>  and still been refused the picture.  The guys at SMF tell me it's because of the .htaccess in attachments.   TP also installs the tp-downloads folder with the same .htaccess.

All I am trying to do is get a random picture a user uploaded to show in that block without having to move it into an unprotected folder manually every time they update it.   I used the snippet from the snippets forum here http://www.tinyportal.net/index.php?topic=12621.0 originally to display pictures in a folder I made for the purpose, and it worked very well indeed - but not using the attachments folder or anywhere my users could upload to!   I only started pulling the code about cos someone said I might be able to access it if I gave the full server path instead of using http

This website is proudly hosted on Crocweb Cloud Website Hosting.