Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global $QUOTES;
- global $QMD5;
- if(!is_file('quotes.ini')){
- $f = fopen('quotes.ini','w');
- fwrite($f,"[quotes]\n0 = \"This is a quote!\"");
- fclose($f);
- }
- $GLOBALS['QMD5'] = md5_file('quotes.ini');
- set_ini_array(parse_ini_file('quotes.ini',true),'QUOTES');
- function saveQ(){
- write_ini_file($GLOBALS['QUOTES'],'quotes.ini',true);
- $GLOBALS['QMD5'] = md5_file('quotes.ini');
- }
- function array_first_open($a){
- for($i = 0;$i<count($a);$i++){
- if(!isset($a[$i])){
- return $i;
- }
- }
- return count($a);
- }
- function M_quote($args,$ex){
- if(md5_file('quotes.ini')!=$GLOBALS['QMD5']){
- $args['server']->out("-----Reloading Quote Database----");
- set_ini_array(parse_ini_file('quotes.ini',true),'QUOTES');
- $GLOBALS['QMD5'] = md5_file('quotes.ini');
- }
- $u = user($args['nick']);
- switch($args['cmd']){
- case '!quote':
- if(count($GLOBALS['QUOTES']['quotes'])!=0){
- if(isset($ex[4])){
- if(isset($GLOBALS['QUOTES']['quotes'][$ex[4]])){
- $args['server']->reply("Quote ".$ex[4].": ".$GLOBALS['QUOTES']['quotes'][$ex[4]]);
- }else{
- $args['server']->reply("Quote ".$ex[4]." not found");
- }
- }else{
- $i = rand(0,count($GLOBALS['QUOTES']['quotes'])-1);
- $args['server']->reply("Quote ".$i.": ".$GLOBALS['QUOTES']['quotes'][$i]);
- }
- }else{
- $args['server']->reply("Quote database is empty");
- }
- break;
- case '!addquote':
- if($u&&isset($u['active'])&&$u['rank']>=3){
- $msg = '';
- foreach($ex as $i => $v){
- if($i>4){
- $msg = $msg.' '.$v;
- }elseif($i == 4){
- $msg = $v;
- }
- }
- $GLOBALS['QUOTES']['quotes'][array_first_open($GLOBALS['QUOTES']['quotes'])] = $msg;
- saveQ();
- $args['server']->reply("Quote added");
- }
- break;
- case '!removequote':
- if($u&&isset($u['active'])&&$u['rank']>=3&&isset($ex[4])){
- unset($GLOBALS['QUOTES']['quotes'][$ex[4]]);
- saveQ();
- }
- break;
- case '!countquotes':
- $c = 0;
- foreach($GLOBALS['QUOTES']['quotes'] as $i => $q){
- if(isset($GLOBALS['QUOTES']['quotes'][$i])){
- $c++;
- }
- }
- $args['server']->reply("Quote count: ".$c);
- break;
- }
- }
- regModule('quote','M_quote');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement