Esempio n. 1
0
 private static function onGMNS(SR_Player $player, SR_Player $target, $arg)
 {
     $pid = $target->getID();
     if (strtolower($arg) === 'on') {
         if (false === SR_NoShout::setNoShout($pid, -1)) {
             return false;
         }
         return $player->message(sprintf('Banned %s from shouting.', $target->getName()));
     } elseif (strtolower($arg) === 'off') {
         if (false === SR_NoShout::setShout($pid)) {
             return false;
         }
         return $player->message(sprintf('Allowed %s to shout again.', $target->getName()));
     } elseif (0 < ($seconds = GWF_TimeConvert::humanToSeconds($arg))) {
         if (false === SR_NoShout::setNoShout($pid, $seconds)) {
             return false;
         }
         return $player->message(sprintf('Banned %s from shouting for %s.', $target->getName(), GWF_TimeConvert::humanDuration($seconds)));
     } else {
         $player->message(Shadowhelp::getHelp($player, 'gmns'));
         return false;
     }
 }
Esempio n. 2
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% <seconds> <the message to alert>. Make %BOT% remember you of something in a specified amount of time.', 'err_seconds' => 'Error in parsing your seconds. Seconds have to be larger or equal to 1. Try 1h13m37s.', 'msg_remember' => 'Ok, i will remember you in %s.', 'err_too_long' => 'This would take too long. Try 2d15m37s', 'err_too_much' => 'You have exhausted your alert slots.'));
global $DOG_PLUG_ALERT_TIMERS;
if (!isset($DOG_PLUG_ALERT_TIMERS)) {
    $DOG_PLUG_ALERT_TIMERS = array();
}
$plug = Dog::getPlugin();
if ($plug->argc() < 2) {
    return $plug->showHelp();
}
$seconds = str_replace('m', 'i', $plug->argv(0));
// Try to parse seconds from input
if (0 >= ($seconds = GWF_TimeConvert::humanToSeconds($seconds))) {
    return $plug->rply('err_seconds');
}
if (GWF_Time::ONE_DAY * 8 < $seconds) {
    return $plug->rply('err_too_long');
}
// Try to parse back duration from parsed seconds
if (false === ($delay = GWF_TimeConvert::humanDurationISO(Dog::getLangISO(), $seconds))) {
    return $plug->rply('err_seconds');
}
$user = Dog::getUser();
if (!isset($DOG_PLUG_ALERT_TIMERS[$user->getID()])) {
    $DOG_PLUG_ALERT_TIMERS[$user->getID()] = 0;
}
if ($DOG_PLUG_ALERT_TIMERS[$user->getID()] >= 3) {
    return $plug->rply('err_too_much');
}
if (!function_exists('dog_plugin_alert_func4')) {
Esempio n. 3
0
 public static function isValidDuration($string, $min, $max)
 {
     $duration = GWF_TimeConvert::humanToSeconds($string);
     return $duration >= $min && $duration <= $max;
 }
Esempio n. 4
0
 private function getTimeout()
 {
     return GWF_TimeConvert::humanToSeconds($this->getConfig('timeout', 'c'));
 }
Esempio n. 5
0
 private function onEdit(GWF_Download $dl)
 {
     $form = $this->getForm($dl);
     if (false !== ($err = $form->validate($this->module))) {
         return $err . $this->templateEdit($dl);
     }
     if (GWF_User::isAdminS()) {
         if (false === $dl->saveVar('dl_price', $form->getVar('price'))) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateEdit($dl);
         }
     }
     $options = 0;
     $options |= isset($_POST['enabled']) ? GWF_Download::ENABLED : 0;
     $options |= isset($_POST['adult']) ? GWF_Download::ADULT : 0;
     $options |= isset($_POST['huname']) ? GWF_Download::HIDE_UNAME : 0;
     $options |= isset($_POST['guest_view']) ? GWF_Download::GUEST_VISIBLE : 0;
     $options |= isset($_POST['guest_down']) ? GWF_Download::GUEST_DOWNLOAD : 0;
     if (false === $dl->saveVars(array('dl_filename' => $form->getVar('filename'), 'dl_gid' => $form->getVar('group'), 'dl_level' => $form->getVar('level'), 'dl_descr' => $form->getVar('descr'), 'dl_options' => $options, 'dl_expire' => GWF_TimeConvert::humanToSeconds($form->getVar('expire'))))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateEdit($dl);
     }
     return $this->module->message('msg_edited') . $this->templateEdit($dl);
 }
Esempio n. 6
0
 public static function getVarValue($value, $type, $min, $max, &$exceed = 0)
 {
     switch ($type) {
         case 'time':
             $value = GWF_TimeConvert::humanToSeconds($value);
             # Fallthrough
         # Fallthrough
         case 'int':
             if (false === is_numeric($value)) {
                 return false;
             }
             if ($min !== NULL && $value < $min) {
                 $exceed = 1;
                 return false;
             }
             if ($max !== NULL && $value > $max) {
                 $exceed = 1;
                 return false;
             }
             return (string) intval($value);
         case 'float':
             if (!is_numeric($value)) {
                 return false;
             }
             if ($min !== NULL && $value < $min) {
                 $exceed = 1;
                 return false;
             }
             if ($max !== NULL && $value > $max) {
                 $exceed = 1;
                 return false;
             }
             return (string) floatval($value);
         case 'text':
             if ($min !== NULL && strlen($value) < $min) {
                 $exceed = 1;
                 return false;
             }
             if ($max !== NULL && strlen($value) > $max) {
                 $exceed = 1;
                 return false;
             }
             return $value;
         case 'bool':
             return self::getBoolValue($value);
         case 'script':
             return $value;
         default:
             return false;
     }
 }
Esempio n. 7
0
 private function onAdd()
 {
     $form = $this->getForm();
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors . $this->templateAdd();
     }
     if (false === ($file = $this->getFile())) {
         $this->uploadedFile($form);
         $file = $form->getVar('file');
     }
     $tempname = $file['tmp_name'];
     if (!file_exists($tempname)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateAdd();
     }
     $mod = $this->module->isModerated($this->module);
     $userid = GWF_Session::getUserID();
     $options = 0;
     $options |= isset($_POST['adult']) ? GWF_Download::ADULT : 0;
     $options |= isset($_POST['huname']) ? GWF_Download::HIDE_UNAME : 0;
     $options |= isset($_POST['guest_view']) ? GWF_Download::GUEST_VISIBLE : 0;
     $options |= isset($_POST['guest_down']) ? GWF_Download::GUEST_DOWNLOAD : 0;
     $options |= $mod ? 0 : GWF_Download::ENABLED;
     $dl = new GWF_Download(array('dl_id' => 0, 'dl_uid' => $userid, 'dl_gid' => $form->getVar('group'), 'dl_level' => $form->getVar('level'), 'dl_token' => GWF_Download::generateToken(), 'dl_count' => 0, 'dl_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'dl_filename' => $form->getVar('filename'), 'dl_realname' => $file['name'], 'dl_descr' => $form->getVar('descr'), 'dl_mime' => GWF_Upload::getMimeType($file['tmp_name']), 'dl_price' => sprintf('%.02f', $form->getVar('price', 0.0)), 'dl_options' => $options, 'dl_voteid' => 0, 'dl_purchases' => 0, 'dl_expire' => GWF_TimeConvert::humanToSeconds($form->getVar('expire'))));
     if (false === $dl->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateAdd();
     }
     $dlid = $dl->getID();
     $filename = 'dbimg/dl/' . $dlid;
     if (false === GWF_Upload::moveTo($file, $filename)) {
         return GWF_HTML::err('ERR_WRITE_FILE', array($filename)) . $this->templateAdd();
     }
     if (false === @unlink($tempname)) {
         return GWF_HTML::err('ERR_WRITE_FILE', array($tempname)) . $this->templateAdd();
     }
     if (false === $dl->createVotes($this->module)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateAdd();
     }
     $this->clearFile();
     if ($mod) {
         $this->sendModMail($dl);
         return $this->module->message('msg_uploaded_mod');
     }
     return $this->module->message('msg_uploaded');
 }