Jump to content


PHP Module System


4 replies to this topic

#1 Balor

    PHP Nerd

  • Members
  • Pip
  • 63 posts
  • Gender:Male
  • Location:Germany->Frankfurt
  • Interests:My beautyful girl, my son and webcoding. I'm also very interested in art but I'm not really good at art... it's sad but true ^^

Posted 15 August 2007 - 02:54 AM

Hi everybody,

does anybody know if there is some sort of tutorial out there on how to write some kind of module system for an WCMS for example? Also does anybody have ideas on how to write such a system? I first thought about integrating a whole folder and dann using eval to integrate a class, but that's too insecure.

Any ideas would be welcome.

Sincerely,
Christian Weber

#2 curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 15 August 2007 - 04:01 AM

ive created my own system......which uses modules, called hottools, when logged in on a page, it allows u to toggle hotspots on or off, and u can click the hotspots and change content of the div tht it is in, in turn, also alows premade modules to be included in.

Its a complex system, so i dont know how well u know php.

#3 Balor

    PHP Nerd

  • Members
  • Pip
  • 63 posts
  • Gender:Male
  • Location:Germany->Frankfurt
  • Interests:My beautyful girl, my son and webcoding. I'm also very interested in art but I'm not really good at art... it's sad but true ^^

Posted 24 August 2007 - 01:50 AM

Well my PHP Skills aren't bad and I would know how to do it, except for the part on how to integrate the script itself. I wanted to have a basic template. Here is an Example:

- Modules
|
|-> Example
|
|-> some folders for additional scripts and graphics
|
|-> module.xml (Contains name of the script, autor, version and description
|
|-> module.php (Contains a class named as defined in module.xml and has some core functions that need to be in there for using)

So if someone want to load up a module, it just initializes a new class via the module name and eval. After the class has been intialized you can give the module an div container where it will be displayed.

My most common question is... how to secure the eval command? With eval other people could add bad code to it.

Sincerely,
Christian Weber

Edited by Balor, 24 August 2007 - 02:33 AM.


#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 24 August 2007 - 12:00 PM

If you don't want to use eval() then why not just use include? I'm assuming you'd have to read the file into a variable anyway if you were going to use eval (unless you read it straight into eval() and skipped the variable step).

Include even has the same return functionality as eval(). Just put a return statement at the end of the file (just like you would any function), and rather than echoing anything out, you can just return it through include.

#5 Balor

    PHP Nerd

  • Members
  • Pip
  • 63 posts
  • Gender:Male
  • Location:Germany->Frankfurt
  • Interests:My beautyful girl, my son and webcoding. I'm also very interested in art but I'm not really good at art... it's sad but true ^^

Posted 25 August 2007 - 04:17 AM

View Postrc69, on Aug 24 2007, 07:00 PM, said:

If you don't want to use eval() then why not just use include? I'm assuming you'd have to read the file into a variable anyway if you were going to use eval (unless you read it straight into eval() and skipped the variable step).

Include even has the same return functionality as eval(). Just put a return statement at the end of the file (just like you would any function), and rather than echoing anything out, you can just return it through include.

Thanks, didn't know that include is giving anything back. I feel a bit dumb now^^





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users