Author Topic: A smaller submit.php  (Read 1694 times)

0 Members and 1 Guest are viewing this topic.

Offline Dudditz

  • Newbie
  • *
  • Posts: 16
  • Karma: -1
    • View Profile
    • PimpMyGamercard
A smaller submit.php
« on: April 25, 2009, 02:43:55 AM »
In the submit.php, a process file is included for each $source
It isnt really an issue right now since phpdirector only uses 3 sources
but as the script grows and more websites become added, all the elseif(include)
lines could become a hassle.
I have over 10 sources which users can currently submit so I rewrote my submit.php like this:
Only an example for reference...
Code: [Select]
$source_sites = array('youtube','google','dailymotion','ETC');
if (in_array($source, $source_sites))
{
  include("processes/process_".$source.".inc.php");
}else{
  $error = $smarty->get_template_vars('LAN_22');
  $smarty->assign_by_ref('error', $error);
  $smarty->display('error.tpl');
  exit;
}

This way, there is only one line needed for every website present or added in the future.
You may find this a better solution for the submit.php as any additional websites that
are added in the future simply need to be set to the array() and upload the process file.

Offline Jeff

  • Global Moderator
  • Sr phpd Member
  • *****
  • Posts: 359
  • Karma: 5
  • Need help? Feel free to ask.
    • View Profile
Re: A smaller submit.php
« Reply #1 on: April 25, 2009, 04:51:00 AM »
Great job.....