Example #1
0
 public function createToken($uid, $token_expire = 0)
 {
     $token_expire = $token_expire > 0 ? time() + $token_expire : time() + 60 * 60 * 24 * 90;
     $token = md5(md5($uid . $token_expire . time() . rand() . "showdoc") . "rdgtrd12367hghf54t");
     $data['uid'] = $uid;
     $data['token'] = $token;
     $data['token_expire'] = $token_expire;
     $data['ip'] = getIPaddress();
     $data['addtime'] = time();
     $ret = $this->add($data);
     if ($ret) {
         //删除过期的token
         $this->where("token_expire < " . time())->delete();
         return $token;
     }
     return false;
 }
Example #2
0
function sendEmail($configData,$formData)
{
// build the message body from the configured fields

	$body = "From ".$formData['fromName']." at ".$formData['fromAddress']."\r\n";
	if (!empty($formData['list1']))
		$body .= $configData['list_prompt'].": ".$configData['list_array'][$formData['list1']]."\r\n";
	if (!empty($formData['line1']))
		$body .= $configData['line1_prompt'].": ".$formData['line1']."\r\n";
	if (!empty($formData['line2']))
		$body .= $configData['line2_prompt'].": ".$formData['line2']."\r\n";
	if (!empty($formData['line3']))
		$body .= $configData['line3_prompt'].": ".$formData['line3']."\r\n";
	if (!empty($formData['line4']))
		$body .= $configData['line4_prompt'].": ".$formData['line4']."\r\n";
	if (!empty($formData['line5']))
		$body .= $configData['line5_prompt'].": ".$formData['line5']."\r\n";
	if (!empty($formData['area_data']))
		$body .= $configData['area_prompt'].": ".$formData['area_data']."\r\n";

// make sure the body and subject don't contain anything they shouldn't

	jimport('joomla.mail.helper');
	$body = JMailHelper::cleanBody($body);
	$subject = JMailHelper::cleanSubject($formData['subject']);

// get the client information

	$ip = getIPaddress();
	$ipmsg = "Client IP: ".$ip."\r\n";
	$ipmsg .= $_SERVER["HTTP_USER_AGENT"]."\r\n";

// from version 2.11 we now send the mail using the Joomla sendMail function (instead of php mail)
// which uses the mail settings configured in Joomla Global Configuration

	$app = &JFactory::getApplication();
	$from = $app->getCfg('mailfrom');
	$fromname = $app->getCfg('fromname');
	$recipient = $configData['toPrimary'];
	$cc = $configData['cc'];
	$bcc = $configData['bcc'];
	$replyto = $formData['fromAddress'];
	$replytoname = $formData['fromName'];
	
// from version 2.15 we build the mail object ourselves so that we can get at the ErrorInfo

	$mail =& JFactory::getMailer();
	$mail->setSender(array($from, $fromname));
	$mail->setSubject($subject);
	$mail->setBody($body.$ipmsg);
	$mail->addRecipient($recipient);
	if ($cc != '')
		$mail->addCC($cc);
	if ($bcc != '')
		$mail->addBCC($bcc);
	$mail->addReplyTo(array($replyto, $replytoname));
	$ret_main = $mail->Send();
	if ($ret_main === true)
		$status = "Sent OK\r\n";
	else
		$status = "Mail was NOT accepted for delivery (".$mail->ErrorInfo.")\r\n";
	
	logText(JText::_('SUBJECT').": $subject\r\n".
		"To: $recipient\r\n".
		"From: $fromname at $from\r\n".
		"Cc: $cc\r\n".
		"Bcc: $bcc\r\n".
		"ReplyTo: $replytoname at $replyto\r\n".
		$ipmsg.
		$body.
		$status.
		"-------------------------\r\n");
	
// if the user wanted a copy, send that separately

	if ($formData['copyMe'] == 1)
		{
		$mail =& JFactory::getMailer();
		$mail->setSender(array($from, $fromname));
		$mail->setSubject($subject);
		$mail->setBody($body);
		$mail->addRecipient($formData['fromAddress']);
		$ret_copy = $mail->Send();
		if ($ret_copy === true)
			$status = "Sent OK\r\n";
		else
			$status = "Mail was NOT accepted for delivery (".$mail->ErrorInfo.")\r\n";
		logText("Copy to: $recipient\r\n".
			$status.
			"-------------------------\r\n");
		}
	return $ret_main;
}
Example #3
0
 * @desc 管理员登录
 * @example http://www.hms.com/HMS/API/action/admin/login.act.php?a_name=seyaney&a_pwd=123456
 */
// GET方式获取管理员名称
$a_name = $_GET['a_name'];
// GET方式获取管理员登录密码
$a_pwd = $_GET['a_pwd'];
/**
 *查询操作
 *@example: select * from admin where a_name='admin' and a_pwd='syn1314'
 */
$sql = "select * from admin where a_name='{$a_name}' and a_pwd='{$a_pwd}' and a_isDel=0";
$res = $_mysqli->db_query_all($sql);
if (count($res) == 1) {
    /*信息匹配成功 把登录信息写入到cookie里*/
    setcookie('userId', $res[0]['a_id']);
    setcookie('userName', $res[0]['a_name']);
    echo '{"res":1}';
    /*更新登录状态信息*/
    $a_loginTimes = $res[0]['a_loginTimes'] + 1;
    $a_loginIP = getIPaddress();
    $a_id = $_COOKIE['userId'];
    /**
     * 更新操作
     * @example update admin set a_loginIP='127.0.0.1',a_loginTimes='15-11-21 03:44:59' where a_id='1'
     */
    $sql = "update admin set a_loginIP='{$a_loginIP}',a_loginTimes='{$a_loginTimes}' where a_id='{$a_id}'";
    $res = $_mysqli->db_noquery($sql);
} else {
    echo '{"res":0}';
}
Example #4
0
            }
        }
    } else {
        if (getenv("HTTP_X_FORWARDED_FOR")) {
            $IPaddress = getenv("HTTP_X_FORWARDED_FOR");
        } else {
            if (getenv("HTTP_CLIENT_IP")) {
                $IPaddress = getenv("HTTP_CLIENT_IP");
            } else {
                $IPaddress = getenv("REMOTE_ADDR");
            }
        }
    }
    return $IPaddress;
}
$clientIP = getIPaddress();
//取得以前更新成功的老IP地址,如果一致,不再更新
$oldClientIP = $_SESSION['clientIP'];
if (strcmp($oldClientIP, $clientIP) == 0) {
    echo "Same IP Address";
    return;
}
/**
 * 获取解析记录列表
 *
 * @param integer $domainId 域名ID
 * @param integer $hostId 主机记录 id(传 0 查全部)
 * @param integer $offset 记录开始的偏移,第一条记录为 0
 * @param integer $rowNum 要获取的记录的数量,最大可取 2000,默认取30条。
 * @return string
 */
 public function getLocation()
 {
     $location = session('city');
     if (empty($location)) {
         $location = taobaoIP(getIPaddress());
         session('city', $location);
     }
 }