本文整理汇总了PHP中qa_call_override函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_call_override函数的具体用法?PHP qa_call_override怎么用?PHP qa_call_override使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_call_override函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: qa_send_email
function qa_send_email($params)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
// @error_log(print_r($params, true));
require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/PHPMailerAutoload.php';
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
$mailer->From = $params['fromemail'];
$mailer->Sender = $params['fromemail'];
$mailer->FromName = $params['fromname'];
$mailer->AddAddress($params['toemail'], $params['toname']);
$mailer->Subject = $params['subject'];
$mailer->Body = $params['body'];
if ($params['html']) {
$mailer->IsHTML(true);
}
if (qa_opt('smtp_active')) {
$mailer->IsSMTP();
$mailer->Host = qa_opt('smtp_address');
$mailer->Port = qa_opt('smtp_port');
if (qa_opt('smtp_secure')) {
$mailer->SMTPSecure = qa_opt('smtp_secure');
}
if (qa_opt('smtp_authenticate')) {
$mailer->SMTPAuth = true;
$mailer->Username = qa_opt('smtp_username');
$mailer->Password = qa_opt('smtp_password');
}
}
return $mailer->Send();
}
示例2: qa_db_blob_exists
function qa_db_blob_exists($blobid)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
return qa_db_read_one_value(qa_db_query_sub('SELECT COUNT(*) FROM ^blobs WHERE blobid=#', $blobid)) > 0;
}
示例3: qa_q_list_page_content
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/updates.php';
$userid = qa_get_logged_in_userid();
// Chop down to size, get user information for display
if (isset($pagesize)) {
$questions = array_slice($questions, 0, $pagesize);
}
$usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
// Prepare content for theme
$qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid)));
$qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
$qa_content['q_list']['qs'] = array();
if (count($questions)) {
$qa_content['title'] = $sometitle;
$defaults = qa_post_html_defaults('Q');
if (isset($categorypathprefix)) {
$defaults['categorypathprefix'] = $categorypathprefix;
}
foreach ($questions as $question) {
$fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults));
if (!empty($fields['raw']['closedbyid'])) {
$fields['closed'] = array('state' => qa_lang_html('main/closed'));
}
$qa_content['q_list']['qs'][] = $fields;
}
} else {
$qa_content['title'] = $nonetitle;
}
if (isset($userid) && isset($categoryid)) {
$favoritemap = qa_get_favorite_non_qs_map();
$categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']];
$qa_content['favorite'] = qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite, qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title']));
}
if (isset($count) && isset($pagesize)) {
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams);
}
if (empty($qa_content['page_links'])) {
$qa_content['suggest_next'] = $suggest;
}
if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) {
$qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams);
}
if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) {
$qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle));
}
return $qa_content;
}
示例4: qa_db_cache_get
function qa_db_cache_get($type, $cacheid)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$content = qa_db_read_one_value(qa_db_query_sub('SELECT content FROM ^cache WHERE type=$ AND cacheid=#', $type, $cacheid), true);
if (isset($content)) {
qa_db_query_sub('UPDATE ^cache SET lastread=NOW() WHERE type=$ AND cacheid=#', $type, $cacheid);
}
return $content;
}
示例5: qa_cookie_get_create
function qa_cookie_get_create()
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'qa-db-cookies.php';
$cookieid = qa_cookie_get();
if (isset($cookieid) && qa_db_cookie_exists($cookieid)) {
} else {
$cookieid = qa_db_cookie_create(qa_remote_ip_address());
}
setcookie('qa_id', $cookieid, time() + 86400 * 365, '/', QA_COOKIE_DOMAIN);
$_COOKIE['qa_id'] = $cookieid;
return $cookieid;
}
示例6: qa_db_hotness_update
function qa_db_hotness_update($firstpostid, $lastpostid = null, $viewincrement = false)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
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 LEFT(parents.type, 1)='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_get_max_upload_size
function qa_get_max_upload_size()
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$mindb = 16777215;
// from MEDIUMBLOB column type
$minphp = trim(ini_get('upload_max_filesize'));
switch (strtolower(substr($minphp, -1))) {
case 'g':
$minphp *= 1024;
case 'm':
$minphp *= 1024;
case 'k':
$minphp *= 1024;
}
return min($mindb, $minphp);
}
示例8: qa_wall_posts_add_rules
function qa_wall_posts_add_rules($usermessages, $start)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$userid = qa_get_logged_in_userid();
$userdeleteall = !(qa_user_permit_error('permit_hide_show') || qa_user_permit_error('permit_delete_hidden'));
// reuse "Hiding or showing any post" and "Deleting hidden posts" permissions
$userrecent = $start == 0 && isset($userid);
// User can delete all of the recent messages they wrote on someone's wall...
foreach ($usermessages as $key => $message) {
if ($message['fromuserid'] != $userid) {
$userrecent = false;
}
// ... until we come across one that they didn't write (which could be a reply)
$usermessages[$key]['deleteable'] = $message['touserid'] == $userid || $userrecent && $message['fromuserid'] == $userid || $userdeleteall;
// if the user has enough permissions to delete from any wall
}
return $usermessages;
}
示例9: qa_page_q_post_rules
function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$userid = qa_get_logged_in_userid();
$cookieid = qa_cookie_get();
$rules['isbyuser'] = qa_post_is_by_user($post, $userid, $cookieid);
$rules['queued'] = substr($post['type'], 1) == '_QUEUED';
$rules['closed'] = $post['basetype'] == 'Q' && (isset($post['closedbyid']) || isset($post['selchildid']) && qa_opt('do_close_on_select'));
// Cache some responses to the user permission checks
$permiterror_post_q = qa_user_permit_error('permit_post_q');
$permiterror_post_a = qa_user_permit_error('permit_post_a');
$permiterror_post_c = qa_user_permit_error('permit_post_c');
$permiterror_edit = qa_user_permit_error($post['basetype'] == 'Q' ? 'permit_edit_q' : ($post['basetype'] == 'A' ? 'permit_edit_a' : 'permit_edit_c'));
$permiterror_retagcat = qa_user_permit_error('permit_retag_cat');
$permiterror_hide_show = qa_user_permit_error($rules['isbyuser'] ? null : 'permit_hide_show');
$permiterror_close_open = qa_user_permit_error($rules['isbyuser'] ? null : 'permit_close_q');
$permiterror_moderate = qa_user_permit_error('permit_moderate');
// General permissions
$rules['authorlast'] = !isset($post['lastuserid']) || $post['lastuserid'] === $post['userid'];
$rules['viewable'] = $post['hidden'] ? !$permiterror_hide_show : ($rules['queued'] ? $rules['isbyuser'] || !$permiterror_moderate : true);
// Answer, comment and edit might show the button even if the user still needs to do something (e.g. log in)
$rules['answerbutton'] = $post['type'] == 'Q' && $permiterror_post_a != 'level' && !$rules['closed'] && (qa_opt('allow_self_answer') || !$rules['isbyuser']);
$rules['commentbutton'] = ($post['type'] == 'Q' || $post['type'] == 'A') && $permiterror_post_c != 'level' && qa_opt($post['type'] == 'Q' ? 'comment_on_qs' : 'comment_on_as');
$rules['commentable'] = $rules['commentbutton'] && !$permiterror_post_c;
$rules['editbutton'] = !$post['hidden'] && ($rules['isbyuser'] || $permiterror_edit != 'level' && !$rules['queued']) && !$rules['closed'];
$rules['editable'] = $rules['editbutton'] && ($rules['isbyuser'] || !$permiterror_edit);
$rules['retagcatbutton'] = $post['basetype'] == 'Q' && (qa_using_tags() || qa_using_categories()) && !$post['hidden'] && ($rules['isbyuser'] || $permiterror_retagcat != 'level');
$rules['retagcatable'] = $rules['retagcatbutton'] && ($rules['isbyuser'] || !$permiterror_retagcat);
if ($rules['editbutton'] && $rules['retagcatbutton']) {
// only show one button since they lead to the same form
if ($rules['retagcatable'] && !$rules['editable']) {
$rules['editbutton'] = false;
} else {
$rules['retagcatbutton'] = false;
}
}
$rules['aselectable'] = $post['type'] == 'Q' && !qa_user_permit_error($rules['isbyuser'] ? null : 'permit_select_a');
$rules['flagbutton'] = qa_opt('flagging_of_posts') && !$rules['isbyuser'] && !$post['hidden'] && !$rules['queued'] && !@$post['userflag'] && qa_user_permit_error('permit_flag') != 'level';
$rules['flagtohide'] = $rules['flagbutton'] && !qa_user_permit_error('permit_flag') && $post['flagcount'] + 1 >= qa_opt('flagging_hide_after');
$rules['unflaggable'] = @$post['userflag'] && !$post['hidden'];
$rules['clearflaggable'] = $post['flagcount'] >= (@$post['userflag'] ? 2 : 1) && !qa_user_permit_error('permit_hide_show');
// Other actions only show the button if it's immediately possible
$notclosedbyother = !($rules['closed'] && isset($post['closedbyid']) && !$rules['authorlast']);
$nothiddenbyother = !($post['hidden'] && !$rules['authorlast']);
$rules['closeable'] = qa_opt('allow_close_questions') && $post['type'] == 'Q' && !$rules['closed'] && !$permiterror_close_open;
$rules['reopenable'] = $rules['closed'] && isset($post['closedbyid']) && !$permiterror_close_open && !$post['hidden'] && ($notclosedbyother || !qa_user_permit_error('permit_close_q'));
// cannot reopen a question if it's been hidden, or if it was closed by someone else and you don't have global closing permissions
$rules['moderatable'] = $rules['queued'] && !$permiterror_moderate;
$rules['hideable'] = !$post['hidden'] && ($rules['isbyuser'] || !$rules['queued']) && !$permiterror_hide_show && ($notclosedbyother || !qa_user_permit_error('permit_hide_show'));
// cannot hide a question if it was closed by someone else and you don't have global hiding permissions
$rules['reshowable'] = $post['hidden'] && !$permiterror_hide_show && !qa_user_moderation_reason() && ($nothiddenbyother && !$post['flagcount'] || !qa_user_permit_error('permit_hide_show'));
// cannot reshow a question if it was hidden by someone else, or if it has flags - unless you have global hiding permissions
$rules['deleteable'] = $post['hidden'] && !qa_user_permit_error('permit_delete_hidden');
$rules['claimable'] = !isset($post['userid']) && isset($userid) && strlen(@$post['cookieid']) && strcmp(@$post['cookieid'], $cookieid) == 0 && !($post['basetype'] == 'Q' ? $permiterror_post_q : ($post['basetype'] == 'A' ? $permiterror_post_a : $permiterror_post_c));
$rules['followable'] = $post['type'] == 'A' ? qa_opt('follow_on_as') : false;
// Check for claims that could break rules about self answering and mulltiple answers
if ($rules['claimable'] && $post['basetype'] == 'A') {
if (!qa_opt('allow_self_answer') && isset($parentpost) && qa_post_is_by_user($parentpost, $userid, $cookieid)) {
$rules['claimable'] = false;
}
if (isset($siblingposts) && !qa_opt('allow_multi_answers')) {
foreach ($siblingposts as $siblingpost) {
if ($siblingpost['parentid'] == $post['parentid'] && $siblingpost['basetype'] == 'A' && qa_post_is_by_user($siblingpost, $userid, $cookieid)) {
$rules['claimable'] = false;
}
}
}
}
// Now make any changes based on the child posts
if (isset($childposts)) {
foreach ($childposts as $childpost) {
if ($childpost['parentid'] == $post['postid'] && ($childpost['basetype'] == 'A' || $childpost['basetype'] == 'C')) {
$rules['deleteable'] = false;
if ($childpost['basetype'] == 'A' && qa_post_is_by_user($childpost, $userid, $cookieid)) {
if (!qa_opt('allow_multi_answers')) {
$rules['answerbutton'] = false;
}
if (!qa_opt('allow_self_answer')) {
$rules['claimable'] = false;
}
}
}
}
}
// Return the resulting rules
return $rules;
}
示例10: qa_get_gravatar_html
function qa_get_gravatar_html($email, $size)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
if ($size > 0) {
return '<img src="' . (qa_is_https_probably() ? 'https' : 'http') . '://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) . '?s=' . (int) $size . '" width="' . (int) $size . '" height="' . (int) $size . '" class="qa-avatar-image" alt=""/>';
} else {
return null;
}
}
示例11: qa_upload_file
function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $onlyimage = false, $imagemaxwidth = null, $imagemaxheight = null)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$result = array();
// Check per-user upload limits
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
require_once QA_INCLUDE_DIR . 'qa-app-limits.php';
switch (qa_user_permit_error(null, QA_LIMIT_UPLOADS)) {
case 'limit':
$result['error'] = qa_lang('main/upload_limit');
return $result;
case false:
qa_limits_increment(qa_get_logged_in_userid(), QA_LIMIT_UPLOADS);
break;
default:
$result['error'] = qa_lang('users/no_permission');
return $result;
}
// Check the uploaded file is not too large
$filesize = filesize($localfilename);
if (isset($maxfilesize)) {
$maxfilesize = min($maxfilesize, qa_get_max_upload_size());
} else {
$maxfilesize = qa_get_max_upload_size();
}
if ($filesize <= 0 || $filesize > $maxfilesize) {
// if file was too big for PHP, $filesize will be zero
$result['error'] = qa_lang_sub('main/max_upload_size_x', number_format($maxfilesize / 1048576, 1) . 'MB');
return $result;
}
// Find out what type of source file was uploaded and if appropriate, check it's an image and get preliminary size measure
$pathinfo = pathinfo($sourcefilename);
$format = strtolower(@$pathinfo['extension']);
$isimage = $format == 'png' || $format == 'gif' || $format == 'jpeg' || $format == 'jpg';
// allowed image extensions
if ($isimage) {
$imagesize = @getimagesize($localfilename);
if (is_array($imagesize)) {
$result['width'] = $imagesize[0];
$result['height'] = $imagesize[1];
switch ($imagesize['2']) {
// reassign format based on actual content, if we can
case IMAGETYPE_GIF:
$format = 'gif';
break;
case IMAGETYPE_JPEG:
$format = 'jpeg';
break;
case IMAGETYPE_PNG:
$format = 'png';
break;
}
}
}
$result['format'] = $format;
if ($onlyimage) {
if (!$isimage || !is_array($imagesize)) {
$result['error'] = qa_lang_sub('main/image_not_read', 'GIF, JPG, PNG');
return $result;
}
}
// Read in the raw file contents
$content = file_get_contents($localfilename);
// If appropriate, get more accurate image size and apply constraints to it
require_once QA_INCLUDE_DIR . 'qa-util-image.php';
if ($isimage && qa_has_gd_image()) {
$image = @imagecreatefromstring($content);
if (is_resource($image)) {
$result['width'] = $width = imagesx($image);
$result['height'] = $height = imagesy($image);
if (isset($imagemaxwidth) || isset($imagemaxheight)) {
if (qa_image_constrain($width, $height, isset($imagemaxwidth) ? $imagemaxwidth : $width, isset($imagemaxheight) ? $imagemaxheight : $height)) {
qa_gd_image_resize($image, $width, $height);
if (is_resource($image)) {
$content = qa_gd_image_jpeg($image);
$result['format'] = $format = 'jpeg';
$result['width'] = $width;
$result['height'] = $height;
}
}
}
if (is_resource($image)) {
// might have been lost
imagedestroy($image);
}
}
}
// Create the blob and return
require_once QA_INCLUDE_DIR . 'qa-app-blobs.php';
$userid = qa_get_logged_in_userid();
$cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
$result['blobid'] = qa_create_blob($content, $format, $sourcefilename, $userid, $cookieid, qa_remote_ip_address());
if (!isset($result['blobid'])) {
$result['error'] = qa_lang('main/general_error');
return $result;
}
$result['bloburl'] = qa_get_blob_url($result['blobid'], true);
//.........这里部分代码省略.........
示例12: qw_request_text
function qw_request_text($field)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
return isset($_REQUEST[$field]) ? preg_replace('/\\r\\n?/', "\n", trim(qa_gpc_to_string($_REQUEST[$field]))) : null;
}
示例13: qa_report_event
function qa_report_event($event, $userid, $handle, $cookieid, $params = array())
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
global $qa_event_reports_suspended;
if ($qa_event_reports_suspended > 0) {
return;
}
$eventmodules = qa_load_modules_with('event', 'process_event');
foreach ($eventmodules as $eventmodule) {
$eventmodule->process_event($event, $userid, $handle, $cookieid, $params);
}
}
示例14: qa_wall_posts_add_rules
function qa_wall_posts_add_rules($usermessages, $start, $userid)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$deleteable = $start == 0 && isset($userid);
// can delete all of the most recent messages...
foreach ($usermessages as $key => $message) {
if ($message['touserid'] != $userid && $message['fromuserid'] != $userid) {
$deleteable = false;
}
// ... until we come across one that doesn't involve me
$usermessages[$key]['deleteable'] = $deleteable;
}
return $usermessages;
}
示例15: qa_db_add_table_prefix
/**
* Return the full name (with prefix) of database table $rawname, usually if it used after a ^ symbol.
*/
function qa_db_add_table_prefix($rawname)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$prefix = QA_MYSQL_TABLE_PREFIX;
if (defined('QA_MYSQL_USERS_PREFIX')) {
switch (strtolower($rawname)) {
case 'users':
case 'userlogins':
case 'userprofile':
case 'userfields':
case 'messages':
case 'cookies':
case 'blobs':
case 'cache':
case 'userlogins_ibfk_1':
// also special cases for constraint names
// also special cases for constraint names
case 'userprofile_ibfk_1':
$prefix = QA_MYSQL_USERS_PREFIX;
break;
}
}
return $prefix . $rawname;
}