本文整理汇总了PHP中qa_remote_ip_address函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_remote_ip_address函数的具体用法?PHP qa_remote_ip_address怎么用?PHP qa_remote_ip_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_remote_ip_address函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: qa_create_new_user
function qa_create_new_user($email, $password, $handle, $level = QA_USER_LEVEL_BASIC, $confirmed = false)
{
require_once QA_INCLUDE_DIR . 'qa-db-users.php';
require_once QA_INCLUDE_DIR . 'qa-db-points.php';
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
require_once QA_INCLUDE_DIR . 'qa-app-cookies.php';
$userid = qa_db_user_create($email, $password, $handle, $level, qa_remote_ip_address());
qa_db_points_update_ifuser($userid, null);
qa_db_uapprovecount_update();
if ($confirmed) {
qa_db_user_set_flag($userid, QA_USER_FLAGS_EMAIL_CONFIRMED, true);
}
if (qa_opt('show_notice_welcome')) {
qa_db_user_set_flag($userid, QA_USER_FLAGS_WELCOME_NOTICE, true);
}
$custom = qa_opt('show_custom_welcome') ? trim(qa_opt('custom_welcome')) : '';
if (qa_opt('confirm_user_emails') && $level < QA_USER_LEVEL_EXPERT && !$confirmed) {
$confirm = strtr(qa_lang('emails/welcome_confirm'), array('^url' => qa_get_new_confirm_url($userid, $handle)));
if (qa_opt('confirm_user_required')) {
qa_db_user_set_flag($userid, QA_USER_FLAGS_MUST_CONFIRM, true);
}
} else {
$confirm = '';
}
if (qa_opt('moderate_users') && qa_opt('approve_user_required') && $level < QA_USER_LEVEL_EXPERT) {
qa_db_user_set_flag($userid, QA_USER_FLAGS_MUST_APPROVE, true);
}
qw_send_notification($userid, $email, $handle, qa_lang('emails/welcome_subject'), nl2br(qa_lang('emails/welcome_body')), array('^password' => isset($password) ? qa_lang('main/hidden') : qa_lang('users/password_to_set'), '^url' => qa_opt('site_url'), '^custom' => strlen($custom) ? $custom . "\n\n" : '', '^confirm' => $confirm));
qa_report_event('u_register', $userid, $handle, qa_cookie_get(), array('email' => $email, 'level' => $level));
return $userid;
}
示例2: mp_announcement_create
function mp_announcement_create($userid, $handle, $cookieid, $title, $content, $format, $text, $notify, $categoryid)
{
/*
* Proceeds to create an announcement
*
*/
require_once QA_INCLUDE_DIR . 'qa-db-post-create.php';
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
require_once QA_INCLUDE_DIR . 'mp-app-users.php';
// persist data to database
$postid = qa_db_post_create('AN', null, $userid, $cookieid, qa_remote_ip_address(), $title, $content, $format, null, $notify, $categoryid);
qa_user_report_action(qa_get_logged_in_userid(), null, null, null, null);
// update new post with category path hierarchy
qa_db_posts_calc_category_path($postid);
// send notifications
if ($notify && isset($postid)) {
$category = mp_get_categoryinfo($categoryid);
$recipients = mp_get_category_userids($categoryid);
foreach ($recipients as $recipient) {
// retrieve the user flags
$userflags = mp_get_user_flags($recipient['userid']);
// check user flags to determine whether user should be notified or not
// of the new answer post
if (!($userflags & QA_USER_FLAGS_NOTIFY_ANNOUNCEMENTS)) {
qa_send_notification($recipient['userid'], null, null, qa_lang('emails/an_posted_subject'), qa_lang('emails/an_posted_body'), array('^an_handle' => $handle, '^category_title' => $category['title'], '^an_title' => $title, '^an_url' => qa_path('mp-announcements-page', null, qa_opt('site_url'), null, null)));
}
}
}
// report announcement create event
qa_report_event('an_post', $userid, $handle, $cookieid, array('postid' => $postid, 'title' => $title, 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $categoryid, 'notify' => $notify));
return $postid;
}
示例3: process_event
function process_event($event, $userid, $handle, $cookieid, $params)
{
qw_do_action('qw_event_' . $event, $event, $userid, $handle, $cookieid, $params);
if (qa_opt('event_logger_to_database')) {
$paramstring = '';
foreach ($params as $key => $value) {
$value_to_text = $this->value_to_text($value, $key);
$value = is_array($value) ? 'array(' . count($value) . ')' . "\t" . $value_to_text : $value_to_text;
$paramstring .= (strlen($paramstring) ? "\t" : '') . $key . '=' . $value;
}
$paramstring = strtr($paramstring, "\n\r", ' ');
qa_db_query_sub('INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) ' . 'VALUES (NOW(), $, $, $, #, $, $)', qa_remote_ip_address(), $userid, $handle, $cookieid, $event, $paramstring);
}
if (qa_opt('event_logger_to_files')) {
// Substitute some placeholders if certain information is missing
if (!strlen($userid)) {
$userid = 'no_userid';
}
if (!strlen($handle)) {
$handle = 'no_handle';
}
if (!strlen($cookieid)) {
$cookieid = 'no_cookieid';
}
$ip = qa_remote_ip_address();
if (!strlen($ip)) {
$ip = 'no_ipaddress';
}
// Build the log file line to be written
$fixedfields = array('Date' => date('Y\\-m\\-d'), 'Time' => date('H\\:i\\:s'), 'IPaddress' => $ip, 'UserID' => $userid, 'Username' => $handle, 'CookieID' => $cookieid, 'Event' => $event);
$fields = $fixedfields;
foreach ($params as $key => $value) {
$fields['param_' . $key] = $key . '=' . $this->value_to_text($value, $key);
}
$string = implode("\t", $fields);
// Build the full path and file name
$directory = qa_opt('event_logger_directory');
if (substr($directory, -1) != '/') {
$directory .= '/';
}
$filename = $directory . 'q2a-log-' . date('Y\\-m\\-d') . '.txt';
// Open, lock, write, unlock, close (to prevent interference between multiple writes)
$exists = file_exists($filename);
$file = @fopen($filename, 'a');
if (is_resource($file)) {
if (flock($file, LOCK_EX)) {
if (!$exists && filesize($filename) === 0 && !qa_opt('event_logger_hide_header')) {
$string = "Question2Answer " . QA_VERSION . " log file generated by Event Logger plugin.\n" . "This file is formatted as tab-delimited text with UTF-8 encoding.\n\n" . implode("\t", array_keys($fixedfields)) . "\textras...\n\n" . $string;
}
fwrite($file, $string . "\n");
flock($file, LOCK_UN);
}
fclose($file);
}
}
}
示例4: validate_post
function validate_post(&$error)
{
if (!empty($_POST['recaptcha_challenge_field']) && !empty($_POST['recaptcha_response_field'])) {
require_once $this->directory . 'recaptchalib.php';
$answer = recaptcha_check_answer(qa_opt('recaptcha_private_key'), qa_remote_ip_address(), $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
if ($answer->is_valid) {
return true;
}
$error = @$answer->error;
}
return false;
}
示例5: validate_post
/**
* Check that the CAPTCHA was entered correctly. reCAPTCHA sets a long string in 'g-recaptcha-response'
* when the CAPTCHA is completed; we check that with the reCAPTCHA API.
*/
public function validate_post(&$error)
{
require_once $this->directory . 'recaptchalib.php';
$recaptcha = new ReCaptcha(qa_opt('recaptcha_private_key'));
$remoteIp = qa_remote_ip_address();
$userResponse = qa_post_text('g-recaptcha-response');
$recResponse = $recaptcha->verifyResponse($remoteIp, $userResponse);
foreach ($recResponse->errorCodes as $code) {
if (isset($this->errorCodeMessages[$code])) {
$error .= $this->errorCodeMessages[$code] . "\n";
}
}
return $recResponse->success;
}
示例6: qa_db_hotness_update
function qa_db_hotness_update($firstpostid, $lastpostid = null, $viewincrement = false)
{
if (qa_should_update_counts()) {
if (!isset($lastpostid)) {
$lastpostid = $firstpostid;
}
$query = 'UPDATE ^posts AS x, (SELECT parents.postid, parents.created AS qcreated, COALESCE(MAX(children.created), parents.created) as acreated, COUNT(children.postid) AS acount, parents.netvotes, parents.views FROM ^posts AS parents LEFT JOIN ^posts AS children ON parents.postid=children.parentid AND children.type=\'A\' WHERE parents.postid>=# AND parents.postid<=# AND parents.type=\'Q\' GROUP BY postid) AS a SET x.hotness=(' . '((TO_DAYS(a.qcreated)-734138)*86400.0+TIME_TO_SEC(a.qcreated))*# + ' . '((TO_DAYS(a.acreated)-734138)*86400.0+TIME_TO_SEC(a.acreated))*# + ' . '(a.acount+0.0)*# + ' . '(a.netvotes+0.0)*# + ' . '(a.views+0.0+#)*#' . ')' . ($viewincrement ? ', x.views=x.views+1, x.lastviewip=INET_ATON($)' : '') . ' WHERE x.postid=a.postid';
// Additional multiples based on empirical analysis of activity on Q2A meta site to give approx equal influence for all factors
$arguments = array($firstpostid, $lastpostid, qa_opt('hot_weight_q_age'), qa_opt('hot_weight_a_age'), qa_opt('hot_weight_answers') * 160000, qa_opt('hot_weight_votes') * 160000, $viewincrement ? 1 : 0, qa_opt('hot_weight_views') * 4000);
if ($viewincrement) {
$arguments[] = qa_remote_ip_address();
}
qa_db_query_raw(qa_db_apply_sub($query, $arguments));
}
}
示例7: qa_captcha_validate
function qa_captcha_validate($form, &$errors)
{
if (qa_captcha_possible()) {
require_once QA_INCLUDE_DIR . 'qa-recaptchalib.php';
if (!empty($form['recaptcha_challenge_field']) && !empty($form['recaptcha_response_field'])) {
$answer = recaptcha_check_answer(qa_opt('recaptcha_private_key'), qa_remote_ip_address(), @$form['recaptcha_challenge_field'], @$form['recaptcha_response_field']);
if (!$answer->is_valid) {
$errors['captcha'] = @$answer->error;
}
} else {
$errors['captcha'] = true;
}
// empty error but still set it
}
}
示例8: process_event
function process_event($event, $userid, $handle, $cookieid, $params)
{
if (!qa_opt('event_logger_to_database')) {
return;
}
$twoway = array('a_select', 'a_unselect', 'q_vote_up', 'a_vote_up', 'q_vote_down', 'a_vote_down', 'q_vote_nil', 'a_vote_nil', 'q_flag', 'a_flag', 'c_flag', 'q_unflag', 'a_unflag', 'c_unflag', 'u_edit', 'u_level', 'u_block', 'u_unblock');
$special = array('a_post', 'c_post');
if (in_array($event, $twoway)) {
if (strpos($event, 'u_') === 0) {
$uid = $params['userid'];
} else {
$uid = qa_db_read_one_value(qa_db_query_sub('SELECT userid FROM ^posts WHERE postid=#', $params['postid']), true);
}
if ($uid != $userid) {
$ohandle = $this->getHandleFromId($uid);
$oevent = 'in_' . $event;
$paramstring = '';
foreach ($params as $key => $value) {
$paramstring .= (strlen($paramstring) ? "\t" : '') . $key . '=' . $this->value_to_text($value);
}
qa_db_query_sub('INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) ' . 'VALUES (NOW(), $, $, $, #, $, $)', qa_remote_ip_address(), $uid, $ohandle, $cookieid, $oevent, $paramstring);
}
}
// comments and answers
if (in_array($event, $special)) {
$pid = qa_db_read_one_value(qa_db_query_sub('SELECT userid FROM ^posts WHERE postid=#', $params['parentid']), true);
if ($pid != $userid) {
$ohandle = $this->getHandleFromId($pid);
switch ($event) {
case 'a_post':
$oevent = 'in_a_question';
break;
case 'c_post':
if ($params['parenttype'] == 'Q') {
$oevent = 'in_c_question';
} else {
$oevent = 'in_c_answer';
}
break;
}
$paramstring = '';
foreach ($params as $key => $value) {
$paramstring .= (strlen($paramstring) ? "\t" : '') . $key . '=' . $this->value_to_text($value);
}
qa_db_query_sub('INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) ' . 'VALUES (NOW(), $, $, $, #, $, $)', qa_remote_ip_address(), $pid, $ohandle, $cookieid, $oevent, $paramstring);
}
}
}
示例9: qa_page_queue_pending
function qa_page_queue_pending()
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
qa_preload_options();
$loginuserid = qa_get_logged_in_userid();
if (isset($loginuserid)) {
if (!QA_FINAL_EXTERNAL_USERS) {
qa_db_queue_pending_select('loggedinuser', qa_db_user_account_selectspec($loginuserid, true));
}
qa_db_queue_pending_select('notices', qa_db_user_notices_selectspec($loginuserid));
qa_db_queue_pending_select('favoritenonqs', qa_db_user_favorite_non_qs_selectspec($loginuserid));
qa_db_queue_pending_select('userlimits', qa_db_user_limits_selectspec($loginuserid));
qa_db_queue_pending_select('userlevels', qa_db_user_levels_selectspec($loginuserid, true));
}
qa_db_queue_pending_select('iplimits', qa_db_ip_limits_selectspec(qa_remote_ip_address()));
qa_db_queue_pending_select('navpages', qa_db_pages_selectspec(array('B', 'M', 'O', 'F')));
qa_db_queue_pending_select('widgets', qa_db_widgets_selectspec());
}
示例10: process_event
function process_event($event, $userid, $handle, $cookieid, $params)
{
if (!qa_opt('event_logger_to_database')) {
return;
}
// needed for function qa_post_userid_to_handle()
require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
$twoway = array('a_select', 'q_vote_up', 'a_vote_up', 'q_vote_down', 'a_vote_down');
$special = array('a_post', 'c_post');
if (in_array($event, $twoway)) {
if (strpos($event, 'u_') === 0) {
$uid = $params['userid'];
} else {
$uid = qa_db_read_one_value(qa_db_query_sub('SELECT userid FROM ^posts WHERE postid=#', $params['postid']), true);
}
if ($uid != $userid) {
$ohandle = qa_post_userid_to_handle($uid);
$oevent = 'in_' . $event;
$paramstring = '';
foreach ($params as $key => $value) {
$paramstring .= (strlen($paramstring) ? "\t" : '') . $key . '=' . $this->value_to_text($value);
}
// write in_ events to qa_eventlog
qa_db_query_sub('INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) ' . 'VALUES (NOW(), $, $, $, #, $, $)', qa_remote_ip_address(), $uid, $ohandle, $cookieid, $oevent, $paramstring);
}
}
// comments and answers
if (in_array($event, $special)) {
// userid (recent C)
$uid = qa_db_read_one_value(qa_db_query_sub('SELECT userid FROM ^posts WHERE postid=#', $params['postid']), true);
// userid (QA)
$pid = qa_db_read_one_value(qa_db_query_sub('SELECT userid FROM ^posts WHERE postid=#', $params['parentid']), true);
// if QA poster is not the same as commenter
if ($pid != $userid) {
$ohandle = qa_post_userid_to_handle($pid);
switch ($event) {
case 'a_post':
$oevent = 'in_a_question';
break;
case 'c_post':
if ($params['parenttype'] == 'Q') {
$oevent = 'in_c_question';
} else {
$oevent = 'in_c_answer';
}
break;
}
$paramstring = '';
foreach ($params as $key => $value) {
$paramstring .= (strlen($paramstring) ? "\t" : '') . $key . '=' . $this->value_to_text($value);
}
qa_db_query_sub('INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) ' . 'VALUES (NOW(), $, $, $, #, $, $)', qa_remote_ip_address(), $pid, $ohandle, $cookieid, $oevent, $paramstring);
}
// q2apro: added logging for comments in thread
if ($event == 'c_post') {
$oevent = 'in_c_comment';
// check if we have more comments to the parent
// DISTINCT: if a user has more than 1 comment just select him unique to inform him only once
$precCommentsQuery = qa_db_query_sub('SELECT DISTINCT userid FROM `^posts`
WHERE `parentid` = #
AND `type` = "C"
AND `userid` IS NOT NULL
', $params['parentid']);
while (($comment = qa_db_read_one_assoc($precCommentsQuery, true)) !== null) {
$userid_CommThr = $comment['userid'];
// unique
// don't inform user that comments, and don't inform user that comments on his own question/answer
if ($userid_CommThr != $uid && $userid_CommThr != $pid) {
$ohandle = qa_post_userid_to_handle($userid_CommThr);
$paramstring = '';
foreach ($params as $key => $value) {
$paramstring .= (strlen($paramstring) ? "\t" : '') . $key . '=' . $this->value_to_text($value);
}
qa_db_query_sub('INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) ' . 'VALUES (NOW(), $, $, $, #, $, $)', qa_remote_ip_address(), $userid_CommThr, $ohandle, $cookieid, $oevent, $paramstring);
}
}
}
// end in_c_comment
}
// end in_array
}
示例11: qa_user_report_action
function qa_user_report_action($userid, $action, $questionid, $answerid, $commentid)
{
require_once QA_INCLUDE_DIR . 'qa-db-users.php';
qa_db_user_written($userid, qa_remote_ip_address());
}
示例12: qa_limits_increment
function qa_limits_increment($userid, $action)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'qa-db-limits.php';
$period = (int) (qa_opt('db_time') / 3600);
if (isset($userid)) {
qa_db_limits_user_add($userid, $action, $period, 1);
}
qa_db_limits_ip_add(qa_remote_ip_address(), $action, $period, 1);
}
示例13: award_badge
function award_badge($object_id, $user_id, $badge_slug, $badge_badge = false)
{
if (!$user_id) {
return;
}
// add badge to userbadges
qa_db_query_sub('INSERT INTO ^userbadges (awarded_at, notify, object_id, user_id, badge_slug, id) ' . 'VALUES (NOW(), 1, #, #, $, 0)', $object_id, $user_id, $badge_slug);
if (qa_opt('event_logger_to_database')) {
// add event
$handle = qa_getHandleFromId($user_id);
qa_db_query_sub('INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) ' . 'VALUES (NOW(), $, $, $, #, $, $)', qa_remote_ip_address(), $user_id, $handle, qa_cookie_get_create(), 'badge_awarded', 'badge_slug=' . $badge_slug . ($object_id ? "\t" . 'postid=' . $object_id : ''));
}
if (qa_opt('badge_email_notify')) {
qa_badge_notification($user_id, $object_id, $badge_slug);
}
// check for sheer number of badges, unless this badge was for number of badges (avoid recursion!)
if (!$badge_badge) {
$this->check_badges($user_id);
}
}
示例14: qa_cookie_report_action
function qa_cookie_report_action($cookieid, $action)
{
require_once QA_INCLUDE_DIR . 'qa-db-cookies.php';
qa_db_cookie_written($cookieid, qa_remote_ip_address());
}
示例15: qa_comment_set_hidden
function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid, $question, $answer)
{
qa_post_unindex($oldcomment['postid']);
qa_db_post_set_type($oldcomment['postid'], $hidden ? 'C_HIDDEN' : 'C', $userid, qa_remote_ip_address());
qa_db_points_update_ifuser($oldcomment['userid'], array('cposts'));
qa_db_ccount_update();
if (!($hidden || $question['hidden'] || @$answer['hidden'])) {
// only index if none of the things it depends on are hidden
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
qa_post_index($oldcomment['postid'], 'C', $question['postid'], null, qa_viewer_text($oldcomment['content'], $oldcomment['format']), null);
}
qa_report_event($hidden ? 'c_hide' : 'c_reshow', $userid, $handle, $cookieid, array('postid' => $oldcomment['postid'], 'parentid' => $oldcomment['parentid'], 'parenttype' => isset($answer) ? $answer['basetype'] : $question['basetype'], 'questionid' => $question['postid']));
}