Example #1
0
 /**
  * Saves an entry into the log table
  * @access public
  * @return boolean
  **/
 public function logData()
 {
     //If we decide to put the logged data into a table, then call $this->insert()
     if (!$this->query) {
         return false;
     }
     try {
         $f = fopen(Config::get('global.logPath'), 'at');
     } catch (Exception $e) {
         try {
             $f = fopen(Config::get('global.logPath'), 'wt');
         } catch (Exception $e) {
             throw new Exception('Error trying to access the log file', -1, $e);
         }
     }
     $date = date('Y-m-d H:i:s');
     $millis = DebugInfo::getRunningTimeInMillis();
     $line = "[{$this->query}]\t[{$this->queryBeforeRedirect}]\t{$this->searchType}\t{$this->registeredUser}\t{$this->skin}\t" . "{$this->preferences}\t{$this->resultCount}\t{$this->resultList}\t{$this->redirect}\t{$date}\t{$millis}\n";
     fwrite($f, $line);
     fclose($f);
 }
            if (!array_key_exists($word, $ifMap)) {
                cacheWordForm($word);
            }
            if (array_key_exists($word, $ifMap)) {
                $lexemList = preg_split('/,/', $ifMap[$word]);
                for ($i = 0; $i < count($lexemList); $i += 2) {
                    fwrite($handle, $lexemList[$i] . "\t" . $lexemList[$i + 1] . "\t" . $dbRow[0] . "\t" . $position . "\n");
                    $indexSize++;
                }
            } else {
                // print "Not found: $word\n";
            }
        }
    }
    if (++$defsSeen % 10000 == 0) {
        $runTime = DebugInfo::getRunningTimeInMillis() / 1000;
        $speed = round($defsSeen / $runTime);
        log_scriptLog("{$defsSeen} of {$numDefs} definitions indexed ({$speed} defs/sec). " . "Word map has " . count($ifMap) . " entries. " . "Memory used: " . round(memory_get_usage() / 1048576, 1) . " MB.");
    }
}
fclose($handle);
log_scriptLog("{$defsSeen} of {$numDefs} definitions indexed.");
log_scriptLog("Index size: {$indexSize} entries.");
OS::executeAndAssert("chmod 666 {$fileName}");
log_scriptLog("Importing file {$fileName} into table FullTextIndex");
db_executeFromOS("load data local infile '{$fileName}' into table FullTextIndex");
util_deleteFile($fileName);
if (!Lock::release(LOCK_FULL_TEXT_INDEX)) {
    log_scriptLog('WARNING: could not release lock!');
}
log_scriptLog('rebuildFullTextIndex.php completed successfully ' . '(against all odds)');