本文整理汇总了PHP中qa_to_override函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_to_override函数的具体用法?PHP qa_to_override怎么用?PHP qa_to_override使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_to_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_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;
}
示例4: 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;
}
示例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_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;
}
示例7: 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));
}
}
示例8: 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);
}
示例9: 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;
}
示例10: 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;
}
示例11: 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);
}
示例12: 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);
}
}
示例13: 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);
//.........这里部分代码省略.........
示例14: qa_set_user_avatar
function qa_set_user_avatar($userid, $imagedata, $oldblobid = null)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'qa-util-image.php';
$imagedata = qa_image_constrain_data($imagedata, $width, $height, qa_opt('avatar_store_size'));
if (isset($imagedata)) {
require_once QA_INCLUDE_DIR . 'qa-db-blobs.php';
$newblobid = qa_db_blob_create($imagedata, 'jpeg', null, $userid, null, qa_remote_ip_address());
if (isset($newblobid)) {
qa_db_user_set($userid, 'avatarblobid', $newblobid);
qa_db_user_set($userid, 'avatarwidth', $width);
qa_db_user_set($userid, 'avatarheight', $height);
qa_db_user_set_flag($userid, QA_USER_FLAGS_SHOW_AVATAR, true);
qa_db_user_set_flag($userid, QA_USER_FLAGS_SHOW_GRAVATAR, false);
if (isset($oldblobid)) {
qa_db_blob_delete($oldblobid);
}
return true;
}
}
return false;
}
示例15: qa_admin_sub_navigation
function qa_admin_sub_navigation()
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$navigation = array();
if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
$navigation['admin/general'] = array('label' => qa_lang_html('admin/general_title'), 'url' => qa_path_html('admin/general'));
$navigation['admin/emails'] = array('label' => qa_lang_html('admin/emails_title'), 'url' => qa_path_html('admin/emails'));
$navigation['admin/user'] = array('label' => qa_lang_html('admin/users_title'), 'url' => qa_path_html('admin/users'));
$navigation['admin/layout'] = array('label' => qa_lang_html('admin/layout_title'), 'url' => qa_path_html('admin/layout'));
$navigation['admin/posting'] = array('label' => qa_lang_html('admin/posting_title'), 'url' => qa_path_html('admin/posting'));
$navigation['admin/viewing'] = array('label' => qa_lang_html('admin/viewing_title'), 'url' => qa_path_html('admin/viewing'));
$navigation['admin/lists'] = array('label' => qa_lang_html('admin/lists_title'), 'url' => qa_path_html('admin/lists'));
if (qa_using_categories()) {
$navigation['admin/categories'] = array('label' => qa_lang_html('admin/categories_title'), 'url' => qa_path_html('admin/categories'));
}
$navigation['admin/permissions'] = array('label' => qa_lang_html('admin/permissions_title'), 'url' => qa_path_html('admin/permissions'));
$navigation['admin/pages'] = array('label' => qa_lang_html('admin/pages_title'), 'url' => qa_path_html('admin/pages'));
$navigation['admin/feeds'] = array('label' => qa_lang_html('admin/feeds_title'), 'url' => qa_path_html('admin/feeds'));
$navigation['admin/points'] = array('label' => qa_lang_html('admin/points_title'), 'url' => qa_path_html('admin/points'));
$navigation['admin/spam'] = array('label' => qa_lang_html('admin/spam_title'), 'url' => qa_path_html('admin/spam'));
$navigation['admin/stats'] = array('label' => qa_lang_html('admin/stats_title'), 'url' => qa_path_html('admin/stats'));
if (!QA_FINAL_EXTERNAL_USERS) {
$navigation['admin/mailing'] = array('label' => qa_lang_html('admin/mailing_title'), 'url' => qa_path_html('admin/mailing'));
}
$navigation['admin/plugins'] = array('label' => qa_lang_html('admin/plugins_title'), 'url' => qa_path_html('admin/plugins'));
}
if (!qa_user_permit_error('permit_moderate')) {
$navigation['admin/moderate'] = array('label' => qa_lang_html('admin/moderate_title'), 'url' => qa_path_html('admin/moderate'));
}
if (qa_opt('flagging_of_posts') && !qa_user_permit_error('permit_hide_show')) {
$navigation['admin/flagged'] = array('label' => qa_lang_html('admin/flagged_title'), 'url' => qa_path_html('admin/flagged'));
}
if (!qa_user_permit_error('permit_hide_show') || !qa_user_permit_error('permit_delete_hidden')) {
$navigation['admin/hidden'] = array('label' => qa_lang_html('admin/hidden_title'), 'url' => qa_path_html('admin/hidden'));
}
return $navigation;
}