473,795 Members | 2,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing functions through a URL?

Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php

function a_function() {echo "Hello!";}

?>
Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.
P.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.514 / Virus Database: 312 - Release Date: 28/08/2003
Jul 16 '05 #1
5 2322
The Plankmeister <plankmeister_N O_@_SPAM_hotmai l.com> wrote:
Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php
function a_function() {echo "Hello!";}
?>

Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.


Hi,

It's definitely not possible.

HTH;
JOn
Jul 16 '05 #2
Hi,

Sure it's possible. You can analyse the url. See if there are strings after
the ?. Next you need to check if that string is a function. If it is....
run it. So if you can program a little bit, it is possible...

Kind regards,

Dirk

Jon Kraft wrote:
The Plankmeister <plankmeister_N O_@_SPAM_hotmai l.com> wrote:
Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php
function a_function() {echo "Hello!";}
?>

Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.


Hi,

It's definitely not possible.

HTH;
JOn


--
BOFH Excuse #380:

Operators killed when huge stack of backup tapes fell over.

Jul 16 '05 #3
Dirk Engels <d.******@stude nt.utwente.nl> wrote:
Jon Kraft wrote:
The Plankmeister <plankmeister_N O_@_SPAM_hotmai l.com> wrote:
Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php
function a_function() {echo "Hello!";}
?>

Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.


It's definitely not possible.


Sure it's possible. You can analyse the url. See if there are strings
after the ?. Next you need to check if that string is a function. If it
is.... run it. So if you can program a little bit, it is possible...


Hi Dirk,

I didn't say it wouldn't be possible for a script to call the function after
analysing the requested url - I merely confirmed that it is absolutely
impossible to call a function through a URL.

http://www.somesiteorother.com/test.php?a_function will never invoke the
function a_function().

JOn
Jul 16 '05 #4
Hi,

Not directly... but there is always a way to do something you want to do...
the sky is the limit :-)

dirk

Jon Kraft wrote:
Dirk Engels <d.******@stude nt.utwente.nl> wrote:
Jon Kraft wrote:
The Plankmeister <plankmeister_N O_@_SPAM_hotmai l.com> wrote:

Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php
function a_function() {echo "Hello!";}
?>

Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.

It's definitely not possible.


Sure it's possible. You can analyse the url. See if there are strings
after the ?. Next you need to check if that string is a function. If it
is.... run it. So if you can program a little bit, it is possible...


Hi Dirk,

I didn't say it wouldn't be possible for a script to call the function
after analysing the requested url - I merely confirmed that it is
absolutely impossible to call a function through a URL.

http://www.somesiteorother.com/test.php?a_function will never invoke the
function a_function().

JOn


--
BOFH Excuse #220:

Someone thought The Big Red Button was a light switch.

Jul 16 '05 #5
Dirk Engels wrote:
Hi,

Not directly... but there is always a way to do something you want to do...
the sky is the limit :-)

dirk


Indeed, it is ;-)) And sometimes its really simple too. I will show you.
>Is it possible to access a function in a php document through a URL?
>
>For instance: http://www.somesiteorother.com/test.php?a_function
>
>And then have something like this in test.php:
>
><?php
>function a_function() {echo "Hello!";}
$_GET["function"]();
?>


But, you would have to access it through:

http://www.somesiteorother.com/test....ion=a_function

The trick used here is that you can use any variable as a variable or function name. Similarly you can use $$variable.

Michiel.

Jul 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3394
by: keepyourstupidspam | last post by:
Hello, I have a class X with a member function setConfigValues(). I want to access this member function in another class Y. Y is not inherited from X. A member function of class X called run() this instanciates the class Y. Class X { run();
6
2625
by: harry | last post by:
Hi ppl I have a question about memory layout of a class. Consider the code below: class Base1 { virtual void f() { cout << "Base1::f" << endl; } virtual void g() { cout << "Base1::g" << endl; } }; class Drive : public Base1{
2
1656
by: Stu | last post by:
Hi, I am migrating a large app to .Net 2 and am having problems with accessing hidden fields using javascript. As I am using masterpages the control names are prefixed with the control reference of the masterpage '_ctl0_cphMain_MyHiddenField' etc. The app uses dynamically assigned masterpages to the control name on the page changes depending on the masterpage being used. There is no
12
11724
by: Steve Blinkhorn | last post by:
Does anyone know of a way of accessing and modifying variables declared static within a function from outside that function? Please no homilies on why it's bad practice: the context is very particular and involves automatically generated code. I know several other ways of attacking my problem, but this would be the cleanest if it could be made to work. A little more context. I use C as the output of a code generating system which...
6
1287
by: Ant | last post by:
I have the following code which works fine for running some tests defined within a module: def a_test(): print "Test A" def b_test(): print "Test B" if __name__ == "__main__":
1
1415
by: DelphiLover | last post by:
Hi. I'm reading and reading, testing and testing, trying to figure out how to do things, how to do things according to best practises and how to do things in the best object oriented way. So... Best practises, in good object oriented fashion: how do I do it. I'm thinking making classes for data access. An Example that ALL books do - customer - and orders. So I'm thinking: Making a customer class
4
8505
by: Joseph Paterson | last post by:
Hi all, I'm having some trouble with the following code (simplified to show the problem) class Counter { protected: int m_counter; }
9
1953
by: fgh.vbn.rty | last post by:
Say I have a base class B and four derived classes d1, d2, d3, d4. I have three functions fx, fy, fz such that: fx should only be called by d1, d2 fy should only be called by d2, d3 fz should only be called by d1, d3, d4 I think I have two options. (1) Make all functions virtual and define them in the required derived classes. This will of course lead to a lot of code duplication and problems in maintainability.
6
8165
by: Bhawna | last post by:
I am into c++ code maintenance for last 3-4 years but recently I am put into design phase of a new project. Being a small comapany I dont have enough guidance from seniors. Currently I am into a situation where I am implementing base class functions by including a pointer to subclass member in base class. Reason being functionality is common for subclasses but the members are common within subclass only (static member of subclass) but...
16
6800
by: s0suk3 | last post by:
This code #include <stdio.h> int main(void) { int hello = {'h', 'e', 'l', 'l', 'o'}; char *p = (void *) hello; for (size_t i = 0; i < sizeof(hello); ++i) {
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.