Example #1
0
    public function RunJob()
    {
        $this->_lock();
        $vortex_a = array();
        $CurrSS_a = array();
        $empire = trim(DataEngine::config_key('config', 'MyEmpire'));
        $cxx_empires = Members::CheckPerms('CARTE_SHOWEMPIRE');
        $this->fp = fopen($this->filename, 'w');
        stream_set_write_buffer($this->fp, 0);
        fwrite($this->fp, 'var ss_info=Array();');
        $sql = 'SELECT `ID`, `POSIN`, `POSOUT` from `SQL_PREFIX_Coordonnee` where `Type`=1';
        $mysql_result = DataEngine::sql($sql);
        while ($line = mysql_fetch_assoc($mysql_result)) {
            $vortex_a[$line['POSOUT']][$line['ID']]['POSIN'] = $line['POSOUT'];
            $vortex_a[$line['POSOUT']][$line['ID']]['POSOUT'] = $line['POSIN'];
            $vortex_a[$line['POSOUT']][$line['ID']]['TYPE'] = 1;
        }
        mysql_free_result($mysql_result);
        $sql = <<<sql
SELECT c.`ID`, c.`TYPE`, c.`POSIN`, c.`POSOUT`, j.`USER`, j.`INFOS`, j.`EMPIRE`,
    IFNULL(g.`Grade`,'') as Grade, IFNULL(m.`Joueur`,'') as Joueur
FROM SQL_PREFIX_Coordonnee as c
    LEFT JOIN SQL_PREFIX_Coordonnee_Joueurs as j on (c.id=j.jid)
    LEFT JOIN `SQL_PREFIX_Membres` m on (j.`USER`=m.`Joueur`)
    LEFT JOIN `SQL_PREFIX_Grade` g on (m.`Grade`=g.`GradeId`)
ORDER BY c.`POSIN` ASC
sql;
        $mysql_result = DataEngine::sql($sql);
        $CurrSS = 0;
        while ($line = mysql_fetch_assoc($mysql_result)) {
            if ($CurrSS == 0) {
                $CurrSS = $line['POSIN'];
            }
            if ($line['POSIN'] != $CurrSS) {
                if (isset($vortex_a[$CurrSS]) && is_array($vortex_a[$CurrSS])) {
                    foreach ($vortex_a[$CurrSS] as $k => $v) {
                        $CurrSS_a[$k] = $v;
                        $CurrSS_a[$k]['type'] = 'Vortex';
                        $CurrSS_a['Vortex'] = isset($CurrSS_a['Vortex']) ? $CurrSS_a['Vortex']++ : 1;
                    }
                    unset($vortex_a[$CurrSS]);
                    // destruction du vortex...
                }
                $this->add_ss($CurrSS, $CurrSS_a);
                $CurrSS = $line['POSIN'];
                $CurrSS_a = array();
                //                if ($CurrSS == 1240)
                //                    break;
                //                if ($CurrSS == 1240)
                //                    xdebug_break();
            }
            $ID = $line['ID'];
            $ss = $line['POSIN'];
            $CurrSS_a[$ID] = $line;
            switch ($line['TYPE']) {
                case 0:
                    $type = 'Joueur';
                    break;
                case 1:
                    $type = 'Vortex';
                    break;
                case 2:
                    $type = 'Planète';
                    break;
                case 3:
                    $type = 'alliance';
                    break;
                case 4:
                    $type = 'Astéroïde';
                    break;
                case 5:
                    $type = 'Ennemi';
                    break;
                case 6:
                    $type = 'pnj';
                    break;
                default:
                    $type = 'na';
            }
            if ($empire != '' && $line['EMPIRE'] == $empire && $cxx_empires) {
                $type = 'empire';
            }
            //                if (eval($typeeval)) $type = 'search';
            if (stristr($line['USER'], $_SESSION['_login']) !== FALSE) {
                $type = 'moi';
            }
            $CurrSS_a[$ID]['type'] = $type;
            if (isset($CurrSS_a[$CurrSS_a[$ID]['type']])) {
                $CurrSS_a[$CurrSS_a[$ID]['type']]++;
            } else {
                $CurrSS_a[$CurrSS_a[$ID]['type']] = 1;
            }
        }
        mysql_free_result($mysql_result);
        if (isset($vortex_a[$CurrSS]) && is_array($vortex_a[$CurrSS])) {
            foreach ($vortex_a[$CurrSS] as $k => $v) {
                $CurrSS_a[$k] = $v;
                $CurrSS_a[$k]['type'] = 'Vortex';
                $CurrSS_a['Vortex'] = isset($CurrSS_a['Vortex']) ? $CurrSS_a['Vortex']++ : 1;
            }
            unset($vortex_a[$CurrSS]);
            // destruction du vortex...
        }
        $this->add_ss($CurrSS, $CurrSS_a);
        fclose($this->fp);
        parent::RunJob();
    }
Example #2
0
 public function RunJob()
 {
     $this->_lock();
     // Do something
     parent::RunJob();
 }