Skip to content

Commit

Permalink
- fix warnings under PHP 5.3
Browse files Browse the repository at this point in the history
- fix clean xdcclistfile
- add Traffic insgesamt
  • Loading branch information
cvs committed Jul 17, 2010
1 parent 02492a1 commit 0cdaee3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 50 deletions.
5 changes: 3 additions & 2 deletions iroffer-sample-de.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# IRC-Nick des Bots
#
# 1) Name des Verzeichnissses ist der Nick
$nick = ereg_replace( '/[^/]*[.]php$', '', $_SERVER[ 'PHP_SELF' ] );
$nick = ereg_replace( '^/(.*/)*', '', $nick );
$nick = dirname( $_SERVER[ 'PHP_SELF' ] );
$nick = basename( $nick );
$nick = 'XDCC|'.$nick;
# 2) Nick wird fest eingetragen:
#$nick = 'XDCC|irofferbot';
Expand Down Expand Up @@ -65,6 +65,7 @@
# 'dailytext' => "Traffic heute",
# 'weeklytext' => "Traffic diese Woche",
# 'monthlytext' => "Traffic diesem Monat",
# 'downltext' => "Traffic insgesammt",
);

# Ende der Einstellungen
Expand Down
5 changes: 3 additions & 2 deletions iroffer-sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# IRC-Nick des Bots
#
# 1) Name des Verzeichnissses ist der Nick
$nick = ereg_replace( '/[^/]*[.]php$', '', $_SERVER[ 'PHP_SELF' ] );
$nick = ereg_replace( '^/(.*/)*', '', $nick );
$nick = dirname( $_SERVER[ 'PHP_SELF' ] );
$nick = basename( $nick );
$nick = 'XDCC|'.$nick;
# 2) Nick wird fest eingetragen:
#$nick = 'XDCC|irofferbot';
Expand Down Expand Up @@ -65,6 +65,7 @@
# 'dailytext' => "Traffic heute",
# 'weeklytext' => "Traffic diese Woche",
# 'monthlytext' => "Traffic diesem Monat",
# 'downltext' => "Traffic insgesammt",
);

# Ende der Einstellungen
Expand Down
90 changes: 44 additions & 46 deletions iroffer-state.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,27 @@
#

$meta_generator = '
<meta name="generator" content="iroffer-state 2.15, iroffer.dinoex.net">
<meta name="generator" content="iroffer-state 2.16, iroffer.dinoex.net">
';

# IRC-Farbe-Codes ausblenden
$strip_in_names = array (
'^ *- *',
"\002",
"\0030[,]0",
"\0030[,]5",
"\0030",
"\00312",
"\00314",
"\00315",
"\0033",
"\0034",
"\0035\037",
"\0035",
"\0037",
"\0032",
"\00310",
"\003",
"\017",
'/^ *- */',
"/\002/",
"/\003[0-9][0-9][,][0-9][0-9]/",
"/\003[0-9][,][0-9][0-9]/",
"/\003[0-9][0-9]/",
"/\003[0-9]/",
"/\037/",
"/\017/",
);

$bowser = '';
if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) )
$bowser = $_SERVER['HTTP_ACCEPT_LANGUAGE'];

if ( strstr( $bowser, 'de' ) ) {
setlocale(LC_TIME, 'de_DE');
$caption = array(
'id' => 'de',
'listf' => 'Datei-Liste',
Expand Down Expand Up @@ -69,6 +61,7 @@
'titlegroup' => 'Liste dieser Packs anzeigen',
);
} else {
setlocale(LC_TIME, 'en_EN');
$caption = array(
'id' => 'en',
'listf' => 'File list',
Expand Down Expand Up @@ -139,7 +132,8 @@ function read_sizecache( $filename ) {
fclose($fp);
$ydata = strtok($tread, "\n");
while ($ydata !== false) {
if ( ereg( '[:]', $ydata ) ) {
$pos = strrpos($ydata, ':');
if ($pos > 0) {
list( $key, $tsize ) = explode(':', $ydata, 2);
if ( $tsize > 0 )
$sizecache[ $key ] = $tsize;
Expand Down Expand Up @@ -173,7 +167,7 @@ function filesize_cache( $filename ) {
return $sizecache[ $filename ];
}
$localfile = $filename;
if ( !ereg( '^/', $filename ) )
if ( substr( $filename , 0, 1 ) != '/' )
$localfile = $base_path.$filename;
if ( $chroot_path != '' )
$localfile = $chroot_path.$localfile;
Expand Down Expand Up @@ -226,15 +220,16 @@ function makesize( $nbytes ) {
function clean_names( $text2 ) {
global $strip_in_names;

$text2 = str_replace( "\000", '', $text2 );
foreach ( $strip_in_names as $skey => $sdata) {
$text2 = ereg_replace( $sdata, '', $text2 );
$text2 = preg_replace( $sdata, '', $text2 );
}
return $text2;
}

function cgi_escape( $string ) {
$string = ereg_replace( '[&]', '%26', $string );
$string = ereg_replace( '[+]', '%2B', $string );
$string = str_replace( '&', '%26', $string );
$string = str_replace( '+', '%2B', $string );
return $string;
}

Expand Down Expand Up @@ -442,7 +437,7 @@ function make_self_back( $order ) {

function read_removed( $statefile ) {

$filename = ereg_replace( '[.]state$', '.removed.xdcc', $statefile );
$filename = preg_replace( '/[.]state$/', '.removed.xdcc', $statefile );

if ( !file_exists( $filename ) )
return;
Expand All @@ -461,14 +456,15 @@ function read_removed( $statefile ) {
continue;
}

if ( ereg( '^Do Not Edit This File[:] ', $data ) ) {
if ( strstr( $data, 'Do Not Edit This File: ' ) ) {
list( $key, $text ) = explode(': ', $data, 2);
list( $irec, $iband, $itotal, $irest ) = explode(' ', $text, 4);
$this->total[ 'downl' ] += $itotal;
$data = strtok("\n");
continue;
}
if ( !ereg( ' ', $data ) ) {
$pos = strpos( $data, ' ' );
if ( $pos === false ) {
$data = strtok("\n");
continue;
}
Expand Down Expand Up @@ -506,7 +502,7 @@ function read_removed( $statefile ) {
}

function read_status( $statefile ) {
$filename = ereg_replace( '[.]state$', '.txt', $statefile );
$filename = preg_replace( '/[.]state$/', '.txt', $statefile );

if ( !file_exists( $filename ) )
return;
Expand All @@ -524,18 +520,17 @@ function read_status( $statefile ) {
$data = strtok("\n");
continue;
}

if ( ereg( '^ *[*]* [0-9]* [Pp]acks ', $data ) ) {
if ( preg_match( '/^ *[*]* * [0-9]* [Pp]acks /', $data ) ) {
$data = preg_replace('/\s\s+/', ' ', $data);
$words = explode(' ', $data);

if ( !isset( $this->total[ 'freeslots' ] ) )
$this->total[ 'freeslots' ] = $words[ 9 ];
if ( !isset( $this->total[ 'maxslots' ] ) )
$this->total[ 'maxslots' ] = $words[ 11 ];

for ( $i = 14; isset( $words[ $i ]); $i += 2 ) {
for ( $i = 4; isset( $words[ $i ]) && isset( $words[ $i + 1 ]); $i += 1 ) {
$words[ $i + 1 ] = str_replace( ',', '', $words[ $i + 1 ] );
switch ( $words[ $i ] ) {
case 'slots':
if ( !isset( $this->total[ 'freeslots' ] ) )
$this->total[ 'freeslots' ] = $words[ $i - 3 ];
if ( !isset( $this->total[ 'maxslots' ] ) )
$this->total[ 'freeslots' ] = $words[ $i - 1 ];
case 'Queue:':
if ( !isset( $this->total[ 'queue' ] ) )
$this->total[ 'queue' ] = $words[ $i + 1 ];
Expand All @@ -557,14 +552,16 @@ function read_status( $statefile ) {
$data = strtok("\n");
continue;
}
if ( ereg( '^ *[*]* Bandwidth Usage ', $data ) ) {
if ( preg_match( '/^ *[*]* * Bandwidth Usage /', $data ) ) {
$data = preg_replace('/\s\s+/', ' ', $data);
$words = explode(' ', $data);
if ( !isset( $this->total[ 'current' ] ) )
$this->total[ 'current' ] = str_replace( ',', '', $words[ 9 ] );

for ( $i = 10; isset( $words[ $i ]); $i += 2 ) {
for ( $i = 4; isset( $words[ $i ]) && isset( $words[ $i + 1 ]); $i += 1 ) {
$words[ $i + 1 ] = str_replace( ',', '', $words[ $i + 1 ] );
switch ( $words[ $i ] ) {
case 'Current:':
if ( !isset( $this->total[ 'current' ] ) )
$this->total[ 'current' ] = $words[ $i + 1 ];
break;
case 'Cap:':
if ( !isset( $this->total[ 'cap' ] ) )
$this->total[ 'cap' ] = $words[ $i + 1 ];
Expand Down Expand Up @@ -674,8 +671,8 @@ function read_state( )
break;
$text = substr( $filedata, $i + 8, $len - 8 );
$tver = clean_names( $text );
$tver = ereg_replace( ',.*$', '', $tver );
$tver = ereg_replace( '\[.*\]', '', $tver );
$tver = preg_replace( '/,.*$/', '', $tver );
$tver = preg_replace( '/\[.*\]/', '', $tver );
$this->total[ 'version' ] = $tver;
break;
case 257: # TIMESTAMP
Expand Down Expand Up @@ -732,7 +729,7 @@ function read_state( )
}
if ( isset( $this->info[ $fpacks ][ 'xx_desc' ] ) )
break;
$text = ereg_replace( '^.*[/]', '', $fname );
$text = preg_replace( '/^.*[\/]/', '', $fname );
$text = clean_names( $text );
if ( $max_filename_len > 0 )
$text = max_name_len( $text, $max_filename_len );
Expand Down Expand Up @@ -836,7 +833,7 @@ function write_table( )
global $caption;

$ausgabe = array();
$nick2 = ereg_replace( '[^A-Za-z_0-9]', '', $this->nick );
$nick2 = preg_replace( '/[^A-Za-z_0-9]/', '', $this->nick );

if ( $this->support_groups == 0 )
$_GET[ 'group' ] = '*';
Expand Down Expand Up @@ -1115,6 +1112,7 @@ function write_table( )
';

$traffic = array (
'downl' => "Traffic insgesamt",
'daily' => "Traffic heute",
'weekly' => "Traffic diese Woche",
'monthly' => "Traffic diesem Monat",
Expand Down Expand Up @@ -1143,7 +1141,7 @@ function write_table( )
</tbody>
</table>
<br>
<!-- iroffer-state 2.15 -->
<!-- iroffer-state 2.16 -->
<a class="credits" href="http://iroffer.dinoex.net/">'.$caption[ 'source' ].'</a>
';

Expand Down

0 comments on commit 0cdaee3

Please sign in to comment.