Esempio n. 1
0
 function __construct(parser $ParserObj)
 {
     switch ($ParserObj->GetType()) {
         case 'xml':
             $this->parser = new xmlParser($ParserObj->GetDataText());
             break;
         case 'json':
             die('not defined now');
             break;
     }
 }
Esempio n. 2
0
function tribe_getContent($caveID, $tribeID)
{
    global $db, $template;
    if (!$tribeID) {
        $template->throwError('Der Stamm wurde nicht gefunden.');
        return;
    }
    // open template
    $template->setFile('tribeDetail.tmpl');
    $template->setShowResource(false);
    $tribe = Tribe::getByID($tribeID);
    if ($tribe == null) {
        $template->throwError('Der Stamm wurde nicht gefunden.');
        return;
    }
    // parse tribe message
    $parser = new parser();
    $tribe['description'] = $parser->p($tribe['description']);
    $ranking = Tribe::getRanking($tribeID);
    $tribe['rank'] = $ranking;
    // leader
    if ($tribe['leaderID'] != 0) {
        $leader = Player::getPlayer($tribe['leaderID']);
        $tribe['leader_name'] = $leader->name;
    }
    $template->addVar('tribe_details', $tribe);
    // history
    $template->addVar('tribe_history', Tribe::getHistory($tribeID));
    // player list
    $template->addVar('tribe_player_list', Tribe::getPlayerList($tribeID, true, true));
    // relations
    $relations = TribeRelation::getRelations($tribeID);
    $relationsData = array();
    if (isset($relations['own'])) {
        foreach ($relations['own'] as $target => $relationData) {
            $relationsData[$target] = array('tribe' => $relationData['targetTag'], 'tribeID_target' => $relationData['tribeID_target'], 'relation_to' => $GLOBALS['relationList'][$relationData['relationType']]['name'], 'relation_from' => isset($relations['other'][$target]) && $relations['other'][$target] ? $GLOBALS['relationList'][$relations['other'][$target]['relationType']]['name'] : $GLOBALS['relationList'][0]['name']);
        }
    }
    if (isset($relations['other'])) {
        foreach ($relations['other'] as $target => $relationData) {
            // already printed out this relation
            if (isset($relationsData[$target])) {
                continue;
            }
            $relationsData[$target] = array('tribe' => $relationData['targetTag'], 'tribeID_target' => $relationData['tribeID_target'], 'relation_to' => $GLOBALS['relationList'][0]['name'], 'relation_from' => $GLOBALS['relationList'][$relationData['relationType']]['name']);
        }
    }
    $template->addVar('relations_data', $relationsData);
}
 public function __construct()
 {
     $this->lng = language::getinstance()->GetLngBlock('ownuniverse');
     foreach (DataEngine::a_ressources() as $v) {
         $this->ressourcesnames[$v['Field']] = $v['Nom'];
     }
     $this->BatimentsName = DataEngine::a_batiments();
     $this->parser = parser::getinstance();
 }
Esempio n. 4
0
 /**
  * Testing greater than compare of versions
  *
  * @return void
  **/
 public function testCompareVersionable()
 {
     $this->assertVersionBiggerThan('2.0.2', '0.0.4');
     $this->assertVersionBiggerThan('1.2.3', '1.2.2');
     $this->assertVersionBiggerThan('0.0.1', '0.0.0');
     // Check that versions that are equal are not bigger/smaller
     $this->assertFalse(Compare::greaterThan(parser::parse('4.0.0'), parser::parse('4.0.0')));
     $this->assertFalse(Compare::smallerThan(parser::parse('4.0.0'), parser::parse('4.0.0')));
 }
Esempio n. 5
0
 public function __construct($filename, $has_header = true, $row_size = 0, $delemiter = ',')
 {
     parent::__construct($filename);
     $this->setDelimiter($delemiter);
     $this->setRowSize($row_size);
     $this->row_counter = 0;
     //$this->header=($has_header)?fgetcsv($this->fh,$this->row_size,$this->delimiter):array();
     if ($has_header) {
         $this->header = array_map('trim', fgetcsv($this->fh, $this->row_size, $this->delimiter));
         $this->column_count = count($this->header);
     } else {
         $this->header = array();
         $this->column_count = 0;
     }
 }
Esempio n. 6
0
/**
 * @author Alex10336
 * Dernière modification: $Id$
 * @license GNU Public License 3.0 ( http://www.gnu.org/licenses/gpl-3.0.txt )
 * @license Creative Commons 3.0 BY-SA ( http://creativecommons.org/licenses/by-sa/3.0/deed.fr )
 * 
 **/
require_once './init.php';
require_once INCLUDE_PATH . 'Script.php';
require_once CLASS_PATH . 'parser.class.php';
Members::CheckPermsOrDie('PERSO');
$lng = language::getinstance()->GetLngBlock('personal');
if (isset($_POST['importation'])) {
    //    $data = file_get_contents('./test/data/mafiche_ff.txt');
    $data = gpc_esc($_POST['importation']);
    $parser = parser::getinstance();
    // simple détection...
    if (p_stripos($parser->GetValueByLabel($data, $lng['ident']), $_SESSION['_login'], 0) !== false) {
        $matrix = explode("\n", trim($data));
        $info = array();
        $info['GameGrade'] = trim($matrix[0]);
        $info['Race'] = $parser->GetValueByLabel($data, $lng['Race']);
        $info['Titre'] = $parser->GetValueByLabel($data, $lng['Titre']);
        $info['Commerce'] = $parser->GetValueByLabel($data, $lng['Commerce']);
        $info['Recherche'] = $parser->GetValueByLabel($data, $lng['Recherche']);
        $info['Combat'] = $parser->GetValueByLabel($data, $lng['Combat']);
        $info['Construction'] = $parser->GetValueByLabel($data, $lng['Construction']);
        $info['Economie'] = $parser->GetValueByLabel($data, $lng['Economie']);
        $info['Navigation'] = $parser->GetValueByLabel($data, $lng['Navigation']);
        $info['POINTS'] = DataEngine::strip_number($parser->GetValueByLabel($data, $lng['POINTS']));
        $info['pts_architecte'] = DataEngine::strip_number($parser->GetValueByLabel($data, $lng['pts_architecte']));
Esempio n. 7
0
 /**
  * @return parser
  */
 public static function getinstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
<?php

$parser = new parser();
$parser->run();
class parser
{
    /** @var string basename of senti files */
    protected $_basename = 'SentiWS_v1.8b';
    /** @var string directory where senti is stored */
    protected $_basedir = '../../ThirdParty/SentiWS_v1.8b/';
    /** @var string output sql file name */
    protected $_outputFile = '002_SentiWS_DATA_INSERT.sql';
    /** @var array parseable files (combined with $_basename) */
    protected $_inputFiles = array('_Negative.txt', '_Positive.txt');
    /** @var array $_typeMapping mapping to get full types */
    protected $_typeMapping = array('NN' => 'noun', 'ADJX' => 'adjective', 'ADV' => 'adverb', 'VVINF' => 'verb');
    /** @var file pointer for outputfile */
    protected $_outputHandle;
    /**
     * Run method for this parser
     * @return void
     */
    public function run()
    {
        $this->_outputHandle = @fopen(realpath(__DIR__) . '/' . $this->_outputFile, "a");
        //attach mode
        foreach ($this->_inputFiles as $inFile) {
            echo "Proceed file: " . $this->_basename . $inFile . PHP_EOL;
            $handler = @fopen(realpath(__DIR__ . '/' . $this->_basedir) . '/' . $this->_basename . $inFile, "r");
            $this->textToSQL($handler);
        }
Esempio n. 9
0
 function process_edits($editor, $actions, $details, $change = false, $display = true, $reverse = false)
 {
     global $template, $user, $db, $phpbb_root_path, $force_install, $mod_installed;
     global $dest_inherits, $dest_template, $children, $config;
     $mod_installed = true;
     if ($reverse) {
         global $rev_actions;
         if (empty($rev_actions)) {
             // maybe should allow for potential extensions here
             $actions = parser::reverse_edits($actions);
         } else {
             $actions = $rev_actions;
             unset($rev_actions);
         }
     }
     $template->assign_vars(array('S_DISPLAY_DETAILS' => (bool) $display, 'S_CHANGE_FILES' => (bool) $change));
     if (!empty($details['PHPBB_VERSION']) && $details['PHPBB_VERSION'] != $config['version']) {
         $version_warnig = sprintf($user->lang['VERSION_WARNING'], $details['PHPBB_VERSION'], $config['version']);
         $template->assign_vars(array('VERSION_WARNING' => $version_warnig, 'S_PHPBB_VESION' => true));
     }
     if (!empty($details['AUTHOR_NOTES']) && $details['AUTHOR_NOTES'] != $user->lang['UNKNOWN_MOD_AUTHOR-NOTES']) {
         $template->assign_vars(array('S_AUTHOR_NOTES' => true, 'AUTHOR_NOTES' => nl2br($details['AUTHOR_NOTES'])));
     }
     // not all MODs will have edits (!)
     if (isset($actions['EDITS'])) {
         $template->assign_var('S_EDITS', true);
         foreach ($actions['EDITS'] as $filename => $edits) {
             // see if the file to be opened actually exists
             if (!file_exists("{$phpbb_root_path}{$filename}")) {
                 $is_inherit = strpos($filename, 'styles/') !== false && !empty($dest_inherits) ? true : false;
                 $template->assign_block_vars('edit_files', array('S_MISSING_FILE' => $is_inherit ? false : true, 'INHERIT_MSG' => $is_inherit ? sprintf($user->lang['INHERIT_NO_CHANGE'], $dest_template, $dest_inherits) : '', 'FILENAME' => $filename));
                 $mod_installed = $is_inherit ? $mod_installed : false;
                 continue;
             } else {
                 $template->assign_block_vars('edit_files', array('S_SUCCESS' => false, 'FILENAME' => $filename));
                 // If installing - not pre_install nor (pre_)uninstall, backup the file
                 // This is to make sure it works with editor_ftp because write_method is
                 // forced to direct when in preview modes, and ignored in editor_manual!
                 if ($change && !$reverse) {
                     $status = $editor->open_file($filename, $this->backup_root);
                 } else {
                     $status = $editor->open_file($filename);
                 }
                 if (is_string($status)) {
                     $template->assign_block_vars('error', array('ERROR' => $status));
                     $mod_installed = false;
                     continue;
                 }
                 $edit_success = true;
                 foreach ($edits as $finds) {
                     $comment = '';
                     foreach ($finds as $find => $commands) {
                         if (isset($finds['comment']) && !$comment && $finds['comment'] != $user->lang['UNKNOWN_MOD_COMMENT']) {
                             $comment = $finds['comment'];
                             unset($finds['comment']);
                         }
                         if ($find == 'comment') {
                             continue;
                         }
                         $find_tpl = array('FIND_STRING' => htmlspecialchars($find), 'COMMENT' => htmlspecialchars($comment));
                         $offset_ary = $editor->find($find);
                         // special case for FINDs with no action associated
                         if (is_null($commands)) {
                             continue;
                         }
                         foreach ($commands as $type => $contents) {
                             if (!$offset_ary) {
                                 $offset_ary['start'] = $offset_ary['end'] = false;
                             }
                             $status = false;
                             $inline_template_ary = array();
                             $contents_orig = $contents;
                             switch (strtoupper($type)) {
                                 case 'AFTER ADD':
                                     $status = $editor->add_string($find, $contents, 'AFTER', $offset_ary['start'], $offset_ary['end']);
                                     break;
                                 case 'BEFORE ADD':
                                     $status = $editor->add_string($find, $contents, 'BEFORE', $offset_ary['start'], $offset_ary['end']);
                                     break;
                                 case 'INCREMENT':
                                 case 'OPERATION':
                                     //$contents = "";
                                     $status = $editor->inc_string($find, '', $contents);
                                     break;
                                 case 'REPLACE WITH':
                                     $status = $editor->replace_string($find, $contents, $offset_ary['start'], $offset_ary['end']);
                                     break;
                                 case 'IN-LINE-EDIT':
                                     // these aren't quite as straight forward.  Still have multi-level arrays to sort through
                                     $inline_comment = '';
                                     foreach ($contents as $inline_edit_id => $inline_edit) {
                                         if ($inline_edit_id === 'inline-comment') {
                                             // This is a special case for tucking comments in the array
                                             if ($inline_edit != $user->lang['UNKNOWN_MOD_INLINE-COMMENT']) {
                                                 $inline_comment = $inline_edit;
                                             }
                                             continue;
                                         }
                                         foreach ($inline_edit as $inline_find => $inline_commands) {
                                             foreach ($inline_commands as $inline_action => $inline_contents) {
                                                 // inline finds are pretty cantankerous, so do them in the loop
                                                 $line = $editor->inline_find($find, $inline_find, $offset_ary['start'], $offset_ary['end']);
                                                 if (!$line) {
                                                     // find failed
                                                     $status = $mod_installed = false;
                                                     $inline_template_ary[] = array('FIND' => array('S_SUCCESS' => $status, 'NAME' => $user->lang[$type], 'COMMAND' => htmlspecialchars($inline_find)), 'ACTION' => array());
                                                     continue 2;
                                                 }
                                                 $inline_contents = $inline_contents[0];
                                                 $contents_orig = $inline_find;
                                                 switch (strtoupper($inline_action)) {
                                                     case 'IN-LINE-':
                                                         $editor->last_string_offset = $line['string_offset'] + $line['find_length'] - 1;
                                                         $status = true;
                                                         continue 2;
                                                         break;
                                                     case 'IN-LINE-BEFORE-ADD':
                                                         $status = $editor->inline_add($find, $inline_find, $inline_contents, 'BEFORE', $line['array_offset'], $line['string_offset'], $line['find_length']);
                                                         break;
                                                     case 'IN-LINE-AFTER-ADD':
                                                         $status = $editor->inline_add($find, $inline_find, $inline_contents, 'AFTER', $line['array_offset'], $line['string_offset'], $line['find_length']);
                                                         break;
                                                     case 'IN-LINE-REPLACE':
                                                     case 'IN-LINE-REPLACE-WITH':
                                                         $status = $editor->inline_replace($find, $inline_find, $inline_contents, $line['array_offset'], $line['string_offset'], $line['find_length']);
                                                         break;
                                                     case 'IN-LINE-OPERATION':
                                                         $status = $editor->inc_string($find, $inline_find, $inline_contents);
                                                         break;
                                                     default:
                                                         $message = sprintf($user->lang['UNRECOGNISED_COMMAND'], $inline_action);
                                                         trigger_error($message, E_USER_WARNING);
                                                         // ERROR!
                                                         break;
                                                 }
                                                 $inline_template_ary[] = array('FIND' => array('S_SUCCESS' => $status, 'NAME' => $user->lang[$type], 'COMMAND' => is_array($contents_orig) ? $user->lang['INVALID_MOD_INSTRUCTION'] : htmlspecialchars($contents_orig)), 'ACTION' => array('S_SUCCESS' => $status, 'NAME' => $user->lang[$inline_action], 'COMMAND' => is_array($inline_contents) ? $user->lang['INVALID_MOD_INSTRUCTION'] : htmlspecialchars($inline_contents)));
                                             }
                                             if (!$status) {
                                                 $mod_installed = false;
                                             }
                                             $editor->close_inline_edit();
                                         }
                                     }
                                     break;
                                 default:
                                     $message = sprintf($user->lang['UNRECOGNISED_COMMAND'], $type);
                                     trigger_error($message, E_USER_WARNING);
                                     // ERROR!
                                     break;
                             }
                             $template->assign_block_vars('edit_files.finds', array_merge($find_tpl, array('S_SUCCESS' => $status)));
                             if (!$status) {
                                 $edit_success = false;
                                 $mod_installed = false;
                             }
                             if (sizeof($inline_template_ary)) {
                                 foreach ($inline_template_ary as $inline_template) {
                                     // We must assign the vars for the FIND first
                                     $template->assign_block_vars('edit_files.finds.actions', $inline_template['FIND']);
                                     // And now the vars for the ACTION
                                     $template->assign_block_vars('edit_files.finds.actions.inline', $inline_template['ACTION']);
                                 }
                                 $inline_template_ary = array();
                             } else {
                                 if (!is_array($contents_orig)) {
                                     $template->assign_block_vars('edit_files.finds.actions', array('S_SUCCESS' => $status, 'NAME' => $user->lang[$type], 'COMMAND' => htmlspecialchars($contents_orig)));
                                 }
                             }
                         }
                     }
                     $editor->close_edit();
                 }
                 $template->alter_block_array('edit_files', array('S_SUCCESS' => $edit_success), true, 'change');
             }
             if ($change) {
                 $status = $editor->close_file("{$this->edited_root}{$filename}");
                 if (is_string($status)) {
                     $template->assign_block_vars('error', array('ERROR' => $status));
                     $mod_installed = false;
                 }
             }
         }
     }
     // end foreach
     // Move included files
     if (isset($actions['NEW_FILES']) && !empty($actions['NEW_FILES'])) {
         $template->assign_var('S_NEW_FILES', true);
         // Because foreach operates on a copy of the specified array and not the array itself,
         // we cannot rely on the array pointer while using it, so we use a while loop w/ each()
         // We need array pointer to rewind the loop when is_array($target) (See Ticket #62341)
         while (list($source, $target) = each($actions['NEW_FILES'])) {
             if (is_array($target)) {
                 // If we've shifted off all targets, we're done w/ that element
                 if (empty($target)) {
                     continue;
                 }
                 // Shift off first target, then rewind array pointer to get next target
                 $target = array_shift($actions['NEW_FILES'][$source]);
                 prev($actions['NEW_FILES']);
             }
             if ($change && ($mod_installed || $force_install)) {
                 $status = $editor->copy_content($this->mod_root . str_replace('*.*', '', $source), str_replace('*.*', '', $target));
                 if ($status !== true && !is_null($status)) {
                     $mod_installed = false;
                 }
                 $template->assign_block_vars('new_files', array('S_SUCCESS' => $status === true ? true : false, 'S_NO_COPY_ATTEMPT' => is_null($status) ? true : false, 'SOURCE' => $source, 'TARGET' => $target));
             } else {
                 if ($display && !$change) {
                     $template->assign_block_vars('new_files', array('SOURCE' => $source, 'TARGET' => $target));
                 } else {
                     if ($change && $display && !$mod_installed && !$force_install) {
                         $template->assign_block_vars('new_files', array('S_NO_COPY_ATTEMPT' => true, 'FILENAME' => $target));
                     }
                 }
             }
         }
     }
     // Delete (or reverse-delete) installed files
     if (!empty($actions['DELETE_FILES'])) {
         $template->assign_var('S_REMOVING_FILES', true);
         // Dealing with a reverse-delete, must heed to the dangers ahead!
         if ($reverse) {
             $directories = array();
             $directories['src'] = array();
             $directories['dst'] = array();
             $directories['del'] = array();
             // Because foreach operates on a copy of the specified array and not the array itself,
             // we cannot rely on the array pointer while using it, so we use a while loop w/ each()
             // We need array pointer to rewind the loop when is_array($target) (See Ticket #62341)
             while (list($source, $target) = each($actions['DELETE_FILES'])) {
                 if (is_array($target)) {
                     // If we've shifted off all targets, we're done w/ that element
                     if (empty($target)) {
                         continue;
                     }
                     // Shift off first target, then rewind array pointer to get next target
                     $target = array_shift($actions['DELETE_FILES'][$source]);
                     prev($actions['DELETE_FILES']);
                 }
                 // Some MODs include 'umil/', avoid deleting!
                 if (strpos($target, 'umil/') === 0) {
                     unset($actions['DELETE_FILES'][$source]);
                     continue;
                 } else {
                     if (strpos($source, '*.*') !== false) {
                         // This could be phpbb_root_path, if "Copy: root/*.* to: *.*" syntax was used
                         // or root/custom_dir if "Copy: root/custom/*.* to: custom/*.*", etc.
                         $source = $this->mod_root . str_replace('*.*', '', $source);
                         $target = str_replace('*.*', '', $target);
                         // Get all of the files in the source directory
                         $files = find_files($source, '.*');
                         // And translate into destination files
                         $files = str_replace($source, $target, $files);
                         // Get all of the sub-directories in the source directory
                         $directories['src'] = find_files($source, '.*', 20, true);
                         // And translate it into destination sub-directories
                         $directories['dst'] = str_replace($source, $target, $directories['src']);
                         // Compare source and destination subdirs, if any, in _reverse_ order! (array_pop)
                         for ($i = 0, $cnt = count($directories['dst']); $i < $cnt; $i++) {
                             $dir_source = array_pop($directories['src']);
                             $dir_target = array_pop($directories['dst']);
                             // Some MODs include 'umil/', avoid deleting!
                             if (strpos($dir_target, 'umil/') === 0) {
                                 continue;
                             }
                             $src_file_cnt = directory_num_files($dir_source, false, true);
                             $dst_file_cnt = directory_num_files($phpbb_root_path . $dir_target, false, true);
                             $src_dir_cnt = directory_num_files($dir_source, true, true);
                             $dst_dir_cnt = directory_num_files($phpbb_root_path . $dir_target, true, true);
                             // Do we have a match in recursive file count and match in recursive subdir count?
                             // This could be vastly improved..
                             if ($src_file_cnt == $dst_file_cnt && $src_dir_cnt == $dst_dir_cnt) {
                                 $directories['del'][] = $dir_target;
                             }
                             unset($dir_source, $dir_target, $src_file_cnt, $dst_file_cnt, $src_dir_cnt, $dst_dir_cnt);
                             //cleanup
                         }
                         foreach ($files as $file) {
                             // Some MODs include 'umil/', avoid deleting!
                             if (strpos($file, 'umil/') === 0) {
                                 continue;
                             } else {
                                 if (!file_exists($phpbb_root_path . $file) && ($change || $display)) {
                                     $template->assign_block_vars('removing_files', array('S_MISSING_FILE' => true, 'S_NO_DELETE_ATTEMPT' => true, 'FILENAME' => $file));
                                 } else {
                                     if ($change && ($mod_installed || $force_install)) {
                                         $status = $editor->remove($file);
                                         $template->assign_block_vars('removing_files', array('S_SUCCESS' => $status === true ? true : false, 'S_NO_DELETE_ATTEMPT' => is_null($status) ? true : false, 'FILENAME' => $file));
                                     } else {
                                         if ($display && !$change) {
                                             $template->assign_block_vars('removing_files', array('FILENAME' => $file));
                                         } else {
                                             if ($change && $display && !$mod_installed && !$force_install) {
                                                 $template->assign_block_vars('removing_files', array('S_NO_DELETE_ATTEMPT' => true, 'FILENAME' => $file));
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         unset($files);
                         //cleanup
                     } else {
                         if (!file_exists($phpbb_root_path . $target) && ($change || $display)) {
                             $template->assign_block_vars('removing_files', array('S_MISSING_FILE' => true, 'S_NO_DELETE_ATTEMPT' => true, 'FILENAME' => $target));
                         } else {
                             if ($change && ($mod_installed || $force_install)) {
                                 $status = $editor->remove($target);
                                 $template->assign_block_vars('removing_files', array('S_SUCCESS' => $status === true ? true : false, 'S_NO_DELETE_ATTEMPT' => is_null($status) ? true : false, 'FILENAME' => $target));
                             } else {
                                 if ($display && !$change) {
                                     $template->assign_block_vars('removing_files', array('FILENAME' => $target));
                                 } else {
                                     if ($change && $display && !$mod_installed && !$force_install) {
                                         $template->assign_block_vars('removing_files', array('S_NO_DELETE_ATTEMPT' => true, 'FILENAME' => $target));
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             // Delete wildcard directories, if any, which should now be empty anyway (no recursive delete needed)
             if ($cnt = count($directories['del'])) {
                 for ($i = 0; $i < $cnt; $i++) {
                     if ($change && ($mod_installed || $force_install)) {
                         $status = $editor->remove($directories['del'][$i]);
                         $template->assign_block_vars('removing_files', array('S_SUCCESS' => $status === true ? true : false, 'S_NO_DELETE_ATTEMPT' => is_null($status) ? true : false, 'FILENAME' => $directories['del'][$i]));
                     } else {
                         if ($display && !$change) {
                             $template->assign_block_vars('removing_files', array('FILENAME' => $directories['del'][$i]));
                         } else {
                             if ($change && $display && !$mod_installed && !$force_install) {
                                 $template->assign_block_vars('removing_files', array('S_NO_DELETE_ATTEMPT' => true, 'FILENAME' => $directories['del'][$i]));
                             }
                         }
                     }
                 }
                 unset($directories['del']);
                 //cleanup
             }
         } else {
             if ($mod_installed || $force_install) {
                 foreach ($actions['DELETE_FILES'] as $file) {
                     $wildcards = strpos($file, '*.*');
                     $file = str_replace('*.*', '', $file);
                     if (!file_exists($phpbb_root_path . $file) && ($change || $display)) {
                         $template->assign_block_vars('removing_files', array('S_MISSING_FILE' => true, 'S_NO_DELETE_ATTEMPT' => true, 'FILENAME' => $file));
                     } else {
                         if ($wildcards || is_file($phpbb_root_path . $file)) {
                             if ($change) {
                                 // Delete, recursively if needed
                                 $status = $editor->remove($file, true);
                                 $template->assign_block_vars('removing_files', array('S_SUCCESS' => $status === true ? true : false, 'S_NO_DELETE_ATTEMPT' => is_null($status) ? true : false, 'FILENAME' => $file));
                             } else {
                                 if ($display) {
                                     $template->assign_block_vars('removing_files', array('FILENAME' => $file));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Perform SQL queries last -- Queries usually cannot be done a second
     // time, so do them only if the edits were successful.  Still complies
     // with the MODX spec in this location
     if (!empty($actions['SQL']) && ($mod_installed || $force_install || $display && !$change)) {
         $template->assign_var('S_SQL', true);
         parser::parse_sql($actions['SQL']);
         $db->sql_return_on_error(true);
         foreach ($actions['SQL'] as $query) {
             if ($change) {
                 $query_success = $db->sql_query($query);
                 if ($query_success) {
                     $template->assign_block_vars('sql_queries', array('S_SUCCESS' => true, 'QUERY' => $query));
                 } else {
                     $error = $db->sql_error();
                     $template->assign_block_vars('sql_queries', array('S_SUCCESS' => false, 'QUERY' => $query, 'ERROR_MSG' => $error['message'], 'ERROR_CODE' => $error['code']));
                     $mod_installed = false;
                 }
             } else {
                 if ($display) {
                     $template->assign_block_vars('sql_queries', array('QUERY' => $query));
                 }
             }
         }
         $db->sql_return_on_error(false);
     } else {
         $template->assign_var('S_SQL', false);
     }
     return $mod_installed;
 }
Esempio n. 10
0
<?
include_once 'parser.php';
$parser = new parser();
$parser->parseNews();
?>
Esempio n. 11
0
 /**
  * Public function parseContent
  * @param $array is the array of values you want to place into separate bins.
  * @operates by comparing against a static set of bins
  * TODO: Add a dynamic binninng system that will allow the computer to grow its number of bins based upon what data it collects.
  * TODO: Currently all items not binned get deleted, ideally they should be tagged with the ID of Links and separated.
  * @return an ARRAY containing all the binned values in the form of array(array(binned_value, category), array(binned_value, ...)...)
  */
 public static function parseContent($array)
 {
     $sportsArray = array("badminton", "baseball", "basketball", "bowling", "boxing", "cross country", "fencing", "field hockey", "football", "golf", "gymnastics", "ice hockey", "track", "lacrosse", "rifle", "rowing", "skiing", "soccer", "softball", "swimming", "diving", "tennis", "volleyball", "water polo", "wrestling");
     $greekClubsArray = array("alpha", "beta", "delta", "zeta", "theta", "kaapa", "sigma", "tau", "omega");
     $proffessionTags = array("professor", "doctor");
     $researchArray = array("research", "laboratory", "institute", "institution");
     $artsArray = array("orchestra", "music", "harmonics", "visual arts", "a cappella");
     $completeArray = array_merge($sportsArray, $greekClubsArray, $proffessionTags, $artsArray);
     //	print_r($completeArray);
     $filteredArray = array();
     $linksArray = array();
     //	print_r(count($array));
     //	print_r(count($completeArray));
     for ($i = 0; $i < count($array); $i++) {
         for ($j = 0; $j < count($completeArray); $j++) {
             $subString = stristr($array[$i], $completeArray[$j]);
             if ($subString !== false) {
                 $filteredArray[] = $array[$i];
                 break;
             } else {
                 $linksArray[] = $array[$i];
             }
         }
     }
     //checkpoint: the $filteredArray should have an array of all the valid values; Next step is to parse them into categories...
     //	print_r($filteredArray);
     $finalArray = array();
     for ($i = 0; $i < count($filteredArray); $i++) {
         if (parser::findStringInArray($filteredArray[$i], $sportsArray)) {
             $finalArray[] = array($filteredArray[$i], "sports");
         }
         if (parser::findStringInArray($filteredArray[$i], $proffessionTags)) {
             $finalArray[] = array($filteredArray[$i], "professor");
         }
         if (parser::findStringInArray($filteredArray[$i], $greekClubsArray)) {
             $finalArray[] = array($filteredArray[$i], "clubs");
         }
         if (parser::findStringInArray($filteredArray[$i], $researchArray)) {
             $finalArray[] = array($filteredArray[$i], "research");
         }
         if (parser::findStringInArray($filteredArray[$i], $artsArray)) {
             $finalArray[] = array($filteredArray[$i], "arts");
         }
     }
     return $finalArray;
 }
Esempio n. 12
0
 function parse($symbol, $lex, $strategy = null)
 {
     return parent::parse($symbol, $lex, $this->strategy);
 }
Esempio n. 13
0
<?
/*
	TODO: still need to settle on what the frontend will recieve from the aparser class.
*/

//import depedencies
require_once("../../../../private/mysql_connect_monstars.php");
require_once('parser.php');

//retrieve url vars !!!!!!!!!!!CHANGE TO POST AFTER TESTING
$user   = $_GET['user'];  //user
$enemy  = $_GET['enemy']; //enemy
$type   = $_GET['type'];

$parser	   = new parser();
$json_user = $parser->init($user, $type);

if($enemy) $json_matchup  = $parser->init_compare($user, $enemy, $type);

echo json_encode(array_merge($json_user, $json_matchup));

?>
Esempio n. 14
0
 /**
  * Loop through all the post phrases and return them in json formatted script
  * @param int $postID
  */
 function get_post_phrases($postID)
 {
     // Some security, to avoid others from seeing private posts
     // fake post for tags
     if ($postID == -555) {
         $phrases = $this->get_tags();
         $title = "tags";
     } else {
         if (!current_user_can('edit_post', $postID)) {
             return;
         }
         global $post;
         // thid is needed because some of the functions below expect it...
         $post = get_post($postID);
         // Display filters
         $title = apply_filters('the_title', $post->post_title);
         $content = apply_filters('the_content', $post->post_content);
         $the_content_feed = apply_filters('the_content_feed', $content);
         $excerpt = apply_filters('get_the_excerpt', $post->post_excerpt);
         $excerpt_rss = apply_filters('the_excerpt_rss', $excerpt);
         //TODO - get comments text
         $parser = new parser();
         $phrases = $parser->get_phrases_list($content);
         $phrases2 = $parser->get_phrases_list($title);
         $phrases3 = $parser->get_phrases_list($the_content_feed);
         $phrases4 = $parser->get_phrases_list($excerpt);
         $phrases5 = $parser->get_phrases_list($excerpt_rss);
         // Merge the two arrays for traversing
         $phrases = array_merge($phrases, $phrases2, $phrases3, $phrases4, $phrases5);
         tp_logger($phrases, 4);
         // Add phrases from permalink
         if ($this->transposh->options->enable_url_translate) {
             $permalink = get_permalink($postID);
             $permalink = substr($permalink, strlen($this->transposh->home_url) + 1);
             $parts = explode('/', $permalink);
             foreach ($parts as $part) {
                 if (!$part || is_numeric($part)) {
                     continue;
                 }
                 $part = str_replace('-', ' ', $part);
                 $phrases[] = urldecode($part);
             }
         }
     }
     // We provide the post title here
     $json['posttitle'] = $title;
     // and all languages we might want to target
     $json['langs'] = array();
     foreach ($phrases as $key) {
         foreach (explode(',', $this->transposh->options->viewable_languages) as $lang) {
             // if this isn't the default language or we specifically allow default language translation, we will seek this out...
             // as we don't normally want to auto-translate the default language -FIX THIS to include only correct stuff, how?
             if (!$this->transposh->options->is_default_language($lang) || $this->transposh->options->enable_default_translate) {
                 // There is no point in returning phrases, languages pairs that cannot be translated
                 if (in_array($lang, transposh_consts::$bing_languages) || in_array($lang, transposh_consts::$google_languages) || in_array($lang, transposh_consts::$apertium_languages)) {
                     list($source, $translation) = $this->transposh->database->fetch_translation($key, $lang);
                     if (!$translation) {
                         // p stands for phrases, l stands for languages, t is token
                         if (!@is_array($json['p'][$key]['l'])) {
                             $json['p'][$key]['l'] = array();
                         }
                         array_push($json['p'][$key]['l'], $lang);
                         if (!in_array($lang, $json['langs'])) {
                             array_push($json['langs'], $lang);
                         }
                     }
                 }
             }
         }
         // only if a languages list was created we'll need to translate this
         if (@is_array($json['p'][$key]['l'])) {
             $json['p'][$key]['t'] = transposh_utils::base64_url_encode($key);
             @$json['length']++;
         }
     }
     // the header helps with debugging
     header("Content-type: text/javascript");
     echo json_encode($json);
 }
Esempio n. 15
0
 /**
     Expects a filename to the simple config.
     @param string $file Path to file.
     @return object.
     **/
 public function __construct($file)
 {
     $result = parser::parseSimpleTemplate($file);
     parent::__construct($file, $result[0], $result[1]);
 }
Esempio n. 16
0
 /**
  * Called when the buffer containing the original page is flushed. Triggers the translation process.
  * @param string $buffer Original page
  * @return string Modified page buffer
  */
 function process_page(&$buffer)
 {
     /*        if (!$this->target_language) {
               global $wp;
               $this->on_parse_request($wp);
               } */
     tp_logger('processing page hit with language:' . $this->target_language, 1);
     $start_time = microtime(TRUE);
     // Refrain from touching the administrative interface and important pages
     if ($this->is_special_page($_SERVER['REQUEST_URI'])) {
         tp_logger("Skipping translation for admin pages", 3);
     } elseif ($this->target_language == '') {
         tp_logger("Skipping translation where target language is unset", 3);
         if (!$buffer) {
             tp_logger("seems like we had a premature flushing");
             $this->tried_buffer = true;
         }
     } elseif ($this->options->is_default_language($this->target_language) && !$this->options->enable_default_translate) {
         tp_logger("Skipping translation for default language {$this->target_language}", 3);
     } else {
         // This one allows to redirect to a static element which we can find, since the redirection will remove
         // the target language, we are able to avoid nasty redirection loops
         if (is_404()) {
             global $wp;
             if (isset($wp->query_vars['pagename']) && file_exists(ABSPATH . $wp->query_vars['pagename'])) {
                 // Hmm
                 tp_logger('Redirecting a static file ' . $wp->query_vars['pagename'], 1);
                 $this->tp_redirect('/' . $wp->query_vars['pagename'], 301);
             }
         }
         tp_logger("Translating {$_SERVER['REQUEST_URI']} to: {$this->target_language}", 1);
         //translate the entire page
         $parse = new parser();
         $parse->fetch_translate_func = array(&$this->database, 'fetch_translation');
         $parse->prefetch_translate_func = array(&$this->database, 'prefetch_translations');
         $parse->url_rewrite_func = array(&$this, 'rewrite_url');
         $parse->split_url_func = array(&$this, 'split_url');
         $parse->dir_rtl = in_array($this->target_language, transposh_consts::$rtl_languages);
         $parse->lang = $this->target_language;
         $parse->default_lang = $this->options->is_default_language($this->target_language);
         $parse->is_edit_mode = $this->edit_mode;
         $parse->might_json = $this->attempt_json;
         $parse->is_auto_translate = $this->is_auto_translate_permitted();
         // TODO - check this!
         if (stripos($_SERVER['REQUEST_URI'], '/feed/') !== FALSE) {
             tp_logger("in rss feed!", 2);
             $parse->is_auto_translate = false;
             $parse->is_edit_mode = false;
             $parse->feed_fix = true;
         }
         $parse->change_parsing_rules(!$this->options->parser_dont_break_puncts, !$this->options->parser_dont_break_numbers, !$this->options->parser_dont_break_entities);
         $buffer = $parse->fix_html($buffer);
         $end_time = microtime(TRUE);
         tp_logger('Translation completed in ' . ($end_time - $start_time) . ' seconds', 1);
     }
     return $buffer;
 }
Esempio n. 17
0
    // And exit
    exit;
}
// Do we want to parse the file?
if ($fetch->parseType) {
    /*****************************************************************
     * Apply the relevant parsing methods to the document
     ******************************************************************/
    // Apply preparsing from plugins
    if ($foundPlugin && function_exists('preParse')) {
        $document = preParse($document, $fetch->parseType);
    }
    // Load the main parser
    require GLYPE_ROOT . '/includes/parser.php';
    // Create new instance, passing in the options that affect parsing
    $parser = new parser($options, $jsFlags);
    // Method of parsing depends on $parseType
    switch ($fetch->parseType) {
        // HTML document
        case 'html':
            // Do we want to insert our own code into the document?
            $inject = $footer = $insert = false;
            // Mini-form only if NOT frame or sniffed
            if ($flag != 'frame' && $fetch->sniff == false) {
                // Showing the mini-form?
                if ($options['showForm']) {
                    $toShow = array();
                    // Prepare the options
                    foreach ($CONFIG['options'] as $name => $details) {
                        // Ignore if forced
                        if (!empty($details['force'])) {
Esempio n. 18
0
// Quick response for empty blazon
if ($options['blazon'] == '') {
    // TODO "your shield here" message?
    header('Content-Type: text/xml; charset=utf-8');
    $output = '<?xml version="1.0" encoding="utf-8" ?><svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" height="' . $options['size'] * 1.2 . '" width="' . $options['size'] . '" viewBox="0 0 1000 1200" >
    <g clip-path="url(#clipPath1)"><desc>argent</desc><g><title>Shield</title><g fill="#F0F0F0">
    <rect x="0" y="0" width="1000" height="1200" ><title>Field</title></rect></g></g></g>
    <defs><clipPath id="clipPath1" > <path d="M 0 0 L 0 800 A 800 400 0 0,0 500 1200 A 800 400 0 0,0 1000 800 L 1000 0 Z" /> </clipPath></defs>
    <text x="10" y="1160" font-size="30" >' . $version['name'] . ' ' . $version['release'] . '</text><text x="10" y="1190" font-size="30" >' . $version['website'] . '</text></svg>';
} else {
    // Otherwise log the blazon for research... (unless told not too)
    if ($options['logBlazon']) {
        error_log($options['blazon']);
    }
    include "parser/parser.inc";
    $p = new parser('english');
    $dom = $p->parse($options['blazon'], 'dom');
    $p = null;
    // destroy parser
    // Resolve references
    if ($options['stage'] == 'parser') {
        echo $dom->saveXML();
        exit;
    }
    include "analyser/references.inc";
    $references = new references($dom);
    $dom = $references->setReferences();
    $references = null;
    // destroy references
    if ($options['stage'] == 'references') {
        echo $dom->saveXML();
Esempio n. 19
0
<?php
require_once 'parser.php';

$output = '';

if($_POST) {
    $parser = new parser();
    $parser->run($_POST['text']);
    $output = $parser->getJSONOutput();
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta content="text/html; charset=UTF-8" http-equiv="content-type">
        <script type="text/javascript" src="js/awesomechart.js"></script>
        <style>

            body{
                background: #fff;
                color: #333;
            }

            a, a:visited, a:link, a:active{
                color: #333;
            }

            a:hover{
                color: #00f;
            }
Esempio n. 20
0
 public static function parse()
 {
     if (!file_exists(self::$filename) && $check) {
         core::alog('ERROR: ' . self::$filename . ' cannot be found.', 'BASIC');
         core::save_logs();
         // force a log save
     }
     // check if it exists
     $lines = file(self::$filename);
     // open the file
     foreach ($lines as $num => $line) {
         $line = trim($line);
         if (substr($line, -1) == ';') {
             $line = substr($line, 0, -1);
         }
         $line = preg_replace('/\\s+/', ' ', $line);
         // clear the crap out of it.
         if (self::check_comment($line) == 'open') {
             self::$comment_opened = true;
         }
         if (self::check_comment($line) == 'close') {
             self::$comment_opened = false;
         }
         if (self::check_comment($line) == 'comment') {
             continue;
         }
         if ($line == '{' || self::$comment_opened) {
             continue;
         }
         // skip it if it's just {
         // or, a multiline comment is open
         if ($line == '}') {
             self::$sub_open = false;
             self::$opened = false;
             self::$opened_dir = '';
             self::$opened_sub = '';
             continue;
         }
         // stop parsing the data for that dir
         // once we've hit };
         if (trim($lines[$num + 1]) == '{' || substr($line, -1) == '{') {
             $rvar = explode(' ', $line);
             $var = trim($rvar[0]);
             // grab the variable, eg. uplink, server. etc
             preg_match("/\"(.*)\"/", $line, $matches);
             $sub_var = isset($matches[1]) ? $matches[1] : '';
             // format our data
             if (in_array($var, self::$multiple)) {
                 if (count($matches) == 2) {
                     self::$config[$var][$sub_var][$var] = trim($matches[1]);
                 } elseif ($line != '{' && $line != '};') {
                     self::$config[$var][$sub_var] = array();
                 }
                 // does this directive allow multiple entries?
                 self::$sub_open = true;
                 self::$opened_sub = $sub_var;
             } else {
                 if (count($matches) == 2) {
                     self::$config[$var][$var] = trim($matches[1]);
                 } elseif ($line != '{' && $line != '};') {
                     self::$config[$var] = array();
                 }
                 // if it doesn't allow multiple entries
             }
             self::$opened = true;
             self::$opened_dir = $var;
             // so, what we do here, we check if we have any "quoted info"
             // for instance uplink "server.name" {
             // if we do, we grab server.name.
             continue;
         }
         // so, we're dealing with a
         // "something {" scenario.
         if (self::$opened && $line != '{' && $line != '}') {
             $rvar = explode(' ', $line);
             $var = trim($rvar[0]);
             unset($rvar[0]);
             $value = isset($rvar[1]) ? implode(' ', $rvar) : '';
             // here we create our var and value variables, fixing a bug
             // with spaces not working in values earlier :@
             if (substr($var, -2) == '[]') {
                 $var = substr($var, 0, -2);
                 // strip the []
                 preg_match("/\"(.*)\"/", $value, $matches);
                 if (count($matches) == 2) {
                     if (self::$sub_open) {
                         self::$config[self::$opened_dir][self::$opened_sub][$var][] = trim($matches[1]);
                     } else {
                         self::$config[self::$opened_dir][$var][] = trim($matches[1]);
                     }
                 }
                 continue;
             }
             // are we dealing with an array, inside of {}
             // we only use the [] formats inside of {}
             // outside it, it's pointless as we can just use {}
             if ($value == '') {
                 preg_match("/\"(.*)\"/", $var, $matches);
                 if (count($matches) == 2) {
                     if (self::$sub_open) {
                         self::$config[self::$opened_dir][self::$opened_sub][] = trim($matches[1]);
                     } else {
                         self::$config[self::$opened_dir][] = trim($matches[1]);
                     }
                 }
             } else {
                 preg_match("/\"(.*)\"/", $value, $matches);
                 if (count($matches) == 2) {
                     if (self::$sub_open) {
                         self::$config[self::$opened_dir][self::$opened_sub][$var] = trim($matches[1]);
                     } else {
                         self::$config[self::$opened_dir][$var] = trim($matches[1]);
                     }
                 }
             }
             // is it a standalone value? eg "test"; or a defined value
             // eg variable "test"; ?
             continue;
         }
         // parse the data inside of { };
     }
     // loooop
 }
 public function wikiSnippet()
 {
     $college = $this->_college;
     $college = str_replace(" ", "_", $college);
     $this->setTitle($college);
     $this->setProp("revisions");
     // section 0
     $this->setFormat("php");
     $this->setAdditionalProperties("&rvprop=content&rvsection&section=0");
     // text content of page, only the text which appears before
     $this->setAPIUrl();
     $source = urlParser::cURL($this->_apiURL);
     $decoded = unserialize($source);
     $key = key($decoded["query"]["pages"]);
     $valueArray = $decoded["query"]["pages"][$key]["revisions"]["0"]["*"];
     //	print_r($valueArray);
     $established = parser::parseSnippet("|established", $valueArray);
     $established = parser::refineSnippet($established, "established");
     //print_r($established);
     $type = parser::parseSnippet("|type", $valueArray);
     $type = parser::refineSnippet($type);
     //print_r($type);
     $president = parser::parseSnippet("|president", $valueArray);
     $president = parser::refineSnippet($president);
     //print_r($president);
     $city = parser::parseSnippet("|city", $valueArray);
     $city = parser::refineSnippet($city);
     //print_r($city);
     $country = parser::parseSnippet("|country", $valueArray);
     $country = parser::refineSnippet($country);
     //print_r($country);
     $location = $city . ", " . $country;
     //print_r($location);
     $endowment = parser::deepParseSnippet("|endowment", $valueArray);
     $endowment = parser::refineSnippet($endowment);
     //print_r($endowment);
     $faculty = parser::parseSnippet("|faculty", $valueArray);
     $faculty = parser::refineSnippet($faculty, "faculty");
     //print_r($faculty);
     if ($faculty == "") {
         $faculty = parser::parseSnippet("|staff", $valueArray);
         // uses $faculty for ease of adding to db
         $faculty = parser::refineSnippet($faculty, "faculty");
         //print_r($athletics);
     }
     $undergrad = parser::parseSnippet("|undergrad", $valueArray);
     if ($undergrad == null) {
         $undergrad = parser::parseSnippet("| undergrad", $valueArray);
     }
     $undergrad = parser::refineSnippet($undergrad, "undergrad");
     //print_r($undergrad);
     $postgrad = parser::parseSnippet("|postgrad", $valueArray);
     if ($postgrad == null) {
         $postgrad = parser::parseSnippet("| postgrad", $valueArray);
     }
     $postgrad = parser::refineSnippet($postgrad, "postgrad");
     if ($postgrad == "") {
         $postgrad = "0";
     }
     //print_r($postgrad);
     $campus = parser::parseNew("|campus", $valueArray);
     $campus = parser::refineSnippet($campus);
     print_r($campus);
     return;
     $athletics = parser::deepParseSnippet("|athletics", $valueArray);
     $athletics = parser::refineSnippet($athletics);
     //	print_r($athletics); // needs further parsing
     if ($athletics == "") {
         $athletics = parser::deepParseSnippet("|free", $valueArray);
         //  used $athletics for ease of adding to db
         $athletics = parser::refineSnippet($faculty);
         //		print_r($athletics); // needs further parsing
     }
     $website = parser::parseSnippet("|website", $valueArray);
     if ($website == false) {
         $website = parser::parseSnippet("website", $valueArray);
     }
     if ($website == false) {
         $website = $this->getUrl();
     }
     //	print_r($website);
     $website = parser::refineSnippet($website);
     //	print_r($website);
     // code to add to database "CollegeSummary"
     $college = str_replace("_", " ", $this->_college);
     $array = array("CollegeUrl" => "{$website}", "CollegeLocation" => "{$location}", "CollegePostGrads" => "{$postgrad}", "CollegeUnderGrads" => "{$undergrad}", "CollegeAcademicStaff" => "{$faculty}", "CollegeEndowmentFund" => "{$endowment}", "CollegeCampus" => "{$campus}", "CollegeType" => "{$type}", "CollegeEstablished" => "{$established}", "CollegePresident" => "{$president}");
     $this->_dbConnection->updateTable("CollegeSummary", "CollegeSummary", "CollegeName", $college, "CollegeID", $array, "CollegeName = '{$college}'");
 }
Esempio n. 22
0
 public function priv_admin($line, $args)
 {
     if ($args['nargs'] < 2) {
         return;
     }
     if ($this->ircClass->getClientConf('dccadminpass') == "") {
         return;
     }
     if (md5($args['arg1']) != $this->ircClass->getClientConf('dccadminpass')) {
         return;
     }
     $query = substr($args['query'], strlen($args['arg1']) + 1);
     $myArgs = parser::createLine($query);
     switch ($args['arg2']) {
         case "chatme":
             $port = $this->dccClass->addChat($line['fromNick'], null, null, true, null);
             if ($port === false) {
                 $this->ircClass->notice($line['fromNick'], "Error starting chat, please try again.", 1);
             }
             break;
         default:
             $chat = new chat_wrapper($line['fromNick'], $this->ircClass);
             $cmdList = $this->parserClass->getCmdList();
             $cmdLower = $myArgs['cmd'];
             if (isset($cmdList['dcc'][$cmdLower])) {
                 if ($myArgs['nargs'] < $cmdList['dcc'][$cmdLower]['numArgs']) {
                     $chat->dccSend("Usage: " . $cmdLower . " " . $cmdList['dcc'][$cmdLower]['usage']);
                     break;
                 }
                 $module = $cmdList['dcc'][$cmdLower]['module'];
                 $class = $cmdList['file'][$module]['class'];
                 $func = $cmdList['dcc'][$cmdLower]['function'];
                 $class->{$func}($chat, $myArgs);
                 $chat->dccSend("ADMIN " . irc::myStrToUpper($cmdLower) . " Requested");
             } else {
                 $chat->dccSend("Invalid Command: " . $myArgs['cmd']);
             }
             break;
     }
 }
Esempio n. 23
0
 private function doCallback()
 {
     if ($this->line != null && is_array($this->line) && isset($this->line['text'])) {
         $lineArgs = parser::createLine($this->line['text']);
     } else {
         $lineArgs = array();
     }
     $func = $this->function;
     $this->class->{$func}($this->line, $lineArgs, $this->type, $this->response);
 }
Esempio n. 24
0
}
function getArr($filename)
{
    $file_array = file($filename);
    foreach ($file_array as $i => $url) {
        $file_array[$i] = rtrim($file_array[$i]);
    }
    return $file_array;
}
function connectToDB()
{
    echo "connecting to DB";
    $host = 'localhost';
    $database = 'pars';
    $user = '******';
    $pswd = 'wgGLtqMf';
    $dbh = mysql_connect($host, $user, $pswd) or die("can`t connect to mysql");
    echo " .";
    mysql_select_db($database) or die("can` connect to database");
    echo ". ";
    mysql_query("SET NAMES 'utf8'");
    mysql_query("SET CHARACTER_SET_CLIENT=utf8");
    mysql_query("SET CHARACTER_SET_RESULTS=utf8");
    echo "connected\n";
}
$domain_end = array();
// config
connectToDB();
$parser = new parser($domains);
$parser->startParsing();
echo "et all\n";
Esempio n. 25
0
  ******************************************************************/
 # Decode gzip compressed content
 if (isset($fetch->headers['content-encoding']) && $fetch->headers['content-encoding'] == 'gzip') {
     if (function_exists('gzinflate')) {
         unset($fetch->headers['content-encoding']);
         $document = gzinflate(substr($document, 10, -8));
     }
 }
 # Apply preparsing from plugins
 if ($foundPlugin && function_exists('preParse')) {
     $document = preParse($document, $fetch->parseType);
 }
 # Load the main parser
 require GLYPE_ROOT . '/includes/parser.php';
 # Create new instance, passing in the options that affect parsing
 $parser = new parser($options, $jsFlags);
 # Method of parsing depends on $parseType
 switch ($fetch->parseType) {
     # HTML document
     case 'html':
         # Do we want to insert our own code into the document?
         $inject = $footer = $insert = false;
         # Mini-form only if NOT frame or sniffed
         if ($flag != 'frame' && $fetch->sniff == false) {
             # Showing the mini-form?
             if ($options['showForm']) {
                 $toShow = array();
                 # Prepare the options
                 foreach ($CONFIG['options'] as $name => $details) {
                     # Ignore if forced
                     if (!empty($details['force'])) {
Esempio n. 26
0
$db = new $sql_db();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
unset($dbpasswd);
$config['am_dir_perms'] = 755;
$config['am_file_perms'] = 644;
// -------------------------- begin stealing from acp_mods
// include automod files
include "{$phpbb_root_path}includes/functions_transfer.{$phpEx}";
include "./includes/editor.{$phpEx}";
include "./includes/functions_mods.{$phpEx}";
include "./includes/mod_parser.{$phpEx}";
$edited_root = '../../mod/';
$backup_root = '';
$editor = new editor_direct();
$editor->create_edited_root($edited_root);
$parser = new parser('xml');
$parser->set_file($mod_path);
$actions = $parser->get_actions();
$mod_installed = true;
// not all MODs will have edits (!)
if (isset($actions['EDITS'])) {
    foreach ($actions['EDITS'] as $filename => $edits) {
        // see if the file to be opened actually exists
        if (!file_exists("{$phpbb_root_path}{$filename}")) {
            $mod_installed = false;
            continue;
        } else {
            $status = $editor->open_file($filename, $backup_root);
            if (is_string($status)) {
                $mod_installed = false;
                continue;
Esempio n. 27
0
 /**
  * Returns the edits array, but now filled with edits to reverse the given array
  * @todo: Add more
  */
 function reverse_edits($actions)
 {
     $reverse_edits = array();
     foreach ($actions['EDITS'] as $file => $edit_ary) {
         foreach ($edit_ary as $edit_id => $edit) {
             foreach ($edit as $find => $action_ary) {
                 foreach ($action_ary as $type => $command) {
                     // it is possible for a single edit in the install process
                     // to become more than one in the uninstall process
                     while (isset($reverse_edits['EDITS'][$file][$edit_id])) {
                         $edit_id++;
                     }
                     switch (strtoupper($type)) {
                         // for before and after adds, we use the find as a tool for more precise finds
                         // this isn't perfect, but it seems better than having
                         // finds of only a couple characters, like "/*"
                         case 'AFTER ADD':
                             $total_find = rtrim($find, "\n") . "\n" . trim($command, "\n");
                             $reverse_edits['EDITS'][$file][$edit_id][$total_find]['replace with'] = $find;
                             break;
                         case 'BEFORE ADD':
                             $total_find = rtrim($command, "\n") . "\n" . trim($find, "\n");
                             // replace with the find
                             $reverse_edits['EDITS'][$file][$edit_id][$total_find]['replace with'] = $find;
                             break;
                         case 'REPLACE WITH':
                         case 'REPLACE, WITH':
                         case 'REPLACE-WITH':
                         case 'REPLACE':
                             // replace $command (new code) with $find (original code)
                             $reverse_edits['EDITS'][$file][$edit_id][$command]['replace with'] = $find;
                             break;
                         case 'IN-LINE-EDIT':
                             $action_id = 0;
                             // build the reverse just like the normal action
                             foreach ($command as $inline_find => $inline_action_ary) {
                                 foreach ($inline_action_ary as $inline_action => $inline_command) {
                                     $inline_command = $inline_command[0];
                                     switch (strtoupper($inline_action)) {
                                         case 'IN-LINE-AFTER-ADD':
                                         case 'IN-LINE-BEFORE-ADD':
                                             // Replace with a blank string
                                             $reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$action_id][$inline_command]['in-line-replace'][] = '';
                                             break;
                                         case 'IN-LINE-REPLACE':
                                             // replace with the inline find
                                             $reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$action_id][$inline_command][$inline_action][] = $inline_find;
                                             break;
                                         default:
                                             // For the moment, we do nothing.  What about increment?
                                             break;
                                     }
                                     $action_id++;
                                 }
                             }
                             break;
                         default:
                             // again, increment
                             break;
                     }
                 }
             }
         }
     }
     if (empty($actions['SQL'])) {
         return $reverse_edits;
     }
     if (sizeof($actions['SQL']) == 1) {
         $actions['SQL'] = explode("\n", $actions['SQL'][0]);
     }
     foreach ($actions['SQL'] as $query) {
         $reverse_edits['SQL'][] = parser::reverse_query($query);
     }
     return $reverse_edits;
 }
Esempio n. 28
0
function player_getContent($caveID, $playerID)
{
    global $db, $template;
    // open template
    $template->setFile('playerDetail.tmpl');
    $template->setShowResource(false);
    // workaround, if no playerID is submitted! TODO
    if ($playerID == 0) {
        $playerID = $_SESSION['player']->playerID;
    }
    $playerDetails = Player::getPlayer($playerID, true);
    if (!$playerDetails) {
        $template->throwError('Da wollte irgendwie was nicht aus der Datenbank ausgelesen werden :(');
        return;
    }
    if ($playerDetails['avatar']) {
        $playerDetails['avatar'] = @unserialize($playerDetails['avatar']);
        $template->addVars(array('player_avatar' => $playerDetails['avatar']['path'], 'player_avatar_width' => $playerDetails['avatar']['width'], 'player_avatar_height' => $playerDetails['avatar']['height']));
    }
    if (!empty($playerDetails['awards'])) {
        $tmp = explode('|', $playerDetails['awards']);
        $awards = array();
        foreach ($tmp as $tag) {
            $awards[] = $tag;
        }
        $playerDetails['award'] = $awards;
    }
    unset($playerDetails['awards']);
    foreach ($playerDetails as $k => $v) {
        if (!$v) {
            $playerDetails[$k] = _('k.A.');
        }
    }
    $playerDetails['mail_receiver'] = urlencode($playerDetails['name']);
    $playerDetails['caveID'] = $caveID;
    $playerTribe = $playerDetails['tribe'];
    $timediff = getUgaAggaTimeDiff(time_fromDatetime($playerDetails['created']), time());
    $playerDetails['age'] = 18 + $timediff['year'];
    // init messages class
    $parser = new parser();
    $playerDetails['description'] = $parser->p($playerDetails['description']);
    // show player's caves
    $caves = getCaves($playerID);
    if ($caves) {
        $template->addVar('player_caves', $caves);
    }
    // show player's history
    $history = Player::getHistory($playerID);
    if (sizeof($history)) {
        $template->addVar('player_history', $history);
    }
    //get player rank
    $sql = $db->prepare("SELECT rank FROM " . RANKING_TABLE . " WHERE playerID = :playerID");
    $sql->bindValue('playerID', $playerID, pDo::PARAM_INT);
    if (!$sql->execute()) {
        page_dberror();
    }
    if ($row = $sql->fetch()) {
        $playerDetails['rank'] = $row['rank'];
    } else {
        $playerDetails['rank'] = '';
    }
    $template->addVars(array('player_details' => $playerDetails));
}
 public function __construct()
 {
     $this->reset();
     $this->lng = language::getinstance()->GetLngBlock('cartographie');
     $this->lngmain = language::getinstance()->GetLngBlock('dataengine');
     $this->allys = DataEngine::config('EmpireAllys');
     $this->wars = DataEngine::config('EmpireEnnemy');
     if (!is_array($this->allys) && $this->allys != '') {
         $this->allys = array($this->allys);
     }
     if (!is_array($this->wars) && $this->wars != '') {
         $this->wars = array($this->wars);
     }
     if (!is_array($this->allys) && $this->allys == '') {
         $this->allys = array();
     }
     if (!is_array($this->wars) && $this->wars == '') {
         $this->wars = array();
     }
     if (is_array($this->allys)) {
         $this->allys = parser::getinstance()->cleaning_array($this->allys);
     }
     if (is_array($this->wars)) {
         $this->wars = parser::getinstance()->cleaning_array($this->wars);
     }
     $this->detelespooler = array();
 }
Esempio n. 30
0
 function process_edits($editor, $actions, $details, $change = false, $display = true, $reverse = false)
 {
     global $template, $user, $db, $phpbb_root_path, $force_install, $mod_installed;
     global $dest_inherits, $dest_template;
     $mod_installed = true;
     if ($reverse) {
         // maybe should allow for potential extensions here
         $actions = parser::reverse_edits($actions);
     }
     $template->assign_vars(array('S_DISPLAY_DETAILS' => (bool) $display, 'S_CHANGE_FILES' => (bool) $change));
     if (!empty($details['AUTHOR_NOTES']) && $details['AUTHOR_NOTES'] != $user->lang['UNKNOWN_MOD_AUTHOR-NOTES']) {
         $template->assign_vars(array('S_AUTHOR_NOTES' => true, 'AUTHOR_NOTES' => nl2br($details['AUTHOR_NOTES'])));
     }
     // not all MODs will have edits (!)
     if (isset($actions['EDITS'])) {
         $template->assign_var('S_EDITS', true);
         foreach ($actions['EDITS'] as $filename => $edits) {
             // see if the file to be opened actually exists
             if (!file_exists("{$phpbb_root_path}{$filename}")) {
                 $is_inherit = strpos($filename, 'styles/') !== false && !empty($dest_inherits) ? true : false;
                 $template->assign_block_vars('edit_files', array('S_MISSING_FILE' => $is_inherit ? false : true, 'INHERIT_MSG' => $is_inherit ? sprintf($user->lang['INHERIT_NO_CHANGE'], $dest_template, $dest_inherits) : '', 'FILENAME' => $filename));
                 $mod_installed = $is_inherit ? $mod_installed : false;
                 continue;
             } else {
                 $template->assign_block_vars('edit_files', array('FILENAME' => $filename));
                 $status = $editor->open_file($filename, $this->backup_root);
                 if (is_string($status)) {
                     $template->assign_block_vars('error', array('ERROR' => $status));
                     $mod_installed = false;
                     continue;
                 }
                 foreach ($edits as $finds) {
                     $comment = '';
                     foreach ($finds as $find => $commands) {
                         if (isset($finds['comment']) && !$comment && $finds['comment'] != $user->lang['UNKNOWN_MOD_COMMENT']) {
                             $comment = $finds['comment'];
                             unset($finds['comment']);
                         }
                         if ($find == 'comment') {
                             continue;
                         }
                         $template->assign_block_vars('edit_files.finds', array('FIND_STRING' => htmlspecialchars($find), 'COMMENT' => htmlspecialchars($comment)));
                         $offset_ary = $editor->find($find);
                         // special case for FINDs with no action associated
                         if (is_null($commands)) {
                             continue;
                         }
                         foreach ($commands as $type => $contents) {
                             if (!$offset_ary) {
                                 $offset_ary['start'] = $offset_ary['end'] = false;
                             }
                             $status = false;
                             $inline_template_ary = array();
                             $contents_orig = $contents;
                             switch (strtoupper($type)) {
                                 case 'AFTER ADD':
                                     $status = $editor->add_string($find, $contents, 'AFTER', $offset_ary['start'], $offset_ary['end']);
                                     break;
                                 case 'BEFORE ADD':
                                     $status = $editor->add_string($find, $contents, 'BEFORE', $offset_ary['start'], $offset_ary['end']);
                                     break;
                                 case 'INCREMENT':
                                 case 'OPERATION':
                                     //$contents = "";
                                     $status = $editor->inc_string($find, '', $contents);
                                     break;
                                 case 'REPLACE WITH':
                                     $status = $editor->replace_string($find, $contents, $offset_ary['start'], $offset_ary['end']);
                                     break;
                                 case 'IN-LINE-EDIT':
                                     // these aren't quite as straight forward.  Still have multi-level arrays to sort through
                                     $inline_comment = '';
                                     foreach ($contents as $inline_find => $inline_commands) {
                                         if ($inline_find == 'inline-comment') {
                                             // This is a special case for tucking comments in the array
                                             if ($inline_commands != $user->lang['UNKNOWN_MOD_INLINE-COMMENT']) {
                                                 $inline_comment = $inline_commands;
                                             }
                                             continue;
                                         }
                                         foreach ($inline_commands as $inline_action => $inline_contents) {
                                             // inline finds are pretty contancerous, so so them in the loop
                                             $line = $editor->inline_find($find, $inline_find, $offset_ary['start'], $offset_ary['end']);
                                             if (!$line) {
                                                 // find failed
                                                 $status = false;
                                                 continue 2;
                                             }
                                             $inline_contents = $inline_contents[0];
                                             $contents_orig = $inline_find;
                                             switch (strtoupper($inline_action)) {
                                                 case 'IN-LINE-BEFORE-ADD':
                                                     $status = $editor->inline_add($find, $inline_find, $inline_contents, 'BEFORE', $line['array_offset'], $line['string_offset'], $line['find_length']);
                                                     break;
                                                 case 'IN-LINE-AFTER-ADD':
                                                     $status = $editor->inline_add($find, $inline_find, $inline_contents, 'AFTER', $line['array_offset'], $line['string_offset'], $line['find_length']);
                                                     break;
                                                 case 'IN-LINE-REPLACE':
                                                 case 'IN-LINE-REPLACE-WITH':
                                                     $status = $editor->inline_replace($find, $inline_find, $inline_contents, $line['array_offset'], $line['string_offset'], $line['find_length']);
                                                     break;
                                                 case 'IN-LINE-OPERATION':
                                                     $status = $editor->inc_string($find, $inline_find, $inline_contents);
                                                     break;
                                                 default:
                                                     trigger_error("Error, unrecognised command {$inline_action}");
                                                     // ERROR!
                                                     break;
                                             }
                                             if ($status) {
                                                 $inline_template_ary[] = array('S_SUCCESS' => $status, 'NAME' => $user->lang[$inline_action], 'COMMAND' => is_array($inline_contents) ? $user->lang['INVALID_MOD_INSTRUCTION'] : htmlspecialchars($inline_contents), 'COMMENT' => $inline_comment);
                                             }
                                         }
                                     }
                                     break;
                                 default:
                                     trigger_error("Error, unrecognised command {$type}");
                                     // ERROR!
                                     break;
                             }
                             $template->assign_block_vars('edit_files.finds.actions', array('S_SUCCESS' => $status, 'NAME' => $user->lang[$type], 'COMMAND' => is_array($contents_orig) ? $user->lang['INVALID_MOD_INSTRUCTION'] : htmlspecialchars($contents_orig)));
                             if (!$status) {
                                 $mod_installed = false;
                             }
                             // these vars must be assigned after the parent block or else things break
                             if (sizeof($inline_template_ary)) {
                                 foreach ($inline_template_ary as $inline_template) {
                                     $template->assign_block_vars('edit_files.finds.actions.inline', $inline_template);
                                 }
                                 $inline_template_ary = array();
                             }
                         }
                     }
                     $editor->close_edit();
                 }
             }
             if ($change) {
                 $status = $editor->close_file("{$this->edited_root}{$filename}");
                 if (is_string($status)) {
                     $template->assign_block_vars('error', array('ERROR' => $status));
                     $mod_installed = false;
                 }
             }
         }
     }
     // end foreach
     // Move included files
     if (isset($actions['NEW_FILES']) && !empty($actions['NEW_FILES']) && $change && ($mod_installed || $force_install)) {
         $template->assign_var('S_NEW_FILES', true);
         foreach ($actions['NEW_FILES'] as $source => $target) {
             $status = $editor->copy_content($this->mod_root . str_replace('*.*', '', $source), str_replace('*.*', '', $target));
             if ($status !== true && !is_null($status)) {
                 $mod_installed = false;
             }
             $template->assign_block_vars('new_files', array('S_SUCCESS' => $status === true ? true : false, 'S_NO_COPY_ATTEMPT' => is_null($status) ? true : false, 'SOURCE' => $source, 'TARGET' => $target));
         }
     }
     // Perform SQL queries last -- Queries usually cannot be done a second
     // time, so do them only if the edits were successful.  Still complies
     // with the MODX spec in this location
     if (!empty($actions['SQL']) && ($mod_installed || $force_install || $display && !$change)) {
         $template->assign_var('S_SQL', true);
         parser::parse_sql($actions['SQL']);
         $db->sql_return_on_error(true);
         foreach ($actions['SQL'] as $query) {
             if ($change) {
                 $query_success = $db->sql_query($query);
                 if ($query_success) {
                     $template->assign_block_vars('sql_queries', array('S_SUCCESS' => true, 'QUERY' => $query));
                 } else {
                     $error = $db->sql_error();
                     $template->assign_block_vars('sql_queries', array('S_SUCCESS' => false, 'QUERY' => $query, 'ERROR_MSG' => $error['message'], 'ERROR_CODE' => $error['code']));
                     $mod_installed = false;
                 }
             } else {
                 if ($display) {
                     $template->assign_block_vars('sql_queries', array('QUERY' => $query));
                 }
             }
         }
         $db->sql_return_on_error(false);
     } else {
         $template->assign_var('S_SQL', false);
     }
     return $mod_installed;
 }