public function get_newsletter_form() { /* BENCHMARK */ $this->benchmark->mark('func_get_newsletter_form_start'); $this->load->helper('data'); $newsletter_html = ''; // only make a newsletter form if users who are not site admins are signed in /*if ('super_admin'==$this->user['user_type'] or 'admin_user'==$this->user['user_type'] or 'supplier_user'==$this->user['user_type']) { $newsletter_html.=''; } else {*/ $attr = array('name' => 'newsletter_form', 'id' => 'newsletter_form', 'class' => 'form'); $hidden = array('url' => uri_string()); // reload url $newsletter_html .= form_open('newsletter/signup', $attr, $hidden); // email field $attr = array('name' => 'newsletter_email', 'id' => 'newsletter_email', 'class' => 'form_field', 'placeholder' => 'enter your email ...', 'value' => get_value(null, 'newsletter_email')); $newsletter_html .= form_input($attr, ''); $newsletter_html .= form_input(array('name' => 'phone_number', 'class' => 'phone_number', 'style' => 'position:absolute;top:-10000px;')); // submit button $attr = array('name' => 'submit', 'id' => 'newsletter_submit', 'class' => 'checkout submit'); $newsletter_html .= form_submit($attr, 'sign up'); $newsletter_html .= form_close(); /*}*/ /* BENCHMARK */ $this->benchmark->mark('func_get_newsletter_form_end'); return $newsletter_html; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('chat'); require_css('side_blocks'); $room_id = array_key_exists('param', $map) ? intval($map['param']) : NULL; $num_messages = array_key_exists('max', $map) ? intval($map['max']) : 5; if (is_null($room_id)) { $room_id = $GLOBALS['SITE_DB']->query_value_null_ok('chat_rooms', 'MIN(id)', array('is_im' => 0)); if (is_null($room_id)) { return new ocp_tempcode(); } } $room_check = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $room_id), '', 1); if (!array_key_exists(0, $room_check)) { return new ocp_tempcode(); } require_code('chat'); if (!check_chatroom_access($room_check[0], true)) { global $DO_NOT_CACHE_THIS; // We don't cache against access, so we have a problem and can't cache $DO_NOT_CACHE_THIS = true; return new ocp_tempcode(); } $content = NULL; if (get_value('no_frames') === '1') { $content = shoutbox_script(true, $room_id, $num_messages); } return do_template('BLOCK_SIDE_SHOUTBOX_IFRAME', array('CONTENT' => $content, 'ROOM_ID' => strval($room_id), 'NUM_MESSAGES' => strval($num_messages))); }
/** * Standard modular run function. * * @return array An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option). */ function run() { if (!addon_installed('backup')) { return array(); } if (get_option('backup_time', true) == '') { return array(); } $limit_hours = intval(get_option('backup_time', true)); require_lang('backups'); $date = intval(get_value('last_backup')); $seconds_ago = mixed(); if ($date != 0) { $seconds_ago = time() - $date; $status = intval($seconds_ago) > $limit_hours * 60 * 60 ? 0 : 1; } else { $status = 0; } $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1'); $config_row = $GLOBALS['SITE_DB']->query_select('config', array('the_page', 'section'), array('the_name' => 'backup_time'), '', 1); if (array_key_exists(0, $config_row)) { $_config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $config_row[0]['the_page']), get_module_zone('admin_config')); $config_url = $_config_url->evaluate(); $config_url .= '#group_' . $config_row[0]['section']; } else { $config_url = NULL; } $url = build_url(array('page' => 'admin_backup', 'type' => 'misc'), 'adminzone'); list($info, $seconds_due_in) = staff_checklist_time_ago_and_due($seconds_ago, $limit_hours); $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => '432685ec6c9f7548ce8b488b6ce00030', 'CONFIG_URL' => $config_url, 'URL' => $url, 'STATUS' => $_status, 'TASK' => do_lang_tempcode('BACKUP'), 'INFO' => $info)); return array(array($tpl, $seconds_due_in, NULL, 'backup_time')); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { // The counter we're using $name = array_key_exists('param', $map) ? $map['param'] : ''; if ($name == '-') { $name = get_page_name() . ':' . get_param('type', 'misc') . ':' . get_param('id', ''); } if ($name == '') { $name = 'hits'; } $start = array_key_exists('start', $map) ? intval($map['start']) : 0; // Set it if it's not already $_current_value = get_value($name); if (is_null($_current_value)) { set_value($name, strval($start)); $current_value = $start; } else { $current_value = intval($_current_value); if ($start > $current_value) { $current_value = $start; set_value($name, strval($current_value)); } } // Hit counter? $hit_count = array_key_exists('hit_count', $map) ? intval($map['hit_count']) : 1; if ($hit_count == 1) { update_stat($name, 1); } return do_template('MAIN_COUNT', array('NAME' => $name, 'VALUE' => strval($current_value))); }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (get_value('implicit_usergroup_sync') === '1') { $last = get_value('last_implicit_sync'); if (is_null($last) || intval($last) < time() - 60 * 60) { $hooks = find_all_hooks('systems', 'ocf_implicit_usergroups'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/ocf_implicit_usergroups/' . $hook); $ob = object_factory('Hook_implicit_usergroups_' . $hook); $group_id = $ob->get_bound_group_id(); $GLOBALS['FORUM_DB']->query_delete('f_group_members', array('gm_group_id' => $group_id)); $list = $ob->get_member_list(); if (!is_null($list)) { foreach ($list as $member_row) { $GLOBALS['FORUM_DB']->query_insert('f_group_members', array('gm_group_id' => $group_id, 'gm_member_id' => $member_row['id'], 'gm_validated' => 1)); } } else { $start = 0; do { $members = collapse_1d_complexity('id', $GLOBALS['FORUM_DB']->query_select('f_members', array('id'), NULL, '', 400, $start)); foreach ($members as $member_id) { if ($ob->is_member_within($member_id)) { $GLOBALS['FORUM_DB']->query_insert('f_group_members', array('gm_group_id' => $group_id, 'gm_member_id' => $member_id, 'gm_validated' => 1)); } } $start += 400; } while (count($members) == 400); } } set_value('last_implicit_sync', strval(time())); } } }
function get_value($indexes, $arrayToAccess) { if (count($indexes) > 1) { return get_value(array_slice($indexes, 1), $arrayToAccess[$indexes[0]]); } return $arrayToAccess[$indexes[0]]; }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (get_forum_type() != 'ocf') { return; } $time = time(); $last_time = intval(get_value('last_confirm_reminder_time')); if ($last_time > time() - 24 * 60 * 60 * 2) { return; } set_value('last_confirm_reminder_time', strval($time)); require_code('mail'); require_lang('ocf'); $GLOBALS['NO_DB_SCOPE_CHECK'] = true; $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'f_members WHERE ' . db_string_not_equal_to('m_validated_email_confirm_code', '') . ' AND m_join_time>' . strval($last_time)); $GLOBALS['NO_DB_SCOPE_CHECK'] = false; foreach ($rows as $row) { $coppa = get_option('is_on_coppa') == '1' && utctime_to_usertime(time() - mktime(0, 0, 0, $row['m_dob_month'], $row['m_dob_day'], $row['m_dob_year'])) / 31536000.0 < 13.0; if (!$coppa) { $zone = get_module_zone('join'); if ($zone != '') { $zone .= '/'; } $url = get_base_url() . '/' . $zone . 'index.php?page=join&type=step4&email=' . rawurlencode($row['m_email_address']) . '&code=' . $row['m_validated_email_confirm_code']; $url_simple = get_base_url() . '/' . $zone . 'index.php?page=join&type=step4'; $message = do_lang('OCF_SIGNUP_TEXT', comcode_escape(get_site_name()), comcode_escape($url), array($url_simple, $row['m_email_address'], strval($row['m_validated_email_confirm_code'])), $row['m_language']); mail_wrap(do_lang('CONFIRM_EMAIL_SUBJECT', get_site_name(), NULL, NULL, $row['m_language']), $message, array($row['m_email_address']), $row['m_username']); } } }
/** * Standard modular run function. * * @return array An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option). */ function run() { if (!addon_installed('newsletter')) { return array(); } if (get_option('news_update_time', true) == '') { return array(); } $limit_hours = intval(get_option('news_update_time', true)); $limit_hours = intval($limit_hours / 3); // 3 news pieces (+ other stuff) per newsletter seems reasonable require_lang('newsletter'); $date = get_value('newsletter_send_time'); $seconds_ago = mixed(); if (!is_null($date)) { $seconds_ago = time() - intval($date); $status = $seconds_ago > $limit_hours * 60 * 60 ? 0 : 1; } else { $status = 0; } $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1'); $config_row = $GLOBALS['SITE_DB']->query_select('config', array('the_page', 'section'), array('the_name' => 'news_update_time'), '', 1); if (array_key_exists(0, $config_row)) { $_config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $config_row[0]['the_page']), get_module_zone('admin_config')); $config_url = $_config_url->evaluate(); $config_url .= '#group_' . $config_row[0]['section']; } else { $config_url = NULL; } $url = build_url(array('page' => 'admin_newsletter', 'type' => 'whatsnew'), 'adminzone'); list($info, $seconds_due_in) = staff_checklist_time_ago_and_due($seconds_ago, $limit_hours); $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => 'fb9483bb05ad90b9f2b7eba0c53996f4', 'CONFIG_URL' => $config_url, 'URL' => $url, 'STATUS' => $_status, 'TASK' => do_lang_tempcode('NEWSLETTER_SEND'), 'INFO' => $info)); return array(array($tpl, $seconds_due_in, NULL, 'news_update_time')); }
function header_social_links() { $social_links = tijara_option('social_links'); if (!is_array($social_links)) { return; } /** * Social sites to font icon reference * * Example: * $social_domains['google'] = '' * * Note: * If no corresponding value is found for a social site, * the domain without extention will be used (e.g.: twitter, facebook...) */ $social_domains = array('google' => array('google-plus', 'Google+'), 'facebook' => array('facebook', 'Facebook'), 'flickr' => array('flickr', 'Flickr'), 'instagram' => array('instagram', 'Instagram'), 'linkedin' => array('linkedin', 'LinkedIn'), 'pinterest' => array('pinterest', 'Pinterest'), 'skype' => array('skype', 'Skype'), 'twitter' => array('twitter', 'Twitter'), 'vimeo' => array('vimeo', 'Vimeo'), 'vk' => array('vk', 'VKontakte'), 'youtube' => array('youtube', 'YouTube')); foreach ($social_links as $social_link) { // Get link domain $social_domain = str_replace('www.', '', get_value(parse_url($social_link), 'host')); // Automatic slug $social_domain_no_ext = array_shift(preg_split('/(?=\\.[^.]+$)/', $social_domain)); // Slug from referece if (isset($social_domains[$social_domain_no_ext])) { $social_slug = $social_domains[$social_domain_no_ext][0]; $social_service = $social_domains[$social_domain_no_ext][1]; } else { $social_slug = 'question-circle'; } echo "<a title = \"" . sprintf(__('Follow on %s', 'tijara'), $social_service) . "\" href=\"{$social_link}\" ><i class=\"{$social_slug} fa fa-{$social_slug}\"></i></a> "; } }
public function display_messages() { if (empty($this->messages)) { return; } $last_message_level = null; foreach ($this->messages as $message) { $css_class = get_value($message->level, $this->message_css_classes, ''); if ($message->level != $last_message_level) { if (!empty($last_message_level)) { echo '</div>'; } echo '<div class="' . $css_class . '">'; $message_header = $this->get_message_header($message->level); if (!empty($message_header)) { echo '<h4 class="wc_aelia message_header">'; echo $message_header; echo '</h4>'; } } $output_msg = empty($message->code) ? '' : $message->code . ' '; $output_msg .= $message->message; echo '<p class="wc_aelia message">'; echo $output_msg; echo '</p>'; $last_message_level = $message->level; } echo '</div>'; }
/** * Standard modular run function for OcCLE notification hooks. * * @param ?integer The "current" time on which to base queries (NULL: now) * @return ~array Array of section, type and message responses (false: nothing) */ function run($timestamp = NULL) { if (!addon_installed('chat')) { return false; } if (!is_null(get_value('occle_watched_chatroom'))) { require_lang('chat'); if (is_null($timestamp)) { $timestamp = time(); } $room = intval(get_value('occle_watched_chatroom')); $room_messages = $GLOBALS['SITE_DB']->query('SELECT COUNT(*) AS cnt FROM ' . get_table_prefix() . 'chat_messages WHERE room_id=' . strval($room) . ' AND date_and_time>=' . strval((int) $timestamp)); if (!array_key_exists(0, $room_messages)) { return false; } if ($room_messages[0]['cnt'] > 0) { $rooms = array(); $messages = $room_messages[0]['cnt']; $room_data = $GLOBALS['SITE_DB']->query_value_null_ok('chat_rooms', 'room_name', array('id' => $room)); if (is_null($room_data)) { return false; } // Selected room deleted $rooms[$room_data] = build_url(array('page' => 'chat', 'type' => 'room', 'id' => $room), get_module_zone('chat')); return array(do_lang('SECTION_CHAT'), do_lang('NEW_MESSAGES'), do_template('OCCLE_CHAT_NOTIFICATION', array('MESSAGE_COUNT' => integer_format($messages), 'ROOMS' => $rooms))); } else { return false; } } else { return false; } }
/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return array Array of stdcommand, stdhtml, stdout, and stderr responses */ function run($options, $parameters, &$occle_fs) { if (array_key_exists('h', $options) || array_key_exists('help', $options)) { return array('', do_command_help('watch_chatroom', array('h', 'u'), array(true)), '', ''); } else { require_code('chat'); if (array_key_exists('u', $options) || array_key_exists('unwatch', $options)) { delete_value('occle_watched_chatroom'); $_chatroom = do_lang('SUCCESS'); } elseif (array_key_exists(0, $parameters)) { if (is_numeric($parameters[0])) { $chatroom = $parameters[0]; } else { $chatroom = get_chatroom_id($parameters[0]); } if (is_null($chatroom)) { return array('', '', '', do_lang('MISSING_RESOURCE')); } set_value('occle_watched_chatroom', $chatroom); $_chatroom = get_chatroom_name($chatroom); } else { $_chatroom = get_chatroom_name(intval(get_value('occle_watched_chatroom')), true); if (is_null($_chatroom)) { return array('', '', '', do_lang('MISSING_RESOURCE')); } } return array('', '', $_chatroom, ''); } }
function custom_menu_tree($menus = array()) { $html = ''; // Build all application menus in a tree format foreach ($menus as $menu) { // Check if this menu has children $count_menu_children = count(get_value($menu, 'children')); // Build a single line menu $html .= '<li id="menu-item-' . get_value($menu, 'id_menu') . '" class="dd-item dd3-item" data-id="' . get_value($menu, 'id_menu') . '" order="' . get_value($menu, 'order_') . '">'; $html .= '<div class="dd-handle dd3-handle"></div>'; $html .= '<div class="dd3-content">'; $class = get_value($menu, 'dtt_inative') != '' ? 'text-error' : ''; $img = image(get_value($menu, 'url_img')); $label = get_value($menu, 'url_img') == '' && get_value($menu, 'label') == '' ? '[NO NAME]' : lang(get_value($menu, 'label')); $html .= '<a href="javascript:void(0)" class="menu-label ' . $class . '" data-toggle="modal" data-target="#modal-menu-' . get_value($menu, 'id_menu') . '">' . $img . ' ' . $label . '</a>'; $html .= '<i class="text-success fa fa-fw fa-check-circle" style="display: none; margin-left: 5px"></i>'; $html .= '<a href="javascript:void(0)" class="menu-delete pull-right hidden"><i class="fa fa-trash fa-fw"></i></a>'; $html .= '</div>'; // If current menu has children items, then build all again if ($count_menu_children > 0) { $html .= '<ol class="dd-list">' . custom_menu_tree(get_value($menu, 'children')) . '</ol>'; } $html .= '</li>'; } return $html; }
/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return array Array of stdcommand, stdhtml, stdout, and stderr responses */ function run($options, $parameters, &$occle_fs) { if (array_key_exists('h', $options) || array_key_exists('help', $options)) { return array('', do_command_help('send_chatmessage', array('h'), array(true, true)), '', ''); } else { if (!array_key_exists(0, $parameters)) { return array('', '', '', do_lang('MISSING_PARAM', '1', 'send_chatmessage')); } if (!array_key_exists(1, $parameters)) { return array('', '', '', do_lang('MISSING_PARAM', '2', 'send_chatmessage')); } require_code('chat'); if (is_numeric($parameters[0])) { $chatroom = $parameters[0]; } elseif ($parameters[0] == 'first-watched') { $_chatroom = get_value('occle_watched_chatroom'); $chatroom = is_null($_chatroom) ? $GLOBALS['SITE_DB']->query_value_null_ok('chat_rooms', 'id', NULL, 'ORDER BY id') : intval($_chatroom); } else { $chatroom = get_chatroom_id($parameters[0]); } if (is_null($chatroom)) { return array('', '', '', do_lang('MISSING_RESOURCE')); } chat_post_message($chatroom, $parameters[1], get_option('chat_default_post_font'), get_option('chat_default_post_colour')); return array('', '', do_lang('SUCCESS'), ''); } }
function build_menu($menus = array()) { // Check if current level is parent $current_line = isset($menus[0]) ? $menus[0] : array(); $root_level = get_value($current_line, 'id_menu_parent') <= 0 ? true : false; if (count($menus) > 0) { foreach ($menus as $menu) { // DEBUG: // print_r($menu); // Counting children menu $count_menu_children = count(get_value($menu, 'children')); // Build a link $link = tag_replace(get_value($menu, 'link')); $target = get_value($menu, 'target') != '' ? ' target="' . tag_replace(get_value($menu, 'target')) . '" ' : ''; $label = lang(get_value($menu, 'label')); $img = image(get_value($menu, 'url_img')); // Build a single line menu if ($count_menu_children > 0) { $class = $root_level ? 'dropdown' : 'dropdown dropdown-submenu'; $caret = $root_level ? '<span class="caret"></span>' : ''; ?> <li class="<?php echo $class; ?> "> <a href="<?php echo $link; ?> " <?php echo $target; ?> class="dropdown-toggle" data-toggle="dropdown"> <?php echo $img . ' ' . $label . $caret; ?> </a> <ul class="dropdown-menu"><?php build_menu(get_value($menu, 'children')); ?> </ul> </li> <?php } else { ?> <li><a href="<?php echo $link; ?> " <?php echo $target; ?> ><?php echo $img . ' ' . $label; ?> </a></li> <?php } } } }
/** * Find what field types this hook can serve. This method only needs to be defined if it is not serving a single field type with a name corresponding to the hook itself. * * @return array Map of field type to field type title */ function get_field_types() { $ret = array('short_text' => do_lang_tempcode('FIELD_TYPE_short_text')); if (get_value('html5') === '1') { $ret += array('tel' => do_lang_tempcode('FIELD_TYPE_tel')); } return $ret; }
/** * Get the tempcode for the form to add a banner, with the information passed along to it via the parameters already added in. * * @param boolean Whether to simplify the banner interface (for the point-store buy process) * @param ID_TEXT The name of the banner * @param URLPATH The URL to the banner image * @param URLPATH The URL to the site the banner leads to * @param SHORT_TEXT The caption of the banner * @param LONG_TEXT Any notes associated with the banner * @param integer The banners "importance modulus" * @range 1 max * @param ?integer The number of hits the banner may have (NULL: not applicable for this banner type) * @range 0 max * @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 expires) * @param ?ID_TEXT The username of 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 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) * @return tempcode The input field tempcode */ function get_banner_form_fields($simplified = false, $name = '', $image_url = '', $site_url = '', $caption = '', $notes = '', $importancemodulus = 3, $campaignremaining = 50, $the_type = 1, $expiry_date = NULL, $submitter = NULL, $validated = 1, $b_type = '', $title_text = '') { require_code('images'); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_BANNER_NAME'), 'name', $name, true)); $fields->attach(form_input_line(do_lang_tempcode('DESTINATION_URL'), do_lang_tempcode('DESCRIPTION_BANNER_URL'), 'site_url', $site_url, false)); // Blank implies iframe if (!$simplified) { $types = nice_get_banner_types($b_type); if ($types->is_empty()) { warn_exit(do_lang_tempcode('NO_CATEGORIES')); } $fields->attach(form_input_list(do_lang_tempcode('_BANNER_TYPE'), do_lang_tempcode('_DESCRIPTION_BANNER_TYPE'), 'b_type', $types, NULL, false, false)); } else { $fields->attach(form_input_hidden('b_type', $b_type)); } if (has_specific_permission(get_member(), 'full_banner_setup')) { $fields->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_SUBMITTER'), 'submitter', is_null($submitter) ? $GLOBALS['FORUM_DRIVER']->get_username(get_member()) : $submitter, false)); } if (get_value('disable_staff_notes') !== '1') { $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false)); } if (has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'cms_banners')) { if ($validated == 0) { $validated = get_param_integer('validated', 0); if ($validated == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } if (addon_installed('unvalidated')) { $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1)); } } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SOURCE_MEDIA')))); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_BANNER'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',swf'))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('IMAGE_URL')), do_lang_tempcode('DESCRIPTION_URL_BANNER'), 'image_url', $image_url, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('BANNER_TITLE_TEXT'), do_lang_tempcode('DESCRIPTION_BANNER_TITLE_TEXT'), 'title_text', $title_text, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_BANNER_DESCRIPTION'), 'caption', $caption, false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('DEPLOYMENT_DETERMINATION')))); if (has_specific_permission(get_member(), 'full_banner_setup')) { $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_PERMANENT), $the_type == BANNER_PERMANENT, do_lang_tempcode('BANNER_PERMANENT'))); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_CAMPAIGN), $the_type == BANNER_CAMPAIGN, do_lang_tempcode('BANNER_CAMPAIGN'))); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_DEFAULT), $the_type == BANNER_DEFAULT, do_lang_tempcode('BANNER_DEFAULT'))); $fields->attach(form_input_radio(do_lang_tempcode('DEPLOYMENT_AGREEMENT'), do_lang_tempcode('DESCRIPTION_BANNER_TYPE'), 'the_type', $radios)); $fields->attach(form_input_integer(do_lang_tempcode('HITS_ALLOCATED'), do_lang_tempcode('DESCRIPTION_HITS_ALLOCATED'), 'campaignremaining', $campaignremaining, false)); $total_importance = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(importance_modulus) FROM ' . get_table_prefix() . 'banners WHERE ' . db_string_not_equal_to('name', $name)); if (is_null($total_importance)) { $total_importance = 0; } $fields->attach(form_input_integer(do_lang_tempcode('IMPORTANCE_MODULUS'), do_lang_tempcode('DESCRIPTION_IMPORTANCE_MODULUS', strval($total_importance), strval($importancemodulus)), 'importancemodulus', $importancemodulus, true)); } $fields->attach(form_input_date(do_lang_tempcode('EXPIRY_DATE'), do_lang_tempcode('DESCRIPTION_EXPIRY_DATE'), 'expiry_date', true, is_null($expiry_date), true, $expiry_date, 2)); return $fields; }
/** * Intercepts the data about to be passed to KISSMetrics, replacing the order * totals with their counterpart in base currency. * * @param array kissmetrics_properties The data to be passed to KISSMetrics. * @return array */ public function wc_kissmetrics_completed_purchase_properties($kissmetrics_properties) { $order_id = get_value('order_id', $kissmetrics_properties); if (!empty($order_id)) { $order = new Aelia_Order($order_id); $kissmetrics_properties['order_total'] = $order->get_total_in_base_currency(); $kissmetrics_properties['shipping_total'] = $order->get_shipping_in_base_currency(); } return $kissmetrics_properties; }
/** * Standard modular run function for attachment hooks. They see if permission to an attachment of an ID relating to this content is present for the current member. * * @param ID_TEXT The ID * @param object The database connection to check on * @return boolean Whether there is permission */ function run($id, $connection) { $info = $connection->query_select('catalogue_entries', array('c_name', 'cc_id'), array('id' => intval($id)), '', 1); if (!array_key_exists(0, $info)) { return false; } if (!has_category_access(get_member(), 'catalogues_catalogue', $info[0]['c_name'])) { return false; } return get_value('disable_cat_cat_perms') === '1' || has_category_access(get_member(), 'catalogues_category', strval($info[0]['cc_id'])); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); require_css('adminzone'); require_lang('tips'); if (get_value('no_frames') === '1') { require_code('misc_scripts'); return staff_tips_script(true); } return do_template('BLOCK_MAIN_STAFF_TIPS_IFRAME'); }
/** * Returns current plugin settings, or the value a specific setting. * * @param string key If specified, method will return only the setting identified * by the key. * @param mixed default The default value to return if the setting requested * via the "key" argument is not found. * @return array|mixed The plugin settings, or the value of the specified * setting. */ public function current_settings($key = null, $default = null) { if (empty($this->_current_settings)) { $this->_current_settings = $this->load(); } if (empty($key)) { return $this->_current_settings; } else { return get_value($key, $this->_current_settings, $default); } }
function db_get_template($tpl_name, &$tpl_source, &$smarty_obj) { global $db; global $thulit; $set = db_get("select id from data where name_id='" . $tpl_name . "' and node_type='template'"); if ($arr = $set->fetchRow()) { $tpl_source = get_value($arr['id'], $thulit['lang']); return true; } else { return false; } }
public function adicionarTerreno($id_personagem, $id_cidade, $terreno) { $query = "\n SELECT COUNT(*) AS 'quantidade'\n FROM personagem_terreno\n WHERE id_personagem = '" . do_escape($id_personagem) . "'\n AND id_cidade = '" . do_escape($id_cidade) . "'\n "; $quantidade = get_value($query, 'quantidade'); if ($quantidade > 0) { $query = "\n UPDATE personagem_terreno SET\n terreno = terreno + " . do_escape($terreno) . "\n WHERE id_personagem = '" . do_escape($id_personagem) . "'\n AND id_cidade = '" . do_escape($id_cidade) . "'\n "; do_update($query); } else { $query = "\n INSERT INTO personagem_terreno (\n id_personagem,\n id_cidade,\n terreno\n ) VALUES (\n '" . do_escape($id_personagem) . "',\n '" . do_escape($id_cidade) . "',\n '" . do_escape($terreno) . "'\n )\n "; do_insert($query); } }
/** * @param string $key * @param mixed $default * @param string $castTo * * @return mixed */ protected function getValue($key, $default = null, $castTo = null) { $value = get_value($key, $default, $this->values); if ($castTo) { if (method_exists($this, 'cast')) { $value = $this->cast($value, $castTo); } else { throw new \LogicException('Casting is not supported.'); } } return $value; }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { //if (!addon_installed('octhief')) return; require_lang('insults'); // ensure it is done once per week $time = time(); $last_time = intval(get_value('last_insult_time')); if ($last_time > time() - 24 * 60 * 60) { return; } // run it once a day set_value('last_insult_time', strval($time)); // how many points a correct response will give $_insult_points = get_option('insult_points', true); if (is_null($_insult_points)) { // add option and default value if not installed yet require_code('database_action'); add_config_option('INSULT_POINTS', 'insult_points', 'integer', 'return \'10\';', 'POINTS', 'INSULT_TITLE'); } $insult_points = isset($_insult_points) && is_numeric($_insult_points) ? intval($_insult_points) : 10; // who to insult? $selected_members = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' ORDER BY RAND( ) ', 2, NULL, true); $selected_member1 = isset($selected_members[0]['id']) && $selected_members[0]['id'] > 0 ? $selected_members[0]['id'] : 0; $selected_member2 = isset($selected_members[1]['id']) && $selected_members[1]['id'] > 0 ? $selected_members[1]['id'] : 0; // send insult to picked members if ($selected_member1 != 0 && $selected_member2 != 0) { $get_insult = ''; if (is_file(get_file_base() . '/text_custom/' . user_lang() . '/insults.txt')) { $insults = file(get_file_base() . '/text_custom/' . user_lang() . '/insults.txt'); $insults_array = array(); foreach ($insults as $insult) { $x = explode('=', $insult); $insults_array[] = $x[0]; } $rand_key = array_rand($insults_array, 1); $rand_key = is_array($rand_key) ? $rand_key[0] : $rand_key; $get_insult = $insults_array[$rand_key]; } if ($get_insult != '') { global $SITE_INFO; $insult_pt_topic_post = do_lang('INSULT_EXPLANATION', get_site_name(), $get_insult, $insult_points); $subject = do_lang('INSULT_PT_TOPIC', $GLOBALS['FORUM_DRIVER']->get_username($selected_member2), $GLOBALS['FORUM_DRIVER']->get_username($selected_member1)); require_code('ocf_topics_action'); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $selected_member2, $selected_member1, true, 0, NULL, ''); require_code('ocf_posts_action'); $post_id = ocf_make_post($topic_id, $subject, $insult_pt_topic_post, 0, true, 1, 0, do_lang('SYSTEM'), NULL, NULL, $GLOBALS['FORUM_DRIVER']->get_guest_id(), NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); require_code('ocf_topics_action2'); send_pt_notification($post_id, $subject, $topic_id, $selected_member2, $selected_member1); } } }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (!addon_installed('catalogues')) { return; } $last = get_value('last_classified_refresh'); $time = time(); if (!is_null($last) && intval($last) > $time - 60 * 60) { return; } // Don't do more than once per hour if (function_exists('set_time_limit')) { @set_time_limit(0); } $start = 0; do { $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries e JOIN ' . get_table_prefix() . 'classifieds_prices p ON p.c_catalogue_name=e.c_name', array('e.*'), array('ce_validated' => 1), '', 1000, $start); foreach ($entries as $entry) { if ($entry['ce_last_moved'] == $entry['ce_add_date']) { require_code('classifieds'); initialise_classified_listing($entry); } // Expiring if ($entry['ce_last_moved'] < $time) { $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_validated' => 0), array('id' => $entry['id']), '', 1); decache('main_cc_embed'); decache('main_recent_cc_entries'); require_code('catalogues2'); calculate_category_child_count_cache($entry['cc_id']); } elseif ($entry['ce_last_moved'] < $time + 60 * 60 * 24 && $entry['ce_last_moved'] > $time + 60 * 60 * 23) { // Expiring in 24 hours require_code('notifications'); require_lang('classifieds'); $member_id = $entry['ce_submitter']; $renew_url = build_url(array('page' => 'classifieds', 'type' => 'adverts', 'id' => $member_id), get_module_zone('classifieds')); require_code('catalogues'); $data_map = get_catalogue_entry_map($entry, NULL, 'CATEGORY', 'DEFAULT', NULL, NULL, array(0)); $ad_title = $data_map['FIELD_0_PLAIN']; if (is_object($ad_title)) { $ad_title = $ad_title->evaluate(); } $subject_tag = do_lang('SUBJECT_CLASSIFIED_ADVERT_EXPIRING', $ad_title, get_site_name(), NULL, get_lang($member_id), false); $mail = do_lang('MAIL_CLASSIFIED_ADVERT_EXPIRING', $ad_title, comcode_escape(get_site_name()), comcode_escape($renew_url->evaluate()), get_lang($member_id), false); // Send actual notification dispatch_notification('classifieds__' . $entry['c_name'], '', $subject_tag, $mail, array($member_id), A_FROM_SYSTEM_PRIVILEGED); } } } while (count($entries) == 1000); set_value('last_classified_refresh', strval($time)); }
function get_amount_rights() { $payrights = get_value('payrights'); if ($payrights == '') { $amount = get_value('amount'); $eff = get_eff_value(); if ($amount == '') { return ''; } return $amount * $eff / 100; } else { return $payrights; } }
public function search($params, $order, $page) { $fields = 'user_id, user_name, true_name, bid, uposition, is_admin, create_uname, create_time'; $where = array(array('is_del', '0'), array('user_name', get_value($params, 'user_name'), 'like'), array('true_name', get_value($params, 'true_name'), 'like'), array('uposition', get_value($params, 'uposition'), 'like'), array('is_admin', get_value($params, 'is_admin'))); $result = $this->db->get_page($this->table, $fields, $where, $order, $page); $this->load->model('sys/branch_model', 'branch_model'); $CI =& get_instance(); foreach ($result['rows'] as $k => $v) { if ($bname = $CI->branch_model->get_name_by_id($v['bid'])) { $result['rows'][$k]['bname'] = $bname; } } return $result; }
/** * The UI for managing super debranding. * * @return tempcode The UI */ function misc() { $title = get_page_title('SUPER_DEBRAND'); require_code('form_templates'); $rebrand_name = get_value('rebrand_name'); if (is_null($rebrand_name)) { $rebrand_name = 'ocPortal'; } $rebrand_base_url = get_value('rebrand_base_url'); if (is_null($rebrand_base_url)) { $rebrand_base_url = 'http://ocportal.com'; } $company_name = get_value('company_name'); if (is_null($company_name)) { $company_name = 'ocProducts'; } $keyboard_map = file_exists(get_file_base() . '/pages/comcode/' . get_site_default_lang() . '/keymap.txt') ? file_get_contents(get_file_base() . '/pages/comcode/' . get_site_default_lang() . '/keymap.txt') : file_get_contents(get_file_base() . '/pages/comcode/' . fallback_lang() . '/keymap.txt'); if (file_exists(get_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/keymap.txt')) { $keyboard_map = file_get_contents(get_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/keymap.txt'); } if (file_exists(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/website.txt')) { $adminguide = file_get_contents(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/website.txt'); } else { $adminguide = do_lang('ADMINGUIDE_DEFAULT_TRAINING'); } if (file_exists(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/start.txt')) { $start_page = file_get_contents(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/start.txt'); } elseif (file_exists(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt')) { $start_page = file_exists(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt') ? file_get_contents(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt') : file_get_contents(get_file_base() . '/adminzone/pages/comcode/' . fallback_lang() . '/start.txt'); } else { $start_page = do_lang('REBRAND_FRONT_PAGE'); } $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('REBRAND_NAME'), do_lang_tempcode('DESCRIPTION_REBRAND_NAME'), 'rebrand_name', $rebrand_name, true)); $fields->attach(form_input_line(do_lang_tempcode('REBRAND_BASE_URL'), do_lang_tempcode('DESCRIPTION_BRAND_BASE_URL', escape_html('docs' . strval(ocp_version()))), 'rebrand_base_url', $rebrand_base_url, true)); $fields->attach(form_input_line(do_lang_tempcode('COMPANY_NAME'), '', 'company_name', $company_name, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('ADMINGUIDE'), do_lang_tempcode('DESCRIPTION_ADMINGUIDE'), 'adminguide', $adminguide, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('ADMINSTART_PAGE'), do_lang_tempcode('DESCRIPTION_ADMINSTART_PAGE'), 'start_page', $start_page, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('KEYBOARD_MAP'), '', 'keyboard_map', $keyboard_map, true)); $fields->attach(form_input_tick(do_lang_tempcode('DELETE_UN_PC'), do_lang_tempcode('DESCRIPTION_DELETE_UN_PC'), 'churchy', false)); $fields->attach(form_input_tick(do_lang_tempcode('SHOW_DOCS'), do_lang_tempcode('DESCRIPTION_SHOW_DOCS'), 'show_docs', get_option('show_docs') == '1')); $fields->attach(form_input_upload(do_lang_tempcode('FAVICON'), do_lang_tempcode('DESCRIPTION_FAVICON'), 'favicon', false, find_theme_image('favicon'), NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_upload(do_lang_tempcode('APPLEICON'), do_lang_tempcode('DESCRIPTION_APPLEICON'), 'appleicon', false, find_theme_image('appleicon'), NULL, true, str_replace(' ', '', get_option('valid_images')))); if (addon_installed('ocf_avatars')) { $fields->attach(form_input_upload(do_lang_tempcode('SYSTEM_AVATAR'), do_lang_tempcode('DESCRIPTION_SYSTEM_AVATAR'), 'system_avatar', false, find_theme_image('ocf_default_avatars/default_set/ocp_fanatic'), NULL, true, str_replace(' ', '', get_option('valid_images')))); } $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF'); $submit_name = do_lang_tempcode('SUPER_DEBRAND'); return do_template('FORM_SCREEN', array('HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('WARNING_SUPER_DEBRAND_MAJOR_CHANGES'), 'SUBMIT_NAME' => $submit_name)); }
/** * Put the contents of a page inside an iframe. This is typically used when a page is being used to traverse a result-set that spans multiple screens. * * @param tempcode The title * @param ?integer The time between refreshes (NULL: do not refresh) * @param ?mixed Data. A refresh will only happen if an AJAX-check indicates this data has changed (NULL: no check) * @return ?tempcode The page output to finish off our current page stream such that it will spawn the iframe (NULL: not internalised) */ function internalise_own_screen($title, $refresh_time = NULL, $refresh_if_changed = NULL) { if (get_value('no_frames') === '1' || get_param_integer('no_frames', 0) == 1 || get_param_integer('keep_no_frames', 0) == 1) { return NULL; } if (!has_js()) { return NULL; } // We need JS to make this a seamless process if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) { return NULL; } // This is already in the iframe require_javascript('javascript_ajax'); require_javascript('javascript_iframe_screen'); $url = find_script('iframe') . '?zone=' . rawurlencode(get_zone_name()) . '&wide_high=1&utheme=' . rawurlencode($GLOBALS['FORUM_DRIVER']->get_theme()); foreach (array_merge($_GET, $_POST) as $key => $param) { if (!is_string($param)) { continue; } if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) { continue; } if (get_magic_quotes_gpc()) { $param = stripslashes($param); } $url .= '&' . $key . '=' . urlencode($param); } if (!is_null($refresh_if_changed)) { require_javascript('javascript_sound'); $change_detection_url = find_script('change_detection') . '?whatever=1'; foreach ($_GET as $key => $param) { if (!is_string($param)) { continue; } if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) { continue; } if (get_magic_quotes_gpc()) { $param = stripslashes($param); } $change_detection_url .= '&' . $key . '=' . urlencode($param); } } else { $refresh_if_changed = ''; $change_detection_url = ''; } return do_template('IFRAME_SCREEN', array('_GUID' => '06554eb227428fd5c648dee3c5b38185', 'TITLE' => $title, 'REFRESH_IF_CHANGED' => md5(serialize($refresh_if_changed)), 'CHANGE_DETECTION_URL' => $change_detection_url, 'REFRESH_TIME' => is_null($refresh_time) ? '' : strval($refresh_time), 'IFRAME_URL' => $url)); }