Ejemplo n.º 1
0
function page_import_form()
{
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'bulk-load') {
        JxBotAsyncLoader::schedule_all();
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'load-abort') {
        JxBotAsyncLoader::stop_loading();
    }
    if (isset($_REQUEST['action']) && substr($_REQUEST['action'], 0, 12) == 'file-toggle-') {
        //print 'Toggle '.substr($_REQUEST['action'], 12);
        JxBotAsyncLoader::toggle_file(substr($_REQUEST['action'], 12));
    }
    ?>

<?php 
    if (isset($_FILES['data_file']) && $_POST['action'] == 'upload') {
        do_handle_upload();
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete-file') {
        do_delete_file();
    }
    ?>


<div class="left" style="margin-right: 3em;">
<?php 
    show_server_files();
    ?>
</div>



<div class="left" style="">
<?php 
    show_process_status();
    ?>

<p><button type="submit" name="action" value="bulk-load">Bulk Load</button> <button type="submit" name="action" value="load-abort">Stop Loading</button> <button type="submit" name="action" value="purge">Unload All</button></p>


<h2>Upload File</h2>

<p><input type="file" name="data_file" id="data_file" size="30"></p>

<p><button type="submit" name="action" value="upload">Upload File</button></p>

</div>

<div class="clear"></div>



<?php 
    /* if the user has requested a load operation,
    	include a call to the asyncronous loader here */
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'bulk-load' || isset($_REQUEST['action']) && substr($_REQUEST['action'], 0, 12) == 'file-toggle-') {
        invoke_asyncronous_loader();
    }
}
Ejemplo n.º 2
0
 public static function process_scheduled()
 {
     /* detatch from invoking HTTP process so we can't be interrupted */
     JxBotAsyncLoader::detatch_http_request();
     /* ensure we are the only instance running this process */
     try {
         if (!JxBotExclusion::get_exclusive()) {
             return;
         }
     } catch (Exception $err) {
         JxBotAsyncLoader::log(JxBotAsyncLoader::LOG_LEVEL_ERROR, $err->getMessage(), '');
         return;
     }
     /* iterate through all scheduled files */
     while (true) {
         $stmt = JxBotDB::$db->prepare('SELECT name FROM file WHERE status = \'Scheduled\' ORDER BY name LIMIT 1');
         $stmt->execute();
         $next = $stmt->fetchAll(PDO::FETCH_NUM);
         if (count($next) == 0) {
             return;
         }
         /* we're done */
         $file = $next[0][0];
         /* flag the file to indicate we're processing it, and prevent a loop if something is amiss */
         JxBotAsyncLoader::set_file_status($file, 'Loading');
         /* does the file actually exist? */
         $path = JxBotConfig::aiml_dir() . $file;
         if (!file_exists($path)) {
             JxBotAsyncLoader::set_file_status($file, 'Not Available');
             continue;
         }
         /* run the AIML importer */
         $importer = new JxBotAimlImport();
         $result = $importer->import($path);
         // ! TODO:  The notices, warnings and errors of this mechanism should be
         //          sent to us via our log() method, not passed back in an array. **
         /* check for errors and notices */
         if (is_array($result)) {
             JxBotAsyncLoader::set_file_status($file, 'Loaded');
             JxBotAsyncLoader::log(JxBotAsyncLoader::LOG_LEVEL_NOTICE, 'Loaded.', $file);
             /* log the results */
             foreach ($result as $notice) {
                 JxBotAsyncLoader::log(JxBotAsyncLoader::LOG_LEVEL_WARNING, $notice, $file);
             }
         } else {
             JxBotAsyncLoader::set_file_status($file, 'Load Error');
             JxBotAsyncLoader::log(JxBotAsyncLoader::LOG_LEVEL_ERROR, $result, $file);
         }
     }
 }
Ejemplo n.º 3
0
The above copyright notice, preamble and this permission notice shall be 
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*******************************************************************************/
/* the bot administration pages */
if (!defined('JXBOT')) {
    die('Direct script access not permitted.');
}
if (isset($_REQUEST['async-load'])) {
    JxBotAsyncLoader::process_scheduled();
    exit;
}
class JxBotAdmin
{
    private static $page = null;
    private static $all_pages = array(array('dashboard', 'Dashboard'), array('chat', 'Chat'), array('database', 'Database'), array('import', 'Import / Export'), array('bot', 'Bot'), array('system', 'System'), array('logout', 'Logout'));
    private static function is_logged_in()
    {
        return isset($_SESSION['jxbot-user']) && isset($_SESSION['jxbot-admin']) && $_SESSION['jxbot-admin'] === true;
    }
    private static function do_logout()
    {
        unset($_SESSION['jxbot-admin']);
        JxBotAdmin::$page = NULL;
        session_destroy();