Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Problem z wczytywaniem ikonki w adminList


ωιє∂źмιи.

Rekomendowane odpowiedzi

Opublikowano

Witam, dzisiaj się natknąłem na pewien problem.. ponieważ gdy mam skrypt getIcons który pozwala, że zapisuje wszystkie ikonki na vpsie i gdy wkleję do skryptu adminList ten kod: '$icon[$sgid]' to bot już nie wchodzi na serwer... ale jak nie wkleję tego $icon to normalnie działa. Co mam zrobić aby wszedł na serwer? Mam coś dodać do adminList? Jak tak to co..?

 

adminList

<?php


error_reporting(E_ALL);
class adminList {
    
    private static $eventName = 'adminList';
    private static $config;
    private static $simpleConfig = array();
    
    private static function loadConfig() {
        global $lang;
        $cfg = getEventConfigValue(self::$eventName);
        if ($cfg != false) {
            self::$config = $cfg;
        } else {
            self::$config = self::$simpleConfig;
            echo ": > [".self::$eventName."]: ".$lang->getConsoleLanguage('SIMPLE_CONFIGURATION')."\n";
        }
        return true;
    }
    
    public static function onRegister()
    {
        self::loadConfig();
        return true;
    }
    public static function format_seconds($seconds)
{
    global $ts;
    
    $uptime = array();
    $uptime['days']=floor($seconds / 86400);
    $uptime['hours']=floor(($seconds - ($uptime['days'] * 86400)) / 3600);
    $uptime['minutes']=floor(($seconds - (($uptime['days'] * 86400)+($uptime['hours']*3600))) / 60);
    $uptime['seconds']=floor(($seconds - (($uptime['days'] * 86400)+($uptime['hours']*3600)+($uptime['minutes'] * 60))));
    
    $uptime_text = '';
    
    if ($uptime['days'] > 0) {
        $uptime_text .= $uptime['days'] . ' ' . ($uptime['days'] == 1 ? 'dnia ' : 'dni ');
    }
    
    if ($uptime['hours'] > 0) {
        $uptime_text .= $uptime['hours'] . ' ' . ($uptime['hours'] == 1 ? 'godziny ' : 'godzin ');
    }
    
    if ($uptime['minutes'] > 0) {
        $uptime_text .= $uptime['minutes'] . ' ' . ($uptime['minutes'] == 1 ? 'minuty' : 'minut');
    }
    
    if ($uptime_text == '') {
        $uptime_text .= $uptime['seconds'] . ' sekund';
    }
    
    return $uptime_text;
}
    public static function onThink()
    {        
        global $ts, $sql;
        $output = self::$config['up_description'];
            $groups = array();
            $clients = array();
            $groupnames = array();
            
            foreach (self::$config['groups'] as $sgid)
            {
                foreach ($ts->getElement('data', $ts->getServerGroupClients($sgid)) as $client) 
                {
                    if (!isset($client['cldbid'])) continue;
                    $groups[$sgid][] = $client['cldbid'];
                }
            }
            
            foreach ($groups as $sgid => $cldbids) 
            {
                foreach ($cldbids as $cldbid) 
                {
                    $client = $ts->getElement('data', $ts->clientInfoFromDb($cldbid));
                    if (!empty($client)) {                        
                        $client['cldbid'] = $cldbid;
                        $client['clid'] = 0;
                        $client['cid'] = 0;
                        $client['channel'] = 'Nie znaleziono!';
                        $client['status'] = 'Offline';
                        $clients[$sgid][] = $client;
                    }
                }
            }
            
            
            foreach ($clients as $sgid => $client) 
            {
                foreach ($client as $i => $value) 
                {
                    foreach ($ts->getElement($ts->getClientList('-uid -away -voice -times -groups -info -icon -country -ip'), 'data') as $cld) 
                    {
                        if ($cld['client_database_id'] == $value['client_database_id']) {
                            $clients[$sgid][$i]['status'] = 'Online';
                            if ($cld['client_away'] == 1 or $cld['client_output_muted'] == 1) {
                                $clients[$sgid][$i]['status'] = 'Away';
                            }
                            $clients[$sgid][$i]['cid'] = $cld['cid'];    
                            $clients[$sgid][$i]['clid'] = $cld['clid'];
                            break;
                        }
                    }   
                    foreach ($ts->getElement($ts->getChannelList(), 'data') as $channel)
                    {
                        if ($channel['cid'] == $clients[$sgid][$i]['cid']) {
                            $clients[$sgid][$i]['channel'] = $channel['channel_name'];
                            break;
                        }
                    }
                }
            }
            foreach ($ts->getElement($ts->getServerGroupList(), 'data') as $group)
            {
                $groupnames[$group['sgid']] = $group['name'];
            }
            
            foreach ($groups as $sgid => $value) 
            {
                $countGroup = count($clients[$sgid]);            
                $output .= '[size=13]'$icon[$sgid]' [' . $groupnames[$sgid] . '][/size]\n Adminów w grupie: '.$countGroup.'';
                    foreach ($clients[$sgid] as $client) 
                    {    
                        $output .= '
                    }
            }    
            $output .='\n
            $ts->editChannel(self::$config['channel'], array('channel_description' => $output));            
    
    }
}
?>
  • ';
                            $query = array('last_active');
                            if ($client['status'] == 'Offline') {
                                $output .= ''.$client['client_nickname'].' jest '.$client['status'].' od '.self::format_seconds(time() - $client['client_lastconnected']).'.\n';
                            } else {
                                $query['last_active'] = time();
                                $output .=  '.'/'.$client['client_unique_identifier'].']'.$client['client_nickname'].' jest '.$client['status'].' na kanale .']'.$client['channel'].'.\n';
                            }
                            $output .= '
';
\n Wygenerowane przez: '.getConfigValue('connection','bot_name').'
';

getIcons

<?php

class getIcons {
    
    private static $eventName = 'getIcons';
    private static $config;
    private static $simpleConfig = array();
    
    private static function loadConfig() {
        global $lang;
        $cfg = getEventConfigValue(self::$eventName);
        if ($cfg != false) {
            self::$config = $cfg;
        } else {
            self::$config = self::$simpleConfig;
            echo ": > [".self::$eventName."]: ".$lang->getConsoleLanguage('SIMPLE_CONFIGURATION')."\n";
        }
        return true;
    }
    
    public static function onRegister()
    {
        self::loadConfig();
        return true;
    }
    public static function onThink()
    {
        global $lang, $ts, $serverInfo;    

        $icon_arr = array();
        $ip = self::$config['virtualserver_ip'];
        $port= $serverInfo['virtualserver_port'];
        $error = '';
        $count=0;
        $count_del = 0;

        $ft= $ts->ftGetFileList(0, '', '/icons');
        
            if(is_dir(self::$config['file_path'].'icons/')){
                $handler = @opendir(self::$config['file_path'].'icons/');
            }else{
                if(@mkdir(self::$config['file_path'].'icons/', 0777)){
                    $handler = @opendir(self::$config['file_path'].'icons/');
                }
            }
        while($datei = readdir($handler)){
            $icon_arr[] = $datei;
        }
            
        $noIcon=0;
        if(!empty($ft['data'])){
            foreach($ft['data'] as $key2 => $value2){
                $foundIcons[] = $value2['name'];
                }
        }
        foreach($icon_arr as $key => $value){
            if(!empty($ft['data'])){
                if($value != "." and $value != ".." and in_array($value, $foundIcons)){
                    $noIcon=1;
                    break;
                }
                if($noIcon == 0){
                    if(@unlink(self::$config['file_path'].'icons/'.$value)){
                        $count_del++;
                    }
                }
            }elseif(strpos($ft['errors'][0], 'ErrorID: 2568 | Message: insufficient client permissions failed_permid')===false){
                if($value!="." AND $value!=".."){
                    if(@unlink(self::$config['file_path'].'icons/'.$value)){
                        $count_del++;
                    }
                }
            }
        }
            
    if(!empty($ft['data'])){    
        foreach($ft['data'] AS $key => $value){
            if(substr($value['name'], 0, 5)=='icon_'){
                if(!in_array($value['name'], $icon_arr)){
                    $count++;
                    $ft2 = $ts->ftInitDownload("/".$value['name'], 0);
                    var_dump($ft2);
                    if($ft2['bool'] !== false and !empty($ft2['data']['port'])){
                        $con_ft = @fsockopen($ip, $ft2['data']['port'], $errnum, $errstr, 10);
                        if($con_ft){
                            fputs($con_ft, $ft2['data']['ftkey']);
                            $data='';
                            while (!feof($con_ft)) 
                                {
                                $data .= fgets($con_ft, 4096);
                                }
                            $handler2 = @fopen(self::$config['file_path'].'icons/'.$value['name'], "w+");
                            if($handler2!==false){
                                fwrite($handler2, $data);
                                fclose($handler2);
                            }else{
                                $error.=sprintf("Can't create or open \"icons/%s-%s/%s\"", $ip, $port, $value['name'])."<br />";
                                break;
                            }
                        }else{
                            $error.= "Connection to the filetransfer server failed."."<br />";
                            break;
                        }
                    }else{
                        $error.=$ft2['errors'][0]."<br />";
                        }
                }
            }
        }
        if($count!=0 AND empty($error)){
                $noerror .= sprintf("Pobra³em %d nowych ikon.", $count)."<br />";
        }
    }
    if($count_del!=0){
            $noerror .= sprintf("Usun¹³em %d starych ikon.", $count_del)."<br />";
    }
    if($error = ''){
        echo $noerror;
    }else {
        echo $error;
    }

        
    }
}
?>

Opublikowano
50 minut temu, orkin napisał:

Doklejasz zmienną do stringa. Musisz przed i po dodać kropkę ".".

Wtedy wyświetla się taki błąd:

PHP Notice:  Undefined variable: icon in /home/bot/files/adminList.php on line 123

Linijka 123:

$output .= ''.$icon[$sgid].' [' . $groupnames[$sgid] . ']\n Adminów w grupie: '.$countGroup.'';

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...