Exemple #1
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     if (false === ($result2 = Common::substrFrom($result, '<br /><br />', false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $stats = explode(':', $result2);
     if (count($stats) !== 7) {
         //			if ($result2 === '0') {
         //				return array(0, 0);
         //			}
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     # username:rank:score:maxscore:challssolved:challcount:usercount
     $uname = $stats[0];
     $rank = intval($stats[1]);
     $onsitescore = intval($stats[2]);
     $maxscore = intval($stats[3]);
     $challssolved = intval($stats[4]);
     $challcount = intval($stats[5]);
     $usercount = intval($stats[6]);
     if ($maxscore === 0 || $challcount === 0 || $usercount === 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($onsitescore, $rank, $challssolved, $maxscore, $usercount, $challcount);
 }
Exemple #2
0
 public static function addToBlacklist($email)
 {
     if (false === ($domain = Common::substrFrom($email, '@', false))) {
         $domain = $email;
     }
     if (self::isBlacklisted($domain)) {
         return true;
     }
     return self::table(__CLASS__)->insertAssoc(array('eb_domain' => $domain), false);
 }
 public function __call($name, $args)
 {
     if (false === ($mo = Common::substrUntil($name, '_'))) {
         return GWF_HTML::error('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     $me = Common::substrFrom($name, '_');
     if (false === ($module = GWF_Module::loadModuleDB($mo))) {
         return GWF_HTML::error('ERR_MODULE_MISSING', array(__FILE__, __LINE__));
     }
     return $module->execute($me);
 }
Exemple #4
0
function warscore_function($socket, $pid)
{
    # Init GWF
    $gwf = new GWF3(getcwd(), array('website_init' => false, 'autoload_modules' => false, 'load_module' => false, 'start_debug' => true, 'get_user' => false, 'log_request' => false, 'no_session' => true, 'store_last_url' => false, 'ignore_user_abort' => false));
    gdo_db();
    GWF_Debug::setDieOnError(false);
    GWF_HTML::init();
    if (false === ($wechall = GWF_Module::loadModuleDB('WeChall', true, true, true))) {
        warscore_error($socket, 'Cannot load WeChall!');
    }
    $wechall->includeClass('WC_Warbox');
    $wechall->includeClass('WC_WarToken');
    $wechall->includeClass('WC_Warflag');
    $wechall->includeClass('WC_Warflags');
    $wechall->includeClass('sites/warbox/WCSite_WARBOX');
    if (false === ($input = socket_read($socket, 2048))) {
        warscore_error($socket, 'Read Error 1!');
    }
    warscore_debug("GOT INPUT: {$input}");
    if (false === ($username = Common::substrUntil($input, "\n", false))) {
        warscore_error($socket, 'No username sent!');
    }
    if (false === ($user = GWF_User::getByName($username))) {
        warscore_error($socket, 'Unknown user!');
    }
    warscore_debug("GOT USER: {$username}");
    if ('' === ($token = Common::substrFrom($input, "\n", ''))) {
        warscore_error($socket, 'No token sent!');
    }
    $token = trim(Common::substrUntil($token, "\n", $token));
    if (!WC_WarToken::isValidWarToken($user, $token)) {
        warscore_error($socket, 'Invalid Token!');
    }
    if (!socket_getpeername($socket, $client_ip, $client_port)) {
        warscore_error($socket, 'Socket Error 2!');
    }
    echo "{$client_ip}\n";
    $boxes = WC_Warbox::getByIP($client_ip);
    if (count($boxes) === 0) {
        warscore_error($socket, 'Unknown Warbox!');
    }
    warscore_debug("GOT N BOXES: " . count($boxes));
    $curr_port = 0;
    foreach ($boxes as $box) {
        $box instanceof WC_Warbox;
        if ($curr_port !== $box->getVar('wb_port')) {
            $curr_port = $box->getVar('wb_port');
            warscore_identd($socket, $box, $user, $client_ip, $client_port);
        }
    }
    socket_write($socket, 'Bailing out! You should not see me.');
    socket_close($socket);
    die(0);
}
Exemple #5
0
 function getRandomRadio($term)
 {
     $term = str_replace(" ", "+", $term);
     $url = 'http://hagbard.host-ed.me/intranet/radio.php?out=inline&shuffle=true&limit=1&search=' . urlencode($term);
     $content = GWF_HTTP::getFromUrl($url . str_replace("%23", "#", urlencode($term)) . '*');
     if ($content === false || strlen($content) == 0) {
         return false;
     }
     echo $content . PHP_EOL;
     $temp = explode('|', $content, 2);
     return array(Common::substrFrom($temp[1], ') ', $temp[1]), $temp[0]);
 }
Exemple #6
0
 /**
  * @param string $cityname
  * @param string $arg
  * @return SR_Location
  */
 public static function getLocationByAbbrev($cityname, $arg)
 {
     $player = Shadowrun4::getCurrentPlayer();
     if (false !== ($c = Common::substrUntil($arg, '_', false))) {
         $cityname = $c;
         $arg = Common::substrFrom($arg, '_', $arg);
     }
     if (false === ($city = Shadowrun4::getCityByAbbrev($cityname))) {
         self::reply($player, 'Unknown city: ' . $cityname);
         return false;
     }
     $city instanceof SR_City;
     return $city->getLocationByAbbrev($arg);
 }
Exemple #7
0
 private function populateFromQueue()
 {
     $type = 1;
     $data = NULL;
     while (false !== msg_receive($this->queue, 1, $type, 16384, $data, false, MSG_IPC_NOWAIT)) {
         $uid = Common::substrUntil($data, ':');
         $message = Common::substrFrom($data, ':');
         echo "GOT {$uid}:{$message}\n";
         if (false !== ($socket = $this->getSocketByResourceB($uid))) {
             $frame = WebSocketFrame::create(WebSocketOpcode::TextFrame, $message);
             $socket->write($frame->encode());
         }
     }
 }
Exemple #8
0
 public function on_scum_Pc()
 {
     if (false === ($chanel = Dog::getChannel())) {
         return Dog::rply('err_only_channel');
     }
     $user = Dog::getUser();
     $msg = $this->msgarg();
     $command = Common::substrUntil($msg, ' ', $msg);
     $message = Common::substrFrom($msg, ' ', '');
     switch ($command) {
         case '':
         case 'help':
             $out = $this->scumHelp($message);
             break;
         case 'init':
             $out = $this->scumInit($user);
             break;
         case 'join':
             $out = $this->scumJoin($user);
             break;
         case 'start':
             $out = $this->scumStart($user);
             break;
         case 'cards':
             $out = $this->scumCards($user);
             break;
         case 'turn':
         case 'deck':
             $out = $this->scumDeck($user);
             break;
         case 'top5':
             $out = $this->scumTop5($user, $message);
             break;
         case 'stats':
             $out = $this->scumStats($user, $message);
             break;
         case 'abort':
             $out = $this->scumAbort($user);
             break;
         case 'pass':
             $out = $this->scumPass($user);
             break;
         default:
             $out = $this->scumPlay($user, $msg, false);
             break;
     }
     return Dog::reply($out);
 }
Exemple #9
0
 public static function execute(SR_Player $player, array $args)
 {
     if (count($args) === 0) {
         Shadowcmd_known_spells::execute($player, array());
         return false;
     }
     $sn = array_shift($args);
     $wanted_level = Common::substrFrom($sn, ':', true);
     $sn = Common::substrUntil($sn, ':', $sn);
     if (false === ($spell = $player->getSpell($sn))) {
         $player->msg('1048');
         //			self::rply($player, '1048');
         // 			$player->message(sprintf('You don\'t know the %s spell.', $sn));
         return false;
     }
     $spell->setMode(SR_Spell::MODE_SPELL);
     return $spell->onCast($player, $args, $wanted_level);
 }
Exemple #10
0
 function dog_trac_helper4($entry, $fullpath, $search, $casei = false)
 {
     if ($casei === true) {
         if (stripos($fullpath, $search) !== false) {
             if (strpos($fullpath, '/disabled_modules/') === false) {
                 global $__DOG_TRAC_RESULTS;
                 $__DOG_TRAC_RESULTS[] = Common::substrFrom($fullpath, GWF_PATH);
             }
         }
     } else {
         if (strpos($fullpath, $search) !== false) {
             if (strpos($fullpath, '/disabled_modules/') === false) {
                 global $__DOG_TRAC_RESULTS;
                 $__DOG_TRAC_RESULTS[] = Common::substrFrom($fullpath, GWF_PATH);
             }
         }
     }
 }
Exemple #11
0
 private static function parseSudoshRow(Module_Audit $module, $row, $fh2)
 {
     // 		echo $row;
     if (false === ($row2 = Common::substrFrom($row, '-sudosh: ', false))) {
         return self::error('Invalid line: ' . $row);
     } elseif (Common::startsWith($row2, 'created')) {
         return self::parseSudoCreated($module, $row2);
     } elseif (Common::startsWith($row2, 'destroyed')) {
         return self::parseSudoDestroyed($module, $row2);
     } elseif (Common::startsWith($row2, 'st')) {
         return true;
         # skip
     } elseif (false === ($id = Common::substrUntil($row2, ':', false))) {
         return self::error('Invalid line: ' . $row);
     } elseif (false === ($row2 = Common::substrFrom($row2, ':', false))) {
         return self::error('Invalid line: ' . $row);
     } else {
         return self::appendToLog($module, $id, $row2);
     }
 }
Exemple #12
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $file = explode('<br>', $result);
     if (count($file) !== 5) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     //		$ranking = $file[1];
     list($ranking, $usercount) = explode('/', trim(Common::substrFrom($file[1], ':')));
     //		$usercount = Common::substrFrom($ranking, "/");
     $challstats = $file[3];
     $challcount = Common::substrFrom($challstats, "/");
     $points = $file[2];
     $back = array();
     preg_match('#(\\d*)\\/(\\d*)#', $points, $back);
     if (count($back) !== 3 || $back[1] < 0 || $back[1] > $back[2] || $usercount == 0 || $challcount == 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($back[1], $ranking, -1, $back[2], $usercount, $challcount);
 }
Exemple #13
0
 /**
  *
  * @param string $user the username
  * @param string|char $message the guess
  * @return the answer
  */
 public function onGuess($user, $message)
 {
     $message = trim($message);
     if ($this->finish) {
         if ($message === 'false') {
             $this->CONFIG['solution_allowed_everytime'] = false;
         }
         $iso = Common::substrFrom($message, ' ', Dog::getChannel()->getLangISO());
         $this->onStartGame($iso);
     } elseif ($message === '') {
         $this->sendOutput('The game has already started');
     } else {
         if (GWF_String::strlen($message) !== 1) {
             $this->trySolution($user, $message);
         } else {
             $this->tryChar($user, $message);
         }
         if (GWF_String::toLower($this->grid) === GWF_String::tolower($this->solution)) {
             $this->winGame($nick);
         }
     }
     return $this->clearOutput();
 }
Exemple #14
0
 /**
  * Call a hook. User is a default argument. calls hook($user, array $args)
  * @param string $name unique ID
  * @param GWF_User $user the current user
  * @param array $args
  */
 public static function call($name, GWF_User $user, array $args = array())
 {
     self::initHooks();
     if (!isset(self::$HOOKS[$name])) {
         // 			GWF_Log::logCritical('Unknown hook: '.$name);
         return true;
     }
     $output = '';
     foreach (self::$HOOKS[$name] as $hook) {
         $modulename = Common::substrFrom($hook[0], '_');
         if (false !== ($module = GWF_Module::loadModuleDB($modulename, true, true))) {
             $output .= self::cleanResult($hook, call_user_func(array($module, $hook[1]), $user, $args));
         }
     }
     if ($output === '') {
         return true;
     }
     GWF_Website::addDefaultOutput($output);
     return false;
 }
Exemple #15
0
<?php

$user = Dog::getUser();
$server = Dog::getServer();
$message = Dog::getIRCMsg()->getArg(1);
$cmd = strtolower(Common::substrUntil($message, ' ', $message));
$msg = Common::substrFrom($message, ' ', $message);
switch ($cmd) {
    case "ping":
    case "time":
    case "action":
    case "finger":
        break;
    case 'version':
        $user->sendCTCP(sprintf('VERSION Dog v%s. Http://dog.gizmore.org', DOG_VERSION));
        break;
}
Dog_Module::map('trigger_ctcp', array($cmd, $msg));
Exemple #16
0
 public function loadLanguage($path)
 {
     if ($this->lang === NULL) {
         $mod = $this->getName();
         # Check for branch first
         $path2 = Common::substrFrom($path, 'lang/', $path);
         # remove lang/ from beginning.
         $branchfile = GWF_WWW_PATH . 'lang/module/' . $mod . '/' . $path2;
         # Branchfile
         if (Common::isDir(dirname($branchfile))) {
             $path3 = $branchfile;
         } else {
             # No branch
             $path3 = sprintf('%smodule/%s/%s', GWF_CORE_PATH, $mod, $path);
         }
         $this->lang = new GWF_LangTrans($path3);
     }
     return $this->lang;
 }
Exemple #17
0
 public static function getCommandName()
 {
     return Common::substrFrom(__CLASS__, '_');
 }
Exemple #18
0
 /**
  * Display classnames of missing quests in a city.
  * @param SR_Player $player
  * @param array $quests
  * @param array $args
  * @return true
  */
 private static function displayMissing(SR_Player $player, array $quests, array $args)
 {
     if (count($args) === 1) {
         $args[] = $player->getParty()->getCity();
     }
     if (count($args) !== 2) {
         return self::reply($player, Shadowhelp::getHelp($player, 'quests'));
     }
     if (false === ($city = Shadowrun4::getCityByAbbrev($args[1]))) {
         return self::reply($player, Shadowhelp::getHelp($player, 'quests'));
     }
     $cityname = $city->getName();
     $names = array();
     $all = SR_Quest::getQuests();
     foreach ($all as $classname => $quest) {
         $quest instanceof SR_Quest;
         if ($quest->getCityName() !== $cityname) {
             continue;
         }
         $q2 = SR_Quest::getQuest($player, $quest->getVar('sr4qu_name'));
         if ($q2->isUnknown($player)) {
             $names[] = Common::substrFrom($classname, '_', $classname);
         }
     }
     return self::rply($player, '5265', array($cityname, GWF_Array::implodeHuman($names)));
 }
Exemple #19
0
 public function receive()
 {
     $type = NULL;
     $message = NULL;
     if (false === msg_receive($this->queue_in, 1, $type, 16384, $message, false, MSG_IPC_NOWAIT)) {
         return false;
     }
     $id = Common::substrUntil($message, ':');
     $message = Common::substrFrom($message, ':');
     $this->conns[$this->parseUsername($message)] = (int) $id;
     return $message;
 }
Exemple #20
0
}
if (!$db->queryWrite('ALTER TABLE dog_dog_channels ADD COLUMN chan_triggers VARCHAR(8) CHARACTER SET ASCII COLLATE ascii_bin')) {
    die('6');
}
# Fix Server hosts
GDO::table('Dog_Server')->deleteWhere('serv_host=""');
GDO::table('Dog_Server')->update('serv_options=' . Dog_Server::DEFAULT_OPTIONS);
$servers = GDO::table('Dog_Server');
foreach ($servers->selectAll('*', '', '', NULL, -1, -1, GDO::ARRAY_O) as $server) {
    $server instanceof Dog_Server;
    $host = $server->getHost();
    $port = substr($host, strrpos($host, ':') + 1);
    $host = substr($host, 0, strrpos($host, ':'));
    $prot = Common::substrUntil($host, '://');
    $ssl = $prot === 'ircs' ? true : false;
    $host = Common::substrFrom($host, '://', $host);
    $server->saveVars(array('serv_host' => $host, 'serv_port' => $port));
    $server->saveOption(Dog_Server::SSL, $ssl);
}
# Copy Nicknames + passwords from config
global $LAMB_CFG;
$nicks = GDO::table('Dog_Nick');
$nicks->createTable(true);
GDO::table('Dog_Channel')->update('chan_options=0x02');
foreach ($LAMB_CFG['servers'] as $srv) {
    $nickname = $srv['nickname'];
    $nickname = Common::substrUntil($nickname, ',', $nickname);
    $password = $srv['password'];
    if (false === ($server = Dog_Server::getByTLD(Common::getDomain($srv['host'])))) {
        die('OUCH!');
    }
Exemple #21
0
 public static function getLocationByTarget($target)
 {
     if (false === ($city = self::getCity(Common::substrUntil($target, '_')))) {
         return false;
     }
     return $city->getLocation(Common::substrFrom($target, '_', ''));
 }
Exemple #22
0
 /**
  * LeatherVest_of_strength:1,quickness:4,marm:4,foo:4
  * @param string $itemname
  * @param int $amount
  * @param boolean $insert
  * @return SR_Item
  */
 public static function createByName($itemname, $amount = true, $insert = true)
 {
     // 		printf("%s(%s, %s, %s)\n", __METHOD__, $itemname, $amount, $insert);
     if ($amount === true) {
         // 			printf("%s(%s, %s, %s)\n", __METHOD__, $itemname, $amount, $insert);
         if (preg_match('/^(\\d+)x(.*)$/iD', $itemname, $matches)) {
             $amount = (int) $matches[1];
             $itemname = $matches[2];
         }
     }
     $name = Common::substrUntil($itemname, '_of_', $itemname);
     if (!array_key_exists($name, self::$items)) {
         Dog_Log::error(sprintf('SR_Item::createByName(%s) failed: Unknown itemname: %s.', $itemname, $name));
         return false;
     }
     $classname = "Item_{$name}";
     if ('' === ($modstring = Common::substrFrom($itemname, '_of_', ''))) {
         $modifiers = NULL;
     } else {
         $modifiers = $modstring;
         if (false === self::checkModifiers($modstring)) {
             return false;
         }
     }
     $item = self::instance($name);
     if ($amount === true) {
         $amount = self::$items[$name]->getItemDefaultAmount();
     }
     $item->setVar('sr4it_amount', $amount);
     $item->setVar('sr4it_modifiers', $modifiers);
     if ($insert === true) {
         if (false === $item->insert()) {
             return false;
         }
     }
     $item->initModifiersB();
     return $item;
 }
Exemple #23
0
 private function cutPrivABC($func)
 {
     return strtolower(Common::substrFrom($func, '_', 'yb', true));
 }
Exemple #24
0
function zreloadCheckInput($shellid, $input, array $answers)
{
    global $allowcmd, $noresponse;
    $level = GWF_Session::get('zreload');
    # replace multi spaces.
    $input = preg_replace('/[ ]{2,}/', ' ', $input);
    $input_cmd = Common::substrUntil($input, ' ');
    $function = 'zreload_func_' . $input_cmd;
    foreach ($answers as $answer) {
        $answer_cmd = Common::substrUntil($answer, ' ');
        # DBG
        //		echo sprintf('Checking<br/>');
        //		echo $input.'<br/>';
        //		echo $answer.'<br/>';
        //		echo '<hr/>';
        //		EVIL!
        //		if ($level === 7  || $level ===8)
        //		{
        //			$input =strtolower($input);
        //		}
        //
        if ($input === $answer) {
            return true;
        }
    }
    foreach ($answers as $answer) {
        if ($input === 'ssh -L 222:164.109.44.69:22 10.2.2.2' && $level === 9) {
            $output = 'Almost, but think again :-) Or read the manual.';
            break;
        } elseif ($input_cmd === $answer_cmd && $allowcmd) {
            $output = 'Yes, you have to use ' . $answer_cmd . '.';
            break;
        } elseif (function_exists($function) && $allowcmd) {
            $output = call_user_func($function, $shellid, Common::substrFrom($input, ' '));
            break;
        } elseif ($input_cmd === '') {
            $output = '';
        } elseif ($allowcmd) {
            $output = 'Unknown command: ' . htmlspecialchars($input_cmd);
        } elseif ($noresponse) {
            $output = 'Authentication failure.';
        } else {
            if ($input_cmd === 'reset') {
                $output = zreload_func_reset($shellid, '');
            } else {
                $output = 'Wrong.';
            }
        }
    }
    zreloadAppendToShell($shellid, $output);
    return false;
}
Exemple #25
0
 /**
  * 
  * @param string $url
  * @return Ambigous <string, false, boolean, unknown>
  */
 public static function getDomain($url)
 {
     $url = Common::substrFrom($url, '://', $url);
     $url = Common::substrUntil($url, '/', $url);
     return Common::regex('#([^\\.]+\\.[^\\.]+)$#D', $url);
 }
Exemple #26
0
 public function onSend(Dog_Server $server, Dog_User $user, $message)
 {
     // 		$c = Dog::getTrigger();
     if (false === ($nickname = Common::substrUntil($message, ' ', false))) {
         return $this->lang('help_send');
     }
     $message = Common::substrFrom($message, ' ');
     if (false === ($user_to = Dog_User::getForServer($server->getID(), $nickname))) {
         return Dog::lang('err_user');
     }
     if (false === Dog_Note::isWithinLimits($user->getID())) {
         return $this->lang('err_limit', array(Dog_Note::LIMIT_AMT, GWF_Time::humanDuration(Dog_Note::LIMIT_TIME)));
     }
     if (false !== ($channel = Dog::getChannel())) {
         if (false !== $channel->getUserByName($nickname)) {
             return $this->lang('err_in_chan', array($nickname));
         }
     }
     if (false === Dog_Note::insertNote($user, $user_to, $message)) {
         return GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->lang('msg_sent', array($nickname));
 }
Exemple #27
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% <channel>[!<SID>]. Try to join a channel.', 'already' => 'I am already on that channel.', 'trying' => 'Trying to join this channel.', 'unknown_serv' => 'This server is unknown.'), 'de' => array('help' => 'Nutze: %CMD% <Kanal>[!<SID>]. Versucht einem Kanal beizutreten.', 'already' => 'Ich bin schon in diesem Kanal.', 'trying' => 'Es wird versucht dem Kanal beizutreten.', 'unknown_serv' => 'Dieser Server ist nicht vorhanden.'));
$plugin = Dog::getPlugin();
if ($plugin->argc() !== 1) {
    return $plugin->showHelp();
}
$arg = $plugin->argv(0);
if (false === ($server = Dog::getServerBySuffix($arg))) {
    return $plugin->rply('unknown_serv');
}
if (false !== ($channel = Dog::getChannelByArg($arg))) {
    return $plugin->rply('already');
}
$chan_name = Common::substrFrom($arg, '!', $arg);
if (false === ($channel = Dog_Channel::getOrCreate($server, $chan_name))) {
    return Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
$plugin->rply('trying');
$channel->saveOption(Dog_Channel::AUTO_JOIN, true);
$server->joinChannel($channel);
Exemple #28
0
 /**
  * Get a lang file for a location.
  * @param SR_Quest $quest
  * @return GWF_LangTrans
  */
 private static function getLangLocation(SR_Location $location)
 {
     // 		$locname = $location->getName();
     $locname = $location->getLangfileName();
     if (false === isset(self::$LANG_LOCATION[$locname])) {
         $llocname = strtolower(Common::substrFrom($locname, '_'));
         $path = sprintf('%scity/%s/lang/location/%s/%s', Shadowrun4::getShadowDir(), $location->getCity(), $llocname, $llocname);
         self::$LANG_LOCATION[$locname] = new GWF_LangTrans($path);
     }
     return self::$LANG_LOCATION[$locname];
 }
Exemple #29
0
 public function msg()
 {
     return trim(Common::substrFrom(Dog::getIRCMsg()->getArg(1), ' ', ''));
 }
Exemple #30
0
 /**
  * Insert a new image.
  * @param int $uid
  * @param string $url
  * @param string $description
  * @return Dog_Link
  */
 public static function insertImage($uid, $url, $content)
 {
     $link = new self(array('link_id' => '0', 'link_uid' => $uid, 'link_url' => $url, 'link_text' => Common::substrFrom($url, '/', 'IMAGE', true), 'link_rating' => '0', 'link_date' => GWF_Time::getDate(14), 'link_type' => 'image'));
     if (false === $link->insert()) {
         echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         return false;
     }
     $path = GWF_WWW_PATH . 'dbimg/dogimg/' . $link->getID();
     if (false === GWF_File::writeFile($path, $content)) {
         echo GWF_HTML::err('ERR_WRITE_FILE', array($path));
         $link->delete();
         return false;
     }
     return $link;
 }