Example #1
0
 private function announceVideo(array $data)
 {
     // Pick ISO for channel?
     if (false !== ($chan = Dog::getChannel())) {
         $iso = $chan->getLangISO();
     } else {
         $iso = Dog::getUser()->getLangISO();
     }
     $vars = array($data['title'], GWF_TimeConvert::humanDurationISO($iso, $data['duration']), sprintf('%.02f', $data['rating']), number_format($data['views']), number_format($data['num_raters']));
     Dog::reply($this->langISO($iso, 'video', $vars));
 }
Example #2
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;
     }
 }
Example #3
0
    $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')) {
    function dog_plugin_alert_func4(array $args)
    {
        global $DOG_PLUG_ALERT_TIMERS;
        $scope = $args[0];
        $scope instanceof Dog_Scope;
Example #4
0
 public static function isValidDuration($string, $min, $max)
 {
     $duration = GWF_TimeConvert::humanToSeconds($string);
     return $duration >= $min && $duration <= $max;
 }
Example #5
0
 private function getTimeout()
 {
     return GWF_TimeConvert::humanToSeconds($this->getConfig('timeout', 'c'));
 }
Example #6
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);
 }
Example #7
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;
     }
 }
Example #8
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');
 }
Example #9
0
 public function onNPCBountyTalk(SR_Player $player, $word, array $args)
 {
     switch (count($args)) {
         case 1:
             $this->reply("Yes. Try #ttj bounty <player{server}> to see the bounty for a player. Try #ttj bounty <player{server}> <nuyen> to raise the bounty for a player.");
             return true;
         case 2:
             if (false === ($target = Shadowrun4::loadPlayerByName($args[1]))) {
                 $this->reply("This player is unknown. Try #ttj <nickname{serverid}>.");
             } else {
                 $this->reply(SR_Bounty::displayBountyPlayer($target));
             }
             return true;
         case 3:
             if (false === ($target = Shadowrun4::loadPlayerByName($args[1]))) {
                 $this->reply("This player is unknown. Try #ttj <nickname{serverid}>.");
                 return true;
             }
             $nuyen = (int) $args[2];
             $min_nuyen = SR_Bounty::getMinNuyen($target);
             if ($nuyen < $min_nuyen) {
                 $this->reply(sprintf('The minimum bounty for %s is %s.', $target->getName(), Shadowfunc::displayNuyen($min_nuyen)));
                 return true;
             }
             if (false === $player->pay($nuyen)) {
                 $this->reply(sprintf("You don't seem to have %s.", Shadowfunc::displayNuyen($nuyen)));
                 return false;
             }
             if (false === SR_Bounty::insertBounty($player, $target, $nuyen)) {
                 $this->reply(sprintf('Database error in %s line %s.', __FILE__, __LINE__));
                 return false;
             }
             $bounty = Shadowfunc::displayNuyen($nuyen);
             $total = Shadowfunc::displayNuyen($target->getBase('bounty'));
             $target->message(sprintf("%s put a bounty on you: +%s = %s!", $player->getName(), $bounty, $total));
             $this->reply(sprintf('You put a bounty of %s on %s. This is valid for %s. Total bounty for this chummer is %s now.', $bounty, $target->getName(), GWF_TimeConvert::humanDuration(SR_Bounty::TIMEOUT), $total));
             return true;
         default:
             return false;
     }
 }
Example #10
0
 private function getTooltip(GWF_Module $mod, $varname, array $var)
 {
     switch ($var['mv_type']) {
         case 'int':
             $default_txt = $this->module->lang('tt_int', array($var['mv_min'], $var['mv_max']));
             break;
         case 'text':
             $default_txt = $this->module->lang('tt_text', array($var['mv_min'], $var['mv_max']));
             break;
         case 'bool':
             $default_txt = $this->module->lang('tt_bool');
             break;
         case 'script':
             $default_txt = $this->module->lang('tt_script');
             break;
         case 'time':
             $min = GWF_TimeConvert::humanDuration((int) $var['mv_min']);
             $max = GWF_TimeConvert::humanDuration((int) $var['mv_max']);
             $default_txt = $this->module->lang('tt_time', array($min, $max));
             break;
         case 'float':
             $default_txt = $this->module->lang('tt_float', array($var['mv_min'], $var['mv_max']));
             break;
     }
     $extkey = 'tt_cfg_' . $varname;
     if ($extkey === ($extend = $mod->lang($extkey))) {
         $extend = '';
     } else {
         $extend = "\n" . $extend;
     }
     return $default_txt . $extend;
 }