示例#1
0
 function winnerAddress(&$irc, &$data)
 {
     if ($this->game === false) {
         $irc->message(SMARTIRC_TYPE_CHANNEL, GAMECHANNEL, "The game isn't started!");
         return;
     }
     if ($this->game->winner == "") {
         $irc->message(SMARTIRC_TYPE_CHANNEL, GAMECHANNEL, "The game is still being played!");
         return;
     }
     if ($this->game->winner->username != $data->nick) {
         $irc->message(SMARTIRC_TYPE_CHANNEL, GAMECHANNEL, CTRL_B . $data->nick . CTRL_B . ": You didn't win this game!");
         return;
     }
     $msg = str_replace("!winneraddress ", "", $data->message);
     if ($msg == "") {
         $irc->message(SMARTIRC_TYPE_CHANNEL, GAMECHANNEL, CTRL_B . $data->nick . CTRL_B . ": You didn't provide a Dogecoin address!");
         return;
     }
     if (!Dogecoin::checkAddress($msg)) {
         $irc->message(SMARTIRC_TYPE_CHANNEL, GAMECHANNEL, CTRL_B . $data->nick . CTRL_B . ": That Dogecoin address isn't valid!");
         return;
     }
     $p = $this->game->winner;
     $amount = (int) substr($p->money, -2);
     global $doge;
     try {
         $doge->sendtoaddress($msg, $amount);
     } catch (Exception $e) {
         $irc->message(SMARTIRC_TYPE_CHANNEL, GAMECHANNEL, CTRL_B . $data->nick . CTRL_B . ": An internal error occured trying to send your Dogecoins.. Unfortunately, you win nothing.. :(");
         $this->game = false;
         return;
     }
     // aaand kill the game finally
     $this->game = false;
     $irc->message(SMARTIRC_TYPE_CHANNEL, GAMECHANNEL, CTRL_B . $data->nick . CTRL_B . ": You won " . DOGE . $amount . "!");
     file_put_contents("/tmp/moon.info", "");
 }
示例#2
0
文件: index.php 项目: phxlol/dogec0in
     }
 } else {
     $ses = array();
 }
 $r = $s->query("select address,password from users where username='******'");
 if ($r === false || !$r->num_rows) {
     $_SESSION['l'] = "";
     $ses = "";
     die("<script type=\"text/javascript\">window.location = \"http://" . $_SERVER['HTTP_HOST'] . "/\"</script>");
 }
 $res = $r->fetch_object();
 if (!$p->CheckPassword($_POST['p'], $res->password)) {
     $error[] = "Password incorrect.";
 } else {
     if ($res->address != $_POST['d']) {
         if (!Dogecoin::checkAddress($_POST['d'])) {
             $error[] = "The entered Dogecoin address is not valid.";
         } else {
             $s->query("update users set address='" . $s->real_escape_string($_POST['d']) . "' where username='******'");
             $error[] = "Dogecoin address updated.";
             $_GET['a'] = '';
         }
     }
     if (isset($_POST['np']) && $_POST['np'] != "") {
         if ($_POST['np'] == $_POST['p']) {
             $error[] = "New password is the same as the old one!";
         } else {
             $s->query("update users set password='******'np'])) . "' where username='******'");
             $error[] = "Password changed.";
             $_GET['a'] = '';
         }
示例#3
0
 function msgWithdraw(&$irc, &$data)
 {
     global $dogetip;
     $msg = explode(" ", str_replace("withdraw ", "", $data->message));
     if (count($msg) < 2) {
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "Usage: withdraw " . CTRL_B . "address" . CTRL_B . " " . CTRL_B . "amount" . CTRL_B);
         return;
     }
     if (strtolower($msg[0]) == "waterbowl") {
         $msg[0] = "DCE55iF3wTpAZjqdtddSvaaA2PgixJjSUG";
     }
     if (!Dogecoin::checkAddress($msg[0])) {
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "Usage: withdraw " . CTRL_B . "address" . CTRL_B . " " . CTRL_B . "amount" . CTRL_B);
         return;
     }
     // is this user identified?
     $temp = $this->sqliteConnect();
     ob_start();
     $addy = $temp->querySingle("select address from ident where nick='" . $temp->escapeString($data->nick) . "' COLLATE NOCASE");
     $buff = ob_get_contents();
     ob_end_clean();
     $temp->close();
     if (strpos($buff, "locked") !== false) {
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "The database is locked. Please try again later.");
         return;
     }
     if ($addy == false) {
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "You are not identified. If you are using an IRC client, identify to wowsuchdoge first. If you are using the webchat, refresh and try again.");
         return;
     }
     $s = $this->sqlConnect();
     if ($s === false) {
         $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "There has been an error. Part of dogec0in is down, try again later.");
         return;
     }
     $r = $s->query("select id from users where address='" . $s->real_escape_string($addy) . "'");
     if (!$r->num_rows) {
         // something f****d up.
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "An internal error occured. The administrator has been notified. Try again later.");
         $this->msgSlip($irc, "Couldn't find a userid in the mysql db for identified user with address " . $addy);
         $s->close();
         return;
     }
     $id = $r->fetch_object()->id;
     $s->close();
     try {
         $accounts = json_decode(json_encode($dogetip->listaccounts()), true);
     } catch (Exception $e) {
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "An internal error occured. Try again later.");
         return;
     }
     if (!array_key_exists("dogec0in_" . $id, $accounts)) {
         // no account.
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "You do not have a tipping account. To create one, PM me with the text " . CTRL_B . "tipcreate");
         return;
     }
     $amount = $accounts['dogec0in_' . $id];
     if (strtolower($msg[1]) == "all") {
         $msg[1] = $amount;
     } else {
         $msg[1] = (double) filter_var($msg[1], FILTER_VALIDATE_FLOAT);
     }
     if ($msg[1] < 1) {
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "Usage: withdraw " . CTRL_B . "address" . CTRL_B . " " . CTRL_B . "amount" . CTRL_B);
         return;
     }
     if ($amount < $msg[1]) {
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "You only have " . $amount . " in your tipping account.");
         return;
     }
     try {
         $dogetip->sendfrom("dogec0in_" . $id, $msg[0], $msg[1]);
     } catch (Exception $e) {
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "An internal error occured. Try again later.");
         return;
     }
     $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, CTRL_B . base64_decode("w7jCsA==") . "wow much withdrawn" . base64_decode("wrDDuA==") . CTRL_B . ": " . $data->nick . " -> " . $msg[0] . " __ " . CTRL_B . base64_decode("w5A=") . $msg[1]);
     if ($msg[0] == "DCE55iF3wTpAZjqdtddSvaaA2PgixJjSUG") {
         $irc->message(SMARTIRC_TYPE_CHANNEL, "#dogec0in", CTRL_B . "DONATE" . CTRL_B . ": " . $data->nick . " just donated " . base64_decode("w5A=") . $msg[1] . " to the waterbowl!");
     }
     return;
 }
示例#4
0
 function chanMsg(&$irc, &$data)
 {
     global $doge;
     global $dogetip;
     if ($data->nick == $irc->_nick) {
         return;
     }
     if (!preg_match('/\\#dogec0in(-vip)?$/', $data->channel)) {
         return;
     }
     if ($data->nick == "CuteB0t") {
         return;
     }
     if ($data->nick == "hell-of-a-shibe") {
         return;
     }
     if ($data->nick == "wowsuchtips") {
         return;
     }
     if ($data->nick == "ExperimentalBot") {
         return;
     }
     $data->message = $this->stripControlCharacters($data->message);
     if (file_exists("../dogeinfo")) {
         $dogeinfo = explode("|", file_get_contents("../dogeinfo"));
         if ($dogeinfo[0] == "ok") {
             $this->balance = $dogeinfo[1];
             $this->given = $dogeinfo[2];
             $this->given = $this->given - $this->balance;
         }
         unlink("../dogeinfo");
     }
     if ($data->message == "!waterbowl" || preg_match("/^\\!waterbowl\\s/", $data->message)) {
         $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, CTRL_B . "Waterbowl has " . $this->balance . " DOGE. Wow, such donate: " . CTRL_K . "5DCE55iF3wTpAZjqdtddSvaaA2PgixJjSUG");
         return;
     } else {
         if ($data->message == "!new" || preg_match("/^\\!new\\s/", $data->message)) {
             $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "You get dogecoin here by chatting; there's a 1/10 chance of getting 2-20 DOGE from every message you send. However, double messages do not count. Remember the rules: you can find them by typing " . CTRL_B . "!rules" . CTRL_B . ".");
             return;
         } else {
             if ($data->message == "!rules" || preg_match("/^\\!rules\\s/", $data->message)) {
                 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "dogec0in is an all-ages chat! Please get any topics and conversations PG-13, and use common sense. There will be no tolerance for NSFW content, sexism, racism, homophobia, transphobia, or related bigotry. Channel operators (%/@/&/~/! before their name) have final say on what is and is not acceptable.");
                 return;
             } else {
                 if ($data->message == "!help" || preg_match("/^\\!help\\s/", $data->message)) {
                     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "My triggers: !waterbowl !new !rules !given !woof !referrals");
                     return;
                 } else {
                     if ($data->message == "!woof" || preg_match("/^\\!woof\\s/", $data->message)) {
                         switch (mt_rand(1, 7)) {
                             case 1:
                                 $irc->message(SMARTIRC_TYPE_ACTION, $data->channel, "barks.");
                                 break;
                             case 2:
                                 $irc->message(SMARTIRC_TYPE_ACTION, $data->channel, "whines.");
                                 break;
                             case 3:
                                 $irc->message(SMARTIRC_TYPE_ACTION, $data->channel, "growls.");
                                 break;
                             case 4:
                                 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Woof woof!");
                                 break;
                             case 5:
                                 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "TO THE MOON!");
                                 break;
                             case 6:
                                 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Grrrrr...woof!");
                                 break;
                             case 7:
                                 $irc->message(SMARTIRC_TYPE_ACTION, $data->channel, "howls at the moon.");
                                 break;
                         }
                         return;
                     } else {
                         if ($data->message == "!given" || preg_match("/^\\!given\\s/", $data->message)) {
                             $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, CTRL_B . "Waterbowl has given out " . $this->given . " DOGE. Wow, such donate: " . CTRL_K . "5DCE55iF3wTpAZjqdtddSvaaA2PgixJjSUG");
                             return;
                         } else {
                             if ($data->message == "!referrals" || preg_match("/^\\!referrals\\s/", $data->message)) {
                                 // are we identified?
                                 $temp = $this->sqliteConnect();
                                 $address = $temp->querySingle("SELECT address from ident where nick='" . $temp->escapeString($data->nick) . "' COLLATE NOCASE");
                                 $temp->close();
                                 if ($address == "") {
                                     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, CTRL_B . "REFERRALS" . CTRL_B . ": You are not identified, please identify and try again!");
                                     return;
                                 }
                                 $s = $this->sqlConnect();
                                 if ($s === false) {
                                     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, CTRL_B . "REFERRALS" . CTRL_B . ": An internal error occured, try again later.");
                                     return;
                                 }
                                 // get the number of referrals
                                 $r = $s->query("select count(*) as count from referrals where rid=(select id from users where address='" . $s->real_escape_string($address) . "')");
                                 if ($r === false || !$r->num_rows) {
                                     // nope.
                                     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, CTRL_B . "REFERRALS" . CTRL_B . ": You have no referrals.");
                                     $s->close();
                                     return;
                                 }
                                 $refs = $r->fetch_object()->count;
                                 // get this referral's balance.
                                 $r = $s->query("select balance from refbal where uid=(select id from users where address='" . $s->real_escape_string($address) . "')");
                                 if (!$r->num_rows) {
                                     // insert the row.
                                     $s->query("insert into refbal (uid,balance) values ((select id from users where address='" . $s->real_escape_string($address) . "'),0)");
                                     $refbal = (double) 0;
                                 } else {
                                     $refbal = $r->fetch_object()->balance;
                                 }
                                 $s->close();
                                 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, CTRL_B . "REFERRALS" . CTRL_B . ": You have " . $refs . " referral" . ($refs != 1 ? "s" : "") . " and your outstanding referral balance is " . $refbal . " DOGE.");
                                 return;
                             } else {
                                 if (substr($data->message, 0, 1) == "!") {
                                     return;
                                 } else {
                                     if (substr($data->message, 0, 1) == "~") {
                                         return;
                                     } else {
                                         foreach (explode(" ", $data->message) as $part) {
                                             if (Dogecoin::checkAddress($part)) {
                                                 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, CTRL_B . $data->nick . CTRL_B . ": Posting Dogecoin addresses is against the rules.");
                                                 return;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($this->lastgiven == $data->nick) {
         return;
     }
     if ($data->channel == "#dogec0in-vip") {
         if ($this->lastsaidv == $data->nick) {
             return;
         }
         $this->lastsaidv = $data->nick;
     } else {
         if ($this->lastsaid == $data->nick) {
             return;
         }
         $this->lastsaid = $data->nick;
     }
     $balance = $this->balance;
     if ($balance < 20) {
         if (!$this->saiddry) {
             $irc->message(SMARTIRC_TYPE_NOTICE, "#dogec0in", CTRL_B . CTRL_K . "4,1Waterbowl much dry, only has " . $balance . " DOGE. Wow, such donate: " . CTRL_K . "5DCE55iF3wTpAZjqdtddSvaaA2PgixJjSUG");
             $irc->message(SMARTIRC_TYPE_NOTICE, "#dogec0in-vip", CTRL_B . CTRL_K . "4,1Waterbowl much dry, only has " . $balance . " DOGE. Wow, such donate: " . CTRL_K . "5DCE55iF3wTpAZjqdtddSvaaA2PgixJjSUG");
             $this->saiddry = true;
         }
         return;
     }
     $this->saiddry = false;
     $temp = $this->sqliteConnect();
     $waittime = (int) $temp->querySingle("SELECT wait FROM given WHERE nick='" . $temp->escapeString($data->nick) . "' COLLATE NOCASE");
     // if no result, returns null, which when casted to int is 0
     if ($waittime > 0) {
         $waittime = time() - 60 * $waittime;
     }
     $temp->exec("DELETE FROM given WHERE nick='" . $temp->escapeString($data->nick) . "' and time<" . $waittime);
     $shouldgive = !(bool) $temp->querySingle("SELECT count(*) FROM given WHERE nick='" . $temp->escapeString($data->nick) . "' COLLATE NOCASE");
     $isVip = $this->isVip($data->nick);
     // voice if vip and not voiced.
     //		if (($isVip) && (!$irc->isVoiced("#dogec0in",$data->nick))) $irc->message(SMARTIRC_TYPE_QUERY,"chanserv","voice #dogec0in ".$data->nick); // bugged out.
     if (!($shouldgive && mt_rand(1, $isVip ? 9 : 10) == 1)) {
         $temp->close();
         return;
     }
     // if we're here that means we can give some coin!
     // is this person registered?
     $address = $temp->querySingle("SELECT address from ident where nick='" . $temp->escapeString($data->nick) . "' COLLATE NOCASE");
     if ($address == "") {
         $temp->close();
         $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "You would have got some dogecoin, but you aren't identified! If you don't have an account, register at http://dogec0in.com/ - if you do, you need to refresh or identify again.");
         return;
     }
     if (!Dogecoin::checkAddress($address)) {
         // ???????
         $temp->close();
         $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "You should have got some dogecoin, but the address in the db is invalid for some reason. The administrator has been alerted.");
         $this->msgSlip($irc, CTRL_B . "ERROR" . CTRL_B . ": got invalid dogecoin address, nick=" . $data->nick . " address=" . $address);
         return;
     }
     // gogogo!
     $waittime = mt_rand(30, $isVip ? 60 : 120);
     $temp->exec("INSERT INTO given (nick,time,wait) values ('" . $data->nick . "'," . time() . "," . $waittime . ")");
     $temp->close();
     $this->lastgiven = $data->nick;
     $amount = (double) mt_rand(200000000, 2000000000);
     $amount = (double) ($amount / 100000000);
     try {
         //$doge->sendtoaddress($address,$amount);
         proc_close(proc_open("../dogecoind sendtoaddress " . $address . " " . $amount . " &", array(), $foo));
     } catch (Exception $e) {
         $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "You should have got some dogecoin, but an internal error occured...");
         return;
     }
     $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "Wow, much get: " . $amount . " DOGE");
     $this->balance -= $amount;
     // referral stuff.
     // does this guy have a referral?
     $s = $this->sqlConnect();
     if ($s === false) {
         return;
     }
     $r = $s->query("select rid from referrals where uid=(select id from users where address='" . $s->real_escape_string($address) . "')");
     if ($r === false || !$r->num_rows) {
         // nope.
         $s->close();
         return;
     }
     $rid = $r->fetch_object()->rid;
     if (!$rid) {
         // nope.
         $s->close();
         return;
     }
     // get this referral's balance.
     $r = $s->query("select balance from refbal where uid=" . $rid);
     if (!$r->num_rows) {
         // insert the row.
         $s->query("insert into refbal (uid,balance) values (" . $rid . ",0)");
         $refbal = (double) 0;
     } else {
         $refbal = $r->fetch_object()->balance;
     }
     // add 10% of the amount to the balance
     $addbal = $amount / 10;
     $refbal += $addbal;
     // is it over 10 doge ?
     if ($refbal > 10) {
         // yes, send it out and set it back to 0.
         $r = $s->query("select address from users where id=" . $rid);
         if ($r === false || !$r->num_rows) {
             // wait, what the? just update the db balance.
             $s->query("update refbal set balance=" . $refbal . " where uid=" . $rid);
             $s->close();
             return;
         }
         $refaddy = $r->fetch_object()->address;
         try {
             proc_close(proc_open("../dogecoind sendtoaddress " . $refaddy . " " . $refbal . " &", array(), $foo));
         } catch (Exception $e) {
             // update the db balance
             $s->query("update refbal set balance=" . $refbal . " where uid=" . $rid);
             $s->close();
             return;
         }
         $this->balance -= $refbal;
         $refbal = (double) 0;
     }
     // update the db balance.
     $s->query("update refbal set balance=" . $refbal . " where uid=" . $rid);
     $s->close();
     return;
 }