function creatureaddon_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "gravefight-start":
            if (get_module_objpref("creatures", $args['creatureid'], "description")) {
                output(stripslashes(get_module_objpref("creatures", $args['creatureid'], "description")));
            }
            break;
        case "creatureencounter":
            $args['creaturegold'] += get_module_objpref("creatures", $args['creatureid'], "addgold");
            $args['creaturehealth'] += get_module_objpref("creatures", $args['creatureid'], "addhit");
            $args['creatureattack'] += get_module_objpref("creatures", $args['creatureid'], "addattack");
            $args['creaturedefense'] += get_module_objpref("creatures", $args['creatureid'], "adddefense");
            if (get_module_objpref("creatures", $args['creatureid'], "image")) {
                rawoutput("<table width = \"100%\"><tr><td width=\"100%\" align = \"center\"><img src=\"./images/" . get_module_objpref("creatures", $args['creatureid'], "image") . "\"></td></tr></table>");
            }
            if (get_module_objpref("creatures", $args['creatureid'], "description") && !httpget("nodesc")) {
                output(stripslashes(get_module_objpref("creatures", $args['creatureid'], "description")));
            }
            break;
        case "battle-victory":
            if ($session['user']['level'] < 15 && e_rand(1, 100) <= get_module_objpref("creatures", $args['creatureid'], "gemchance") && get_module_objpref("creatures", $args['creatureid'], "gemmessage")) {
                $message = get_module_objpref("creatures", $args['creatureid'], "gemmessage");
                output($message);
                debug("Creature Addon module is awarding a gem.");
                $session['user']['gems']++;
                debuglog("found a gem when slaying a " . $args['creaturename']);
            }
            break;
    }
    return $args;
}
function findgem_runevent($type, $link)
{
    global $session;
    output("`^Fortune smiles on you and you find a `%gem`^!`0");
    $session['user']['gems']++;
    debuglog("found a gem in the dirt");
}
Beispiel #3
0
function get_spotify_page($url)
{
    debuglog("Getting Spotify Page " . $url, "SPOTIBIO");
    if (file_exists('prefs/jsoncache/spotify/' . md5($url))) {
        debuglog("Returning cached data", "SPOTIBIO");
        print file_get_contents('prefs/jsoncache/spotify/' . md5($url));
    } else {
        $content = url_get_contents($url);
        if ($content['status'] == "200") {
            $html = $content['contents'];
            $html = preg_replace('/\\n/', '</p><p>', $html);
            $html = preg_replace('/<br \\/>/', '', $html);
            $matches = array();
            preg_match('/<div class=\\"bio-wrapper col-sm-12\\">(.*?)<\\/div>/', $html, $matches);
            $r = "";
            if (array_key_exists(1, $matches)) {
                $r = preg_replace('/<button id=\\"btn-reveal\\".*?<\\/button>/', '', $matches[1]);
                $r = preg_replace('/<a .*?>/', '', $r);
                $r = preg_replace('/<\\/a>/', '', $r);
            }
            file_put_contents('prefs/jsoncache/spotify/' . md5($url), '<p>' . $r . '</p>');
            print "<p>" . $r . "</p>";
        } else {
            header('HTTP/1.1 400 Bad Request');
        }
    }
}
Beispiel #4
0
function yobit_api_query2($method, $req = array())
{
    $api_key = '';
    $api_secret = '';
    $req['method'] = $method;
    $req['nonce'] = time();
    $post_data = http_build_query($req, '', '&');
    $sign = hash_hmac("sha512", $post_data, $api_secret);
    $headers = array('Sign: ' . $sign, 'Key: ' . $api_key);
    $ch = null;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; SMART_API PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')');
    curl_setopt($ch, CURLOPT_URL, 'https://yobit.net/tapi/');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
    $res = curl_exec($ch);
    if ($res === false) {
        $e = curl_error($ch);
        debuglog($e);
        curl_close($ch);
        return null;
    }
    curl_close($ch);
    $result = json_decode($res, true);
    if (!$result) {
        debuglog($res);
    }
    return $result;
}
Beispiel #5
0
function postToEcwid($notice)
{
    require 'config.php';
    $x_response_code = '1';
    // 1=approved, 2=declined
    $x_response_reason_code = '1';
    // 1=approved, 2= declined
    $x_trans_id = $notice['id'];
    $x_invoice_num = $notice['posData'][1];
    $x_amount = $notice['posData'][0];
    $string = $hashValue . $login . $x_trans_id . $x_amount;
    $x_MD5_Hash = md5($string);
    $datatopost = array("x_response_code" => $x_response_code, "x_response_reason_code" => $x_response_reason_code, "x_trans_id" => $x_trans_id, "x_invoice_num" => $x_invoice_num, "x_amount" => $x_amount, "x_MD5_Hash" => $x_MD5_Hash);
    switch ($notice['status']) {
        case 'completed':
        case 'confirmed':
            $url = 'http://app.ecwid.com/authorizenet/' . $storeId;
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $datatopost);
            //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            if ($response === false) {
                debuglog('request to ecwid.com failed');
                debuglog(curl_error($ch));
            }
            curl_close($ch);
            return $response;
        default:
            return false;
    }
}
Beispiel #6
0
function htoi($s)
{
    $val = 0.0;
    $x = 0;
    if ($s[$x] == '0' && ($s[$x + 1] == 'x' || $s[$x + 1] == 'X')) {
        $x += 2;
    }
    while (isset($s[$x])) {
        //		debuglog("{$s[$x]}");
        if ($s[$x] >= '0' && $s[$x] <= '9') {
            $val = $val * 16 + $s[$x] - '0';
        } else {
            if ($s[$x] >= 'A' && $s[$x] <= 'F') {
                debuglog($s[$x]);
                debuglog($s[$x] - chr('A'));
                $val = $val * 16 + ord($s[$x]) - ord('A') + 10;
            } else {
                if ($s[$x] >= 'a' && $s[$x] <= 'f') {
                    $val = $val * 16 + ord($s[$x]) - ord('a') + 10;
                } else {
                    return 0;
                }
            }
        }
        $x++;
    }
    return $val;
}
function es_bridge_gp_dohook($hook, $args)
{
    global $session, $baseaccount;
    $item = httpget('item');
    $action = httpget('action');
    if ($session['user']['armor'] != $baseaccount['armor'] && ($action == 'weararmor' || $action == 'buyarmor') && $session['user']['armor'] == $item) {
        $category = 'armor';
        $defense = $session['user']['defense'];
    } elseif ($session['user']['weapon'] != $baseaccount['weapon'] && ($action == 'wearweapon' || $action == 'buyweapon') && $session['user']['weapon'] == $item) {
        $category = 'weapon';
        $attack = $session['user']['attack'];
    } else {
        $category = false;
    }
    if ($category && get_module_pref($category, 'mysticalshop')) {
        $current_id = get_module_pref($category . 'id', 'mysticalshop');
        debug("Current ID is {$current_id}");
        require_once './modules/mysticalshop/lib.php';
        mysticalshop_destroyitem($category);
        mysticalshop_resetbuffs($current_id);
        require_once './modules/mysticalshop_buffs/stripbuff.php';
        mysticalshop_buffs_stripbuff();
        if ($category == 'armor') {
            $session['user']['defense'] = $defense;
        } else {
            $session['user']['attack'] = $attack;
        }
        debuglog('es_bridge_gp: ' . $category . ' (ID: ' . $current_id . ') item removed on action "' . $action . '".');
    }
    return $args;
}
Beispiel #8
0
function get_lfm_page($page, $lang)
{
    $url = $page . "/+wiki";
    if ($lang) {
        debuglog("Getting Bio with language " . $lang, "LFMBIO");
        $url .= "?lang=" . $lang;
    }
    if (file_exists('prefs/jsoncache/lastfm/' . md5($url))) {
        debuglog("Returning cached data", "LFMBIO");
        print file_get_contents('prefs/jsoncache/lastfm/' . md5($url));
    } else {
        debuglog("Getting Bio Page " . $url, "LFMBIO");
        $content = url_get_contents($url);
        if ($content['status'] == "200") {
            debuglog("  .. Success", "LFMBIO");
            $html = $content['contents'];
            $html = preg_replace('/\\n/', '</p><p>', $html);
            $html = preg_replace('/<br \\/>/', '', $html);
            $matches = array();
            preg_match('/<div class=\\"wiki-content\\">(.*?)<\\/div>/', $html, $matches);
            if (array_key_exists(1, $matches)) {
                debuglog("  ... Found Wiki Data", "LFMBIO");
                file_put_contents('prefs/jsoncache/lastfm/' . md5($url), '<p>' . $matches[1] . '</p>');
                print "<p>" . $matches[1] . "</p>";
            } else {
                header('HTTP/1.1 400 Bad Request');
            }
        } else {
            header('HTTP/1.1 400 Bad Request');
        }
    }
}
Beispiel #9
0
function BackendClearEarnings()
{
    //	debuglog(__FUNCTION__);
    $delay = time() - 150 * 60;
    $total_cleared = 0;
    $list = getdbolist('db_earnings', "status=1 and mature_time<{$delay}");
    foreach ($list as $earning) {
        $user = getdbo('db_accounts', $earning->userid);
        if (!$user) {
            $earning->delete();
            continue;
        }
        $coin = getdbo('db_coins', $earning->coinid);
        if (!$coin) {
            $earning->delete();
            continue;
        }
        $earning->status = 2;
        // cleared
        $earning->price = $coin->price;
        $earning->save();
        // 		$refcoin = getdbo('db_coins', $user->coinid);
        // 		if($refcoin && $refcoin->price<=0) continue;
        // 		$value = $earning->amount * $coin->price / ($refcoin? $refcoin->price: 1);
        $value = yaamp_convert_amount_user($coin, $earning->amount, $user);
        $user->balance += $value;
        $user->save();
        if ($user->coinid == 6) {
            $total_cleared += $value;
        }
    }
    if ($total_cleared > 0) {
        debuglog("total cleared from mining {$total_cleared} BTC");
    }
}
Beispiel #10
0
/**
 * return array of the courses associated to a netid
 *
 * @param string $netid
 * @return array key: course code; value: course description
 */
function courses_list($netid)
{
    // prepared requests
    $statements = array('course_all_get' => 'SELECT DISTINCT ' . db_gettable('courses') . '.course_code AS mnemonic, ' . db_gettable('courses') . '.course_name AS label ' . 'FROM ' . db_gettable('courses') . ' ' . 'ORDER BY mnemonic ASC', 'user_courses_get' => 'SELECT DISTINCT ' . db_gettable('users_courses') . '.ID, ' . db_gettable('courses') . '.course_code, ' . db_gettable('courses') . '.shortname, ' . db_gettable('courses') . '.course_name, ' . db_gettable('courses') . '.in_recorders, ' . db_gettable('users_courses') . '.origin ' . 'FROM ' . db_gettable('courses') . ' ' . 'INNER JOIN ' . db_gettable('users_courses') . ' ON ' . db_gettable('courses') . '.course_code = ' . db_gettable('users_courses') . '.course_code ' . 'WHERE user_ID = :user_ID');
    $db = db_prepare($statements);
    if (!$db) {
        debuglog("could not connect to sgbd:" . mysql_error());
        die;
    }
    $result = array();
    if ($netid == "") {
        // retrieves all courses in the database
        $course_list = db_courses_all_get();
        $result = array();
        foreach ($course_list as $value) {
            $result[$value['mnemonic']] = $value['mnemonic'] . '|' . $value['label'];
        }
    } else {
        // retrieves all courses for a given netid
        $course_list = db_user_courses_get($netid);
        $result = array();
        foreach ($course_list as $value) {
            $result[$value['course_code']] = $value['course_code'] . '|' . $value['course_name'];
        }
    }
    db_close();
    return $result;
}
function findgold_runevent($type, $link)
{
    global $session;
    $min = $session['user']['level'] * get_module_setting("mingold");
    $max = $session['user']['level'] * get_module_setting("maxgold");
    $gold = e_rand($min, $max);
    output("`^Fortune smiles on you and you find %s gold!`0", $gold);
    $session['user']['gold'] += $gold;
    debuglog("found {$gold} gold in the dirt");
}
Beispiel #12
0
function musicCollectionSpotifyPlaylistHack($monitor)
{
    $dirs = array();
    $playlists = do_mpd_command("listplaylists", true, true);
    if (array_key_exists('playlist', $playlists)) {
        foreach ($playlists['playlist'] as $pl) {
            debuglog("Scanning Playlist " . $pl, "COLLECTION", 8);
            fwrite($monitor, "\nScanning Playlist " . $pl);
            doMpdParse('listplaylistinfo "' . format_for_mpd($pl) . '"', $dirs, array("spotify"));
        }
    }
}
Beispiel #13
0
function doFileBrowse($path, $prefix)
{
    global $connection, $prefs;
    debuglog("Browsing " . $path, "DIRBROWSER");
    $parts = true;
    $foundfile = false;
    $filedata = array();
    $dircount = 0;
    fputs($connection, 'lsinfo "' . format_for_mpd($path) . '"' . "\n");
    while (!feof($connection) && $parts) {
        $parts = getline($connection);
        if (is_array($parts)) {
            $s = trim($parts[1]);
            if (substr($s, 0, 1) != ".") {
                switch ($parts[0]) {
                    case "file":
                        if (!$foundfile) {
                            $foundfile = true;
                        } else {
                            if (!$prefs['ignore_unplayable'] || array_key_exists('Title', $filedata) && substr($filedata['Title'], 0, 12) != "[unplayable]") {
                                printFileItem(getFormatName($filedata), $filedata['file'], $filedata['Time']);
                            }
                            $filedata = array();
                        }
                        $filedata[$parts[0]] = $parts[1];
                        break;
                    case "playlist":
                        if ($path != "") {
                            // Ignore playlists located at the root. This is cleaner and makes more sense
                            printPlaylistItem(basename($parts[1]), $parts[1]);
                        }
                        break;
                    case "directory":
                        printDirectoryItem($parts[1], basename($parts[1]), $prefix, $dircount, false);
                        $dircount++;
                        break;
                    case "Title":
                    case "Time":
                    case "Artist":
                    case "Album":
                        $filedata[$parts[0]] = $parts[1];
                        break;
                }
            }
        }
    }
    if (array_key_exists('file', $filedata)) {
        if (!$prefs['ignore_unplayable'] || array_key_exists('Title', $filedata) && substr($filedata['Title'], 0, 12) != "[unplayable]") {
            printFileItem(getFormatName($filedata), $filedata['file'], $filedata['Time']);
        }
    }
}
function abandoncastle_runevent($type)
{
    global $session;
    if (!get_module_pref("wasfound") and get_module_setting("forestvil") == 1) {
        output("`n`2While walking in the Forest, you have found a path that leads to an `bAbandoned Castle`b, which is very old.`n`nA sign near the castle says:`n\"`#Beware, only the bravest warrior should enter the Castle. If you decide to enter, your chance to die is pretty high.");
        addnews("%s has found a path to the Abandoned Castle.", $session['user']['name']);
        debuglog("found the Abandoned Castle");
        addnav("Enter the Castle", "runmodule.php?module=abandoncastle");
        addnav("Back to the Forest", "forest.php");
    } else {
        redirect("forest.php?op=search");
    }
}
Beispiel #15
0
function get_int_text($key, $sub = null)
{
    global $translations;
    if (array_key_exists($key, $translations)) {
        if (is_array($sub)) {
            return htmlspecialchars(vsprintf($translations[$key], $sub), ENT_QUOTES);
        } else {
            return htmlspecialchars($translations[$key], ENT_QUOTES);
        }
    } else {
        debuglog("ERROR! Translation key " . $key . " not found!", "INTERNATIONAL");
        return "UNKNOWN KEY";
    }
}
Beispiel #16
0
function clean_cache_dir($dir, $time)
{
    debuglog("Cache Cleaner is running on " . $dir, "CACHE CLEANER");
    $cache = glob($dir . "*");
    $now = time();
    foreach ($cache as $file) {
        if (!is_dir($file)) {
            if ($now - filemtime($file) > $time) {
                debuglog("Removing file " . $file, "CACHE CLEANER", 4);
                @unlink($file);
            }
        }
    }
}
Beispiel #17
0
function send_email_alert($name, $title, $message, $t = 10)
{
    //	debuglog(__FUNCTION__);
    $last = memcache_get(controller()->memcache->memcache, "last_email_sent_{$name}");
    if ($last + $t * 60 > time()) {
        return;
    }
    debuglog("mail('" . YAAMP_ADMIN_EMAIL . "', {$title}, ...)");
    $b = mail(YAAMP_ADMIN_EMAIL, $title, $message);
    if (!$b) {
        debuglog('error sending email');
    }
    memcache_set(controller()->memcache->memcache, "last_email_sent_{$name}", time());
}
Beispiel #18
0
function updateRawCoin($marketname, $symbol, $name = 'unknown')
{
    if ($symbol == 'BTC') {
        return;
    }
    $coin = getdbosql('db_coins', "symbol=:symbol", array(':symbol' => $symbol));
    if (!$coin) {
        debuglog("new coin {$marketname} {$symbol} {$name}");
        $coin = new db_coins();
        $coin->txmessage = true;
        $coin->hassubmitblock = true;
        $coin->name = $name;
        $coin->symbol = $symbol;
        $coin->created = time();
        $coin->save();
        mail(YAAMP_ADMIN_EMAIL, "New coin {$symbol}", "new coin {$symbol} ({$name}) on {$marketname}");
        sleep(30);
    } else {
        if ($coin->name == 'unknown' && $name != 'unknown') {
            $coin->name = $name;
            $coin->save();
        }
    }
    $list = getdbolist('db_coins', "symbol=:symbol or symbol2=:symbol", array(':symbol' => $symbol));
    foreach ($list as $coin) {
        $market = getdbosql('db_markets', "coinid={$coin->id} and name='{$marketname}'");
        if (!$market) {
            $market = new db_markets();
            $market->coinid = $coin->id;
            $market->name = $marketname;
        }
        $market->deleted = false;
        $market->save();
    }
    /////////
    // 	if($coin->enable || !empty($coin->algo) || !empty($coin->errors) || $coin->name == 'unknown') return;
    // 	debuglog("http://www.cryptocoinrank.com/$coin->name");
    //  	$data = file_get_contents("http://www.cryptocoinrank.com/$coin->name");
    //  	if($data)
    //  	{
    // 	 	$b = preg_match('/Algo: <span class=\"d-gray\">(.*)<\/span>/', $data, $m);
    // 	 	if($b)
    // 	 	{
    // 	 		$coin->errors = trim($m[1]);
    // 			$coin->save();
    // 	 	}
    //  	}
}
Beispiel #19
0
function check_file($file, $data)
{
    // NOTE. WE've configured curl to follow redirects, so in truth this code should never do anything
    $matches = array();
    if (preg_match('/See: (.*)/', $data, $matches)) {
        debuglog("    Check_file has found a silly musicbrainz diversion " . $data, "GETALBUMCOVER");
        $new_url = $matches[1];
        system('rm "' . $file . '"');
        $aagh = url_get_contents($new_url);
        debuglog("    check_file is getting " . $new_url, "GETALBUMCOVER");
        $fp = fopen($file, "x");
        if ($fp) {
            fwrite($fp, $aagh['contents']);
            fclose($fp);
        }
    }
}
function scry_run()
{
    global $session;
    addcommentary();
    $area = httpget("area");
    $village = httpget("village");
    $op = httpget("op");
    $cost = $session['user']['level'] * get_module_setting("cost");
    if ($op == "pay") {
        if ($session['user']['gold'] >= $cost) {
            $session['user']['gold'] -= $cost;
            set_module_pref("talks", 0);
            set_module_pref("speaking", 1);
            debuglog("spent {$cost} gold to scry a remote village");
            redirect("runmodule.php?module=scry&op=talk&area=" . htmlentities($area, ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "&village=" . htmlentities($village, ENT_COMPAT, getsetting("charset", "ISO-8859-1")));
            page_footer();
        } else {
            page_header("Gypsy Seer's tent");
            villagenav();
            addnav("Continue looking around", "gypsy.php");
            output("`5You offer the old gypsy woman your `^%s`5 gold for her scrying services, but she informs you that such a pittance is far too little.", $session['user']['gold']);
            page_footer();
        }
    } elseif ($op == "talk") {
        $times = get_module_setting("uses");
        if ($times && get_module_pref("talks") >= $times) {
            page_header("Gypsy Seer's tent");
            output("`5Looking around dazedly, it takes you a moment to realize that you are no longer viewing the village of %s and that the gypsy woman is staring at you with her hand out.", $village);
            output("`5\"`!I'll need more gold if you want to keep taking up space for my other paying customers!`5\", she demands.`n`n");
            output("You start to demand, \"`&What other customers?`5\" but decide that it's best not to annoy someone who has such power.");
            addnav(array("Scrying (%s gold)", $cost));
            addnav(array("Scry %s", $village), "runmodule.php?module=scry&op=pay&area=" . htmlentities($area, ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "&village=" . htmlentities($village, ENT_COMPAT, getsetting("charset", "ISO-8859-1")));
            addnav("Other");
            addnav("Return to the tent", "gypsy.php");
            villagenav();
            page_footer();
        } else {
            page_header("Peering in the bowl, you view %s", $village);
            output("`5While staring into the inky water, you are able to make out the people of %s:`n", $village);
            commentdisplay("", $area, "Project", 25, "projects");
            addnav("Look up from the bowl", "gypsy.php");
            page_footer();
        }
    }
}
Beispiel #21
0
 protected function jsonQuery($url)
 {
     $opts = array('http' => array('method' => 'GET', 'timeout' => 10));
     //        debuglog($url);
     $context = stream_context_create($opts);
     $feed = @file_get_contents($url, false, $context);
     //        debuglog($feed);
     if (!$feed) {
         debuglog("c-cex error {$url}");
         return null;
         //array('error' => 'Invalid parameters');
     } else {
         $a = json_decode($feed, true);
         if (!$a) {
             debuglog($feed);
         }
         return $a;
     }
 }
Beispiel #22
0
function cryptsy_api_query($method, array $req = array())
{
    //	debuglog("calling cryptsy_api_query $method");
    //	debuglog($req);
    // API settings
    $key = '';
    // your API-key
    $secret = '';
    // your Secret-key
    $req['method'] = $method;
    $mt = explode(' ', microtime());
    $req['nonce'] = $mt[1];
    // generate the POST data string
    $post_data = http_build_query($req, '', '&');
    $sign = hash_hmac("sha512", $post_data, $secret);
    // generate the extra headers
    $headers = array('Sign: ' . $sign, 'Key: ' . $key);
    // our curl handle (initialize if required)
    static $ch = null;
    if (is_null($ch)) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Cryptsy API PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')');
    }
    curl_setopt($ch, CURLOPT_URL, 'https://api.cryptsy.com/api');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    // run the query
    $res = curl_exec($ch);
    if ($res === false) {
        debuglog("ERROR cryptsy_api_query {$method}");
        return null;
    }
    $dec = json_decode($res, true);
    if (!$dec) {
        debuglog("ERROR cryptsy_api_query {$method}");
        debuglog($res);
        return null;
    }
    //	sleep(1);
    return $dec;
}
function textme_sendmail($post = [], $from = 'LotGD Staff')
{
    $accounts = db_prefix('accounts');
    $post['to'] = filter_var($post['to'], FILTER_SANITIZE_STRING);
    $post['body'] = trim(explode("---Original", $post['body'])[0]);
    $body = "From {$from}: \n{$post['body']}";
    $sql = db_query("SELECT acctid FROM {$accounts} WHERE login = '******'to']}'");
    $row = db_fetch_assoc($sql);
    $prefs = get_all_module_prefs('textme', $row['acctid']);
    foreach ($prefs as $key => $val) {
        $prefs[$key] = trim($val);
    }
    if ($prefs['user_number'] != '' && $prefs['user_carrier'] != 'none') {
        require_once 'lib/sanitize.php';
        $checkSent = mail("{$prefs['user_number']}@{$prefs['user_carrier']}", '', stripslashes(full_sanitize($body)), "From: textme@{$_SERVER['HTTP_HOST']}");
        if (!$checkSent) {
            debuglog("failed to send a message to {$post['to']} ({$prefs['user_number']}@{$prefs['user_carrier']})");
        }
    }
}
Beispiel #24
0
 public function actionSellto()
 {
     if (!$this->admin) {
         return;
     }
     $market = getdbo('db_markets', getiparam('id'));
     $coin = getdbo('db_coins', $market->coinid);
     $amount = getparam('amount');
     $remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
     $info = $remote->getinfo();
     if (!$info || !$info['balance']) {
         return false;
     }
     $deposit_info = $remote->validateaddress($market->deposit_address);
     if (!$deposit_info || !isset($deposit_info['isvalid']) || !$deposit_info['isvalid']) {
         user()->setFlash('error', "invalid address {$coin->name}, {$market->deposit_address}");
         $this->redirect(array('site/coin', 'id' => $coin->id));
     }
     $amount = min($amount, $info['balance'] - $info['paytxfee']);
     //		$amount = max($amount, $info['balance'] - $info['paytxfee']);
     $amount = round($amount, 8);
     debuglog("selling ({$market->deposit_address}, {$amount})");
     $tx = $remote->sendtoaddress($market->deposit_address, $amount);
     if (!$tx) {
         user()->setFlash('error', $remote->error);
         $this->redirect(array('site/coin', 'id' => $coin->id));
     }
     $exchange = new db_exchange();
     $exchange->market = $market->name;
     $exchange->coinid = $coin->id;
     $exchange->send_time = time();
     $exchange->quantity = $amount;
     $exchange->price_estimate = $coin->price;
     $exchange->status = 'waiting';
     $exchange->tx = $tx;
     $exchange->save();
     $this->redirect(array('site/coin', 'id' => $coin->id));
 }
function strategyhut_run()
{
    global $session;
    $cost = get_module_setting("cost");
    $op = httpget("op");
    page_header("The Strategy Hut");
    output("`5`c`bThe Strategy Hut`b`c");
    if ($op == "") {
        addnav(array("Ask for Advice (`^%s gold`0)", $cost), "runmodule.php?module=strategyhut&op=ask");
        output("`&You enter the hut, to find `6Atrus `&busy at his desk.");
        output("\"`^Well, a young warrior in search of help!");
        output("For a small fee, I will offer advice to you.`3\"`n`n");
        output("`&Hesitantly, you approach the burly warrior.`n`n");
        output("`&You blink a few times before you realize he was actually talking to you.");
        output("`6Atrus `&doesn't seem very patient, so you'd better decide quickly if you want to hear his advice!`n");
    } elseif ($session['user']['gold'] < $cost) {
        output("`&You go through your pockets, searching for money, but you don't have enough.");
        output("After a moment of intense searching, `6Atrus `&starts to scowl, and you decide to leave before he gets annoyed.`n`n");
    } else {
        $session['user']['gold'] -= $cost;
        debuglog("spent {$cost} gold at the strategy hut");
        output("`&You give `6Atrus `^%s gold`7.", $cost);
        output("`&He nods, and thinks for a moment.`n`n");
        $phrases = array("\"`^Heal often, bank often.`3\"", "\"`^Think balance: weapons and armor must be close in level, not enough defense and your first attack will be your last.`3\"", "\"`^Don't be afraid to slum, in the lower DK levels, speed is NOT a priority. Later is different.`3\"", "\"`^That stat bar is your life, when it gets into the yellow zone, heal. When it goes red, pray.`3\"", "\"`^In PvP, pick your targets with care. If not sure, DON'T... or you'll be explaining to {deathoverlord}`^ what happened.`3\"", "\"`^You don't always need to resurrect. There will be times to save favor for emergencies.`3\"", "\"`^If it's a game bug, petition it. If it's a gameplay issue, petition it.`3\"", "\"`^A good offense is not always a good defense, even the strongest players die in the forest.`3\"", "\"`^Confidence is one thing: attacking a God is suicide. Check the bio first.`3\"", "\"`^Keep an open mind and think it through. Only a fool fights blindly.`3\"", "\"`^There is a dragon, and when you are ready, it will be too. Patience.`3\"", "\"`^Travelling between towns can be dangerous. Heal first.`3\"", "\"`^Talk to everyone in all the villages, visit the shops and stalls. Explore. Learn.`3\"", "\"`^Lower DK players die often in the beginning. It happens to all of us.`3\"", "\"`^When you face the dragon, be ready and fully healed... or it will eat you for lunch.`3\"", "\"`^Your mount or familiar is an asset... learn what it can do, and know its limits. *And* yours, as well.`3\"", "\"`^There is no shame in knowing when to run. Better a bruised ego than a visit to {deathoverlord}`^.`3\"", "\"`^Log in ONCE per game day only, or you will be killed repeatedly... and lose experience as a result. There is no safe place.`3\"", "\"`^If you can't resurrect, log off and wait for New Day. You are already dead.`3\"", "\"`^A good player treats his fellows with courtesy and respect. A wise player knows that new friends can help him succeed.`3\"", "\"`^Don't forget to feed your mount or familiar.`3\"");
        $question = e_rand(0, count($phrases) - 1);
        $phrases = translate_inline($phrases);
        $myphrase = $phrases[$question];
        $myphrase = str_replace('{deathoverlord}', getsetting('deathoverlord', '`$Ramius'), $myphrase);
        output_notl("%s`n`n", $myphrase);
        output("`&You ponder his advice for a moment, before thanking him and making your exit.`n`n");
        if (is_module_active("medals")) {
            require_once "modules/medals.php";
            medals_award_medal("strategyhut", "Strategy Seeker", "This player asked for help in the Strategy Hut.", "medal_strategy.png");
        }
    }
    villagenav();
    page_footer();
}
					if(isset($session[bufflist]['mount']))
						unset($session[bufflist]['mount']);
				} else {
					if ($horsecanenter) {
						output("Your {$playermount['mountname']} managed to escape being crushed. You know that it is trained to return to the village.`n");
					} else {
						output("Fortunately you left your {$playermount['mountname']} tethered outside.  You know that it is trained to return to the village.`n");
					}
				}
				$exp=$session[user][experience]*0.6;
				output("At least you learned something about mining from this experience and have gained $exp experience.`n`n");
				output("`3You may continue to play tommorrow`n");
				$session[user][experience]+=$exp;
				$session[user][alive]=false;
				$session[user][hitpoints]=0;
			    debuglog("lost {$session['user']['gold']} gold and {$session['user']['gems']} gems by dying in the goldmine");
				$session[user][gold]=0;
				$session[user][gems]=0;
				addnav("Daily News","news.php");
				addnews($session[user][name]." was completely buried when ".($session[user][sex]?"she":"he")." became greedy digging in the mines");
			} else {
				if ($session[user][race] == 4) {
					output("Fortunately your dwarven skill let you escape unscathed.`n");
				} elseif ($horsesave) {
					if ($playermount['mine_savemsg'])
						output($playermount['mine_savemsg']);
					else
						output("Your {$playermount['mountname']} managed to drag you to safety in the nick of time!`n");
				} else {
					output("Through sheer luck you manage to escape the cave-in intact!`n");
				}
Beispiel #27
0
function do_mpd_command($command, $return_array = false, $force_array_results = false)
{
    global $is_connected, $connection, $prefs;
    $retarr = array();
    if ($is_connected) {
        debuglog("MPD Command " . $command, "MPD", 9);
        $success = fputs($connection, $command . "\n");
        if ($success) {
            while (!feof($connection)) {
                $var = parse_mpd_var(fgets($connection, 1024));
                if (isset($var)) {
                    if ($var === true && count($retarr) == 0) {
                        // Got an OK or ACK but - no results or return_array is false
                        return true;
                    }
                    if ($var === true) {
                        break;
                    }
                    if ($var[0] == false) {
                        debuglog("Error for '" . $command . "'' : " . $var[1], "MPD", 1);
                        if ($return_array == true) {
                            $retarr['error'] = $var[1];
                        } else {
                            return false;
                        }
                        break;
                    }
                    if ($return_array == true) {
                        if (array_key_exists($var[0], $retarr)) {
                            if (is_array($retarr[$var[0]])) {
                                array_push($retarr[$var[0]], $var[1]);
                            } else {
                                $tmp = $retarr[$var[0]];
                                $retarr[$var[0]] = array($tmp, $var[1]);
                            }
                        } else {
                            if ($force_array_results) {
                                $retarr[$var[0]] = array($var[1]);
                            } else {
                                $retarr[$var[0]] = $var[1];
                            }
                        }
                    }
                }
            }
        } else {
            if (array_key_exists('player_backend', $prefs)) {
                $retarr['error'] = "There was an error communicating with " . ucfirst($prefs['player_backend']) . "! (could not write to socket)";
            } else {
                $retarr['error'] = "There was an error communicating with the player! (could not write to socket)";
            }
        }
    }
    return $retarr;
}
Beispiel #28
0
                 if ($session['user']['boughtroomtoday']) {
                 } else {
                     if ($_GET['pay'] == 2) {
                         $fee = getsetting("innfee", "5%");
                         if (strpos($fee, "%")) {
                             $expense += round($expense * $fee / 100, 0);
                         } else {
                             $expense += $fee;
                         }
                         $goldline = ",goldinbank=goldinbank-{$expense}";
                     } else {
                         $goldline = ",gold=gold-{$expense}";
                     }
                     $goldline .= ",boughtroomtoday=1";
                 }
                 debuglog("spent {$expense} gold on an inn room");
                 $sql = "UPDATE accounts SET loggedin=0,location=1 {$goldline} WHERE acctid = " . $session['user'][acctid];
                 db_query($sql) or die(sql_error($sql));
             }
             $session = array();
             redirect("index.php");
         } else {
             output("\"Aah, so that's how it is,\" Cedrik says as he puts the key he had retrieved back on to its hook ");
             output("behind his counter.  Perhaps you'd like to get sufficient funds before you attempt to engage in ");
             output("local commerce.");
         }
     }
 } else {
     if ($session['user']['boughtroomtoday']) {
         output("You already paid for a room for the day.");
         addnav("Go to room", "inn.php?op=room&pay=1");
function waterfall_runevent($type)
{
    global $session;
    // We assume this event only shows up in the forest currently.
    $from = "forest.php?";
    $session['user']['specialinc'] = "module:waterfall";
    $op = httpget('op');
    switch ($op) {
        case "search":
        case "":
            output("`n`2You see a small path that leads away from the main trail. The path is overgrown and you almost didn't see it as you crept by.`n`n");
            output("As you crouch down to study the trail, you notice footprints leading down the path but, oddly, none coming out. While studying the path you hear what sounds like running water.`n");
            addnav("T?Follow the Trail", $from . "op=trail");
            addnav("Continue in the forest", $from . "op=leave");
            break;
        case "trail":
            output("`2You take the path and begin exploring...`n`n");
            $rand = e_rand(1, 12);
            switch ($rand) {
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                    output("`2After a few hours of exploring you become lost.`n`n");
                    output("`&You `\$lose `&some Stamina finding your way back.`n`n");
                    if ($session['user']['turns'] > 0) {
                        $session['user']['turns']--;
                    }
                    $session['user']['specialinc'] = "";
                    break;
                case 6:
                case 7:
                case 8:
                    output("`^After a few minutes of exploring you find a waterfall!`n`n");
                    output("`2You also notice a small ledge along the rock face of the waterfall.`n");
                    output("Should you walk the ledge?");
                    addnav("Walk the ledge", $from . "op=ledge");
                    addnav("Return to the forest", $from . "op=leaveleave");
                    break;
                case 9:
                case 10:
                case 11:
                case 12:
                    output("`^After a few minutes exploring the area you find a waterfall!`n");
                    output("`2Thirsty from the walk to the falls you are trying to decide whether or not to take a drink.`n");
                    addnav("Take a drink", $from . "op=drink");
                    addnav("Return to the forest", $from . "op=leaveleave");
                    break;
            }
            break;
        case "ledge":
            $session['user']['specialinc'] = "";
            $fall = e_rand(1, 9);
            switch ($fall) {
                case 1:
                case 2:
                case 3:
                case 4:
                    $gems = e_rand(1, 2);
                    output("`&You carefully walk the ledge behind the waterfall and find... `%%s %s`n", $gems, translate_inline($gems == 1 ? "gem" : "gems"));
                    $session['user']['gems'] += $gems;
                    debuglog("found {$gems} gem(s) behind the waterfall.");
                    break;
                case 5:
                case 6:
                case 7:
                case 8:
                    $lhps = round($session['user']['hitpoints'] * 0.25);
                    $session['user']['hitpoints'] -= $lhps;
                    output("`&You carefully walk the ledge behind the waterfall but not carefully enough!`n");
                    output("You slip and fall, hurting yourself.`n`n");
                    output("`4You have lost `\$%s `4hitpoints during your fall.", $lhps);
                    if ($session['user']['gold'] > 0) {
                        $gold = round($session['user']['gold'] * 0.15);
                        output("`4You also notice that you lost `^%s gold `4during the ordeal.`n`n", $gold);
                        $session['user']['gold'] -= $gold;
                        debuglog("lost {$gold} gold when he fell in the water by the waterfall.");
                    }
                    break;
                case 9:
                    output("`7As you are walking the ledge you slip and fall,`n");
                    output("hitting the rocks and the water below!`n`n");
                    output("`4`nYou have died and lost all your gold!");
                    output("`nYou may continue playing tomorrow.`n");
                    $session['user']['turns'] = 0;
                    $session['user']['hitpoints'] = 0;
                    debuglog("lost {$session['user']['gold']} gold when he fell from the top of the waterfall.");
                    $session['user']['gold'] = 0;
                    $session['user']['alive'] = false;
                    addnews("`%The broken body of %s`% was found partially submerged by the rocks under a waterfall.", $session['user']['name']);
                    addnav("Daily News", "news.php");
                    break;
            }
            break;
        case "drink":
            $session['user']['specialinc'] = "";
            $cnt = e_rand(1, 6);
            switch ($cnt) {
                case 1:
                case 2:
                case 3:
                    output("`2You drink from the falls and feel refreshed!`n`n");
                    output("`^You have been restored to full health!");
                    if ($session['user']['hitpoints'] < $session['user']['maxhitpoints']) {
                        $session['user']['hitpoints'] = $session['user']['maxhitpoints'];
                    }
                    break;
                case 4:
                    output("`2You walk to the base of the waterfall and drink deeply of the pure water.`n");
                    output("As you drink, you feel a tingling sensation spread all over your body...`n");
                    output("You feel refreshed and healthier than ever!`n`n");
                    $hptype = "permanently";
                    if (!get_module_setting("carrydk") || is_module_active("globalhp") && !get_module_setting("carrydk", "globalhp")) {
                        $hptype = "temporarily";
                    }
                    $hptype = translate_inline($hptype);
                    output("`^Your hitpoints have been restored and your maximum hitpoints have been %s increased by 1.", $hptype);
                    $session['user']['maxhitpoints']++;
                    if ($session['user']['hitpoints'] < $session['user']['maxhitpoints']) {
                        $session['user']['hitpoints'] = $session['user']['maxhitpoints'];
                    }
                    set_module_pref("extrahps", get_module_pref("extrahps") + 1);
                    break;
                case 5:
                case 6:
                    output("`2You drink from the falls and you start feeling weird.  You sit down and become ill.`n");
                    output("`4You lose some Stamina while recovering!");
                    if ($session['user']['turns'] > 0) {
                        $session['user']['turns']--;
                    }
                    break;
            }
            break;
        case "leave":
            output("`^You stare at the path for a few more moments trying to get the courage to explore it. A piercing chill runs up your spine that makes you start trembling.  At this point you have decided to stay on the main trail.  You quickly move away from the mysterious trail.");
            $session['user']['specialinc'] = "";
            break;
        case "leaveleave":
            output("`^You decide that discretion is the better part of valor, or at least survival, and return to the forest.");
            $session['user']['specialinc'] = "";
            break;
    }
    output_notl("`0");
}
Beispiel #30
-1
function processUrl($url)
{
    libxml_use_internal_errors(true);
    $html = @file_get_contents_curl($url);
    if (!$html) {
        debuglog("* no response from {$url}");
        return null;
    }
    $encoding = mb_detect_encoding($html, 'UTF-8, ISO-8859-1', true);
    if ($encoding == 'UTF-8') {
        $html = mb_convert_encoding($html, 'HTML-ENTITIES', $encoding);
    }
    $doc = new DOMDocument();
    $res = $doc->loadHTML($html);
    $info = array();
    $nodes = $doc->getElementsByTagName('title');
    if (!$nodes) {
        return null;
    }
    $info['title'] = substr($nodes->item(0)->nodeValue, 0, 256);
    $metas = $doc->getElementsByTagName('meta');
    for ($i = 0; $i < $metas->length; $i++) {
        $meta = $metas->item($i);
        $info['overview'] = processUrlKeyword($meta, 'name', 'description', $info['overview'], 512, false);
        $info['overview'] = processUrlKeyword($meta, 'property', 'og:description', $info['overview'], 512);
        $info['overview'] = processUrlKeyword($meta, 'property', 'rnews:description', $info['overview'], 512);
        $info['image_url'] = processUrlKeyword($meta, 'name', 'image', $info['image_url'], 1024, false);
        $info['image_url'] = processUrlKeyword($meta, 'property', 'og:image', $info['image_url'], 1024);
        $info['site_name'] = processUrlKeyword($meta, 'name', 'site_name', $info['site_name'], 64, false);
        $info['site_name'] = processUrlKeyword($meta, 'property', 'og:site_name', $info['site_name'], 64);
        $info['site_name'] = processUrlKeyword($meta, 'name', 'application-name', $info['site_name'], 64, false);
        $info['type'] = processUrlKeyword($meta, 'name', 'type', $info['type'], 64, false);
        $info['type'] = processUrlKeyword($meta, 'property', 'og:type', $info['type'], 64);
        $info['image_url'] = processUrlKeyword($meta, 'name', 'twitter:image', $info['image_url'], 1024);
        $info['player'] = processUrlKeyword($meta, 'name', 'twitter:player', $info['player'], 1024);
        $info['player_width'] = processUrlKeyword($meta, 'name', 'twitter:player:width', $info['player_width']);
        $info['player_height'] = processUrlKeyword($meta, 'name', 'twitter:player:height', $info['player_height']);
    }
    return $info;
}