Exemplo n.º 1
0
 /**
 * Documentation for this function.
 */
 function onMakeFinalPDB()
 {
     $context = getContext();
     $newModel = $_SESSION['models'][$context['newModel']];
     $oldModel = $_SESSION['models'][$newModel['parent']];
     $newPDB = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb'];
     $oldPDB = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $oldModel['pdb'];
     $url = $_SESSION['dataURL'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb'];
     // Put our money where our mouth is and calculate that new PDB file
     $all_changes = $context['sswingChanges'];
     $usercnit = $_REQUEST['cnit'];
     // Remove changes for residues that weren't selected
     foreach ($all_changes as $k => $v) {
         $res = substr($k, 0, 9);
         if (!isset($usercnit[$res])) {
             unset($all_changes[$k]);
         } else {
             $changed_res[$res] = $res;
         }
         // used below for the lab notebook
     }
     // Make PDB file
     pdbSwapCoords($oldPDB, $newPDB, $all_changes);
     // Make up the lab notebook entry
     $text = "The following residues were automatically refit by SSWING, creating {$newModel['pdb']} from {$oldModel['pdb']}:\n<ul>\n";
     foreach ($changed_res as $res) {
         $text .= "<li>{$res}</li>\n";
     }
     $text .= "</ul>\n";
     $text .= "<p>You can now <a href='{$url}'>download the optimized and annotated PDB file</a> (" . formatFilesize(filesize($newPDB)) . ").</p>\n";
     $entryNum = addLabbookEntry("Refit sidechains with SSWING to get {$newModel['pdb']}", $text, "{$oldModel['id']}|{$newModel['id']}", 'auto');
     $ctx = array('labbookEntry' => $entryNum);
     pageGoto("generic_done.php", $ctx);
 }
Exemplo n.º 2
0
 /**
 * Documentation for this function.
 */
 function onStartSSwing()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Go back') {
         $c = getContext();
         $ctx['modelID'] = $c['modelID'];
         $ctx['map'] = $c['map'];
         pageGoto("sswing_setup1.php", $ctx);
         return;
     }
     $ctx = getContext();
     unset($_SESSION['bgjob']);
     // Clean up any old data
     $_SESSION['bgjob']['modelID'] = $ctx['modelID'];
     $_SESSION['bgjob']['edmap'] = $ctx['map'];
     $_SESSION['bgjob']['cnit'] = $req['cnit'];
     $_SESSION['bgjob']['fastSearch'] = $req['fastSearch'];
     mpLog("sswing:Launched SSWING to refit " . count($_req['cnit']) . " residue(s)");
     // launch background job
     pageGoto("job_progress.php");
     launchBackground(MP_BASE_DIR . "/jobs/sswing.php", "sswing_choose.php", 5);
 }
Exemplo n.º 3
0
 function printNewItemTR()
 {
     $all_vswitches = getVLANSwitches();
     global $pageno;
     $hintcodes = array('prev_vdid' => 'DEFAULT_VDOM_ID', 'prev_vstid' => 'DEFAULT_VST_ID', 'prev_objid' => NULL);
     $focus = array();
     foreach ($hintcodes as $hint_code => $option_name) {
         if (array_key_exists($hint_code, $_REQUEST)) {
             assertUIntArg($hint_code);
             $focus[$hint_code] = $_REQUEST[$hint_code];
         } elseif ($option_name != NULL) {
             $focus[$hint_code] = getConfigVar($option_name);
         } else {
             $focus[$hint_code] = NULL;
         }
     }
     printOpFormIntro('add');
     echo '<tr>';
     if ($pageno != 'object') {
         echo '<td>';
         // hide any object that is already in the table
         $options = array();
         foreach (getNarrowObjectList('VLANSWITCH_LISTSRC') as $object_id => $object_dname) {
             if (!in_array($object_id, $all_vswitches)) {
                 $ctx = getContext();
                 spreadContext(spotEntity('object', $object_id));
                 $decision = permitted(NULL, NULL, 'del');
                 restoreContext($ctx);
                 if ($decision) {
                     $options[$object_id] = $object_dname;
                 }
             }
         }
         printSelect($options, array('name' => 'object_id', 'tabindex' => 101, 'size' => getConfigVar('MAXSELSIZE')), $focus['prev_objid']);
         echo '</td>';
     }
     if ($pageno != 'vlandomain') {
         echo '<td>' . getSelect(getVLANDomainOptions(), array('name' => 'vdom_id', 'tabindex' => 102, 'size' => getConfigVar('MAXSELSIZE')), $focus['prev_vdid']) . '</td>';
     }
     if ($pageno != 'vst') {
         $options = array();
         foreach (listCells('vst') as $nominee) {
             $ctx = getContext();
             spreadContext($nominee);
             $decision = permitted(NULL, NULL, 'add');
             restoreContext($ctx);
             if ($decision) {
                 $options[$nominee['id']] = niftyString($nominee['description'], 30, FALSE);
             }
         }
         echo '<td>' . getSelect($options, array('name' => 'vst_id', 'tabindex' => 103, 'size' => getConfigVar('MAXSELSIZE')), $focus['prev_vstid']) . '</td>';
     }
     echo '<td>' . getImageHREF('Attach', 'set', TRUE, 104) . '</td></tr></form>';
 }
Exemplo n.º 4
0
 /**
 * Launches Prekin when the user submits the form.
 */
 function onRunPrekin()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     // Otherwise, moving forward:
     if (isset($req['modelID']) && isset($req['scriptName'])) {
         $_SESSION['lastUsedModelID'] = $req['modelID'];
         // this is now the current model
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob'] = $req;
         mpLog("makekin:Creating simple kinemages from built-in Prekin script '{$req['scriptName']}'");
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/makekin.php", "generic_done.php", 3);
     } else {
         $context = getContext();
         if (isset($req['modelID'])) {
             $context['modelID'] = $req['modelID'];
         }
         if (isset($req['scriptName'])) {
             $context['scriptName'] = $req['scriptName'];
         }
         setContext($context);
     }
 }
Exemplo n.º 5
0
 function onFolderClose($arg)
 {
     $context = getContext();
     $context['isExpanded'][$arg] = false;
     setContext($context);
 }
Exemplo n.º 6
0
 /**
 * This function calls the notebook editor so the user can modify the notebook
 * entry. Control is transfered to another page, namely, notebook_edit.php.
 * When that page is done, it will call pageReturn(), and control will return
 * to this class--display() will be called again to show the entry.
 *
 * This function gets called when the user clicks the link made by display()
 *
 * $arg contains the entry number of the notebook entry to edit. It was specified
 * by the call to makeEventURL() that occurs in display(), above.
 * $req is filled in with the usually info from the form submission, but
 * we don't need to use it for anything here.
 */
 function onPdbConvert()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     if (isset($req['modelID'])) {
         $_SESSION['lastUsedModelID'] = $req['modelID'];
         // this is now the current model
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob'] = $req;
         mpLog("convertPdb:Converted '{$req['modelID']}' to PDBv2.3");
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/pdb_convert.php", "generic_done.php", 3);
     } else {
         $context = getContext();
         if (isset($req['modelID'])) {
             $context['modelID'] = $req['modelID'];
         }
         //if(isset($req['scriptName']))   $context['scriptName']  = $req['scriptName'];
         setContext($context);
     }
 }
Exemplo n.º 7
0
 $options = getOptions($params);
 if (($site = array_shift($params)) === null) {
     $site = 'default';
 }
 if (($tplsite = array_shift($params)) === null) {
     $tplsite = 'default';
 }
 spl_autoload_register('setupAutoload');
 require 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
 $aimeos = new \Aimeos\Bootstrap(isset($options['extdir']) ? (array) $options['extdir'] : array());
 $taskPaths = $aimeos->getSetupPaths($tplsite);
 setIncludePaths($taskPaths);
 $conf = getConfig($aimeos->getConfigPaths(), $options);
 $conf->set('setup/site', $site);
 $dbconfig = getDbConfig($conf);
 $ctx = getContext($conf);
 $dbm = $ctx->getDatabaseManager();
 $manager = new \Aimeos\MW\Setup\Manager\Multiple($dbm, $dbconfig, $taskPaths, $ctx);
 $action = isset($options['action']) ? $options['action'] : 'migrate';
 $task = isset($options['task']) ? $options['task'] : null;
 switch ($action) {
     case 'clean':
         $manager->clean($task);
         break;
     case 'migrate':
         $manager->migrate($task);
         break;
     case 'rollback':
         $manager->rollback($task);
         break;
     default:
Exemplo n.º 8
0
/**
    Types of Disqus searches
    1. Context: postid
    2. Search: email,username,user,string
    3. Scope: identity, thread
    4. List of postids: commands, rule posts

    Results are processes but not acted upon (only marked and get ruleid, watch, etc set)

    Issues:
    Separate searches for children, level and parents? If not - then we must preserve ids in the table. How do we know that ids need rewriting?
    Answer: each row containst context information: one of [queue, level, child, parent], tab_id, view, identity. Each search deletes all the previous
    rows first.

    A: Create a table of postid/parentid to fetch old contexts from disqus  qwp_post_index. Also should have a field to indicate if came alone or with the full thread.
    If the postid is not present in qwp_post_index (with the context) then get parents but put a pseudo post as a sibling into level grid explaining the issue and offering to fetch the entire
    old thread. This will also put the context into a tear-away tab if not already there. When the thread is loaded the context is rebuilt and the pseudo-post gone.

    B: Need to have stale post indication. WHen the local post is present, calculate first if is stale or not before going to discus. Formula should be 
    age of the post devided by the interval since last update < 2. Also means adding updatedAt field.


    Update: add last:nnn search



    **/
function backgroundSearch($scope, $ct, $cv, $search, $tab_id)
{
    //this is slow version of loadQueueItems. First it does same as loadQueue saving postids, then goes to disqus and gets the same posts.
    //Then compares the ids, if same only updates text and generates change tick, if new = new posts tick for the specific tab
    // $posts=loadPosts($scope,$ct,$cv,$search,$tab_id);
    /**
            1. Determine the type of request
                a. search
                b. all posts for identity
                c. all posts for thread
                d. ids (commands or rule)
                e. context:level
                f: context:child
            **/
    global $control;
    global $access_token;
    global $unDataService;
    global $nmDataService;
    global $global_username;
    global $logService;
    global $view;
    global $queueType;
    global $global_emailHash;
    if ($queueType == "queue" && empty($search) && empty($ct) && empty($cv)) {
        echo json_encode(array("success" => true, "total" => 0, "posts" => 0));
        return;
    }
    if ($scope == 'watch' && !$control['watch'] || $scope == 'deleted' && !$control['deleted']) {
        echo json_encode(array("success" => true, "total" => 0, "posts" => 0));
        return;
    }
    if ($scope == 'watch' || $scope == 'deleted' || $scope == 'approved' || $scope == 'unconfirmed') {
        echo json_encode(array("success" => true, "total" => 0, "posts" => 0));
        return;
    }
    $forumid = $control['forumid'];
    $ds = $nmDataService->getForumHubDataService($forumid);
    $fdata = $nmDataService->getForumData($forumid);
    $disqus_forumid = $fdata['external_id'];
    if ($scope == 'all' && !$control['deleted']) {
        $scope = 'working';
    }
    $context = 'queue';
    if (strpos($queueType, ':') !== FALSE) {
        $exp = explode(':', $queueType);
        $queueType = $exp[0];
        $context = $exp[1];
    }
    if ($context == 'queue') {
        $type = 'queue';
    } else {
        $type = 'post';
    }
    if ($ct == "thread") {
        $context = 'root';
        $type = 'root';
    }
    $selfsearch = false;
    if ($search == 'rself') {
        $search = '';
        $selfsearch = true;
    }
    $source = "type=" . $type . ";" . "scope=" . $scope . ";" . "constraint_type=" . $ct . ";" . "constraint_value=" . $cv . ";" . "tab_id=" . $tab_id . ";" . "search=" . $search;
    $logService->log('DEBUG', '@@@backgroundSearch', 'source::' . $source, $global_username);
    if ($context == 'queue' && $scope == 'all' && !empty($ct) && $ct == 'identity') {
        //b.
        $username = $ds->getUsernameByIdentity($cv, $forumid);
        $search = "user:"******"success" => false, "msg" => "ERROR1: Exception:" + var_log($x)));
            exit;
        }
    } else {
        if ($type == 'root' && !empty($ct) && $ct == 'thread') {
            //c.
            $thread = $cv;
            $search_to_show = "thread:" . $thread;
            if ($selfsearch) {
                $search = $source;
            }
            // $logService->log('DEBUG','###backgroundSearch','direct_source(search)::'.$search.'::$search_to_show::'.$search_to_show,$global_username);
            /* $ispresent=$ds->getThreadTitle($thread,$forumid);   
               if($ispresent) {
                    echo json_encode(array(
                   "success" => true,
                   "total" => 0,
                   "posts" => 0
                   ));
                   return;
               }*/
            $isload = $ds->getThreadSearch($thread, $forumid);
            if (!$isload) {
                $go = $ds->startServerSearch($tab_id, $scope, 'thread', 'all', $forumid, $search_to_show, $search);
                // the search param has the primary source of the search that created the pseudo post
                if ($go) {
                    try {
                        set_time_limit(0);
                        $ds->startThreadSearch($thread, $forumid);
                        $ds->updateThreadPseudoPosts($thread, $forumid);
                        getThread($ds, $fdata, $forumid, $access_token, $disqus_forumid, $thread, $go);
                        $ds->removeThreadPseudoPosts($thread, $forumid);
                        $ds->completeServerSearch($tab_id, $scope, 'thread', 'all', $forumid, $search_to_show);
                        $ds->completeThreadSearch($thread, $forumid);
                        set_time_limit(30);
                    } catch (Exception $x) {
                        set_time_limit(30);
                        $ds->completeServerSearch($tab_id, $scope, 'thread', 'all', $forumid, $search_to_show);
                        $logService->log('ERROR', 'backgroundSearch', fe($x), $forumid);
                        echo json_encode(array("success" => false, "msg" => "ERROR2: Exception:" + $x->getMessage()));
                        exit;
                    }
                }
            }
        } else {
            if ($context == 'queue' && $scope == 'commands') {
                //d.1
                //get list of postids
                $posts = array();
                $username = $ds->getUsernameByIdentity($cv, $forumid);
                $search = "user:"******"success" => false, "msg" => "ERROR2: Exception:" + var_log($x)));
                            exit;
                        }
                    }
                }
            } else {
                if ($context == 'queue' && $scope == 'rules' && !empty($ct) && $ct == 'rule') {
                    //d.2
                    //get list of postids
                    $posts = array();
                    $username = $ds->getUsernameByIdentity($cv, $forumid);
                    $search = "rules:" . $username;
                    // this is for nice display purpose only
                    if ($ct == 'rule') {
                        $posts = $ds->getRulePostids($cv, $forumid);
                        if ($posts) {
                            $go = $ds->startServerSearch($tab_id, $scope, 'rule', 'posts', $forumid, $search, $source);
                            try {
                                if ($go) {
                                    set_time_limit(0);
                                    foreach ((array) $posts as $post) {
                                        $postid = $post['postid'];
                                        getPost($ds, $fdata, $forumid, $access_token, $disqus_forumid, $postid, $go);
                                    }
                                    $ds->completeServerSearch($tab_id, $scope, 'rule', 'posts', $forumid, $search);
                                    set_time_limit(30);
                                }
                            } catch (Exception $x) {
                                set_time_limit(30);
                                if ($go) {
                                    $ds->completeServerSearch($tab_id, $scope, 'rule', 'posts', $forumid, $search);
                                }
                                $logService->log('ERROR', 'backgroundSearch', fe($x), $forumid);
                                echo json_encode(array("success" => false, "msg" => "ERROR4: Exception:" + var_log($x)));
                                exit;
                            }
                        }
                    }
                } else {
                    if ($context == 'level' && !empty($ct) && $ct == 'post') {
                        //e - also need to get parent
                        /**
                                A.Parent processing:
                                    1. Get all parent context postids from qwp_post_index. Find all the postids that are either missing from tab_posts or are stale.
                                    Get them from disqus. If any were missing - send updateparent tick to UI.
                                    2. If the index does not have a complete chain - get a context (in disqus terms) from discus. Send updateparent tick to UI.
                                B. Level processing:
                                    1. Check if the post has context. If yes - get all the level postids from index, compare them to tab_posts and check if any are stale. For missing or stale get from disqus.
                                    No ticks - the new and changed messages will be handled routinely by crawler processPosts.
                                    2. If no context send a tick to put a pseudo post up inviting user to get the complete thread loaded if they want to see the full context.
                        
                        **/
                        /**
                            Archiving refactoring 4/1/2015
                                    if parent==-1 and thread.state==2 get the thread from archive (restoreThread())
                                    else
                                    walk index, if(thread.state==2) for each index with missing post get it from archive, only else go to Disqus for a copy
                        
                            The queue search on background will also search archive and restore found posts, without their threads and will not change the state of the thread        
                        
                        
                        **/
                        $username = $ds->getUsernameByIdentity($cv, $forumid);
                        $search = "post:" . $cv;
                        // this is for nice display purpose only
                        $postid = $cv;
                        $hasparent = false;
                        $go = $ds->startServerSearch($tab_id, $scope, 'post', 'context', $forumid, $search, $source);
                        if ($go) {
                            set_time_limit(0);
                            try {
                                $index_postids = $ds->getParentPostidsFromIndex($cv, $forumid);
                                //check if it is complete chain
                                $len = sizeof($index_postids);
                                $last_post = null;
                                if ($len >= 1) {
                                    $last_post = $index_postids[$len - 1];
                                }
                                $now = time();
                                if ($last_post && $last_post['parentid'] == -1) {
                                    //complete chain
                                    if ($last_post['postid'] != $postid) {
                                        $hasparent = true;
                                    } else {
                                        /**  4/1/2015   **/
                                        $ds->restoreThreadIfArchived($last_post['thread'], $forumid);
                                    }
                                    //$logService->log('DEBUG','backgroundSearch','Parent chain (size='.$len.') is present locally in index for postid='.$cv,$forumid);
                                    $local_postids = $ds->getPostsByMissingPostids($index_postids, $forumid);
                                    $skip_ids = array();
                                    foreach ((array) $local_postids as $lp) {
                                        //stale calculations
                                        $age = $now - $lp['createdat'];
                                        $sinceupdate = $now - $lp['updatedat'];
                                        if ($sinceupdate != 0 && $age / $sinceupdate > 2) {
                                            //fresh enough
                                            $skip_ids[] = $lp['postid'];
                                        }
                                    }
                                    $sent = false;
                                    foreach ($index_postids as $post) {
                                        //  $logService->log('DEBUG','backgroundSearch','Inside index_postids loop for postid='.$cv,$forumid);
                                        $postid = $post['postid'];
                                        if (in_array($post['postid'], $skip_ids)) {
                                            continue;
                                        }
                                        $updatedat = $ds->getPostUpdatedat($forumid, $postid);
                                        if ($updatedat > $now) {
                                            //another thread updated the post meanwhile
                                            continue;
                                        }
                                        // $logService->log('DEBUG','backgroundSearch','Calling getPost for postid='.$cv,$forumid);
                                        /** first try archive 4/1/2015   **/
                                        getPost($ds, $fdata, $forumid, $access_token, $disqus_forumid, $postid, $go);
                                        $sent = true;
                                    }
                                } else {
                                    // get a complete disqus context for potid
                                    $logService->log('DEBUG', 'backgroundSearch:level', 'Getting complete disqusus context for postid=' . $cv, $forumid);
                                    getContext($ds, $fdata, $forumid, $access_token, $disqus_forumid, $postid, $go);
                                    // $logService->log('DEBUG',' after backgroundSearch:level','Getting complete disqusus context for postid='.$cv,$global_username);
                                }
                                //B: Level processing
                                $postid = $cv;
                                //check if in context
                                // $logService->log('DEBUG','begin:level','',$global_username);
                                $has_context = $ds->checkHasContextonIndex($postid, $forumid);
                                if ($has_context) {
                                    /**
                                                                3/8/2015
                                                                Thread archiving refactoring. If has context the thread coule be archived
                                    
                                    
                                                            **/
                                    if ($hasparent) {
                                        $index_postids = $ds->getLevelPostidsFromIndex($postid, $forumid);
                                        // $logService->log('DEBUG',' getLevelPostidsFromIndex:level',var_log($local_postids,'$index_postids'),$global_username);
                                        $now = time();
                                        $local_postids = $ds->getPostsByMissingPostids($index_postids, $forumid);
                                        //$local_postids=$ds->getPostidsFromTabPosts($global_emailHash,$view,$tab_id,'level');
                                        //  $logService->log('DEBUG',' aftergetPostidsFromTabPosts:level',var_log($local_postids,'$local_postids'),$global_username);
                                        $skip_ids = array();
                                        foreach ((array) $local_postids as $lp) {
                                            //stale calculations
                                            $age = $now - $lp['createdat'];
                                            $sinceupdate = $now - $lp['updatedat'];
                                            if ($sinceupdate) {
                                                if ($age / $sinceupdate > 2) {
                                                    //fresh enough
                                                    $skip_ids[] = $lp['postid'];
                                                }
                                            }
                                        }
                                        foreach ($index_postids as $post) {
                                            $postid = $post['postid'];
                                            if (in_array($post['postid'], $skip_ids)) {
                                                continue;
                                            }
                                            $updatedat = $ds->getPostUpdatedat($forumid, $postid);
                                            if ($updatedat > $now) {
                                                //another thread updated the post meanwhile
                                                continue;
                                            }
                                            // $logService->log('DEBUG',' calling getPost:level',$postid,$global_username);
                                            /** first try archive 4/1/2015   **/
                                            getPost($ds, $fdata, $forumid, $access_token, $disqus_forumid, $postid, $go);
                                        }
                                    } else {
                                        //just this one post if at the top level
                                        getPost($ds, $fdata, $forumid, $access_token, $disqus_forumid, $postid, $go);
                                    }
                                } else {
                                    //insert a pseudopost
                                    // $logService->log('DEBUG','before insert pseudopost:level','',$global_username);
                                    $ds->insertPseudopost($tab_id, "level", $postid, $forumid, $source);
                                    //  $logService->log('DEBUG','after insert pseudopost:level','',$global_username);
                                }
                                $ds->completeServerSearch($tab_id, $scope, 'post', 'context', $forumid, $search);
                                set_time_limit(30);
                                // $logService->log('DEBUG','exit backgroundSearch:level','',$global_username);
                            } catch (Exception $x) {
                                set_time_limit(30);
                                $ds->completeServerSearch($tab_id, $scope, 'post', 'context', $forumid, $search);
                                $logService->log('ERROR', 'backgroundSearch', fe($x), $forumid);
                                echo json_encode(array("success" => false, "msg" => "ERROR3: Exception:" + var_log($x)));
                                exit;
                            }
                        }
                    } else {
                        if ($context == 'child' && !empty($ct) && $ct == 'post') {
                            //f
                            /**
                            
                                    C. Child processing: same as level except no pseudo post needed    
                                        **/
                            $username = $ds->getUsernameByIdentity($cv, $forumid);
                            $search = "post:" . $cv;
                            // this is for nice display purpose only
                            $postid = $cv;
                            $go = $ds->startServerSearch($tab_id, $scope, 'post', 'children', $forumid, $search, $source);
                            if ($go) {
                                set_time_limit(0);
                                try {
                                    $has_context = $ds->checkHasContextonIndex($cv, $forumid);
                                    $postid = $cv;
                                    if ($has_context) {
                                        $index_postids = $ds->getChildPostidsFromIndex($postid, $forumid);
                                        $now = time();
                                        $local_postids = $ds->getPostsByMissingPostids($index_postids, $forumid);
                                        //$local_postids=$ds->getPostidsFromTabPosts($global_emailHash,$view,$tab_id,'child');
                                        $skip_ids = array();
                                        foreach ((array) $local_postids as $lp) {
                                            //stale calculations
                                            $age = $now - $lp['createdat'];
                                            $sinceupdate = $now - $lp['updatedat'];
                                            //$logService->log('DEBUG','backgroundSearch:child stale calc','$age='.$age.';$sinceupdate='.$sinceupdate,$global_username);
                                            if ($sinceupdate) {
                                                if ($age / $sinceupdate > 2) {
                                                    //fresh enough
                                                    $skip_ids[] = $lp['postid'];
                                                }
                                            }
                                        }
                                        foreach ($index_postids as $post) {
                                            $postid = $post['postid'];
                                            if (in_array($post['postid'], $skip_ids)) {
                                                continue;
                                            }
                                            getPost($ds, $fdata, $forumid, $access_token, $disqus_forumid, $postid, $go);
                                        }
                                    }
                                    $ds->completeServerSearch($tab_id, $scope, 'post', 'children', $forumid, $search);
                                    set_time_limit(30);
                                    // $logService->log('DEBUG','exit backgroundSearch:child','',$global_username);
                                } catch (Exception $x) {
                                    set_time_limit(30);
                                    $ds->completeServerSearch($tab_id, $scope, 'post', 'children', $forumid, $search);
                                    $logService->log('ERROR', 'backgroundSearch:children', fe($x), $forumid);
                                    echo json_encode(array("success" => false, "msg" => "ERROR3: Exception:" + var_log($x)));
                                    exit;
                                }
                            }
                        } else {
                            if ($context == 'queue') {
                                //a.
                                $go = false;
                                try {
                                    $go = $ds->startServerSearch($tab_id, $scope, $ct, $cv, $forumid, $search, $source);
                                    if ($go) {
                                        set_time_limit(0);
                                        $ds->archiveSearch($forumid, $scope, $ct, $cv, $search, $context);
                                        $posts = disqus_search($ds, $fdata, $forumid, $access_token, $disqus_forumid, $search, 300, $go);
                                        // limit free form search to 300 posts
                                        set_time_limit(30);
                                        //
                                        // $logService->log('DEBUG','backgroundSearch','search::'.$search,$forumid);
                                        if (strpos($search, 'last:') !== FALSE || strpos($search, 'days:') !== FALSE) {
                                            // init load
                                            // $logService->log('DEBUG','backgroundSearch 2','search::'.$search,$forumid);
                                            $tabs = $ds->loadUserForumTabs($control, $view);
                                            //$logService->log('DEBUG','backgroundSearch 3','tabs::'.var_log($tabs),$forumid);
                                            foreach ($tabs as $tab) {
                                                $tab_id2 = $tab['tab_id'];
                                                // $logService->log('DEBUG','Dispatch tick',' TabPosts backgroundSearch tab_id='.$tab_id,$forumid);
                                            }
                                        }
                                        //$logService->log('DEBUG','Dispatch tick',' ServerSearchLog backgroundSearch ',$forumid);
                                        $ds->completeServerSearch($tab_id, $scope, $ct, $cv, $forumid, $search);
                                    }
                                } catch (Exception $x) {
                                    if ($go) {
                                        $ds->completeServerSearch($tab_id, $scope, $ct, $cv, $forumid, $search);
                                    }
                                    $logService->log('ERROR', 'backgroundSearch', fe($x), $forumid);
                                    echo json_encode(array("success" => false, "msg" => "ERROR: Exception:" + var_log($x)));
                                    exit;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    echo json_encode(array("success" => true, "total" => 0, "posts" => 0));
}
Exemplo n.º 9
0
version : 1.0 
description : This class will allow manipulation of configuration content via an OO class. The current plan is 
to have a javascript 'Settings' tab which will use ajax to manipulate server XML (or other format). Each settings 
will trigger the appropriate PHP script. Only specific parameters can be passed into the configuration files, obv 
because they need to read specific character sequences or strings to function! Some settings will be configured by system 
events as well, esp. to avoid failures in execution. 


Dynamic configurations are included, such as the current display pattern (which is also stored in the session). Requests will be 
accepted by this class for certain information otherwise unavailable to javascript, but not including animations, speech, et
*/
@session_start();
@($q = htmlspecialchars(strip_tags($_POST['q'])));
switch ($q) {
    case 'getContext':
        getContext();
        break;
    case 'updateContext':
        updateContext($r, $s, $t);
}
function getContext()
{
    if ($_SESSION['username'] == null) {
        $_SESSION['mode'] == 'GEN';
    }
    if (!($_SESSION['username'] == null)) {
        //get the user's progress and mode
        //get the uiconfig associated with the mode
        // if these don't exist return 'INTRO'
    }
}
Exemplo n.º 10
0
 /**
 * This function calls the notebook editor so the user can modify the notebook
 * entry. Control is transfered to another page, namely, notebook_edit.php.
 * When that page is done, it will call pageReturn(), and control will return
 * to this class--display() will be called again to show the entry.
 *
 * This function gets called when the user clicks the link made by display()
 *
 * $arg contains the entry number of the notebook entry to edit. It was specified
 * by the call to makeEventURL() that occurs in display(), above.
 * $req is filled in with the usually info from the form submission, but
 * we don't need to use it for anything here.
 */
 function onFillGaps()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     if (isset($req['modelID'])) {
         $_SESSION['lastUsedModelID'] = $req['modelID'];
         // this is now the current model
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob'] = $req;
         mpLog("makekin:Filling fragments in: '{$req['modelID']}'");
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/fillfragments.php", "generic_done.php", 3);
     } else {
         $context = getContext();
         if (isset($req['modelID'])) {
             $context['modelID'] = $req['modelID'];
         }
         //if(isset($req['scriptName']))   $context['scriptName']  = $req['scriptName'];
         setContext($context);
     }
 }
Exemplo n.º 11
0
function getUrlContent($url)
{
    //    if(isset ($_SESSION["megavideoLinkCache"])) {
    //        $cache = unserialize($_SESSION["megavideoLinkCache"]);
    //    }else {
    //        $cache = array();
    //
    //    }
    //Get contents from internet, or rudimentary session cache
    $content = @file_get_contents($url);
    //echo $content;
    $_SESSION["megavideolinkLastReferer"] = $url;
    $url = explode(" ", $http_response_header[5]);
    if (strpos($http_response_header[0], "404") || strpos($http_response_header[0], "301")) {
        //        $content = $cache[$url];
        //    }else{
        //        $cache[$url] = $content;
        //        //Save cache to session
        //        $_SESSION["megavideoLinkCache"] = serialize($cache);
        $cookie = "Cookie: ";
        foreach ($_COOKIE as $key => $value) {
            $cookie = $cookie . $key . "=" . $value . "; ";
        }
        $content = @file_get_contents($url[1], false, getContext($cookie));
    }
    return $content;
}
{
    $title = trim($movie->find('div[class="right"] p[class="name"] a', 0)->plaintext);
    return $title;
}
function getMovieImageURL($movie)
{
    $url = trim($movie->find('div[class="left"] p', 0)->find('img', 0)->src);
    return sprintf("http://www.cinemasunshine.co.jp%s", $url);
}
function getContext()
{
    $opts = array('http' => array('method' => "GET", 'header' => "User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)"));
    return stream_context_create($opts);
}
require 'scraperwiki/simple_html_dom.php';
$html = file_get_html('http://www.cinemasunshine.co.jp/next_showing/?theaterSelect=2', false, getContext());
foreach ($html->find('div[class="movieListArea"]') as $movie) {
    $record = array('url' => getMovieURL($movie), 'openDay' => getMovieOpenDay($movie), 'title' => getMovieTitle($movie), 'imageUrl' => getMovieImageURL($movie));
    scraperwiki::save(array('url'), $record);
}
$html->__destruct();
function getMovieURL($movie)
{
    $url = trim($movie->find('div[class="right"] p[class="name"] a', 0)->href);
    return $url;
}
function getMovieOpenDay($movie)
{
    $day = $movie->find('div[class="right"] p[class="day"]', 0)->plaintext;
    preg_match('/^([0-9]{4}\\/[0-9]{1,2}\\/[0-9]{1,2}).*$/', $day, $matcher);
    return count($matcher) > 0 ? $matcher[1] : '';
Exemplo n.º 13
0
 /**
 * Documentation for this function.
 */
 function onChooseResidues()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     // Otherwise, moving forward:
     if (isset($req['modelID']) && isset($req['map'])) {
         $ctx['modelID'] = $req['modelID'];
         $ctx['map'] = $req['map'];
         pageGoto("sswing_setup2.php", $ctx);
     } else {
         $ctx = getContext();
         if (isset($req['modelID'])) {
             $ctx['modelID'] = $req['modelID'];
         }
         if (isset($req['map'])) {
             $ctx['map'] = $req['map'];
         }
         setContext($ctx);
     }
 }
Exemplo n.º 14
0
 /**
 * Documentation for this function.
 */
 function onAddH()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     // Otherwise, moving forward:
     if (isset($req['modelID']) && isset($req['method']) && isset($req['blength'])) {
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob']['modelID'] = $req['modelID'];
         $_SESSION['bgjob']['makeFlipkin'] = $req['makeFlipkin'];
         $_SESSION['bgjob']['nqh_regularize'] = $req['nqh_regularize'];
         $_SESSION['bgjob']['reduce_blength'] = $req['blength'];
         $_SESSION['reduce_blength'] = $_SESSION['bgjob']['reduce_blength'];
         if ($req['method'] == 'build') {
             if ($_SESSION['bgjob']['reduce_blength'] == 'ecloud') {
                 mpLog("reduce-build:User ran default Reduce -build job; flipkins=" . $_REQUEST['makeFlipkin']);
             } else {
                 mpLog("reduce-build:User ran default Reduce -build -nuclear job; flipkins=" . $_REQUEST['makeFlipkin']);
             }
             // launch background job
             pageGoto("job_progress.php");
             launchBackground(MP_BASE_DIR . "/jobs/reduce-build.php", "reduce_choose.php", 5);
         } elseif ($req['method'] == 'nobuild') {
             if ($_SESSION['bgjob']['reduce_blength'] == 'ecloud') {
                 mpLog("reduce-nobuild:User ran Reduce with -nobuild9999 flag");
             } else {
                 mpLog("reduce-nobuild:User ran Reduce with -nobuild9999 -nuclear flag");
             }
             // launch background job
             pageGoto("job_progress.php");
             launchBackground(MP_BASE_DIR . "/jobs/reduce-nobuild.php", "generic_done.php", 5);
         }
     } else {
         $context = getContext();
         if (isset($req['modelID'])) {
             $context['modelID'] = $req['modelID'];
         }
         if (isset($req['method'])) {
             $context['method'] = $req['method'];
         }
         if (isset($req['blength'])) {
             $context['blength'] = $req['blength'];
         }
         setContext($context);
     }
 }
Exemplo n.º 15
0
/** dispatch procedure **/
if ($_GET['id']) {
    include 'dbsetup.php';
    include 'util.php';
    display(synset(mysql_real_escape_string($_GET['id']), "", ""));
} else {
    if ($_GET['word'] && $_GET['pos']) {
        include 'dbsetup.php';
        include 'util.php';
        display(synset(false, mysql_real_escape_string($_GET['word']), mysql_real_escape_string($_GET['pos'])));
    } else {
        if ($_GET['words'] && $_GET['type'] == "context") {
            include 'dbsetup.php';
            include 'util.php';
            $words = decode($_GET['words']);
            $answer = getContext($words);
            display($answer);
        }
    }
}
function synset($id, $word, $pos)
{
    $query = "SELECT * from word where word = '" . $word . "' and pos = '" . $pos . "';";
    if ($id) {
        $query = "SELECT * from word where id = " . $id . ";";
    }
    $result = mysql_query($query);
    $row = array();
    $row2 = array();
    $answer = array();
    while ($row = mysql_fetch_array($result)) {
Exemplo n.º 16
0
function createIPv6Prefix($range = '', $name = '', $is_connected = FALSE, $taglist = array(), $vlan_ck = NULL)
{
    // $range is in aaa0:b::c:d/x format, split into ip/mask vars
    $rangeArray = explode('/', $range);
    if (count($rangeArray) != 2) {
        throw new InvalidRequestArgException('range', $range, 'Invalid IPv6 prefix');
    }
    $ip = $rangeArray[0];
    $mask = $rangeArray[1];
    $net = constructIPRange(ip6_parse($ip), $mask);
    usePreparedInsertBlade('IPv6Network', array('ip' => $net['ip_bin'], 'last_ip' => ip_last($net), 'mask' => $mask, 'name' => $name));
    $network_id = lastInsertID();
    # RFC3513 2.6.1 - Subnet-Router anycast
    if ($is_connected) {
        updateV6Address($net['ip_bin'], 'Subnet-Router anycast', 'yes');
    }
    produceTagsForNewRecord('ipv6net', $taglist, $network_id);
    if ($vlan_ck != NULL) {
        $ctx = getContext();
        fixContext(spotEntity('ipv6net', $network_id));
        if (permitted('ipv6net', '8021q', 'bind')) {
            commitSupplementVLANIPv6($vlan_ck, $network_id);
        }
        restoreContext($ctx);
    }
    return $network_id;
}
Exemplo n.º 17
0
 /**
 * Documentation for this function.
 */
 function onAddH()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     // Otherwise, moving forward:
     if (isset($req['ensID']) && isset($req['method']) && isset($req['blength'])) {
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob']['ensID'] = $req['ensID'];
         $_SESSION['bgjob']['method'] = $req['method'];
         $_SESSION['bgjob']['reduce_blength'] = $req['blength'];
         mpLog("reduce-ensemble:User ran default Reduce -{$req['method']} job on an ensemble");
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/ens_reduce.php", "generic_done.php", 5);
     } else {
         $context = getContext();
         if (isset($req['ensID'])) {
             $context['ensID'] = $req['ensID'];
         }
         if (isset($req['method'])) {
             $context['method'] = $req['method'];
         }
         if (isset($req['blength'])) {
             $context['blength'] = $req['blength'];
         }
         setContext($context);
     }
 }