public static function minimalinit()
 {
     if (!defined('ROOT_URL')) {
         if (p_strlen(ROOT_PATH) > p_strlen($_SERVER['DOCUMENT_ROOT'])) {
             define('ROOT_URL', p_substr(ROOT_PATH, p_strlen($_SERVER['DOCUMENT_ROOT'])));
         } else {
             define('ROOT_URL', '/');
         }
     }
     define('INCLUDE_URL', ROOT_URL . 'Script/');
     define('IMAGES_URL', ROOT_URL . 'Images/');
     define('ADDONS_URL', ROOT_URL . 'addons/');
     define('TEMPLATE_URL', ROOT_URL . 'tpl/');
     define('CACHE_URL', ROOT_URL . 'cache/');
     define('BTN_URL', CACHE_URL . 'btn-');
     DataEngine::conf_cache('perms');
     DataEngine::conf_cache('config');
     // Fix multiple installations/conflit avec forum ou autre soft utilisant les sessions
     session_set_cookie_params(0, ROOT_URL);
     if (!NO_SESSIONS) {
         session_start() or trigger_error('Erreur de session', E_USER_ERROR);
     }
     return self::$initialized = true;
 }
Example #2
0
function initimg($Nbx, $Nby, $taillex, $tailley)
{
    global $colormap, $image, $debug_cl;
    $map = map::getinstance();
    $image = imagecreate($Nbx * $taillex, $Nby * $tailley);
    $background_color = imagecolorallocate($image, 0, 0, 0);
    $blanc = imagecolorallocate($image, 254, 254, 254);
    $rouge = imagecolorallocate($image, 85, 0, 64);
    imagefilledrectangle($image, 0, 0, $Nbx * $taillex, $Nby * $tailley, $background_color);
    // Tableau des couleurs...
    $colormap = DataEngine::config('MapColors');
    $colormap = $colormap[$map->itineraire ? 0 : $map->sc + 1];
    if ($map->itineraire) {
        $map->load_prefs('1;0;0;0;' . $map->sc . ';' . $map->taille . ';0;0;0');
    }
    foreach ($colormap as $k => $c) {
        $R = hexdec(p_substr($c, 1, 2));
        $V = hexdec(p_substr($c, 3, 2));
        $B = hexdec(p_substr($c, 5, 2));
        $colormap[$k] = imagecolorallocate($image, $R, $V, $B);
    }
    $colormap[-1] = $debug_cl = $blanc;
    $colormap[-2] = $rouge;
    // Centre de communication...
    $comlevel = ownuniverse::getinstance()->get_comlevel();
    if (is_array($comlevel)) {
        foreach ($comlevel as $k => $planet) {
            list($CoordsY, $CoordsX) = map::ss2xy($planet['ss']);
            $level = $planet['level'];
            if ($level > 0) {
                ImageFilledEllipse($image, 1 + ($CoordsY - 1) * $taillex + round($taillex / 2) + 1, 1 + ($CoordsX - 1) * $tailley + round($tailley / 2) + 1, $level * 20 * $taillex, $level * 20 * $tailley, $colormap["0"]);
            }
        }
    }
    return $image;
}
 private function Ressources_Check_Value(&$value, $checkpercent)
 {
     if (is_numeric($value) && $value > 0) {
         return true;
     }
     switch (mb_strtolower($value, 'utf8')) {
         case $this->lng['ress10%']:
         case $this->lng['ress20%']:
         case $this->lng['ress40%']:
         case $this->lng['ress50%']:
         case $this->lng['ress70%']:
         case $this->lng['ress80%']:
         case $this->lng['ress90%']:
             return true;
     }
     if ($checkpercent) {
         if (!is_numeric($value) && is_numeric(p_substr($value, 0, p_strlen($value) - 1))) {
             $value = p_substr($value, 0, p_strlen($value) - 1);
         }
         if (is_numeric($value) && $value >= 100) {
             $value = 100;
         }
         if (is_numeric($value) && $value < 0) {
             $value = 0;
         }
         if (is_numeric($value)) {
             $value = $value . '%';
             return true;
         }
     }
     if ($value == '') {
         return true;
     }
     return false;
 }
Example #4
0
 /**
  * @param		mixte				Debug text
  * @param		boolean			New line before
  * @return	boolean
  */
 public static function map_debug($text, $newline = true)
 {
     if (!IN_DEV) {
         return false;
     }
     global $image, $debug_cl;
     static $x = 1, $y = -15, $map;
     if (!$map) {
         $map = map::getinstance();
     }
     if (DEBUG_PLAIN) {
         return print_r($text);
     }
     if (!IS_IMG) {
         return false;
     }
     if (!isset($image)) {
         return false;
     }
     if (is_array($text)) {
         $text = str_replace("\t\t", '', print_r($text, true));
     }
     if ($newline) {
         $x = 1;
         $y += 15;
     }
     $text = utf8_decode($text);
     for ($i = 0; $i < strlen($text); $i++) {
         $c = p_substr($text, $i, 1);
         if ($x - 10 >= $map->taille - 15 or $c == "\n") {
             $x = 1;
             $y += 15;
         }
         if ($c == "\n") {
             continue;
         }
         imagechar($image, 4, $x, $y, $c, $debug_cl);
         $x += 10;
     }
     return true;
 }
    function AddPillage_log($mode, $idate, $msg)
    {
        // check si existant
        $sql = sprintf('SELECT `pid` FROM SQL_PREFIX_troops_pillage WHERE Player=\'%s\' AND date=%d', sqlesc($_SESSION['_login']), $idate);
        $result = DataEngine::sql($sql);
        if (mysql_numrows($result) > 0) {
            return $this->lng['log_allreadyexists'];
        }
        // Type du log/bataille
        // Puis recherche de la bataille (coords+participation)
        if ($mode == 'defender') {
            preg_match($this->lng['defender_regex'], $msg, $info);
            $ident = $this->lng['defender_ident'];
            if (!($planets = ownuniverse::getinstance()->get_coordswithname())) {
                return $this->lng['battle_error_ownuniverse'];
            }
            foreach ($planets as $v) {
                if ($v['Name'] == $info[$this->lng[$mode . '_regex_planetid']]) {
                    cartographie::getinstance()->FormatId($v['Coord'], $idsys, $iddet, 'troops::AddPillage_log(def,1)');
                    break;
                }
            }
            $sql = sprintf('SELECT `ID` FROM `SQL_PREFIX_troops_attack` WHERE `type`=\'%s\' AND ' . '`coords_ss`=\'%s\' AND `coords_3p`=\'%s\' AND `when`<=%d AND `when`>=%d' . ' AND `players_defender` LIKE \'%%"%s"%%\' AND `players_attack` LIKE \'%%"%s"%%\'' . 'ORDER BY `when` DESC LIMIT 1', sqlesc($mode), $idsys, $iddet, $idate, $idate - 604800, sqlesc($_SESSION['_login']), sqlesc($info[$this->lng[$mode . '_regex_userid']]));
            $result = DataEngine::sql($sql);
            if (mysql_numrows($result) < 1) {
                return $this->lng['log_battlenofound'];
            }
            $line = mysql_fetch_assoc($result);
            $mid = $line['ID'];
        } else {
            preg_match($this->lng['attacker_regex'], $msg, $info);
            $ident = $this->lng['attacker_ident'];
            $sql = <<<sql
SELECT `POSIN`, `COORDET` FROM `SQL_PREFIX_Coordonnee`
LEFT JOIN `SQL_PREFIX_Coordonnee_Joueurs` on `ID`=`jID`
WHERE `TYPE` in (0,3,5) AND `USER`='%s' AND `INFOS`='%s'
sql;
            $sql = sprintf($sql, $info[$this->lng[$mode . '_regex_userid']], $info[$this->lng[$mode . '_regex_planetid']]);
            $result = DataEngine::sql($sql);
            if (mysql_numrows($result) < 1) {
                return $this->lng['log_coordsnotfound'];
            }
            if (mysql_numrows($result) > 1) {
                return $this->lng['log_multiplecoords'];
            }
            $line = mysql_fetch_assoc($result);
            $idsys = $line['POSIN'];
            $iddet = $line['COORDET'];
            $sql = sprintf('SELECT `ID` FROM `SQL_PREFIX_troops_attack` WHERE `type`=\'%s\' AND ' . '`coords_ss`=\'%s\' AND `coords_3p`=\'%s\' AND `when`<%d AND `when`>%d AND ' . '`players_attack` LIKE \'%%"%s"%%\' AND `players_defender` LIKE \'%%"%s"%%\'', sqlesc($mode), $idsys, $iddet, $idate, $idate - 604800, sqlesc($_SESSION['_login']), sqlesc($info[$this->lng[$mode . '_regex_userid']]));
            $result = DataEngine::sql($sql);
            if (mysql_numrows($result) < 1) {
                return $this->lng['log_battlenofound'];
            }
            if (mysql_numrows($result) > 1) {
                return 'Error battle result > 1 (omfg)';
            }
            $line = mysql_fetch_assoc($result);
            $mid = $line['ID'];
        }
        // Info à ajouter
        $amsg = explode("\n", trim(p_substr($msg, p_stripos($msg, $ident, 0) + p_strlen($ident), -1)));
        $ares = DataEngine::a_ressources();
        $fields = array();
        $sets = array();
        $fields[] = 'date';
        $sets[] = $idate;
        $fields[] = 'mid';
        $sets[] = $mid;
        $fields[] = 'Player';
        $sets[] = '\'' . sqlesc($_SESSION['_login']) . '\'';
        foreach ($ares as $k => $v) {
            foreach ($amsg as $line) {
                list($key, $value) = explode(':', $line);
                if ($v['Nom'] == trim($key)) {
                    $fields[] = 'ress' . $k;
                    $sets[] = DataEngine::strip_number($value);
                    break;
                }
            }
        }
        $fields = implode(',', $fields);
        $sets = implode(',', $sets);
        $sql = 'INSERT INTO `SQL_PREFIX_troops_pillage` (' . $fields . ') VALUES (' . $sets . ')';
        $result = DataEngine::sql($sql);
        return $this->lng['log_added'];
    }
Example #6
0
 private function add_ss($ss, $data)
 {
     $line = array();
     $tmp = '';
     // map::ss_info
     foreach ($data as $k => $v) {
         /// $k = ID mysql/nb type @@ $v = array...
         if (isset($v['EMPIRE'])) {
             $v['EMPIRE'] = htmlspecialchars(addcslashes($v['EMPIRE'], '"'));
         }
         switch ($v['type']) {
             case 'moi':
                 $line['ownplanet'][] = $v['INFOS'];
                 break;
             case 'empire':
                 if (!isset($line['empire'])) {
                     $line['empire'] = array();
                 }
                 if ($v['Joueur'] != '') {
                     $line['empire'][] = $v['Joueur'] . ' (' . $v['Grade'] . ')';
                 } else {
                     $line['empire'][] = $v['USER'];
                 }
                 break;
             case 'Vortex':
                 if (!isset($line['wormholes'])) {
                     $line['wormholes'] = array();
                 }
                 $line['wormholes'][] = $v['POSOUT'];
                 break;
             case 'Joueur':
                 if (!isset($line['players'])) {
                     $line['players'] = array();
                 }
                 if ($v['EMPIRE'] != '') {
                     $line['players'][] = $v['USER'] . ' [' . $v['EMPIRE'] . ']';
                 } else {
                     $line['players'][] = $v['USER'];
                 }
                 break;
                 //                case 'search':
                 //                    if (!isset($line['searchresult']))
                 //                        $line['searchresult'] = array();
                 //
                 //                    if ($v['EMPIRE'] != '')
                 //                        $line['searchresult'][] = $v['USER'] . ' [' . $v['EMPIRE'] . ']';
                 //                    else
                 //                        $line['searchresult'][] = $v['USER'];
                 //                    break;
             //                case 'search':
             //                    if (!isset($line['searchresult']))
             //                        $line['searchresult'] = array();
             //
             //                    if ($v['EMPIRE'] != '')
             //                        $line['searchresult'][] = $v['USER'] . ' [' . $v['EMPIRE'] . ']';
             //                    else
             //                        $line['searchresult'][] = $v['USER'];
             //                    break;
             case 'alliance':
                 if (!isset($line['alliance'])) {
                     $line['alliance'] = array();
                 }
                 $line['alliance'][] = $v['USER'] . ' [' . $v['EMPIRE'] . ']';
                 break;
             case 'Ennemi':
                 if (!isset($line['ennemys'])) {
                     $line['ennemys'] = array();
                 }
                 if ($v['EMPIRE'] != '') {
                     $line['ennemys'][] = $v['USER'] . ' [' . $v['EMPIRE'] . ']';
                 } else {
                     $line['ennemys'][] = $v['USER'];
                 }
                 break;
             case 'pnj':
                 if (!isset($line['reaperfleet'])) {
                     $line['reaperfleet'] = array();
                 }
                 $line['reaperfleet'][] = $v['INFOS'];
                 break;
             case 'Planète':
                 if (!isset($line['planets'])) {
                     $line['planets'] = 1;
                 } else {
                     $line['planets']++;
                 }
                 break;
             case 'Astéroïde':
                 if (!isset($line['asteroids'])) {
                     $line['asteroids'] = 1;
                 } else {
                     $line['asteroids']++;
                 }
                 break;
             case 'cdr':
                 if (!isset($line['cdr'])) {
                     $line['cdr'] = 1;
                 } else {
                     $line['cdr']++;
                 }
                 break;
         }
     }
     if (true) {
         $tmp = 'ss_info[' . $ss . ']={';
         foreach ($line as $k => $v) {
             if (is_array($v) && count($v) > 0) {
                 array_walk($v, 'array_js');
                 $tmp .= $k . ':[' . implode(',', $v) . '],';
             } elseif (!is_array($v)) {
                 $tmp .= $k . ':' . (is_numeric($v) ? $v : '"' . $v . '"') . ',';
             }
         }
         fwrite($this->fp, p_substr($tmp, 0, p_strlen($tmp) - 1) . ' };');
     } else {
         $tmp = 'ss_info[' . $ss . ']={' . PHP_EOL;
         foreach ($line as $k => $v) {
             if (is_array($v) && count($v) > 0) {
                 array_walk($v, 'array_js');
                 $tmp .= $k . ':[' . implode(',', $v) . '],' . PHP_EOL;
             } elseif (!is_array($v)) {
                 $tmp .= $k . ':' . (is_numeric($v) ? $v : '"' . $v . '"') . ',' . PHP_EOL;
             }
         }
         fwrite($this->fp, p_substr($tmp, 0, p_strlen($tmp) - p_strlen(PHP_EOL) - 1) . ' };' . PHP_EOL);
     }
 }
Example #7
0
    //-- Fin partie personalisable. ------------------------------------------------
    $img->SaveAs($key . '.png')->Render();
}
include_once '../../../../init.php';
include_once INCLUDE_PATH . 'Script.php';
Members::CheckPermsOrDie(AXX_ROOTADMIN);
addons::getinstance()->ButtonRegen($listing, $defaultsetting);
if (isset($_GET['ident'])) {
    include CLASS_PATH . 'img.class.php';
    do_btn(gpc_esc($_GET['ident']));
} else {
    include TEMPLATE_PATH . 'sample.tpl.php';
    $tpl = tpl_sample::getinstance();
    $files = scandir('./');
    foreach ($files as $file) {
        if (p_substr($file, -4) == '.png') {
            unlink($file);
        }
    }
    foreach ($listing as $key => $dummy) {
        $tpl->PushOutput('<span class="color_header"> &#37;BTN_URL%' . $key . '.png </span><img src="./gen.php?ident=' . $key . '&' . time() . '"/><br/>');
    }
    $tpl->PushOutput(<<<x
<script>
window.onload = function() {
    if (parent.location.href != location.href) parent.location.href=parent.location.href+'?done';
};
</script>
x
);
    $tpl->DoOutput(false);
Example #8
0
 ///---
 // TODO: Revoir l'affichage du cron vortex...
 $dates[0] = date('Y-m-d H:i:s');
 $dates[1] = mktime($lngmain['wormholes_hour'], $lngmain['wormholes_minute'], 0, date('m'), date('d') - date('w') + $lngmain['wormholes_day']);
 //    $dates[2] = mktime(3, 01, 0, date('m'), date('d') - date('w') - 7);
 $tpl->admin_vortex($dates, $cleanvortex_delete, DataEngine::config('wormhole_cleaning'));
 //---
 $empire = array();
 $mysql_result = DataEngine::sql('SELECT `EMPIRE` from `SQL_PREFIX_Coordonnee_Joueurs` GROUP BY `EMPIRE` ASC');
 while ($ligne = mysql_fetch_array($mysql_result)) {
     if (trim($ligne['EMPIRE']) == '') {
         continue;
     }
     $cur_emp = htmlentities(stripslashes($ligne['EMPIRE']), ENT_QUOTES, 'utf-8');
     $shw_emp = DataEngine::utf_strip($ligne['EMPIRE']);
     $shw_emp = p_strlen($shw_emp) > 50 ? p_substr($shw_emp, 0, 47) . '...' : $shw_emp;
     $shw_emp = htmlentities($shw_emp, ENT_QUOTES, 'utf-8');
     $empire[$cur_emp] = $shw_emp;
 }
 $tpl->empire_switch($empire, $emp_upd);
 $tpl->empire_allys($empire);
 $tpl->empire_wars($empire);
 $tpl->empire_allywars($allysnb, $warsnb);
 //$tpl->empire_wars($empire, $emp_war);
 //
 //---
 $dates = array();
 $dates[$lng['dates'][0]] = '-1';
 $dates[$lng['dates'][1]] = time();
 $dates[$lng['dates'][2]] = mktime(3, 0, 0, date('m'), date('d') - date('w'));
 $dates[$lng['dates'][3]] = mktime(3, 0, 0, date('m'), date('d') - date('w') - 7);
 /**
  * Parsing donnée planète
  * @param	string
  */
 public function parse_planet($data)
 {
     if ($this->readonly) {
         return false;
     }
     //        $data = str_replace("\n\n", "\n", $data);
     if (DataEngine::$browser->getBrowser() == Browser::BROWSER_IE) {
         $data = implode("\n", explode("      ", $data));
     }
     $data = explode("\n", $data);
     foreach ($data as $k => $v) {
         if (trim($v) != "") {
             $result[] = trim($v);
         }
     }
     $this->GetRessFrom($result, $result2, 1, $this->ressourcesnames, $this->lng['planet_key_0'], '', 'percent_');
     $from_pos = array_search($this->lng['planet_key_1'], $data);
     $to_pos = array_search($this->lng['planet_key_2'], $data);
     $slice = array_slice($data, $from_pos + 1, $to_pos - $from_pos - 2);
     foreach ($slice as $v) {
         if (strpos($v, $this->lng['planet_key_3']) !== false) {
             $result2['Coord'] = str_replace(':', '-', $this->parser->GetInner($v, $this->lng['planet_key_3']));
         }
         if (strpos($v, $this->lng['planet_key_4']) !== false) {
             $result2[0]['percent_water'] = $this->parser->GetInner($v, $this->lng['planet_key_4']);
         }
     }
     $tmp = $this->ressourcesnames;
     $tmp['water'] = null;
     foreach ($tmp as $k => $v) {
         if (!is_numeric($k)) {
             $v = $k;
         }
         $result2[0]["percent_{$v}"] = p_substr($result2[0]["percent_{$v}"], 0, -1, 'utf8');
     }
     return $result2;
 }
Example #10
0
 function GetInner($data, $from, $to = '')
 {
     $l = p_strlen($from);
     $f = p_stripos($data, $from, 0);
     $t = p_stripos($data, $to, $l + $f);
     if ($f === false) {
         $inner = $data;
     } elseif ($t === false) {
         $inner = p_substr($data, $f + $l, -1);
     } else {
         $inner = p_substr($data, $f + $l, $t - $f - $l);
     }
     return trim($inner);
 }