Little Badge Script

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
I posted this on the PlusEMU Support thread also because I was asking for help but I managed to figure it out a bit so this may help some of you

I was reading up on some stuff and managed to come together with this after compiling together some examples I found
This will auto give you the queries so you can just truncate your badge_definitions table and run this and it will make sure every badge works
If anyone wants to expand on this to make it search for if the badge already exists and skips that query from showing to stop duplicates so you dont have to truncate everytime It would be highly appreciated because its 5am for me right now and my mind isnt so fresh
Just replace DATABASENAME with your database name
PHP:
<?php
$target = "c_images/album1584/";
$weeds = array('.', '..');
$directories = array_diff(scandir($target), $weeds);  
foreach($directories as $value)
{
$gifkill=str_replace('.gif', '', $value);
$gif2kill=str_replace('.GIF', '', $gifkill);
$uppercasewords=ucwords($gif2kill);
if(is_file($target.$value))
{
echo "INSERT INTO `DATABASENAME`.`badge_definitions` (`code`, `required_right`) VALUES ('".$uppercasewords."', '');<br />";
}
}
?>
 

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
If you wanna simplify it a tiny bit you can do this
PHP:
$gifkill=str_replace('.gif', '', $value);
$gif2kill=str_replace('.GIF', '', $gifkill);

to this

$gif2kill = str_replace(['.gif', '.GIF'], '', $value);
 

Brought

更加努力
Jan 14, 2013
593
203
If you wanna simplify it a tiny bit you can do this
PHP:
$gifkill=str_replace('.gif', '', $value);
$gif2kill=str_replace('.GIF', '', $gifkill);

to this

$gif2kill = str_replace(['.gif', '.GIF'], '', $value);
Why not just update your original code?
 

BIOS

ಠ‿ಠ
Apr 25, 2012
906
247
You could also do it this way
PHP:
define('DATABASENAME', 'habbo'); // change this to your database name

$get = glob('c_images/album1584/*.{gif,GIF}', GLOB_BRACE);
foreach($get as $badge){
    if(is_file($badge)){
        echo "INSERT INTO `".DATABASENAME."`.`badge_definitions` (`code`, `required_right`) VALUES ('".basename($badge, '.gif')."', '');";
        echo '<br />';
    }
}
 

Brought

更加努力
Jan 14, 2013
593
203
You could also do it this way
PHP:
define('DATABASENAME', 'habbo'); // change this to your database name

$get = glob('c_images/album1584/*.{gif,GIF}', GLOB_BRACE);
foreach($get as $badge){
    if(is_file($badge)){
        echo "INSERT INTO `".DATABASENAME."`.`badge_definitions` (`code`, `required_right`) VALUES ('".basename($badge, '.gif')."', '');";
        echo '<br />';
    }
}
<3_<3
 

Users who are viewing this thread

Top