Пример #1
0
    function main()
    {
        # KFD 2/17/09.  If installed with Debian package, will
        #               have username and password of "start".
        #               Must force a new id now.
        #
        if (SessionGet('UID') == 'start') {
            if (gp('user_id') != '') {
                if (gp('user_id') == '') {
                    ErrorAdd("User Id may not be empty");
                }
                if (substr(gp('user_id'), 0, 5) == 'andro') {
                    ErrorAdd("User Id may not begin with 'andro'");
                }
                if (gp('password1') != gp('password2')) {
                    ErrorAdd("Passwords do not match");
                }
                if (strlen(trim(gp('password1'))) == 0) {
                    ErrorAdd("Password may not be empty");
                }
                if (!Errors()) {
                    $row = array('user_id' => gp('user_id'), 'member_password' => gp('password1'));
                    SQLX_Insert('usersroot', $row);
                    if (!Errors()) {
                        scDBConn_Pop();
                        SessionSet('UID', gp('user_id'));
                        SessionSet('PWD', gp('password1'));
                        scDBConn_Push();
                        SQL("DELETE FROM USERSROOT WHERE user_id='start'");
                        # Get rid of the form that replaces login
                        $file = fsDirTop() . 'application/x_login_form.inc.html';
                        $fileto = $file . '.done';
                        @rename($file, $fileto);
                        ?>
                        <h1>New Root User Created</h1>
                        
                        <p>Your new user is created.</p>
                        
                        <p><a href="index.php?st2logout=1">
                           Return to Login Page</a></p>
                        <?php 
                        return;
                    }
                }
            }
            ?>
            <h1>New Install - Must Create User</h1>
            
            <p>You are logged into your Node Manager with the default
               username of "start" and password "start".  We have to change
               this right now so nobody can get into your new system.
            </p>
            
            <p>Please provide a new ROOT (superuser) user id and password
               below.  Andromeda will create the new user, log you in as
               that user, and remove the "start" user.
            </p>
            
            <table>
              <tr><td align="left">User Name
                  <td><input name = 'user_id' /> (may not begin with 'andro')
              <tr><td align="left">Password
                  <td><input type="password" name = 'password1'/>
              <tr><td align="left">Password (verify)
                  <td><input type="password" name = 'password2'/>
            </table>
            <input type="submit" value="Create User Now" />
            <?php 
            return;
        }
        /* FUTURE X6 VERSION OF NODE MANAGER
           ?>
           <h1>Node Manager Upgrade Required</h1>
           
           <p>The new version of the Node Manager uses the "x6" 
              interface to provide a richer experience.  Please click
              the link below to upgrade your Node Manager.  Once the
              upgrade is complete, log out and back in.
           </p>
           
           <p><a href="javascript:Popup('index.php?gp_page=a_builder&gp_out=none&x2=1&txt_application=andro','Build')"
               >Upgrade Node Manager Now</a>.</p>
               
           <p><a href="?st2logout=1">Logout After Upgrade</a>.</p>
           
           <?php
           return;
           */
        # <------- EARLY RETURN.
        # KFD 1/10/08, The old x_welcome screen is not used anymore,
        #              we have the new 'cpanel' now in x6.
        # ===============================================================
        ?>
        <h1>Welcome to the Andromeda Node Manager</h1>
        <?php 
        // Work out if there is a new release available
        //
        $apps = svnVersions();
        $andro = a($apps, 'andro', array('svn_url' => ''));
        if (trim($andro['svn_url']) == '') {
            $htmlVersions = '';
        } else {
            $htmlVersions = @file_get_contents($andro['svn_url']);
        }
        $matches = array();
        preg_match_all('/<li><a href=.*\\>(.*)<\\/a><\\/li>/', $htmlVersions, $matches);
        $versions = ArraySafe($matches, 1, array());
        if (count($versions) > 0) {
            $latest = array_pop($versions);
            $latest = str_replace('/', '', $latest);
            // Get current latest
            $current = $andro['local'];
            if ($latest > $current) {
                ?>
            <br/>
            <div style="border: 5px solid gray; color: blue
            font-weight: bolder; margin: 8px; padding: 0 8px 8px 8px">
            <h2>New Version of Andromeda Available</h2>
            
            <p>Version <?php 
                echo $latest;
                ?>
 is available.   <a href="?gp_page=a_pullsvn"
            >Click Here </a> to go to the Pull Code From Subversion.
            </div>
            <?php 
            }
        }
        $dirs = SQL_AllRows("select * from webpaths where webpath='DEFAULT'");
        ?>
<div style="font-size: 120%; line-height: 120%; padding: 10px">

<h2>For First Time Users</h2>
    This program is the Andromeda <b>Node Manager</b>.  You use this
    program to build your applications.
    <br/>
    <br/>
    Our main documentation is <a target="_blank" href=
    "http://www.andromeda-project.org/">here</a>.
    <br/>
    <br/>

    If you want to start programming a new application right away, 
    <a target="_blank"  href=
    "http://www.andromeda-project.org/creatinganapplication.html"
    >The instructions are here</a>, or you can just 
    <a href="?gp_page=applications&gp_mode=ins">define a new application here.</a>
    <br/>
    <br/>

After you defined an application, click on the "build this application"
link to create all of the directories and the empty database.</p>
<br/>
<br/>

<h2>Your Application Program Files</h2>

After building the application skeleton you can start working on the
   database specification.  If your application code is "test", then put
   the database specification into the file
   <br/>
   <br/>
   <b><?php 
        echo $dirs[0]['dir_pub'];
        ?>
/test/application/test.dd.yaml</b>
<br/>
<br/>

All Andromeda applications start with
a database specification.  These specifications are 
more powerful than anything else out there, 
and you will want learn the Andromeda's 
<a target="_blank" href=
"http://www.andromeda-project.org/databaseprogramming.html"
>Database Programming</a> language.

<br/>
<br/>
Once you are ready to try some custom pages, you are ready to look
at <a target="_blank" href=
"http://www.andromeda-project.org/webprogramming.html"
>Web Programming</a>.
   
    
</div>        
        <?php 
    }
Пример #2
0
 function mainLayout($container)
 {
     # Erase default help message
     vgfSet('htmlHelp', '');
     html('h1', $container, 'Configuration Review');
     $table = html('table', $container);
     $table->hp['id'] = 'x2data1';
     $thead = html('thead', $table);
     $tr = html('tr', $thead);
     $tr->h('th', 'Setting', 'dark');
     $tr->h('th', 'Framework', 'dark');
     $tr->h('th', 'Application', 'dark');
     $tr->h('th', 'Instance', 'dark');
     $tr->h('th', 'User', 'dark');
     $tr->h('th', 'Your Setting', 'dark');
     # Include any of the files that exist
     $dir = fsDirTop() . "/dynamic/table_config";
     $configfw = $configapp = $configinst = $configuser = array();
     if (file_exists($dir . 'fw.php')) {
         include $dir . 'fw.php';
     }
     if (file_exists($dir . 'app.php')) {
         include $dir . 'app.php';
     }
     if (file_exists($dir . 'inst.php')) {
         include $dir . 'inst.php';
     }
     if (file_exists($dir . 'user_' . SessionGet('UID') . '.php')) {
         include $dir . 'user_' . SessionGet('UID') . '.php';
     }
     $dd = ddTable('configapp');
     $askip = array('recnum', 'skey', 'skey_quiet', '_agg', 'uid_ins');
     $tbody = html('tbody', $table);
     $flipper = 0;
     foreach ($dd['flat'] as $column_id => $colinfo) {
         if (in_array($column_id, $askip)) {
             continue;
         }
         $tr = html('tr', $tbody);
         if ($flipper > 2) {
             $tr->addClass('lightgray');
         } else {
             if ($flipper != 2) {
                 $tr->addClass('lightgraybottom');
             }
         }
         $flipper += 1;
         if ($flipper == 6) {
             $flipper = 0;
         }
         html('td', $tr, $colinfo['description']);
         # The four levels from files
         html('td', $tr, a($configfw, $column_id));
         html('td', $tr, a($configapp, $column_id));
         html('td', $tr, a($configinst, $column_id));
         if (a($colinfo, 'flagcarry', 'N') == 'Y') {
             html('td', $tr, a($configuser, $column_id));
         } else {
             html('td', $tr, 'n/a');
         }
         # The final resolved value
         html('td', $tr, ConfigGet($column_id));
     }
 }
Пример #3
0
 /**
  * The user has requested that we download the latest 
  * version of each application from its respective
  * 
  *
  */
 function mainPull()
 {
     # Don't hold up the system
     Session_write_close();
     $rows = svnVersions();
     $dir = fsDirTop() . 'pkg-apps/';
     x_echoFlush('<pre>');
     x_EchoFlush('<h2>Pulling Software Updates From SVN</h2>');
     // Loop through the apps.
     foreach ($rows as $row) {
         x_EchoFlush("");
         x_echoFlush("<b>Application: " . $row['application'] . "</b>");
         if ($row['svn_url'] == '') {
             x_echoFlush("  No SVN repository, skipping.");
             continue;
         }
         # Add a trailing slash to svn_url
         $row['svn_url'] = AddSlash(trim($row['svn_url']));
         # If there is a username and password both, use those
         $urlDisplay = $row['svn_url'];
         $url = $row['svn_url'];
         if ($row['svn_uid'] != '' && $row['svn_pwd'] != '') {
             list($proto, $urlstub) = explode("//", $url);
             $uid = $row['svn_uid'];
             $pwd = $row['svn_pwd'];
             $url = "{$proto}//{$uid}:{$pwd}@{$urlstub}";
             $urlDisplay = "{$proto}//{$uid}:*****@{$urlstub}";
         }
         x_echoFlush("  Complete URL: " . $urlDisplay);
         # Now pull the list of versions
         x_echoFlush("  Querying for latest version");
         $rawtext = @file_get_contents($url);
         if ($rawtext) {
             $matches = array();
             preg_match_all('!\\<li\\>\\<a.*\\>(.*)\\</a\\>\\</li\\>!U', $rawtext, $matches);
             $versions = $matches[1];
             foreach ($versions as $key => $version) {
                 if ($version == '..') {
                     unset($versions[$key]);
                 }
             }
             if (count($versions) == 0) {
                 x_EchoFlush("  No versions listed, nothing to pull.");
                 continue;
             }
         } else {
             x_EchoFlush("Unable to get a release list from the svn server.");
             continue;
         }
         # Work out what the latest was and report it
         $latest = array_pop($versions);
         if (substr($latest, -1) == '/') {
             $latest = substr($latest, 0, strlen($latest) - 1);
         }
         x_echoFlush("  Latest version is: " . $latest);
         x_EchoFlush("  Local version is: " . $row['local']);
         # Decide if we need to continue
         if ($latest == $row['local']) {
             x_EchoFlush("  Local version is latest, nothing do to.");
             continue;
         }
         # Determine some stub values and pass processing to
         # the recursive file puller.  If no uid & pwd, use subversion
         x_EchoFlush("  Local version is out of date, pulling latest");
         $dirv = $dir . trim($row['application']) . '-VER-' . $latest . '/';
         if ($row['svn_uid'] != '' && $row['svn_pwd'] != '') {
             mkdir($dirv);
             $this->svnWalk("{$url}/{$latest}/", $dirv);
         } else {
             $command = "svn export {$url}{$latest} {$dirv}";
             x_echoFlush("  Pulling code now, this make take a minute or three...");
             x_EchoFlush($command);
             `{$command}`;
             x_echoFlush("  Code pulled, finished with this application.");
         }
         x_echoFlush("  Copying files into application directory");
         $basedir = str_replace('andro/', '', fsDirTop());
         if (isWindows()) {
             $command = 'xcopy /y /e /c /k /o ' . $dirv . '* ' . $basedir . trim($row['application']) . '/';
         } else {
             $command2 = 'cp -Rf ' . $dirv . '* ' . $basedir . trim($row['application']) . '/';
         }
         echo $command2;
         `{$command2}`;
     }
     x_echoFlush("<hr/>");
     x_EchoFlush("<h3>Processing Complete</h3>");
     $this->flag_buffer = false;
 }
Пример #4
0
    function writeFiles($constants, $skin, $color, $size, $cssFinal)
    {
        # At long last, after all of that work, we are ready
        # to write the file.  The last bit of processing we
        # do as we go along here is to remove empty or null
        # values to reduce clutter.
        ob_start();
        ?>
/* ==================================================== *\
 * Andromeda Generated CSS file                         
 * Generated: <?php 
        echo date('r', time()) . "\n";
        ?>
 * Skin, color, size: <?php 
        echo "{$skin}, {$color}, {$size}\n";
        ?>
\* ==================================================== */
        <?php 
        echo "\n";
        foreach ($cssFinal as $selector => $rules) {
            if (substr($selector, 0, 1) == '@') {
                $selector = '#' . substr($selector, 1);
            }
            $selector = str_replace(';', ':', $selector);
            echo "{$selector} {\n";
            foreach ($rules as $rule => $value) {
                if ($rule == '__yaml_line') {
                    continue;
                }
                if (trim($value) == '' || is_null($value)) {
                    continue;
                }
                echo "    " . str_pad($rule . ':', 25, ' ', STR_PAD_RIGHT) . "{$value};\n";
            }
            echo "}\n\n";
        }
        $filename = fsDirTop() . "templates/x6/skins/x6skin.{$skin}.{$color}.{$size}.css";
        $cssDone = ob_get_clean();
        file_put_contents($filename, $cssDone);
        # Another job, write out the CSS as a serialized
        # associative array so that plugins and other code
        # knows how big things are.  Also add in all of the
        # options to the array so we know the original
        # constants by their nicknames.
        #
        $phpStuff = array('defines' => $constants, 'css' => $cssFinal);
        $filename = fsDirTop() . "templates/x6/skinsphp/x6skin.{$skin}.{$color}.{$size}.ser.txt";
        file_put_contents($filename, serialize($phpStuff));
    }
Пример #5
0
/**
* @deprecated
*/
function jsOutput()
{
    // Get the array and see if there is anything to do
    $ajs = vgfGet('jsIncludes', array());
    $jqp = vgfGet('jqPlugins', array());
    $ajs = array_merge($ajs, $jqp);
    if (count($ajs) == 0) {
        return;
    }
    // Initialize array of files that must be minified
    $aj = array();
    // Loop through each file and either add it to list of
    // files to minify or output it directly
    $debug = trim(ConfigGet('js_css_debug', 'N'));
    if (vgfGet('x6')) {
        $debug = 'Y';
    }
    foreach ($ajs as $js) {
        $external = false;
        if (substr($js['file'], 0, 7) == 'http://') {
            $external = true;
        }
        if ($debug == 'N' && $external == false) {
            //if(false) {
            $aj[] = $js['file'];
            if ($js['comments'] != '') {
                ?>
                <!--
                <?php 
                echo $js['comments'];
                ?>
                -->
                <?php 
            }
        } else {
            $insert = $external ? '' : tmpPathInsert();
            ?>
            <script type="text/javascript"
                     src="<?php 
            echo $insert . $js['file'];
            ?>
" >
            <?php 
            echo $js['comments'];
            ?>
            </script>
            <?php 
        }
    }
    // If they needed minification, we have to work out now
    // what that file will be, maybe generate it, and create
    // a link to it
    //
    # KFD 8/20/08, Now minifying files during the build, so we
    #              grab that file if we can find it.  See below
    /*
    if(count($aj)==0) return;
    $list = implode('|',$aj);
    $md5  = substr(md5($list),0,15);
    $file = fsDirTop()."/clib/js-min-$md5.js";
    
    if(!file_exists($file)) {
        require 'jsmin-1.1.0.php';
        $string = '';
        foreach($aj as $ajone) {
            $f = fsDirTop().$ajone;
            $string.=JSMin::minify(file_get_contents($f));
        }
        file_put_contents($file,$string);
    }
    */
    if (count($aj) == 0) {
        return;
    }
    $list = implode('|', $aj);
    $md5 = substr(md5($list), 0, 15);
    $file = fsDirTop() . "/clib/js-min-{$md5}.js";
    if (!file_exists($file)) {
        $string = '';
        foreach ($aj as $ajone) {
            if (file_exists($ajone . '.mjs')) {
                $string .= file_get_contents(fsDirTop() . $ajone . '.mjs');
            } else {
                $string .= file_get_contents(fsDirTop() . $ajone);
            }
        }
        file_put_contents($file, $string);
        chmod($file, 0664);
    }
    // Finally, put out the file
    ?>
    <script type="text/javascript"
             src="<?php 
    echo tmpPathInsert() . "clib/js-min-{$md5}.js";
    ?>
" >
    </script>
    <?php 
}
Пример #6
0
    function x6main()
    {
        $top = html('div');
        $top->addClass('fadein');
        $top->h('h1', 'User Options');
        $height = x6cssdefine('insideheight') - x6cssHeight('h1') * 2;
        $pad1 = x6cssDefine('pad1');
        $tabs = $top->addTabs('useroptions', $height);
        # --------------------------------------------------------------
        # This is skin stuff
        # --------------------------------------------------------------
        $tab1 = $tabs->addTab('Appearance');
        $tab1->hp['style'] = "padding: {$pad1}px";
        $file = fsDirTop() . 'templates/x6/skinsphp/x6skins.ser.txt';
        $skins = unserialize(file_get_contents($file));
        $select = html('select');
        $cookie = arr($_COOKIE, 'x6skin', 'Default.Gray.1024');
        foreach ($skins as $name => $stats) {
            $option = $select->h('option', $name);
            $option->hp['value'] = $stats;
            # Note that $cookie was defined above
            if ($cookie == $stats) {
                $option->hp['selected'] = 'selected';
            }
        }
        $select->hp['onchange'] = 'x6ChangeSkin(this)';
        ob_start();
        ?>
        
        <script>
        window.x6ChangeSkin = function(select) {
            // Sourceforge 2753325 use quirksmode-supplied set cookie
            createCookie('x6skin',select.value,3650);
            //document.cookie 
            //    = "x6skin="+select.value+"; expires=12/31/2049 00:00:00;";
            window.location.reload(true);
        }
        </script>
        <h2>Skin Selection</h2>
        Skin: <?php 
        echo $select->render();
        ?>
        <?php 
        $tab1->setHtml(ob_get_clean());
        # <------- EARLY RETURN
        #
        if (!inGroup('debugging')) {
            $top->render();
            return;
        }
        # --------------------------------------------------------------
        # Now for javascript and logging
        # --------------------------------------------------------------
        $tab2 = $tabs->addTab('Javascript Development');
        $tab2->hp['style'] = "padding: {$pad1}px";
        $tab2->h('h2', 'Alternate Javascript Files');
        $tab2->h('p', 'You can use this feature to debug and enhance the
            Andromeda Javascript files without having a complete installation.
            Here is how it works:');
        $ul = $tab2->h('ul');
        $ul->h('li', 'Use Firebug to make local copies of x6.js and androLib.js');
        $ul->h('li', 'Put these files somewhere you can edit them which is also
              on a <i>publicly visible website</i>.');
        $ul->h('li', 'Put the address of the public website here, including a
              trailing slash.');
        $ul->h('li', '<span style="color:red">If you make a mistake and the files
              are not visible, this demo will stop working.  Close your
              browser and try again.</span>');
        $tab2->h('span', 'Alternate Location:&nbsp;&nbsp;');
        $input = html('input');
        $input->hp['size'] = 70;
        $input->hp['id'] = 'altjs';
        $input->hp['value'] = arr($_COOKIE, 'altjs', '');
        $input->code['change'] = <<<JS
        function(input) {
            createCookie('altjs',input.value);
        }
JS;
        $tab2->addChild($input);
        $tab2->h('h2', 'Logging');
        $tab2->h('p', 'Logging is by default turned off.  Use the checkboxes
            below to turn on the various logging features.');
        $a = $tab2->h('a-void', 'Detect console devices');
        $a->code['click'] = <<<JS
        function(input) {
            var msg = x6consoleActivate();
            if(msg==false) {
                alert("No console devices found, logging is disabled");
            }
            else {
                alert(msg);
            }
        }
JS;
        $tab2->br(2);
        $loptions = array('Server' => 'Server-Side Query Log', 'FBLite' => 'I am on IE, load Firebug Lite for me', 'Group' => 'Javascript Log Outline', 'Log' => 'Javascript Log Detail', 'Warn' => 'Warnings', 'Info' => 'Informational', 'Error' => 'Errors', 'Time' => 'Time start/end (requires firebug)');
        foreach ($loptions as $loption => $description) {
            $input = html('input');
            $input->hp['type'] = 'checkbox';
            $input->hp['command'] = $loption;
            $input->code['click'] = <<<JS
            function(input) {
                var command = x6.p(input,'command');
                var checked = input.checked;
                if(checked) {
                    x6.console['enable'+command] = true;
                    createCookie('log_'+command,1);
                }
                else {
                    x6.console['enable'+command] = false;
                    eraseCookie('log_'+command);
                }
            }
JS;
            if (arr($_COOKIE, 'log_' . $loption, 0) == 1) {
                $input->hp['checked'] = 'checked';
            }
            $tab2->addChild($input);
            $tab2->h('span', $description);
            $tab2->br();
            if ($loption == 'Server') {
                $tab2->br();
            }
        }
        # --------------------------------------------------------------
        # End of the line
        # --------------------------------------------------------------
        $top->render();
    }
Пример #7
0
/**
 * Pull all apps out of the server and then examine
 * the local station for latest versions
 *
 */
function svnVersions()
{
    // Get a list of applications
    $sq = "SELECT skey,application,description\n               ,svn_url\n               ,'  ' as local\n               ,'  ' as latest\n               ,svn_uid,svn_pwd,flag_svn\n           FROM applications\n          WHERE flag_svn = 'Y'\n          ORDER by application";
    $rows = SQL_Allrows($sq, 'application');
    // Get latest pkg-apps entries
    $dir = fsDirTop() . 'pkg-apps/';
    if (!file_exists($dir)) {
        mkdir($dir);
    }
    $vdirs = scandir($dir);
    foreach ($vdirs as $vdir) {
        if ($vdir == '.') {
            continue;
        }
        if ($vdir == '..') {
            continue;
        }
        if (strpos($vdir, '-VER-') === false) {
            continue;
        }
        // split into app and version
        list($app, $vers) = explode('-VER-', $vdir);
        if (isset($rows[$app])) {
            $rows[$app]['local'] = max($rows[$app]['local'], $vers);
        }
    }
    return $rows;
}
Пример #8
0
 function viewClob()
 {
     $table_id = gp('x6page');
     $skey = SQLFC(gp('skey'));
     $column = gp('column');
     $sql = 'SELECT "' . $column . '" from "' . $table_id . '" where skey= ' . $skey;
     echo "<pre>";
     $text = SQL_OneValue($column, $sql);
     echo $text;
     file_put_contents(fsDirTop() . 'tmp/viewClob.txt', $text);
     echo "</pre>";
     exit;
 }
Пример #9
0
function index_hidden_x6Dispatch($x6page, $x6file, $x6yaml, $x6profile, $x6plugin, $x6action)
{
    # This is everything that *might* go back, make a place
    # for all of it
    $GLOBALS['AG']['x4'] = array('error' => array(), 'debug' => array(), 'notice' => array(), 'html' => array(), 'script' => array());
    vgfSet('x6', true);
    # KFD 12/10/08, allow dynamic lookups.
    #
    if (gp('x6select', false)) {
        $table_id = gp('x6page');
        $gpletters = gp('gpletters');
        # KFD 4/11/09 Sourceforge 2753358 do real matches
        $matches = aFromGp('mtch_');
        $rows = RowsForSelect($table_id, $gpletters, $matches, '', true);
        foreach ($rows as $idx => $row) {
            unset($rows[$idx]['skey']);
            foreach ($row as $col => $val) {
                if ($col != 'skey') {
                    $rows[$idx][$col] = trim($val);
                }
            }
        }
        x6Data('x6select', $rows);
        echo json_encode_safe($GLOBALS['AG']['x4']);
        return;
    }
    # Make hidden variables for x6page and module
    hidden('x6page', $x6page);
    hidden('x6module', gp('x6module', 'X'));
    # This little bit of magic loads up the CSS information
    # for the current template and skin, allowing downstream
    # code to determine how much space they have to work with
    #
    $x6skin = arr($_COOKIE, 'x6skin', 'Default.Gray.1024');
    setCookie('x6skin', $x6skin);
    if ($x6skin != '') {
        $filename = fsDirTop() . "templates/x6/skinsphp/x6skin.{$x6skin}.ser.txt";
        if (file_exists($filename)) {
            $serialized = file_get_contents($filename);
            $GLOBALS['AG']['x6skin'] = unserialize($serialized);
        }
    }
    # If they have already defined MPPages in applib, we will
    # pick it up here with this global declaration.
    #
    # MPPages lists pages that may be accessed w/o login
    global $MPPages;
    if (!is_array($MPPages)) {
        $MPPages = array();
    }
    $MPPages['x_home'] = 'Home Page';
    $MPPages['x_login'] = '******';
    $MPPages['x_noauth'] = 'Authorization Required';
    $MPPages['x_password'] = "******";
    $MPPages['x_mpassword'] = "******";
    $MPPages['x_paypalipn'] = 'Paypal IPN';
    # Session timeouts.  Need to code for basic page access
    # and code for ajax timeouts.
    if (!LoggedIn() && !in_array($x6page, array_keys($MPPages))) {
        if (gpExists('json')) {
            x4Script("window.location='index.php?gp_page=x_login'");
            echo json_encode($GLOBALS['AG']['x4']);
        } else {
            echo "<script>window.location='index.php?gp_page=x_login&x2=1'</script>";
        }
        return;
    }
    # Include the basic x6 class, and set a default for
    # the class and the method call
    include 'androX6.php';
    $x6class = 'androX6';
    $x6method = 'x6main';
    # This is the core resolution where we figure out what class
    # to use and what method to call.  It is a little complicated
    # because we support 3 different kinds of pages (yaml, profile
    # and custom) plus calls from plugins to refresh, plus JSON
    # calls to do database stuff.
    if ($x6plugin != '') {
        # DEFUNCT.  We don't use plugins, they were an early
        #           idea, but profiles and androHTML classes
        #           made them unecessary.
        # A plugin always wins.  A call to a plugin assumes that
        # x6action is also specified.  We are going to instantiate
        # the plugin and call the method named by x6action.
        #$x6file  = '';
        #$x6class = 'x6plugin'.$x6plugin;
        #$x6method= $x6action;
        #include($x6class.'.php');
    } else {
        # No plugin means we are either using the base andromeda
        # class androX6, or using a custom class.  We only use
        # a custom class if the programmer has supplied a file.
        # So if that file exists we load that and use it.
        if ($x6file != '') {
            $x6class = 'x6' . $x6page;
            include $x6class . '.php';
        }
        # The next major decision is whether we are calling some
        # specific action, or loading a page.  If an action was
        # specified that wins.
        if ($x6action != '') {
            $x6method = $x6action;
        } else {
            # KFD 12/22/08.  Support for androPage! Extremely important!
            if (file_exists("application/{$x6page}.page.yaml")) {
                $x6class = 'androPage';
                $x6method = 'x6main';
                include 'androPage.php';
            } else {
                # Now we must be loading a page, because no plugin was
                # specified and no action.  At this point all that is
                # left to figure out is whether we load a profile or
                # go for the default "x6main" routine.
                if ($x6profile != '') {
                    $x6method = 'profile_' . $x6profile;
                } else {
                    $x6method = 'x6main';
                }
            }
            # If we are loading a page, we need the x6 javascript
            # and the first command in jqDocReady should be to
            # initialize the objects so downstrem code can make
            # them visible.
            # KFD 12/23/08, see if they set a cookie for an
            #               alternate location.
            # KFD 1/22/09 , Yikes! Don't do this if JSON was passed
            if (gp('json', '') != '1') {
                $xpath = arr($_COOKIE, 'altjs', 'clib/');
                jsInclude($xpath . 'x6.js');
                #jsInclude('clib/jquery.maskedinput-1.1.4.js');
                jqDocReady('x6.init()');
            }
        }
    }
    # Final trap.  If the class is androX6 and the method
    # is x6main, this means an unprogrammed page: there is
    # no custom program file and no profile in the yaml.
    # So we default to the conventional profile.
    #
    # KFD 2/17/09 Sourceforge 2546056
    #             This means that bad page requests go to
    #             profile_conventional(), so that is where
    #             we trap for them.  See androX6::profile_conventional()
    if ($x6method == 'x6main' && $x6class == 'androX6') {
        $x6method = 'profile_conventional';
        # KFD 2/2/09.  Allow fallback to x2 processing.  If the
        #              app is set for it, and a file exists, call
        #              that instead
        if (configGet('x6_x2', 'N') == 'Y') {
            if (file_exists(fsDirTop() . 'application/' . $x6page . '.php')) {
                include_once 'x_table2.php';
                include_once $x6page . '.php';
                $x6class = $x6page;
                $x6method = "main";
            }
        }
    }
    # Now everything is resolved.  We know what class to instantiate
    # and what method to call, so go for it.
    ob_start();
    $obj = new $x6class();
    # KFD 3/30/09 Sourceforge 2697962 Do this here, so it
    #             does not matter if androX6 or androPage
    $obj->hld = aFromGp('hld_');
    $obj->dd = ddTable($x6page);
    $obj->x6page = $x6page;
    $obj->view = arr($obj->dd, 'viewname', '');
    $obj->{$x6method}();
    $HTML = ob_get_clean();
    # KFD 3/20/09 Sourceforge 2697962
    #             Make sure programmer never has to send out
    #             hold variables, they should go automatically
    if (gp('json') != 1) {
        if (isset($obj->hld)) {
            foreach ($obj->hld as $name => $value) {
                # KFD 3/20/09 Sourceforge 2697962
                #             Put out as hidden instead
                hidden('hld_' . $name, $value);
                #$inp = $top->h('input');
                #$inp->hp['type'] = 'hidden';
                #$inp->hp['name'] = $inp->hp['id'] = 'hld_'.$name;
                #$inp->hp['value'] = $value;
            }
        }
    }
    # Now if they made a "main" call, see if they want us to
    # send back some script as well
    if ($x6method == 'x6main') {
        if (method_exists($obj, 'x6script')) {
            ob_start();
            $obj->x6script();
            x6script(ob_get_clean());
        }
    }
    # And again see if they are sending out any popups
    if ($x6method == 'x6main') {
        if (method_exists($obj, 'x6modals')) {
            ob_start();
            $obj->x6modals();
            $HTML .= ob_get_clean();
        }
    }
    x6HTML('*MAIN*', $HTML);
    # Put errors in that were reported by database operations
    if (Errors()) {
        $errs = errorsGet();
        foreach ($errs as $err) {
            x4Error($err);
        }
    }
    # CODE BELOW HERE WAS TAKEN FROM X4 UNCHANGED.
    # if the "json" flag is set, we return all output as JSON,
    # otherwise we package it up with the normal template and
    # return it as main content
    if (gp('json') == 1) {
        echo json_encode_safe($GLOBALS['AG']['x4']);
    } else {
        # Don't need a form in x6 mode
        vgaSet('NOFORM', true);
        #  Put things where the template expects to find them
        vgfSet('HTML', $GLOBALS['AG']['x4']['html']['*MAIN*']);
        #  If there was some script, add that in
        foreach ($GLOBALS['AG']['x4']['script'] as $script) {
            jqDocReady($script);
        }
        # Just before the absolute very last command is the
        # firing of our (currently) one and only queue
        jqDocReady('x6events.fireQueue("afterInit")');
        # The absolute very last command is the fade in
        $fadeIn = "\$('.fadein').fadeIn('slow',function() { x6.initFocus(); });";
        jqDocReady($fadeIn);
        # DUPLICATE ALERT: This code copied from
        #                  index_hidden_page() below
        index_hidden_template('x4');
        global $J;
        $mainframe = $J['mainframe'];
        $my = $J['my'];
        $mosConfig_absolute_path = $J['mC_absolute_path'];
        $mosConfig_live_site = $J['mC_live_site'];
        $template_color = $J['template_color'];
        $template_color = 'red';
        $file = $GLOBALS['AG']['dirs']['root'] . '/templates/' . $mainframe->GetTemplate() . "/index.php";
        include $file;
    }
    return;
}
Пример #10
0
 function delfile()
 {
     # If user is not logged in and not in file maintenance,
     # quietly ignore
     if (!LoggedIn()) {
         return;
     }
     if (!inGroup('filemaint')) {
         return;
     }
     $filename = fsDirTop() . 'apppub/' . gp('file');
     unlink($filename);
 }