本文整理汇总了PHP中log_it函数的典型用法代码示例。如果您正苦于以下问题:PHP log_it函数的具体用法?PHP log_it怎么用?PHP log_it使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_it函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Standard modular run function.
*
* @param array A map of parameters.
* @return tempcode The result of execution.
*/
function run($map)
{
require_code('textfiles');
$file = array_key_exists('param', $map) ? $map['param'] : 'admin_notes';
$title = array_key_exists('title', $map) ? $map['title'] : do_lang('NOTES');
$lang_none = array_key_exists('lang_none', $map) ? $map['lang_none'] : '0';
$scrolls = array_key_exists('scrolls', $map) ? $map['scrolls'] : '0';
$lang = $lang_none == '1' ? NULL : '';
$file = filter_naughty($file, true);
$new = post_param('new', NULL);
if (!is_null($new)) {
$hooks = find_all_hooks('blocks', 'main_notes');
foreach (array_keys($hooks) as $hook) {
require_code('hooks/blocks/main_notes/' . filter_naughty_harsh($hook));
$ob = object_factory('Hook_notes_' . filter_naughty_harsh($hook), true);
if (is_null($ob)) {
continue;
}
$ob->run($file);
}
write_text_file($file, $lang, $new);
log_it('NOTES', $file);
attach_message(do_lang_tempcode('SUCCESS'), 'inform');
}
$contents = read_text_file($file, $lang, true);
$post_url = get_self_url();
$map_comcode = '';
foreach ($map as $key => $val) {
$map_comcode .= ' ' . $key . '="' . addslashes($val) . '"';
}
return do_template('BLOCK_MAIN_NOTES', array('_GUID' => 'f737053505de3bd8ccfe806ec014b8fb', 'TITLE' => $title, 'BLOCK_NAME' => 'main_notes', 'MAP' => $map_comcode, 'CONTENTS' => $contents, 'SCROLLS' => array_key_exists('scrolls', $map) && $map['scrolls'] == '1', 'URL' => $post_url));
}
示例2: add_banner_quiet
/**
* Add a banner to the database, and return the new ID of that banner in the database.
*
* @param ID_TEXT The name of the banner
* @param URLPATH The URL to the banner image
* @param SHORT_TEXT The title text for the banner (only used for text banners, and functions as the 'trigger text' if the banner type is shown inline)
* @param SHORT_TEXT The caption of the banner
* @param ?integer The number of hits the banner may have (NULL: not applicable for this banner type)
* @range 0 max
* @param URLPATH The URL to the site the banner leads to
* @param integer The banners "importance modulus"
* @range 1 max
* @param LONG_TEXT Any notes associated with the banner
* @param SHORT_INTEGER The type of banner (0=permanent, 1=campaign, 2=default)
* @set 0 1 2
* @param ?TIME The banner expiry date (NULL: never)
* @param ?MEMBER The banners submitter (NULL: current member)
* @param BINARY Whether the banner has been validated
* @param ID_TEXT The banner type (can be anything, where blank means 'normal')
* @param ?TIME The time the banner was added (NULL: now)
* @param integer The number of return hits from this banners site
* @param integer The number of banner hits to this banners site
* @param integer The number of return views from this banners site
* @param integer The number of banner views to this banners site
* @param ?TIME The banner edit date (NULL: never)
*/
function add_banner_quiet($name, $imgurl, $title_text, $caption, $campaignremaining, $site_url, $importance_modulus, $notes, $the_type, $expiry_date, $submitter, $validated = 0, $b_type = '', $time = NULL, $hits_from = 0, $hits_to = 0, $views_from = 0, $views_to = 0, $edit_date = NULL)
{
if (!is_numeric($importance_modulus)) {
$importance_modulus = 3;
}
if (!is_numeric($campaignremaining)) {
$campaignremaining = NULL;
}
if (is_null($time)) {
$time = time();
}
if (is_null($submitter)) {
$submitter = get_member();
}
$test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => $name));
if (is_null($test)) {
if (!addon_installed('unvalidated')) {
$validated = 1;
}
$GLOBALS['SITE_DB']->query_insert('banners', array('b_title_text' => $title_text, 'b_type' => $b_type, 'edit_date' => $edit_date, 'add_date' => $time, 'expiry_date' => $expiry_date, 'the_type' => $the_type, 'submitter' => $submitter, 'name' => $name, 'img_url' => $imgurl, 'caption' => insert_lang_comcode($caption, 2), 'campaign_remaining' => $campaignremaining, 'site_url' => $site_url, 'importance_modulus' => $importance_modulus, 'notes' => '', 'validated' => $validated, 'hits_from' => $hits_from, 'hits_to' => $hits_to, 'views_from' => $views_from, 'views_to' => $views_to));
if (function_exists('decache')) {
decache('main_banner_wave');
decache('main_topsites');
}
log_it('ADD_BANNER', $name, $caption);
}
}
示例3: ocf_delete_multi_moderation
/**
* Delete a multi moderation.
*
* @param AUTO_LINK The ID of the multi moderation we are deleting.
*/
function ocf_delete_multi_moderation($id)
{
$_name = $GLOBALS['FORUM_DB']->query_value('f_multi_moderations', 'mm_name', array('id' => $id));
$name = get_translated_text($_name, $GLOBALS['FORUM_DB']);
$GLOBALS['FORUM_DB']->query_delete('f_multi_moderations', array('id' => $id), '', 1);
delete_lang($_name, $GLOBALS['FORUM_DB']);
log_it('DELETE_MULTI_MODERATION', strval($id), $name);
}
示例4: choose_flagrant
/**
* Choose a flagrant text message.
*
* @param AUTO_LINK The ID of the flagrant text message to choose
*/
function choose_flagrant($id)
{
$message = $GLOBALS['SITE_DB']->query_value('text', 'the_message', array('id' => $id));
$message = get_translated_text($message);
log_it('CHOOSE_FLAGRANT', strval($id), $message);
$GLOBALS['SITE_DB']->query_update('text', array('active_now' => 0));
$GLOBALS['SITE_DB']->query_update('text', array('activation_time' => time(), 'active_now' => 1), array('id' => $id), '', 1);
persistant_cache_delete('FLAGRANT');
}
示例5: delete_ticket_type
/**
* Delete a ticket type.
*
* @param integer The ticket type
*/
function delete_ticket_type($ticket_type)
{
$_ticket_type = get_translated_text($ticket_type);
$GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'tickets', 'category_name' => strval($_ticket_type)));
$GLOBALS['SITE_DB']->query_delete('gsp', array('module_the_name' => 'tickets', 'category_name' => strval($_ticket_type)));
//delete_lang($ticket_type); Needed for if existing ticket looked up
$GLOBALS['SITE_DB']->query_delete('ticket_types', array('ticket_type' => $ticket_type), '', 1);
log_it('DELETE_TICKET_TYPE', strval($ticket_type), $_ticket_type);
}
示例6: save_config
/**
* Standard pointstore item configuration save function.
*/
function save_config()
{
$forw = post_param_integer('forw', -1);
if ($forw != -1) {
$dforw = post_param('dforw');
$GLOBALS['SITE_DB']->query_insert('prices', array('name' => 'forw_' . $dforw, 'price' => $forw));
log_it('POINTSTORE_ADD_MAIL_FORWARDER', $dforw);
}
$this->_do_price_mail();
}
示例7: save_config
/**
* Standard pointstore item configuration save function.
*/
function save_config()
{
$pop3 = post_param_integer('pop3', -1);
if ($pop3 != -1) {
$dpop3 = post_param('dpop3');
$GLOBALS['SITE_DB']->query_insert('prices', array('name' => 'pop3_' . $dpop3, 'price' => $pop3));
log_it('POINTSTORE_ADD_MAIL_POP3', $dpop3);
}
$this->_do_price_mail();
}
示例8: ocf_make_multi_moderation
/**
* Add a multi moderation to the system.
*
* @param SHORT_TEXT The name of the multi moderation.
* @param LONG_TEXT The post text to add when applying (blank: don't add a post).
* @param ?AUTO_LINK The forum to move the topic when applying (NULL: do not move).
* @param ?BINARY The pin state after applying (NULL: unchanged).
* @param ?BINARY The sink state after applying (NULL: unchanged).
* @param ?BINARY The open state after applying (NULL: unchanged).
* @param SHORT_TEXT The forum multi code for where this multi moderation may be applied.
* @param SHORT_TEXT The title suffix.
* @return AUTO_LINK The ID of the multi moderation just added.
*/
function ocf_make_multi_moderation($name, $post_text, $move_to, $pin_state, $sink_state, $open_state, $forum_multi_code = '*', $title_suffix = '')
{
if ($move_to == -1) {
$move_to = NULL;
}
if ($pin_state == -1) {
$pin_state = NULL;
}
if ($open_state == -1) {
$open_state = NULL;
}
if ($sink_state == -1) {
$sink_state = NULL;
}
$id = $GLOBALS['FORUM_DB']->query_insert('f_multi_moderations', array('mm_name' => insert_lang($name, 3, $GLOBALS['FORUM_DB']), 'mm_post_text' => $post_text, 'mm_move_to' => $move_to, 'mm_pin_state' => $pin_state, 'mm_sink_state' => $sink_state, 'mm_open_state' => $open_state, 'mm_forum_multi_code' => $forum_multi_code, 'mm_title_suffix' => $title_suffix), true);
log_it('ADD_MULTI_MODERATION', strval($id), $name);
return $id;
}
示例9: run
/**
* Standard modular run function.
*
* @param array A map of parameters.
* @return tempcode The result of execution.
*/
function run($map)
{
$file = array_key_exists('param', $map) ? $map['param'] : 'admin_notes';
$title = array_key_exists('title', $map) ? $map['title'] : do_lang('NOTES');
$scrolls = array_key_exists('scrolls', $map) ? $map['scrolls'] : '0';
$new = post_param('new', NULL);
if (!is_null($new)) {
set_long_value('note_text_' . $file, $new);
log_it('NOTES', $file);
attach_message(do_lang_tempcode('SUCCESS'), 'inform');
}
$contents = get_long_value('note_text_' . $file);
if (is_null($contents)) {
$contents = '';
}
$post_url = get_self_url();
$map_comcode = '';
foreach ($map as $key => $val) {
$map_comcode .= ' ' . $key . '="' . addslashes($val) . '"';
}
return do_template('BLOCK_MAIN_NOTES', array('_GUID' => '2a9e1c512b66600583735552b56e0911', 'TITLE' => $title, 'BLOCK_NAME' => 'main_db_notes', 'MAP' => $map_comcode, 'SCROLLS' => array_key_exists('scrolls', $map) && $map['scrolls'] == '1', 'CONTENTS' => $contents, 'URL' => $post_url));
}
示例10: install
/**
* Standard modular install function.
*
* @param ?integer What version we're upgrading from (NULL: new install)
* @param ?integer What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
*/
function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
{
//first ensure there is 'buttons' banners category, and if it doesn't exist create it
$id = 'buttons';
$is_textual = 0;
$image_width = 120;
$image_height = 60;
$max_file_size = 70;
$comcode_inline = 0;
$test = $GLOBALS['SITE_DB']->query_value_null_ok('banner_types', 'id', array('id' => $id));
if (is_null($test)) {
$GLOBALS['SITE_DB']->query_insert('banner_types', array('id' => $id, 't_is_textual' => $is_textual, 't_image_width' => $image_width, 't_image_height' => $image_height, 't_max_file_size' => $max_file_size, 't_comcode_inline' => $comcode_inline));
log_it('ADD_BANNER_TYPE', $id);
}
$submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
require_code('banners3');
//create default banners, if they don't exist
add_banner_quiet('ocportal', 'data_custom/causes/ocportal.gif', 'ocPortal', 'ocPortal', 0, 'http://ocportal.com/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('firefox', 'data_custom/causes/firefox.gif', 'Firefox', 'Firefox', 0, 'http://www.mozilla.com/firefox/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('w3cxhtml', 'data_custom/causes/w3c-xhtml.gif', 'W3C XHTML', 'W3C XHTML', 0, 'http://www.w3.org/MarkUp/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('w3ccss', 'data_custom/causes/w3c-css.gif', 'W3C CSS', 'W3C CSS', 0, 'http://www.w3.org/Style/CSS/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
//no banner image
//add_banner_quiet('w3cwcag','data_custom/causes/w3c-wcag.gif','W3C WCAG','W3C WCAG',0,'http://www.w3.org/TR/WCAG10/',3,'',0,NULL,$submitter,1,'buttons',NULL,0,0,0,0,NULL);
add_banner_quiet('cancerresearch', 'data_custom/causes/cancerresearch.gif', 'Cancer Research', 'Cancer Research', 0, 'http://www.cancerresearchuk.org/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('rspca', 'data_custom/causes/rspca.gif', 'RSPCA', 'RSPCA', 0, 'http://www.rspca.org.uk/home', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('peta', 'data_custom/causes/peta.gif', 'PETA', 'PETA', 0, 'http://www.peta.org', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('Unicef', 'data_custom/causes/unicef.gif', 'Unicef', 'Unicef', 0, 'http://www.unicef.org', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('wwf', 'data_custom/causes/wwf.gif', 'WWF', 'WWF', 0, 'http://www.wwf.org/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('greenpeace', 'data_custom/causes/greenpeace.gif', 'Greenpeace', 'Greenpeace', 0, 'http://www.greenpeace.com', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('helptheaged', 'data_custom/causes/helptheaged.gif', 'HelpTheAged', 'HelpTheAged', 0, 'http://www.helptheaged.org.uk/en-gb', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('nspcc', 'data_custom/causes/nspcc.gif', 'NSPCC', 'NSPCC', 0, 'http://www.nspcc.org.uk/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('oxfam', 'data_custom/causes/oxfam.gif', 'Oxfam', 'Oxfam', 0, 'http://www.oxfam.org', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('bringdownie6', 'data_custom/causes/bringdownie6.gif', 'BringDownIE6', 'BringDownIE6', 0, 'http://www.bringdownie6.com', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('cnd', 'data_custom/causes/cnd.gif', 'CND', 'CND', 0, 'http://www.cnduk.org/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('amnestyinternational', 'data_custom/causes/amnestyinternational.gif', 'Amnesty International', 'Amnesty International', 0, 'http://www.amnesty.org/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('bhf', 'data_custom/causes/bhf.gif', 'British Heart Foundation', 'British Heart Foundation', 0, 'http://www.bhf.org.uk/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
add_banner_quiet('gnu', 'data_custom/causes/gnu.gif', 'GNU', 'GNU', 0, 'http://www.gnu.org/', 3, '', 0, NULL, $submitter, 1, 'buttons', NULL, 0, 0, 0, 0, NULL);
}
示例11: attach_image_to_event
function attach_image_to_event($event_obj, $post_obj)
{
global $attachment_urls_arr;
$post_id = $post_obj->ID;
if (isset($event_obj->ClassDescription->ImageURL)) {
log_it('found url: ' . $event_obj->ClassDescription->ImageURL);
$url = $event_obj->ClassDescription->ImageURL;
} else {
return false;
// what to use as a fallback? or use nothing?
}
if (!($id = array_search($url, $attachment_urls_arr))) {
$tmp = download_url($url);
if (is_wp_error($tmp)) {
// download failed, handle error
log_it('download error');
return false;
}
$file_array = array();
// Set variables for storage
// fix file filename for query strings
preg_match('/[^\\?]+\\.(jpg|jpe|jpeg|gif|png)/i', $url, $matches);
$file_array['name'] = basename($matches[0]);
$file_array['tmp_name'] = $tmp;
// If error storing temporarily, unlink
if (is_wp_error($tmp)) {
log_it('temp store error');
@unlink($file_array['tmp_name']);
$file_array['tmp_name'] = '';
}
// do the validation and storage stuff
$id = media_handle_sideload($file_array, $post_id, $desc);
// If error storing permanently, unlink
if (is_wp_error($id)) {
log_it('sideload error');
@unlink($file_array['tmp_name']);
}
$attachment_urls_arr[$id] = $url;
log_it("returned new attachment id {$id}");
log_it("tmp_name is: " . $file_array['tmp_name']);
// create the thumbnails
$attach_data = wp_generate_attachment_metadata($id, get_attached_file($id));
ob_start();
print_r($attach_data);
$foo = ob_get_clean();
log_it($foo);
$bar = wp_update_attachment_metadata($id, $attach_data);
log_it('wp_update_attachment_metadata returned: ' . $bar);
}
// and let the events calendar know about it
//$meta_arr = array ('_thumbnail_id' => $id );
update_post_meta($post_id, '_thumbnail_id', $id);
}
示例12: render_tab
/**
* Standard modular render function for profile tabs edit hooks.
*
* @param MEMBER The ID of the member who is being viewed
* @param MEMBER The ID of the member who is doing the viewing
* @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later
* @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set)
*/
function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
{
$order = 0;
// Actualiser
if (post_param('submitting_settings_tab', NULL) !== NULL) {
require_code('ocf_members_action2');
$is_ldap = ocf_is_ldap_member($member_id_of);
$is_httpauth = ocf_is_httpauth_member($member_id_of);
$is_remote = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_password_compat_scheme') == 'remote';
if ($is_ldap || $is_httpauth || $is_remote || $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'assume_any_member')) {
$password = NULL;
} else {
$password = post_param('edit_password');
if ($password == '') {
$password = NULL;
} else {
$password_confirm = trim(post_param('password_confirm'));
if ($password != $password_confirm) {
warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH'))));
}
}
}
$custom_fields = ocf_get_all_custom_fields_match($GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of), $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_of != $member_id_viewing ? NULL : 1, $member_id_of != $member_id_viewing ? NULL : 1);
$actual_custom_fields = ocf_read_in_custom_fields($custom_fields, $member_id_of);
$pt_allow = array_key_exists('pt_allow', $_POST) ? implode(',', $_POST['pt_allow']) : '';
$tmp_groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true);
$all_pt_allow = '';
foreach (array_keys($tmp_groups) as $key) {
if ($key != db_get_first_id()) {
if ($all_pt_allow != '') {
$all_pt_allow .= ',';
}
$all_pt_allow .= strval($key);
}
}
if ($pt_allow == $all_pt_allow) {
$pt_allow = '*';
}
$pt_rules_text = post_param('pt_rules_text', NULL);
if (has_specific_permission($member_id_viewing, 'member_maintenance')) {
$validated = post_param_integer('validated', 0);
$primary_group = $is_ldap || !has_specific_permission($member_id_viewing, 'assume_any_member') ? NULL : post_param_integer('primary_group', NULL);
$is_perm_banned = post_param_integer('is_perm_banned', 0);
$old_is_perm_banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned');
if ($old_is_perm_banned != $is_perm_banned) {
if ($is_perm_banned == 1) {
ocf_ban_member($member_id_of);
} else {
ocf_unban_member($member_id_of);
}
}
$highlighted_name = post_param_integer('highlighted_name', 0);
if (has_specific_permission($member_id_viewing, 'probate_members')) {
$on_probation_until = get_input_date('on_probation_until');
$current__on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until');
if ((is_null($on_probation_until) || $on_probation_until <= time()) && $current__on_probation_until > time()) {
log_it('STOP_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of));
} elseif (!is_null($on_probation_until) && $on_probation_until > time() && $current__on_probation_until <= time()) {
log_it('START_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of));
} elseif (!is_null($on_probation_until) && $current__on_probation_until > $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) {
log_it('REDUCE_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of));
} elseif (!is_null($on_probation_until) && $current__on_probation_until < $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) {
log_it('EXTEND_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of));
}
} else {
$on_probation_until = NULL;
}
} else {
$validated = NULL;
$primary_group = NULL;
$highlighted_name = NULL;
$on_probation_until = NULL;
}
if (has_actual_page_access($member_id_viewing, 'admin_ocf_join') || has_specific_permission($member_id_of, 'rename_self')) {
$username = $is_ldap || $is_remote ? NULL : post_param('edit_username', NULL);
} else {
$username = NULL;
}
$email = post_param('email_address', NULL);
if (!is_null($email)) {
$email = trim($email);
}
$theme = post_param('theme', NULL);
if ($is_remote) {
$preview_posts = NULL;
$zone_wide = NULL;
$auto_monitor_contrib_content = NULL;
$views_signatures = NULL;
$timezone = NULL;
} else {
$preview_posts = post_param_integer('preview_posts', 0);
$zone_wide = post_param_integer('zone_wide', 0);
//.........这里部分代码省略.........
示例13: ocf_make_custom_field
/**
* Make a custom profile field.
*
* @param SHORT_TEXT Name of the field.
* @param BINARY Whether the field is locked (i.e. cannot be deleted from the system).
* @param SHORT_TEXT Description of the field.
* @param LONG_TEXT The default value for the field.
* @param BINARY Whether the field is publicly viewable.
* @param BINARY Whether the field is viewable by the owner.
* @param BINARY Whether the field may be set by the owner.
* @param BINARY Whether the field is encrypted.
* @param ID_TEXT The type of the field.
* @set short_text long_text short_trans long_trans integer upload picture url list tick float
* @param BINARY Whether it is required that every member have this field filled in.
* @param BINARY Whether this field is shown in posts and places where member details are highlighted (such as an image in a member gallery).
* @param BINARY Whether this field is shown in preview places, such as in the teaser for a member gallery.
* @param ?integer The order of this field relative to other fields (NULL: next).
* @param LONG_TEXT The usergroups that this field is confined to (comma-separated list).
* @param boolean Whether to check that no field has this name already.
* @param BINARY Whether the field is to be shown on the join form
* @return AUTO_LINK The ID of the new custom profile field.
*/
function ocf_make_custom_field($name, $locked = 0, $description = '', $default = '', $public_view = 0, $owner_view = 0, $owner_set = 0, $encrypted = 0, $type = 'long_text', $required = 0, $show_in_posts = 0, $show_in_post_previews = 0, $order = NULL, $only_group = '', $no_name_dupe = false, $show_on_join_form = 0)
{
$dbs_back = $GLOBALS['NO_DB_SCOPE_CHECK'];
$GLOBALS['NO_DB_SCOPE_CHECK'] = true;
if ($only_group == '-1') {
$only_group = '';
}
// Can only encrypt things if encryption support is available
require_code('encryption');
//if (!is_encryption_enabled()) $encrypted=0;
// Can't have publicly-viewable encrypted fields
if ($encrypted == 1) {
$public_view = 0;
}
if ($no_name_dupe) {
$test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON f.cf_name=t.id', 'f.id', array('text_original' => $name));
if (!is_null($test)) {
$GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back;
return $test;
}
}
if (is_null($order)) {
$order = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'MAX(cf_order)');
if (is_null($order)) {
$order = 0;
} else {
$order++;
}
}
$map = array('cf_name' => insert_lang($name, 2, $GLOBALS['FORUM_DB']), 'cf_locked' => $locked, 'cf_description' => insert_lang($description, 2, $GLOBALS['FORUM_DB']), 'cf_default' => $default, 'cf_public_view' => $public_view, 'cf_owner_view' => $owner_view, 'cf_owner_set' => $owner_set, 'cf_type' => $type, 'cf_required' => $required, 'cf_show_in_posts' => $show_in_posts, 'cf_show_in_post_previews' => $show_in_post_previews, 'cf_order' => $order, 'cf_only_group' => $only_group, 'cf_show_on_join_form' => $show_on_join_form);
$id = $GLOBALS['FORUM_DB']->query_insert('f_custom_fields', $map + array('cf_encrypted' => $encrypted), true, true);
if (is_null($id)) {
$id = $GLOBALS['FORUM_DB']->query_insert('f_custom_fields', $map, true);
}
// Still upgrading, cf_encrypted does not exist yet
list($_type, $index) = get_cpf_storage_for($type);
require_code('database_action');
// ($index?'#':'').
$GLOBALS['FORUM_DB']->add_table_field('f_member_custom_fields', 'field_' . strval($id), $_type);
// Default will be made explicit when we insert rows
$indices_count = $GLOBALS['FORUM_DB']->query_value('db_meta_indices', 'COUNT(*)', array('i_table' => 'f_member_custom_fields'));
if ($indices_count < 60) {
if ($index) {
if ($_type != 'LONG_TEXT') {
$GLOBALS['FORUM_DB']->create_index('f_member_custom_fields', 'mcf' . strval($id), array('field_' . strval($id)), 'mf_member_id');
}
if (strpos($_type, '_TEXT') !== false) {
$GLOBALS['FORUM_DB']->create_index('f_member_custom_fields', '#mcf_ft_' . strval($id), array('field_' . strval($id)), 'mf_member_id');
}
} elseif (strpos($type, 'trans') !== false || $type == 'posting_field') {
$GLOBALS['FORUM_DB']->create_index('f_member_custom_fields', 'mcf' . strval($id), array('field_' . strval($id)), 'mf_member_id');
// For joins
}
}
log_it('ADD_CUSTOM_PROFILE_FIELD', strval($id), $name);
$GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back;
return $id;
}
示例14: module_do_upload
/**
* The actualiser for uploading a file.
*
* @return tempcode The UI.
*/
function module_do_upload()
{
if (!has_specific_permission(get_member(), 'upload_filedump')) {
access_denied('I_ERROR');
}
$title = get_page_title('FILEDUMP_UPLOAD');
if (function_exists('set_time_limit')) {
@set_time_limit(0);
}
// Slowly uploading a file can trigger time limit, on some servers
$place = filter_naughty(post_param('place'));
require_code('uploads');
if (!is_swf_upload(true) && (!array_key_exists('file', $_FILES) || !is_uploaded_file($_FILES['file']['tmp_name']))) {
$attach_name = 'file';
$max_size = get_max_file_size();
if (isset($_FILES[$attach_name]) && ($_FILES[$attach_name]['error'] == 1 || $_FILES[$attach_name]['error'] == 2)) {
warn_exit(do_lang_tempcode('FILE_TOO_BIG', integer_format($max_size)));
} elseif (isset($_FILES[$attach_name]) && ($_FILES[$attach_name]['error'] == 3 || $_FILES[$attach_name]['error'] == 6 || $_FILES[$attach_name]['error'] == 7)) {
warn_exit(do_lang_tempcode('ERROR_UPLOADING_' . strval($_FILES[$attach_name]['error'])));
} else {
warn_exit(do_lang_tempcode('ERROR_UPLOADING'));
}
}
$file = $_FILES['file']['name'];
if (get_magic_quotes_gpc()) {
$file = stripslashes($file);
}
if (!has_specific_permission(get_member(), 'upload_anything_filedump') || get_file_base() != get_custom_file_base()) {
check_extension($file);
}
$file = str_replace('.', '-', basename($file, '.' . get_file_extension($file))) . '.' . get_file_extension($file);
if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place . $file)) {
$max_size = get_max_file_size();
if ($_FILES['file']['size'] > $max_size) {
warn_exit(do_lang_tempcode('FILE_TOO_BIG', integer_format(intval($max_size))));
}
$full = get_custom_file_base() . '/uploads/filedump' . $place . $file;
if (is_swf_upload(true)) {
@rename($_FILES['file']['tmp_name'], $full) or warn_exit(do_lang_tempcode('FILE_MOVE_ERROR', escape_html($file), escape_html('uploads/filedump' . $place)));
} else {
@move_uploaded_file($_FILES['file']['tmp_name'], $full) or warn_exit(do_lang_tempcode('FILE_MOVE_ERROR', escape_html($file), escape_html('uploads/filedump' . $place)));
}
fix_permissions($full);
sync_file($full);
$return_url = build_url(array('page' => '_SELF', 'place' => $place), '_SELF');
$test = $GLOBALS['SITE_DB']->query_value_null_ok('filedump', 'description', array('name' => $file, 'path' => $place));
if (!is_null($test)) {
delete_lang($test);
}
$GLOBALS['SITE_DB']->query_delete('filedump', array('name' => $file, 'path' => $place), '', 1);
$description = post_param('description');
$GLOBALS['SITE_DB']->query_insert('filedump', array('name' => $file, 'path' => $place, 'the_member' => get_member(), 'description' => insert_lang_comcode($description, 3)));
require_code('notifications');
$subject = do_lang('FILEDUMP_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $file, $place);
$mail = do_lang('FILEDUMP_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($file), array(comcode_escape($place), comcode_escape($description)));
dispatch_notification('filedump', $place, $subject, $mail);
log_it('FILEDUMP_UPLOAD', $file, $place);
if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), get_page_name(), get_zone_name())) {
syndicate_described_activity('filedump:ACTIVITY_FILEDUMP_UPLOAD', $place . '/' . $file, '', '', '', '', '', 'filedump');
}
return redirect_screen($title, $return_url, do_lang_tempcode('SUCCESS'));
} else {
warn_exit(do_lang_tempcode('OVERWRITE_ERROR'));
}
return new ocp_tempcode();
}
示例15: ocf_member_handle_promotion
/**
* Check to see if a member deserves promotion, and handle it.
*
* @param ?MEMBER The member (NULL: current member).
*/
function ocf_member_handle_promotion($member_id = NULL)
{
if (!addon_installed('points')) {
return;
}
if (get_page_name() == 'admin_import') {
return;
}
if (is_null($member_id)) {
$member_id = get_member();
}
require_code('ocf_members');
if (ocf_is_ldap_member($member_id)) {
return;
}
require_code('points');
$total_points = total_points($member_id);
$groups = $GLOBALS['OCF_DRIVER']->get_members_groups($member_id, false, true);
$or_list = '';
foreach ($groups as $id) {
if ($or_list != '') {
$or_list .= ' OR ';
}
$or_list .= 'id=' . strval($id);
}
$promotions = $GLOBALS['FORUM_DB']->query('SELECT id,g_promotion_target FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_groups WHERE (' . $or_list . ') AND g_promotion_target IS NOT NULL AND g_promotion_threshold<=' . strval((int) $total_points) . ' ORDER BY g_promotion_threshold');
$promotes_today = array();
foreach ($promotions as $promotion) {
$_p = $promotion['g_promotion_target'];
if (!array_key_exists($_p, $groups) && !array_key_exists($_p, $promotes_today)) {
// If it is our primary
if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_primary_group') == $promotion['id']) {
$GLOBALS['FORUM_DB']->query_update('f_members', array('m_primary_group' => $_p), array('id' => $member_id), '', 1);
} else {
$GLOBALS['FORUM_DB']->query_delete('f_group_members', array('gm_member_id' => $member_id, 'gm_group_id' => $_p), '', 1);
$GLOBALS['FORUM_DB']->query_insert('f_group_members', array('gm_validated' => 1, 'gm_member_id' => $member_id, 'gm_group_id' => $_p), false, true);
$GLOBALS['FORUM_DB']->query_delete('f_group_members', array('gm_member_id' => $member_id, 'gm_group_id' => $promotion['id']), '', 1);
// It's a transition, so remove old membership
}
// Carefully update run-time cacheing
global $USERS_GROUPS_CACHE;
foreach (array(true, false) as $a) {
foreach (array(true, false) as $b) {
if (isset($USERS_GROUPS_CACHE[$member_id][$a][$b])) {
$groups = $USERS_GROUPS_CACHE[$member_id][$a][$b];
$pos = array_search($_p, $groups);
if ($pos !== false) {
unset($groups[$pos]);
}
$groups[] = $promotion['id'];
$USERS_GROUPS_CACHE[$member_id][$a][$b] = $groups;
}
}
}
$promotes_today[$_p] = 1;
}
}
if (count($promotes_today) != 0) {
$name = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_username');
log_it('MEMBER_PROMOTED_AUTOMATICALLY', strval($member_id), $name);
}
}