Solved

How do i read this image src link (php code)

Posted on 2016-08-03
10
37 Views
Last Modified: 2016-08-04
Hi there,

I am trying to modify specific icons within a moodle template that i have recently purchased. However, when inspecting the icon, i get this image source instead :

src="http://mydomain.com/theme/image.php/lambda/page/1468608429/icon" class="iconlarge activityicon" role="presentation" id="yui_3_17_2_1_1470251148074_2050"

and

src="http://mydomain.com/theme/image.php/lambda/core/1468608429/f/sourcecode-24" class="iconlarge activityicon" role="presentation" id="yui_3_17_2_1_1470251148074_1581"

What html/php function is being used here? How is the src being used to go inside the image.php file? and what happens within this php file? Can someone give me a direction to go and research ?
The explanation of src attribute in w3schools does not cover this kind of usage.

Help - trying to make sense of this.
0
Comment
  • 5
  • 3
  • 2
10 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 41741229
'src' can be anything that returns the correct content.  They are may using 'image.php' to generate the 'icon' image.  If they are, that means it doesn't exist as an image until that page is called.
0
 

Author Comment

by:NeverEndingFlashStories
ID: 41741255
Thanks for the response. What confuses me is the lack of parameter being passed? and why wasn't this done in the css?

And what the purpose of the directory listing after the .php is for :

http://mydomain.com/theme/image.php/lambda/page/1468608429/icon

I am interested in duplicating this functionality, but i don't know where to start. Do you have a tutorial or material online you can point me to?
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 41741293
It can't be done in CSS because CSS can't generate an image.  '/lambda/page/1468608429/icon' probably tells 'image.php' what to generate.  There is not likely to be a tutorial for this since it is probably a custom function.  Unless you can find the code for 'image.php' and understand it, you probably aren't going to duplicate it.
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 41741447
Are you sure this is right?
src="http://mydomain.com/theme/image.php/lambda/page/1468608429/icon

Open in new window


Any chance it could be something like this?
src="http://mydomain.com/theme/image.php?lambda/page/1468608429/icon

Open in new window


If it really is the former, then you might want to look at your .htaccess file to see what it's doing with rewrite rules.  It might be extracting the lambda/page/1468608429/icon from the src= attribute and rewriting this information into URL arguments for the image.php script.
0
 

Author Comment

by:NeverEndingFlashStories
ID: 41742538
Hi , Thanks for the responses.

@Dave : I apologize, i don't think i am very clear on what i am confused about. I am a beginner at webdesign, and I am interested in specific functions, methods, etc that I have not seen before being used in PHP or HTML, or CSS.
I wasn't looking for specifically tutorial or information on the particular image generation function, but more on what is actually happening.

I am probably confused on something really basic. Such as, why does this link work and not give a 404 error? I have never read anything anywhere in my short life of php that says I can tag additional forward slashes after .php

http://mydomain.com/theme/image.php/lambda/page/1468608429/icon

I am looking for more information on, "here is how and why you can have http://mydomain.com/blabla.txt/hello.doc/something.pdf/somethingelse/work

But i don't even know where to begin. Googling the question 'forward slash after .php' kind of comes with what you'd expect : a lot of confused search results.

@Ray it is indeed the former link. Thanks for the suggestion about .htaccess . If it is an .htaccess function , then it is out of my scope of php learning at this point (since its server related), so i can simply forget about it and move on. Unfortunately, it does not seem like it is an .htaccess file - i can't find any in the installation that i did not put myself.

This guy seemed to have a similar, but reversed problem : http://stackoverflow.com/questions/28138019/page-gets-a-trailing-forward-slash-after-php


On a related note, out of curiosity i just tried loading up

"domain.com/test.php/blablablabla"  and it loaded up something from test.php (incorrectly and incomplete) instead of the normal "NOT FOUND - 404"

So i guess it is very normal for a browser to ignore .php/something and simply maybe pass an argument to the page which is not a GET function or POST.
I am looking for a page info or tutorial or the php manual page similar to  http://php.net/manual/en/reserved.variables.get.php that basically explains this behavior, and why the developer of moodle used it instead of, GET, or POST. Is it more secure? is it a replacement for the deprecated GET? or is it an undocumented behaviour of PHP , and whatever trails behind the forward slash needs to be captured or the page loads halfway?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41742590
0
 

Author Comment

by:NeverEndingFlashStories
ID: 41743010
Hi Ray, yes it is.
I've contacted the developer, but apparently the image function is part of the moodle core.

I have found image.php online on github, its this one :

https://github.com/moodle/moodle/blob/master/theme/image.php

The if statement at the beginning of that code refers to the method  :
min_get_slash_argument() description

This is the actual code of that method :
http://xref-diff.mukudu-dev.net/moodle26/lib/configonlylib.php.source.html#l165

This is where i am now presently stuck. Not quite sure what the reference to IIS is. Do you have an insight on what this is doing ? Or which if statement is relevant to the purpose of deciphering a forward slash trailing after .php?
0
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 41743116
why does this link work and not give a 404 error?
The answer is that someone has made it work.  '.htaccess' to re-format the request is probably the correct answer.  I can't give you a tutorial on something like this that as far as I know is unique to the software you are using.  

All I can tell you is that the 'src' can be any kind of link as long as it returns the proper response.  I have used PHP to return simple images and JavaScript although I never use that 'method' to attach data to the URL, just regular GETs is all I've used.
0
 

Author Comment

by:NeverEndingFlashStories
ID: 41743259
Hi All,

I found the .htaccess on github. I can't find it on the server itself - though i can see hidden files.

From the .htaccess :
### Firstly, if you are using Apache 2, you need the following
### three lines to allow Apache to pass a PATH_INFO variable
### correctly for URLs like http://server/file.php/arg1/arg2

<IfDefine APACHE2>
    AcceptPathInfo on
</IfDefine>

Open in new window



And from php manual on pathinfo() :
http://php.net/manual/en/function.pathinfo.php

A generic explanation for PATH_INFO was then found here : http://stackoverflow.com/questions/2261951/what-exactly-is-path-info-in-php

Thanks for the suggestions, the clue indeed was inside .htaccess !
0
 

Author Closing Comment

by:NeverEndingFlashStories
ID: 41743260
Thanks for persisting with my convoluted question!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now