15

Dynamic generation of php class based on URL parameters

 3 years ago
source link: https://www.codesd.com/item/dynamic-generation-of-php-class-based-on-url-parameters.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Dynamic generation of php class based on URL parameters

advertisements

I have an image generating class and a number of sub classes inherited from this. Each sub class generates a different image. I would like to pass the class to generate (or some sort of identifier) in the URL. EG: www.mysite.com/image.php?class=image002 In image.php I could read the class name from the URL, compare this to my database to find the class, then include that class file and generate. I feel that this is not the correct way of doing it. Are there better ways?


Apparently there is nothing wrong with your passing values into url that way especially if these image names are unique and are not sensitive data. unique so that you dont execute the same class with two different images. but you could just append/prepend a random string to the image value. also as hamza said hope they aren't php classes

Related Articles

Dynamic calling of PHP class methods

Is there any security problem with dynamically calling a method in a class from user input. For example: <?php class A { public function foo() { return true; } } $obj = new A(); $method = $_GET['method']; $obj->$method(); I am aware that the user wi

How do I get a specific response (data logging) from a PHP script based on the parameters sent to this script?

I want to make a desktop application (Delphi) and an online PHP script. Each desktop application sends some unique identifiers to the PHP script and expects an answer (a record of data) from it. The record of data is generated instantly by the PHP sc

Calling PHP classes from a URL

I'm using a class called Group_Attributes() in my project. I have it placed in my project and I call it the usual way. $gt = new Group_Attributes(); This class is also accessible as text on http://myurl.com/files/Group_Attributes.php which outputs th

Dynamic route to Flask actions based on URL

Want a quick and dirty Flask test server where I can type in a url path 0.0.0.0/**something** and get it to call a corresponding method of the same name. Something like this: from flask import Flask app = Flask(__name__) @app.route('/<action>') def

Dynamic creation of a query based on sending parameters to a controller

In my task management application, users should be able to filter tasks based on : assignedTo, priority, status and/or dueDate I am not sure on how to create a dynamic query in that it will build a query based on the available parameters. For example

Choice of classes based on given parameters

This question already has an answer here: pick a subclass based on a parameter 3 answers So i have a class: class Unit(object): def __init__(self, name, x , y, z): self.name = name self.strength = x + y self.intelligence = x + z self.speed = y + z -

What is the best way to create a Java Servlet or JSP that optionally includes content based on URL parameters

I want to create a JSP page or servlet that will work in 2 ways. A user visits their own profile page: http//something.com/profile/ Or they visit their friends page: http://something.com/profile/FriendsName They could also visit their own page throug

Oracle Stored Procedure - dynamically generate a selection statement based on optional parameters

create or replace PROCEDURE get_txn_by_account_id( p_ACCOUNT_ID IN txn.ACCOUNT_ID%TYPE DEFAULT NULL ) IS BEGIN FOR x IN (SELECT * FROM txn where account_id=p_ACCOUNT_ID) LOOP dbms_output.put_line(x.txn_ID || ', ' || x.txn_VER_NB); END LOOP; END get_t

Creating dynamic PHP code based on the MySQL column data types

I am developing a tool that creates PHP classes based on tables in my database. Most of the functionality is based on data from SHOW COLUMNS FROM $table. Each column typically relates to an instance variable in the new class being created. What I hav

Hide the php extension and URL url parameters using htaccess godaddy linux hosting

This question already has an answer here: Removing .php file extension with .htaccess file 5 answers How to remove .php extension and hide url parameters from url using htaccess file on Godaddy linux hosting. I am using this code. <IfModule mod_rewri

Can I set a PHP class property from an existing variable?

I am trying to figure out how I want to handle settings in my PHP app. I have pretty much decide that I would like to use a Confg class file so it will be autoloaded and flexible in the future. Below is some stuff I was playing with. I know you canno

How to create an instance of an existing PHP class in a secure and dynamic way?

Say I have a file Foo.php: <?php interface ICommand { function doSomething(); } class Foo implements ICommand { public function doSomething() { return "I'm Foo output"; } } ?> If I want to create a class of type Foo I could use: require_on

Is there an option for dynamic extension of the class in PHP?

What I meant is to change the base class for a derived class dynamically. For example there are two classes B1 and B2. When I run a php script with parameter class=b1, a class (say class D) defined in that script should extend class B1 else if parame

ASP.NET MVC Sets the CSS class dynamically to list the item based on the route

I'm looking at the StackOverflow website and I've noticed that there is a Class="youarehere" attribute set to the buttons of active views. This results in the orange styling instead of the grey styling. Can anybody tell me how they're doing this

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK