function roll($target) { // returns 1 1d100 if ($target == "") { $target = -1; } $string = array(randnum(), 0); usleep(1000); $string[1] = randnum(); $result = $string[0] . ", " . $string[1]; $sum = $string[0] * 10 + $string[1]; $critical = ""; if ($string[0] == $string[1]) { $critical = "critical "; } /* Old Fudge Dice stuff foreach($string as $die) { if($die < 3) { $result .= "- "; $sum--; } elseif($die < 5) { $result .= "0 "; } else { $result .= "+ "; $sum++; } } */ if ($sum == 99) { return "Critical Success!"; } else { if ($sum == 0) { return "Critical Failure!"; } else { if ($target < 0) { return $result . " " . $critical; } else { if ($sum > $target) { return $result . " (" . $critical . "failure, margin: " . ($sum - $target) . ") [" . $target . "]"; } else { return $result . " (" . $critical . "success, margin: " . $sum . ") [" . $target . "]"; } } } } }
function roll($dice = 1) { $dice = intval($dice, $again = 10); if ($dice < 1) { $chancedie = true; } if ($dice > 50) { return "Too many dice at once."; } $result = ""; $reroll = 0; $successes = 0; $rdotorg = true; $rollbunch = randnum($dice, 1, 10); for ($i = 0; $i < $dice; $i++) { $thisgo = $rollbunch[$i]; if (!is_int($thisgo) or !$rdotorg) { $thisgo = mt_rand(1, 10); $rdotorg = false; } if ($thisgo > $again - 1) { $reroll++; } if ($chance and $thisgo > 9) { $success++; } else { if ($thisgo > 7) { $successes++; } } $result .= $thisgo . " "; } if (!$rdotorg) { $result = "* " . $result; } if ($chancedie) { return "Chance Roll! " . mt_rand(1, 10) . "*<br>"; } else { if ($reroll < 1) { return $result . "// Successes: " . $successes . "<br>"; } else { return $result . "// Successes: " . $successes . "<br> Rerolls: " . roll($reroll); } } }
/** * 重置用户密码 *@param $id 传人数据id *@examlpe */ public function rspwd($id) { $Public = A('Index', 'Public'); $Mailer = A('Mail', 'Public'); //main $user = D('User_table'); if (!is_int((int) $id)) { echo 0; } else { $rand_pwd = randnum(6); $data['password'] = md5($rand_pwd); $map['id'] = array('eq', $id); $info = $user->where($map)->find(); $edit = $user->where($map)->save($data); if ($edit !== false) { $to = $info['email']; $title = '重置密码通知'; $name = $info['username']; $notes = 'Dear ' . $info['username']; $mail_cfg = $Public->MC(); $host = C('CFG_HOST'); $contents = '<p><span style="color: rgb(51, 51, 51); font-family: verdana, Tahoma, Arial, 宋体, sans-serif; font-size: 14px; ">您好:</span></p><p><span style="color: rgb(51, 51, 51); font-family: verdana, Tahoma, Arial, 宋体, sans-serif; font-size: 14px; ">您在项目管理系統的密码已被重置</span></p><p><span style="color: rgb(51, 51, 51); font-family: verdana, Tahoma, Arial, 宋体, sans-serif; font-size: 14px; ">账号:' . $name . ' 密码:' . $rand_pwd . '</span></p><p><span style="color: rgb(51, 51, 51); font-family: verdana, Tahoma, Arial, 宋体, sans-serif; font-size: 14px; ">登錄地址:</span><a target="_blank" href="' . $host . '">' . $host . '</a></p><p><span style="color: rgb(51, 51, 51); font-family: verdana, Tahoma, Arial, 宋体, sans-serif; font-size: 14px; ">此邮件由系统自动发送,请不要回复,如有问题请联系系统管理员!</span></p>'; $send = $Mailer->set($title, $contents, $mail_cfg); $Mailer->mailObj->AddAddress($to, $notes); $send = $Mailer->mailObj->send(); $Mailer->mailObj->ClearAddresses(); unset($Mailer, $m_cfg, $notes, $name, $to, $title, $contents, $data); if ($send == 1) { echo 1; } else { $data['password'] = $info['password']; $map['id'] = array('eq', $id); $edit = $user->where($map)->save($data); echo 2; } } else { echo 0; } } unset($data, $user, $map, $info); }