common.func.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. function write_money_use($info = '', $cost = '')
  3. {
  4. global $db;
  5. global $db_mymps;
  6. global $s_uid;
  7. global $timestamp;
  8. $timestamp = $timestamp ? $timestamp : time();
  9. if ($db->query('INSERT INTO `' . $db_mymps . 'member_record_use` (userid,paycost,subject,pubtime) VALUES (\'' . $s_uid . '\',\'' . $cost . '\',\'' . $info . '\',\'' . $timestamp . '\')')) {
  10. return true;
  11. }
  12. else {
  13. return false;
  14. }
  15. }
  16. function member_reg($userid, $userpwd, $email = '', $safequestion = '', $safeanswer = '', $openid = '', $cname = '', $status = '', $openid_wx = '', $logo = '', $prelogo = '')
  17. {
  18. global $mymps_global;
  19. global $db;
  20. global $db_mymps;
  21. global $member_log;
  22. global $timestamp;
  23. if ($openid) {
  24. if ($db->getOne('SELECT id FROM `' . $db_mymps . 'member` WHERE openid = \'' . $openid . '\'')) {
  25. write_msg('openid已重复!请重新完善帐号信息!');
  26. }
  27. }
  28. if ($openid_wx) {
  29. if ($db->getOne('SELECT id FROM `' . $db_mymps . 'member` WHERE openid_wx = \'' . $openid_wx . '\'')) {
  30. write_msg('openid已重复!请重新完善帐号信息!');
  31. }
  32. }
  33. $ip = GetIP();
  34. $safeanswer = trim($safeanswer);
  35. $row = $db->getRow('SELECT money_own FROM `' . $db_mymps . 'member_level` WHERE id = \'1\'');
  36. $money_own = $row['money_own'];
  37. $status = $status == 1 || $mymps_global['cfg_member_verify'] == 1 || $mymps_global['cfg_member_verify'] == 4 ? 1 : 0;
  38. $sql = 'INSERT INTO `' . $db_mymps . 'member`(id,userid,userpwd,logo,prelogo,email,safequestion,safeanswer,levelid,joinip,loginip,jointime,logintime,money_own,openid,openid_wx,cname,status) VALUES (\'\',\'' . $userid . '\',\'' . $userpwd . '\',\'' . $logo . '\',\'' . $prelogo . '\',\'' . $email . '\',\'' . $safequestion . '\',\'' . $safeanswer . '\',\'1\',\'' . $ip . '\',\'' . $ip . '\',\'' . $timestamp . '\',\'' . $timestamp . '\',\'' . $money_own . '\',\'' . $openid . '\',\'' . $openid_wx . '\',\'' . $cname . '\',\'' . $status . '\')';
  39. $db->query($sql);
  40. }
  41. function sendpm($fromuser = '', $touser = '', $title = '', $content = '', $if_sys = 0)
  42. {
  43. global $db;
  44. global $db_mymps;
  45. global $timestamp;
  46. $fromuser = $fromuser ? mhtmlspecialchars($fromuser) : '';
  47. $touser = $touser ? mhtmlspecialchars($touser) : '';
  48. $title = $title ? mhtmlspecialchars($title) : '';
  49. $content = $content ? $content : '';
  50. $pubtime = $timestamp ? $timestamp : time();
  51. $result = array();
  52. $title = str_replace('\'', '"', $title);
  53. $content = str_replace('\'', '"', $content);
  54. empty($title) && ($title = substring($content, 0, 15));
  55. if (empty($touser)) {
  56. exit('请指定要发短消息的用户名');
  57. }
  58. if (empty($content) || $fromuser == $touser) {
  59. $result['succ'] = 'no';
  60. $result['member'] = $touser;
  61. return $result;
  62. exit();
  63. }
  64. if (!($ifuser = $db->getOne('SELECT userid FROM `' . $db_mymps . 'member` WHERE userid = \'' . $touser . '\''))) {
  65. $result['succ'] = 'no';
  66. $result['member'] = $touser;
  67. }
  68. else {
  69. $db->query('INSERT INTO `' . $db_mymps . 'member_pm` (title,content,fromuser,touser,pubtime,if_sys) VALUES (\'' . $title . '\',\'' . $content . '\',\'' . $fromuser . '\',\'' . $touser . '\',\'' . $pubtime . '\',\'' . $if_sys . '\')');
  70. $result['succ'] = 'yes';
  71. $result['member'] = $touser;
  72. }
  73. return $result;
  74. }
  75. ?>