• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Eventually CRACKED IT - Menu driven multiple CodeIgniter applications

#21
[eluser]jstine[/eluser]
That's far more elegant than my solution: Here's what I'm using on my server - I can't post my actual link as it's for my actual production environment, but this is the working code:

Code:
<?php
if($_GET['key'] == "r4yt7WwQrte99")
{

  error_reporting(-1);//E_ALL | E_STRICT);

  ini_set('display_errors',1);

    // this filename can be renamed to suit your requirements
    $filename = $_SERVER['PHP_SELF'];  
    
  // check to see if a parameter path has been passed
  if (isset($_GET['new_application_path']))
  {
      session_start();
      
    // set session variable to be used in index.php
    $clean = $_GET['new_application_path'];
    $_SESSION['_MENU_'] = str_replace("\\\\","\\",$clean);
    //print_r($_GET);
    //echo "<br />";
    //print_r($_SESSION['_MENU_']);die;
    // Redirect browser
    header("Location: http://" . $_SERVER['SERVER_NAME'] . "/index.php");
    exit;
  }
  
  // SESSION RESET EVERYTIME if and only if no GET parameter variable passed
  session_unset();
  session_start();
  $_SESSION['js_counter'] = 0;

  
  // set your application paths here
  $ci_application_paths = array
  (
      'ci_application',
      'ci_sandbox',
  );
        
  define('LOCALHOST', 'localhost' === $_SERVER['SERVER_NAME']);
  $html_title = 'Application Selector';
        
//=====================================================
function j_clean($row)
{
  $row = str_replace('<i>','',$row);
  $row = str_replace('</i>','',$row);
  
  return $row;
}//endfunc j_clean()    


// ================ endof Php stuff ===================
?&gt;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
  &lt;title&gt;&lt;?php echo $html_title;?&gt;&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;meta name="author"             content="John_Betong" /&gt;
  &lt;meta name="keywords"           content="CodeIgniter Menu" /&gt;
  &lt;meta name="description"        content="My Menu - maybe the best thing since sliced bread?" /&gt;
  &lt;meta http-equiv="imagetoolbar" content="no" /&gt;
  &lt;link rel="icon" href="/favicon.ico" type="image/x-icon"  /&gt;
  &lt;link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /&gt;
  &lt;style type='text/css'&gt;
     html     {border:0; margin:0; padding:0}      
    body        {font-family:"Lucida Grande",verdana,arial,helvetica,sans-serif;font-size:100%}
    i           {color:#f00; font-weight:700;font-size:1.20em}  
    body        {background:#627AAD none; color:#00f}
    a,
    pre,        
    #container  {background:#CECECE none; color:#000; border:solid 1px; padding:1em}
    #container  {width:40%;margin:4em auto}
    pre,
    #button            {background-color:#fff;margin:2em 0}
    a,    
    #button            {font-size:1.0 em}
    a                        {float:right}
  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

  <div id='container'>  
    <h1>&lt;?php echo $html_title;?&gt;</h1>
    <br />
    <h2>Select application to run</h2>
    &lt;?php /*  CI application paths */ ?&gt;
      &lt;form action='&lt;?php echo $filename;?&gt;'&gt;
        <dl>
           &lt;?php
              foreach($ci_application_paths as $row):
                echo '<dd>';
                  echo "&lt;input type='radio' name='new_application_path' value='";
                    echo j_clean($row);
                  echo "' /&gt; " .$row;
                echo "</dd>";
              endforeach;
           ?&gt;
           <dt>
          &lt;input type="hidden" name="tx" value="r4yt7WwQrte99" /&gt;
              &lt;input type="submit" value="  Start MeCritic Application  " id='button'/&gt;
           </dt>
        </dl>
      &lt;/form&gt;

      &lt;?php if(LOCALHOST) { ?&gt;
          <h4>$_SERVER</h4>
          <pre>
            &lt;?php print_r( $_SERVER);?&gt;
           </pre>
          <h4>$_SESSION</h4>
          <pre>
            &lt;?php print_r( $_SESSION);?&gt;
           </pre>
      &lt;?php } ?&gt;

  </div>&lt;?php /* container */ } else { echo "You don't have permission to access this file. Please send an email to x@x.com if you feel this is incorrect.";}?&gt;
&lt;/body&gt;
&lt;/html&gt;

And this is called via - http://www.thedomain.com/ci_menu/index.p...t7WwQrte99

As I mentioned before if you wanted to give a temporary link to a third party you could add and additional key value at the top to allow for your 3rd party link.

Thanks again for all the help getting the script up and running! And I'm glad I could contribute back if even in concept.

#22
[eluser]John_Betong_002[/eluser]
Quote:Thanks again for all the help getting the script up and running! And I’m glad I could contribute back if even in concept.

I am pleased I was able to help and also for your contribution which made the script far more effective.
&nbsp;
&nbsp;
&nbsp;

#23
[eluser]John_Betong_002[/eluser]
Quote:Thanks again for all the help getting the script up and running! And I’m glad I could contribute back if even in concept.

I am pleased I was able to help and also for your contribution which made the script far more effective.
&nbsp;
&nbsp;
&nbsp;


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.