/** * The actualiser for a gift point transaction. * * @return tempcode The UI */ function do_give() { $member_id_of = get_param_integer('id'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USER_POINT_FIND')), array('_SELF:_SELF:member:id=' . strval($member_id_of), do_lang_tempcode('_POINTS', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id_of)))))); $title = get_page_title('POINTS'); $trans_type = post_param('trans_type', 'gift'); $amount = post_param_integer('amount'); $reason = post_param('reason'); $worked = false; $member_id_viewing = get_member(); if ($member_id_of == $member_id_viewing && !has_specific_permission($member_id_viewing, 'give_points_self')) { $message = do_lang_tempcode('PE_SELF'); } elseif (is_guest($member_id_viewing)) { $message = do_lang_tempcode('MUST_LOGIN'); } else { if ($trans_type == 'gift') { $anonymous = post_param_integer('anonymous', 0); $viewer_gift_points_available = get_gift_points_to_give($member_id_viewing); //$viewer_gift_points_used=get_gift_points_used($member_id_viewing); if ($viewer_gift_points_available < $amount && !has_specific_permission($member_id_viewing, 'have_negative_gift_points')) { $message = do_lang_tempcode('PE_LACKING_GIFT_POINTS'); } elseif ($amount < 0 && !has_specific_permission($member_id_viewing, 'give_negative_points')) { $message = do_lang_tempcode('PE_NEGATIVE_GIFT'); } elseif ($reason == '') { $message = do_lang_tempcode('IMPROPERLY_FILLED_IN'); } else { // Write transfer require_code('points2'); give_points($amount, $member_id_of, $member_id_viewing, $reason, $anonymous == 1); // Randomised gifts if (mt_rand(0, 4) == 1) { $message = do_lang_tempcode('PR_LUCKY'); $_current_gift = point_info($member_id_viewing); $current_gift = array_key_exists('points_gained_given', $_current_gift) ? $_current_gift['points_gained_given'] : 0; $GLOBALS['FORUM_DRIVER']->set_custom_field($member_id_viewing, 'points_gained_given', $current_gift + 25); // TODO: 25 should be a config option } else { $message = do_lang_tempcode('PR_NORMAL'); } $worked = true; } } if ($trans_type == 'refund') { $trans_type = 'charge'; $amount = -$amount; } if ($trans_type == 'charge') { if (has_actual_page_access($member_id_viewing, 'adminzone')) { require_code('points2'); charge_member($member_id_of, $amount, $reason); $left = available_points($member_id_of); $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); if (is_null($username)) { $username = do_lang('UNKNOWN'); } $message = do_lang_tempcode('USER_HAS_BEEN_CHARGED', escape_html($username), escape_html(integer_format($amount)), escape_html(integer_format($left))); $worked = true; } else { access_denied('I_ERROR'); } } } if ($worked) { // Show it worked / Refresh $url = build_url(array('page' => '_SELF', 'type' => 'member', 'id' => $member_id_of), '_SELF'); return redirect_screen($title, $url, $message); } else { return warn_screen($title, $message); } }
/** * Wrapper and actualiser to delete a realm. Does not return. * * @param MEMBER The member who is in the room */ function delete_realm_wrap($member_id) { $attempt_member = $member_id; $realm = $GLOBALS['SITE_DB']->query_value('w_members', 'location_realm', array('id' => $member_id)); if ($realm == 0) { ocw_refresh_with_message(do_lang_tempcode('W_DEL_PRIMARY_REALM'), 'warn'); } if (!has_specific_permission($attempt_member, 'administer_ocworld') && $GLOBALS['SITE_DB']->query_value('w_realms', 'owner', array('id' => $realm)) != $attempt_member) { ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn'); } if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'w_rooms WHERE location_realm=' . strval((int) $realm) . ' AND owner<>' . strval((int) $attempt_member)) > 0) { ocw_refresh_with_message(do_lang_tempcode('W_NO_DEL_OTHERS_ROOMS_REALM'), 'warn'); } // Refund them require_code('points2'); $price = get_price('mud_realm'); charge_member($attempt_member, intval(-0.7 * $price), do_lang('W_DELETE_REALM_OCWORLD', strval($realm))); delete_realm($realm); }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done2() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); $title = get_page_title('OCGIFTS_TITLE'); $gift_id = get_param_integer('gift'); $member_id = get_member(); $to_member = post_param('username', ''); $gift_message = post_param('gift_message', ''); $member_row = $GLOBALS['FORUM_DB']->query_select('f_members', array('*'), array('m_username' => $to_member), '', 1); if (isset($member_row[0]['id']) && $member_row[0]['id'] > 0) { $to_member_id = $member_row[0]['id']; $anonymous = post_param_integer('anonymous', 0); $gift_row = $GLOBALS['SITE_DB']->query_select('ocgifts', array('*'), array('id' => $gift_id)); if (isset($gift_row[0]['id']) && $gift_row[0]['id'] > 0) { //check available points and charge $available_points = available_points($member_id); if ($gift_row[0]['price'] > $available_points) { warn_exit(do_lang_tempcode('CANT_AFFORD')); } require_code('points2'); //get gift points charge_member($member_id, $gift_row[0]['price'], do_lang('GIFT_PURCHASING') . ' - ' . strval($gift_row[0]['price']) . ' point(-s).'); $gift_row_id = $GLOBALS['SITE_DB']->query_insert('members_gifts', array('to_user_id' => $to_member_id, 'from_user_id' => $member_id, 'gift_id' => $gift_id, 'add_time' => time(), 'is_anonymous' => $anonymous, 'topic_id' => NULL, 'gift_message' => $gift_message), true); } if (isset($gift_row[0]['id']) && $gift_row[0]['id'] > 0) { require_code('notifications'); if ($anonymous == 0) { $subject = do_lang('GOT_GIFT'); $message = '[html]' . do_lang('GIFT_EXPLANATION1', $GLOBALS['FORUM_DRIVER']->get_username($member_id), $gift_row[0]['name']) . '[/html].' . "\n\n" . '[img]' . get_custom_base_url() . '/' . $gift_row[0]['image'] . '[/img]' . "\n\n" . $gift_message; dispatch_notification('gift', NULL, $subject, $message, array($to_member_id)); } else { $subject = do_lang('GOT_GIFT', NULL, NULL, NULL, get_lang($to_member_id)); $message = '[html]' . do_lang('GIFT_EXPLANATION2', $gift_row[0]['name'], NULL, NULL, get_lang($to_member_id)) . '[/html].' . "\n\n" . '[img]' . get_custom_base_url() . '/' . $gift_row[0]['image'] . '[/img]' . "\n\n" . $gift_message; dispatch_notification('gift', NULL, $subject, $message, array($to_member_id), A_FROM_SYSTEM_UNPRIVILEGED); } } } else { warn_exit(do_lang_tempcode('NO_MEMBER_SELECTED')); } // Show message $result = do_lang_tempcode('GIFT_CONGRATULATIONS'); $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, $result); }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); if (get_option('is_on_' . $class . '_buy') == '0' || get_forum_type() != 'ocf') { return new ocp_tempcode(); } if ($GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_highlighted_name') == 1) { warn_exit(do_lang_tempcode('_ALREADY_HAVE')); } $title = get_page_title('NAME_HIGHLIGHTING'); post_param_integer('confirm'); // To make sure we're not being passed by a GET // Check points $cost = intval(get_option($class)); $points_left = available_points(get_member()); if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) { return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left))); } // Actuate $GLOBALS['FORUM_DB']->query_update('f_members', array('m_highlighted_name' => 1), array('id' => get_member()), '', 1); require_code('points2'); charge_member(get_member(), $cost, do_lang('NAME_HIGHLIGHTING')); $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'NAME_HIGHLIGHTING', 'details' => '', 'details2' => '')); // Show message $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE')); }
/** * Standard stage of pointstore item purchase. * * @return tempcode The UI */ function _upgradebanner() { if (get_option('is_on_banner_buy') == '0') { return new ocp_tempcode(); } $title = get_page_title('TITLE_BANNER_UPGRADE'); $member_id = get_member(); $pointsleft = available_points($member_id); $myrow = $this->handle_has_no_banner(); $curhit = $myrow['campaign_remaining']; $curimp = $myrow['importance_modulus']; $name = $myrow['name']; //So we don't have to call these big ugly names, again... $futhit = post_param_integer('hits'); $futimp = post_param_integer('importance'); //Checking to be sure we've ordered numbers that are positive if (!($futimp >= 0 && $futhit >= 0)) { return warn_screen($title, do_lang_tempcode('BAD_INPUT')); } //Checking to be sure we haven't ordered nothing... if ($futimp == 0 && $futhit == 0) { return warn_screen($title, do_lang_tempcode('SILLY_INPUT')); } //How many importance and hits will we have after this? $afthit = $curhit + $futhit; $aftimp = $curimp + $futimp; //Getting the prices of hits and importance... $impprice = intval(get_option('banner_imp')); $hitprice = intval(get_option('banner_hit')); //Figuring out the price of importance and hits, depedning on how many they bought. $impcost = $futimp * $impprice; $hitcost = $futhit * $hitprice; $total_price = $hitcost + $impcost; $points_after = $pointsleft - $total_price; //Check to see this isn't costing us more than we can afford if ($points_after < 0 && !has_specific_permission(get_member(), 'give_points_self')) { return warn_screen($title, do_lang_tempcode('CANT_AFFORD')); } //If this is *not* our first time through, do a confirmation screen. Else, make the purchase. $ord = post_param_integer('ord', 0); if ($ord == 0) { $proceed_url = build_url(array('page' => '_SELF', 'type' => '_upgradebanner', 'id' => 'banners'), '_SELF'); $keep = new ocp_tempcode(); $keep->attach(form_input_hidden('hits', strval($futhit))); $keep->attach(form_input_hidden('importance', strval($futimp))); $keep->attach(form_input_hidden('ord', '1')); $action = do_lang_tempcode('BANNER_UPGRADE_CONFIRM', integer_format($futimp), integer_format($futhit)); return do_template('POINTSTORE_CONFIRM_SCREEN', array('_GUID' => 'acdde0bd41ccd1459bbd7a1e9ca5ed68', 'TITLE' => $title, 'MESSAGE' => $action, 'ACTION' => '', 'COST' => integer_format($total_price), 'POINTS_AFTER' => integer_format($points_after), 'CANCEL_URL' => build_url(array('page' => '_SELF'), '_SELF'), 'PROCEED_URL' => $proceed_url, 'KEEP' => $keep)); } // Our Query $GLOBALS['SITE_DB']->query_update('banners', array('campaign_remaining' => $afthit, 'importance_modulus' => $aftimp), array('name' => $name), '', 1); //Charge the user for their purchase require_code('points2'); charge_member($member_id, $total_price, do_lang('BANNER_UPGRADE_LINE', integer_format($futhit), integer_format($futimp))); $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('BANNER_UPGRADED')); }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); if (get_option('is_on_' . $class . '_buy') == '0') { return new ocp_tempcode(); } $topic_id = post_param_integer('select_topic_id', -1); if ($topic_id == -1) { $_topic_id = post_param('manual_topic_id'); $topic_id = intval($_topic_id); } $title = get_page_title('TOPIC_PINNING'); // Check points $cost = intval(get_option($class)); $points_left = available_points(get_member()); if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) { return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left))); } // Actuate $GLOBALS['FORUM_DRIVER']->pin_topic($topic_id); require_code('points2'); charge_member(get_member(), $cost, do_lang('TOPIC_PINNING')); $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'TOPIC_PINNING', 'details' => strval($topic_id), 'details2' => '')); // Show message $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE')); }
/** * The actualiser for a member to buy an item from the room they are in. Does not return. * * @param MEMBER The member buying the item * @param string The name of the item * @param MEMBER The owner of the item copy */ function buy($member_id, $item_name, $copy_owner) { // Check we have the points and that it exists list($realm, $x, $y) = get_loc_details($member_id); $cost = $GLOBALS['SITE_DB']->query_value_null_ok('w_items', 'cost', array('name' => $item_name, 'location_x' => $x, 'location_y' => $y, 'location_realm' => $realm, 'copy_owner' => $copy_owner)); if (is_null($cost)) { ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn'); } if ($cost > available_points($member_id)) { ocw_refresh_with_message(do_lang_tempcode('W_EXPENSIVE', integer_format($cost)), 'warn'); } if ($cost == 0) { ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn'); } // Charge them if (!has_specific_permission($member_id, 'administer_ocworld') || !is_guest($copy_owner)) { require_code('points2'); $price = $cost; if (available_points($member_id) < $price) { ocw_refresh_with_message(do_lang_tempcode('W_EXPENSIVE', integer_format($price)), 'warn'); } charge_member($member_id, $price, do_lang('W_BOUGHT_OCWORLD', escape_html($item_name))); charge_member($copy_owner, -$price * 0.7, do_lang('W_SOLD_OCWORLD', escape_html($item_name))); } basic_pickup($member_id, $item_name, $copy_owner); ocw_refresh_with_message(do_lang_tempcode('W_BOUGHT', escape_html($item_name), integer_format($cost))); }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { //if (!addon_installed('ocdeadpeople')) return; // ensure it is done once per week $time = time(); $last_time = intval(get_value('last_dead_time')); if ($last_time > time() - 24 * 60 * 60) { return; } // run it once a day set_value('last_dead_time', strval($time)); require_lang('ocdeadpeople'); // get just disease that should spead and are enabled $diseases_to_spread = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'diseases WHERE (last_spread_time<(' . strval(time()) . '-(spread_rate*60*60)) OR last_spread_time=0) AND enabled=1', NULL, NULL, true); if (is_null($diseases_to_spread)) { return; } foreach ($diseases_to_spread as $disease) { // select infected by the disease members $sick_by_disease_members = $GLOBALS['SITE_DB']->query('SELECT user_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'members_diseases WHERE sick=1 AND disease_id=' . strval($disease['id']) . ' ', NULL, NULL, true); if (is_null($sick_by_disease_members)) { return; } $sick_members = array(); foreach ($sick_by_disease_members as $sick_member) { $sick_members[] = $sick_member['user_id']; } $sick_members[] = $GLOBALS['FORUM_DRIVER']->get_guest_id(); foreach ($sick_by_disease_members as $sick_member) { require_code('points2'); require_lang('ocdeadpeople'); // charge disease points charge_member($sick_member['user_id'], $disease['points_per_spread'], do_lang('DISEASE_GET') . ' "' . $disease['name'] . '"'); // pick a random friend to infect $friends_a = array(); if (addon_installed('chat')) { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'chat_buddies WHERE member_likes=' . strval(intval($sick_member['user_id'])) . ' OR member_liked=' . strval(intval($sick_member['user_id'])) . ' ORDER BY date_and_time'); // get friends foreach ($rows as $i => $row) { if ($row['member_likes'] != $sick_member['user_id']) { $friends_a[$row['member_likes']] = $row['member_likes']; } else { $friends_a[$row['member_liked']] = $row['member_liked']; } } } $friends_list = implode(",", $friends_a); $friends_healthy = array(); foreach ($friends_a as $friend) { if (!in_array($friend, $sick_members)) { $friends_healthy[] = $friend; } } $to_infect = array_rand($friends_healthy); // infect random friend if (isset($friends_healthy[$to_infect]) && $friends_healthy[$to_infect] != 0) { $member_rows = $GLOBALS['SITE_DB']->query_select('members_diseases', array('*'), array('user_id' => $friends_healthy[$to_infect], 'disease_id' => $disease['id'])); $insert = true; $has_immunization = false; if (isset($member_rows[0]['user_id']) && $member_rows[0]['user_id'] != 0) { // there is already a db member disease record $insert = false; if ($member_rows[0]['immunisation'] == 1) { $has_immunization = true; } } if (!$has_immunization) { //$cure_url=build_url(array('page'=>'pointstore','type'=>'action_done','id'=>'ocdeadpeople','disease'=>$disease['id'],'cure'=>1),'_SEARCH'); $cure_url = build_url(array('page' => 'pointstore', 'type' => 'action', 'id' => 'ocdeadpeople'), '_SEARCH', NULL, false, false, true); $cure_url = $cure_url->evaluate(); if ($insert) { // infect the member for the first time $GLOBALS['SITE_DB']->query_insert('members_diseases', array('user_id' => $friends_healthy[$to_infect], 'disease_id' => $disease['id'], 'sick' => 1, 'cure' => 0, 'immunisation' => 0)); } else { // infect the member again $GLOBALS['SITE_DB']->query_update('members_diseases', array('user_id' => $friends_healthy[$to_infect], 'disease_id' => $disease['id'], 'sick' => 1, 'cure' => 0, 'immunisation' => 0), array('user_id' => $friends_healthy[$to_infect], 'disease_id' => $disease['id']), '', 1); } $message = do_lang('DISEASES_MAIL_MESSAGE', $disease['name'], $disease['name'], array($cure_url, get_site_name()), get_lang($friends_healthy[$to_infect])); dispatch_notification('got_disease', NULL, do_lang('DISEASES_MAIL_SUBJECT', get_site_name(), $disease['name'], NULL, get_lang($friends_healthy[$to_infect])), $message, array($friends_healthy[$to_infect]), A_FROM_SYSTEM_PRIVILEGED); $sick_members[] = $friends_healthy[$to_infect]; } } } // proceed with infecting a random but not immunised member (disease initiation) // ============================================================================= // get immunised members first $immunised_members_rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'members_diseases WHERE disease_id=' . strval($disease['id']) . ' AND immunisation=1', NULL, NULL, true); $immunised_members = array(); foreach ($immunised_members_rows as $im_member) { $immunised_members[] = $im_member['user_id']; } $sick_and_immunised_members = array(); $sick_and_immunised_members = array_merge($sick_members, $immunised_members); // create a list of members to be avoided - sick and immunised members should be avoided !!! $avoid_members = implode(",", $sick_and_immunised_members); $avoid_members = strlen($avoid_members) == 0 ? '0' : $avoid_members; // if there is a randomly selected members that can be infected, otherwise all of the members are already infected or immunised $random_member = $GLOBALS['SITE_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id NOT IN (' . $avoid_members . ') ORDER BY RAND()', 1, NULL, true); if (isset($random_member[0]['id']) && $random_member[0]['id'] > 0) { $member_rows = $GLOBALS['SITE_DB']->query_select('members_diseases', array('*'), array('user_id' => strval($random_member[0]['id']), 'disease_id' => $disease['id'])); $insert = true; if (isset($member_rows[0]['user_id']) && $member_rows[0]['user_id'] > 0) { // there is already a db member disease record $insert = false; } require_code('notifications'); //$cure_url=build_url(array('page'=>'pointstore','type'=>'action_done','id'=>'ocdeadpeople','disease'=>$disease['id'],'cure'=>1),'_SEARCH'); $cure_url = build_url(array('page' => 'pointstore', 'type' => 'action', 'id' => 'ocdeadpeople'), '_SEARCH', NULL, false, false, true); $cure_url = $cure_url->evaluate(); if ($insert) { // infect the member for the first time $GLOBALS['SITE_DB']->query_insert('members_diseases', array('user_id' => strval($random_member[0]['id']), 'disease_id' => $disease['id'], 'sick' => 1, 'cure' => 0, 'immunisation' => 0)); } else { // infect the member again $GLOBALS['SITE_DB']->query_update('members_diseases', array('user_id' => strval($random_member[0]['id']), 'disease_id' => $disease['id'], 'sick' => 1, 'cure' => 0, 'immunisation' => 0), array('user_id' => strval($random_member[0]['id']), 'disease_id' => strval($disease['id'])), '', 1); } $message = do_lang('DISEASES_MAIL_MESSAGE', $disease['name'], $disease['name'], array($cure_url, get_site_name()), get_lang($random_member[0]['id'])); dispatch_notification('got_disease', NULL, do_lang('DISEASES_MAIL_SUBJECT', get_site_name(), $disease['name'], NULL, get_lang($random_member[0]['id'])), $message, array($random_member[0]['id']), A_FROM_SYSTEM_PRIVILEGED); } // record disease spreading $GLOBALS['SITE_DB']->query_update('diseases', array('last_spread_time' => strval(time())), array('id' => strval($disease['id'])), '', 1); } }
/** * Standard aed_module add actualiser. * * @return ID_TEXT The entry added */ function add_actualisation() { $explanation = post_param('explanation'); $member_id = post_param_integer('member_id'); $message = post_param('message', ''); $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id); if (is_null($username)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', escape_html($username))); } $save = post_param('save'); if ($save != '') { $GLOBALS['FORUM_DB']->query_delete('f_saved_warnings', array('s_title' => $save), '', 1); $GLOBALS['FORUM_DB']->query_insert('f_saved_warnings', array('s_title' => $save, 's_explanation' => $explanation, 's_message' => $message)); } // Send PT if ($message != '') { require_code('ocf_topics_action'); require_code('ocf_topics_action2'); require_code('ocf_posts_action'); require_code('ocf_posts_action2'); $_title = do_lang('NEW_WARNING_TO_YOU'); $pt_topic_id = ocf_make_topic(NULL, '', '', 1, 1, 0, 0, 0, get_member(), $member_id); $post_id = ocf_make_post($pt_topic_id, $_title, $message, 0, true, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false); send_pt_notification($post_id, $_title, $pt_topic_id, $member_id); } // Topic silencing $silence_from_topic = post_param_integer('topic_id', NULL); if (!is_null($silence_from_topic)) { $_silence_from_topic = get_input_date('silence_from_topic'); $GLOBALS['SITE_DB']->query_delete('msp', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'topics', 'category_name' => strval($silence_from_topic))); } else { $_silence_from_topic = NULL; } if (!is_null($_silence_from_topic)) { $GLOBALS['SITE_DB']->query_insert('msp', array('active_until' => $_silence_from_topic, 'member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'topics', 'category_name' => strval($silence_from_topic), 'the_value' => '0')); } else { $silence_from_topic = NULL; } // Forum silencing $silence_from_forum = post_param_integer('forum_id', NULL); if (!is_null($silence_from_forum)) { $GLOBALS['SITE_DB']->query_delete('msp', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum))); $GLOBALS['SITE_DB']->query_delete('msp', array('member_id' => $member_id, 'specific_permission' => 'submit_midrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum))); $_silence_from_forum = get_input_date('silence_from_forum'); } else { $_silence_from_forum = NULL; } if (!is_null($_silence_from_forum)) { $GLOBALS['SITE_DB']->query_insert('msp', array('active_until' => $_silence_from_forum, 'member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum), 'the_value' => '0')); $GLOBALS['SITE_DB']->query_insert('msp', array('active_until' => $_silence_from_forum, 'member_id' => $member_id, 'specific_permission' => 'submit_midrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum), 'the_value' => '0')); } else { $silence_from_forum = NULL; } // Probation $probation = post_param_integer('probation', 0); if (has_specific_permission(get_member(), 'probate_members')) { if ($probation != 0) { $on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_on_probation_until'); if (is_null($on_probation_until) || $on_probation_until < time()) { $on_probation_until = time(); } $on_probation_until += $probation * 60 * 60 * 24; $GLOBALS['FORUM_DB']->query_update('f_members', array('m_on_probation_until' => $on_probation_until), array('id' => $member_id), '', 1); } } // Ban member if (has_specific_permission(get_member(), 'member_maintenance')) { $banned_member = post_param_integer('banned_member', 0); if ($banned_member == 1) { $GLOBALS['FORUM_DB']->query_update('f_members', array('m_is_perm_banned' => 1), array('id' => $member_id), '', 1); } } else { $banned_member = 0; } // IP ban $banned_ip = ''; if (addon_installed('securitylogging')) { if (has_actual_page_access(get_member(), 'admin_ipban')) { $_banned_ip = post_param_integer('banned_ip', 0); if ($_banned_ip == 1) { $banned_ip = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_ip_address'); require_code('failure'); add_ip_ban($banned_ip); } } } // Change group $changed_usergroup_from = NULL; if (has_specific_permission(get_member(), 'member_maintenance')) { $__changed_usergroup_from = post_param('changed_usergroup_from'); if ($__changed_usergroup_from == '') { $_changed_usergroup_from = NULL; } else { $_changed_usergroup_from = intval($__changed_usergroup_from); } if (!is_null($_changed_usergroup_from) && $_changed_usergroup_from != -1) { $changed_usergroup_from = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_primary_group'); $GLOBALS['FORUM_DB']->query_update('f_members', array('m_primary_group' => $_changed_usergroup_from), array('id' => $member_id), '', 1); } } // Prepare to charge points (used in ocf_make_warning) $charged_points = post_param_integer('charged_points', 0); // Make the warning $warning_id = ocf_make_warning($member_id, $explanation, NULL, NULL, post_param_integer('is_warning', 0), $silence_from_topic, $silence_from_forum, $probation, $banned_ip, $charged_points, $banned_member, $changed_usergroup_from); // Charge points if (addon_installed('points')) { if (has_actual_page_access(get_member(), 'admin_points')) { if ($charged_points != 0) { require_code('points2'); charge_member($member_id, $charged_points, do_lang('FOR_PUNISHMENT', strval($warning_id))); } } } return strval($warning_id); }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); $disease_id = get_param('disease', 0); $member_id = get_member(); //default values $sick = 0; $get_cure = get_param_integer('cure', 0); $get_immunization = get_param_integer('immunization', 0); $cure = $get_cure == 1 ? 1 : 0; $immunization = $get_immunization == 1 ? 1 : 0; $member_rows = $GLOBALS['SITE_DB']->query_select('members_diseases', array('*'), array('user_id' => $member_id, 'disease_id' => $disease_id)); $insert = true; if (isset($member_rows[0]['user_id']) && $member_rows[0]['user_id'] != 0) { //there is already a db member disease record $insert = false; $sick = $get_cure == 1 && $member_rows[0]['sick'] == 1 ? 0 : $sick; } else { //we should insert a new db member disease record } $rows = $GLOBALS['SITE_DB']->query_select('diseases', array('*'), array('id' => $disease_id)); $cure_price = isset($rows[0]['cure_price']) && intval($rows[0]['cure_price']) > 0 ? intval($rows[0]['cure_price']) : 0; $immunization_price = isset($rows[0]['immunisation_price']) && intval($rows[0]['immunisation_price']) > 0 ? intval($rows[0]['immunisation_price']) : 0; $amount = $get_immunization == 1 ? $immunization_price : $cure_price; $title = get_page_title('DISEASES_CURES_IMMUNIZATIONS_TITLE'); // Check points $points_left = available_points(get_member()); if (!has_specific_permission(get_member(), 'give_points_self')) { if ($points_left < $amount) { return warn_screen($title, do_lang_tempcode('_CANT_AFFORD_THIS')); } } // Actuate require_code('points2'); if ($get_immunization == 1) { charge_member(get_member(), $amount, do_lang('IMMUNIZATION_PURCHASED')); } else { charge_member(get_member(), $amount, do_lang('CURE_PURCHASED')); } if ($insert) { $GLOBALS['SITE_DB']->query_insert('members_diseases', array('user_id' => $member_id, 'disease_id' => $disease_id, 'sick' => strval($sick), 'cure' => strval($cure), 'immunisation' => strval($immunization))); } else { $GLOBALS['SITE_DB']->query_update('members_diseases', array('user_id' => $member_id, 'disease_id' => $disease_id, 'sick' => strval($sick), 'cure' => strval($cure), 'immunisation' => strval($immunization)), array('user_id' => $member_id, 'disease_id' => $disease_id), '', 1); } if ($get_immunization == 1) { // Show message $result = do_lang_tempcode('IMMUNIZATION_CONGRATULATIONS'); } else { // Show message $result = do_lang_tempcode('CURE_CONGRATULATIONS'); } $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, $result); }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); post_param_integer('confirm'); // Make sure POSTed $id = get_param_integer('sub_id'); $rows = $GLOBALS['SITE_DB']->query_select('pstore_customs', array('id', 'c_title', 'c_cost', 'c_one_per_member'), array('id' => $id, 'c_enabled' => 1)); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $cost = $rows[0]['c_cost']; $c_title = get_translated_text($rows[0]['c_title']); $title = get_page_title('PURCHASE_SOME_PRODUCT', true, array(escape_html($c_title))); // Check points $points_left = available_points(get_member()); if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) { return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left))); } if ($rows[0]['c_one_per_member'] == 1) { // Test to see if it's been bought $test = $GLOBALS['SITE_DB']->query_value_null_ok('sales', 'id', array('purchasetype' => 'PURCHASE_CUSTOM_PRODUCT', 'details2' => strval($rows[0]['id']), 'memberid' => get_member())); if (!is_null($test)) { warn_exit(do_lang_tempcode('ONE_PER_MEMBER_ONLY')); } } require_code('points2'); charge_member(get_member(), $cost, $c_title); $sale_id = $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'PURCHASE_CUSTOM_PRODUCT', 'details' => $c_title, 'details2' => strval($rows[0]['id'])), true); require_code('notifications'); $subject = do_lang('MAIL_REQUEST_CUSTOM', comcode_escape($c_title), NULL, NULL, get_site_default_lang()); $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); $message_raw = do_lang('MAIL_REQUEST_CUSTOM_BODY', comcode_escape($c_title), $username, NULL, get_site_default_lang()); dispatch_notification('pointstore_request_custom', 'custom' . strval($id) . '_' . strval($sale_id), $subject, $message_raw, NULL, NULL, 3, true); // Show message $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE')); }
/** * The actualiser to charge a member points. * * @return tempcode The UI */ function points_charge() { $title = get_page_title('CHARGE_USER'); $member = post_param_integer('user'); $amount = post_param_integer('amount'); $reason = post_param('reason'); require_code('points2'); charge_member($member, $amount, $reason); $left = available_points($member); $username = $GLOBALS['FORUM_DRIVER']->get_username($member); if (is_null($username)) { $username = do_lang('UNKNOWN'); } $text = do_lang_tempcode('USER_HAS_BEEN_CHARGED', escape_html($username), escape_html(integer_format($amount)), escape_html(integer_format($left))); // Show it worked / Refresh $url = get_param('redirect', NULL); if (is_null($url)) { $_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $member), get_module_zone('points')); $url = $_url->evaluate(); } return redirect_screen($title, $url, $text); }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); if (get_option('is_on_' . $class . '_buy') == '0') { return new ocp_tempcode(); } $amount = post_param_integer('amount', -1); $title = get_page_title('GAMBLING'); // Check points $cost = intval(get_option('minimum_gamble_amount')); $points_left = available_points(get_member()); $max = min(intval(get_option('maximum_gamble_amount')), $points_left); if (!has_specific_permission(get_member(), 'give_points_self') || $amount < 0) { if ($amount < $cost || $amount > $max) { warn_exit(do_lang_tempcode('INVALID_GAMBLE_AMOUNT')); } if ($points_left < $amount) { return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left))); } } // Calculate $average_gamble_multiplier = floatval(get_option('average_gamble_multiplier')) / 100.0; $maximum_gamble_multiplier = floatval(get_option('maximum_gamble_multiplier')) / 100.0; $above_average = mt_rand(0, 10) < 5; if ($above_average) { // $winnings=round($average_gamble_multiplier*$amount+mt_rand(0,round($maximum_gamble_multiplier*$amount-$average_gamble_multiplier*$amount))); Even distribution is NOT wise $peak = $maximum_gamble_multiplier * $amount; $under = 0.0; $number = intval(round($average_gamble_multiplier * $amount + mt_rand(0, intval(round($maximum_gamble_multiplier * $amount - $average_gamble_multiplier * $amount))))); for ($x = 1; $x < intval($peak); $x++) { $p = $peak * (1.0 / pow(floatval($x) + 0.4, 2.0) - 1.0 / pow($maximum_gamble_multiplier * floatval($amount), 2.0)); // Using a 1/x^2 curve. 0.4 is a bit of a magic number to get the averaging right $under += $p; if ($under > floatval($number)) { break; } } $winnings = intval(round($average_gamble_multiplier * $amount + $x * 1.1)); // 1.1 is a magic number to make it seem a bit fairer } else { $winnings = mt_rand(0, intval(round($average_gamble_multiplier * $amount))); } // Actuate require_code('points2'); charge_member(get_member(), $amount - $winnings, do_lang('GAMBLING')); $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'GAMBLING', 'details' => strval($amount), 'details2' => '')); // Show message if ($winnings > $amount) { $result = do_lang_tempcode('GAMBLE_CONGRATULATIONS', integer_format($winnings - $amount), integer_format($amount)); } else { $result = do_lang_tempcode('GAMBLE_COMMISERATIONS', integer_format($amount - $winnings), integer_format($amount)); } $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, $result); }
/** * Farm out the files for downloads. */ function dload_script() { // Closed site $site_closed = get_option('site_closed'); if ($site_closed == '1' && !has_specific_permission(get_member(), 'access_closed_site') && !$GLOBALS['IS_ACTUALLY_ADMIN']) { header('Content-Type: text/plain'); @exit(get_option('closed')); } global $SITE_INFO; if (!is_guest() || !isset($SITE_INFO['any_guest_cached_too']) || $SITE_INFO['any_guest_cached_too'] == '0') { if (get_param('for_session', '-1') != md5(strval(get_session_id())) && get_option('anti_leech') == '1' && ocp_srv('HTTP_REFERER') != '') { warn_exit(do_lang_tempcode('LEECH_BLOCK')); } } require_lang('downloads'); $id = get_param_integer('id', 0); // Lookup $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; // Permission if (!has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) { access_denied('CATEGORY_ACCESS'); } // Cost? $got_before = $GLOBALS['SITE_DB']->query_value_null_ok('download_logging', 'the_user', array('the_user' => get_member(), 'id' => $id)); if (addon_installed('points')) { if ($myrow['download_cost'] > 0) { require_code('points2'); $member = get_member(); if (is_guest($member)) { access_denied('NOT_AS_GUEST'); } // Check they haven't downloaded this before (they only get charged once - maybe they are resuming) if (is_null($got_before)) { $cost = $myrow['download_cost']; $member = get_member(); if (is_guest($member)) { access_denied('NOT_AS_GUEST'); } $dif = $cost - available_points($member); if ($dif > 0 && !has_specific_permission(get_member(), 'have_negative_gift_points')) { warn_exit(do_lang_tempcode('LACKING_POINTS', integer_format($dif))); } require_code('points2'); charge_member($member, $cost, do_lang('DOWNLOADED_THIS', get_translated_text($myrow['name']))); if ($myrow['download_submitter_gets_points'] == 1) { system_gift_transfer(do_lang('THEY_DOWNLOADED_THIS', get_translated_text($myrow['name'])), $cost, $myrow['submitter']); } } } } // Filename $full = $myrow['url']; $breakdown = @pathinfo($full) or warn_exit(do_lang_tempcode('HTTP_DOWNLOAD_NO_SERVER', $full)); // $filename=$breakdown['basename']; if (!array_key_exists('extension', $breakdown)) { $extension = ''; } else { $extension = strtolower($breakdown['extension']); } if (url_is_local($full)) { $_full = get_custom_file_base() . '/' . rawurldecode($full); } else { $_full = rawurldecode($full); } // Is it non-local? If so, redirect if (!url_is_local($full) || !file_exists(get_file_base() . '/' . rawurldecode(filter_naughty($full)))) { if (url_is_local($full)) { $full = get_custom_base_url() . '/' . $full; } if (strpos($full, chr(10)) !== false || strpos($full, chr(13)) !== false) { log_hack_attack_and_exit('HEADER_SPLIT_HACK'); } header('Location: ' . $full); log_download($id, 0, !is_null($got_before)); // Bandwidth used is 0 for an external download return; } // Some basic security: don't fopen php files if ($extension == 'php') { log_hack_attack_and_exit('PHP_DOWNLOAD_INNOCENT', integer_format($id)); } // Size, bandwidth, logging $size = filesize($_full); if (is_null($got_before)) { $bandwidth = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(file_size) AS answer FROM ' . get_table_prefix() . 'download_logging l LEFT JOIN ' . get_table_prefix() . 'download_downloads d ON l.id=d.id WHERE date_and_time>' . strval(time() - 24 * 60 * 60 * 32)); if ($bandwidth + floatval($size) > floatval(get_option('maximum_download')) * 1024 * 1024 * 1024 && !has_specific_permission(get_member(), 'bypass_bandwidth_restriction')) { warn_exit(do_lang_tempcode('TOO_MUCH_DOWNLOAD')); } require_code('files2'); check_shared_bandwidth_usage($size); } log_download($id, $size, !is_null($got_before)); // Send header if (strpos($myrow['original_filename'], chr(10)) !== false || strpos($myrow['original_filename'], chr(13)) !== false) { log_hack_attack_and_exit('HEADER_SPLIT_HACK'); } header('Content-Type: application/octet-stream' . '; authoritative=true;'); if (get_option('immediate_downloads') == '1') { require_code('mime_types'); header('Content-Type: ' . get_mime_type(get_file_extension($myrow['original_filename'])) . '; authoritative=true;'); header('Content-Disposition: filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($myrow['original_filename']))) . '"'); } else { if (strstr(ocp_srv('HTTP_USER_AGENT'), 'MSIE') !== false) { header('Content-Disposition: filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($myrow['original_filename']))) . '"'); } else { header('Content-Disposition: attachment; filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($myrow['original_filename']))) . '"'); } } header('Accept-Ranges: bytes'); // Caching header("Pragma: private"); header("Cache-Control: private"); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 24 * 365) . ' GMT'); $time = is_null($myrow['edit_date']) ? $myrow['add_date'] : $myrow['edit_date']; $time = max($time, filemtime($_full)); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $time) . ' GMT'); // Default to no resume $from = 0; $new_length = $size; @ini_set('zlib.output_compression', 'Off'); // They're trying to resume (so update our range) $httprange = ocp_srv('HTTP_RANGE'); if (strlen($httprange) > 0) { $_range = explode('=', ocp_srv('HTTP_RANGE')); if (count($_range) == 2) { if (strpos($_range[0], '-') === false) { $_range = array_reverse($_range); } $range = $_range[0]; if (substr($range, 0, 1) == '-') { $range = strval($size - intval(substr($range, 1)) - 1) . $range; } if (substr($range, -1, 1) == '-') { $range .= strval($size - 1); } $bits = explode('-', $range); if (count($bits) == 2) { list($from, $to) = array_map('intval', $bits); if ($to - $from != 0 || $from == 0) { $new_length = $to - $from + 1; header('HTTP/1.1 206 Partial Content'); header('Content-Range: bytes ' . $range . '/' . strval($size)); } else { $from = 0; } } } } header('Content-Length: ' . strval($new_length)); if (function_exists('set_time_limit')) { @set_time_limit(0); } error_reporting(0); // Send actual data $myfile = fopen($_full, 'rb'); fseek($myfile, $from); $i = 0; flush(); // Works around weird PHP bug that sends data before headers, on some PHP versions while ($i < $new_length) { $content = fread($myfile, min($new_length - $i, 1048576)); echo $content; $len = strlen($content); if ($len == 0) { break; } $i += $len; } fclose($myfile); /* Security note... at the download adding/editing stage, we ensured that only files accessible to the web server (in raw form) could end up in our database. Therefore we did not check here that our file was accessible in raw form. */ }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { //if (!addon_installed('octhief')) return; require_code('ocf_topics_action2'); require_code('points'); require_lang('octhief'); // ensure it is done once per week $time = time(); $last_time = intval(get_value('last_thieving_time')); if ($last_time > time() - 24 * 60 * 60 * 7) { return; } set_value('last_thieving_time', strval($time)); $octhief_type = get_option('octhief_type', true); $octhief_type = isset($octhief_type) && strlen($octhief_type) > 0 ? $octhief_type : 'Members that are inactive, but has lots points'; $_octhief_number = get_option('octhief_number', true); $octhief_number = isset($_octhief_number) && is_numeric($_octhief_number) ? intval($_octhief_number) : 1; $_octhief_points = get_option('octhief_points', true); $octhief_points = isset($_octhief_points) && is_numeric($_octhief_points) ? intval($_octhief_points) : 10; $octhief_group = get_option('octhief_group', true); $octhief_group = isset($octhief_group) && strlen($octhief_group) > 0 ? $octhief_group : 'Member'; // start determining the various cases if ($octhief_type == "Members that are inactive, but has lots points") { $all_members = $GLOBALS['FORUM_DRIVER']->get_top_posters(1000); $points = array(); foreach ($all_members as $member) { $id = $GLOBALS['FORUM_DRIVER']->pname_id($member); $signin_time = $member['m_last_visit_time']; $points[$signin_time] = array('points' => available_points($id), 'id' => $id); } ksort($points); //print_r($points); $octhief_number = count($points) > $octhief_number ? $octhief_number : count($points); $theft_count = 0; foreach ($points as $member) { $theft_count++; if ($theft_count > $octhief_number) { break; } // start stealing require_code('points2'); require_lang('octhief'); $total_points = $member['points']; $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points; $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($member['id']) . ' ORDER BY RAND( ) ', 1, NULL, true); $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0; // get THIEF points charge_member($member['id'], $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.'); if ($give_to_member > 0) { system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member); require_code('ocf_topic_action'); require_code('ocf_posts_action'); $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points), $GLOBALS['FORUM_DRIVER']->get_username($member['id']), $GLOBALS['FORUM_DRIVER']->get_username($give_to_member)); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $member['id'], $give_to_member, false, 0, NULL, ''); $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $GLOBALS['FORUM_DRIVER']->pname_id($member)); send_pt_notification($post_id, $subject, $topic_id, $GLOBALS['FORUM_DRIVER']->pname_id($member), $give_to_member); } } } elseif ($octhief_type == "Members that are rich") { $all_members = $GLOBALS['FORUM_DRIVER']->get_top_posters(100); $points = array(); foreach ($all_members as $member) { $id = $GLOBALS['FORUM_DRIVER']->pname_id($member); $points[$id] = available_points($id); } arsort($points); $octhief_number = count($points) > $octhief_number ? $octhief_number : count($points); $theft_count = 0; foreach ($points as $member_id => $av_points) { $theft_count++; if ($theft_count > $octhief_number) { break; } // start stealing require_code('points2'); require_lang('octhief'); $total_points = $av_points; $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points; $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($member_id) . ' ORDER BY RAND( ) ', 1, NULL, true); $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0; // get THIEF points charge_member($member_id, $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.'); if ($give_to_member > 0) { system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member); require_code('ocf_topic_action'); require_code('ocf_posts_action'); $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points)); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $member_id, $give_to_member, false, 0, NULL, ''); $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $member); send_pt_notification($post_id, $subject, $topic_id, $member, $give_to_member); } } } elseif ($octhief_type == "Members that are random") { $random_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( ) ', $octhief_number, NULL, true); $octhief_number = count($random_members) > $octhief_number ? $octhief_number : count($random_members); foreach ($random_members as $member) { // start stealing require_code('points2'); require_lang('octhief'); $total_points = available_points($member['id']); $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points; $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($member['id']) . ' ORDER BY RAND( ) ', 1, NULL, true); $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0; // get THIEF points charge_member($member['id'], $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.'); if ($give_to_member != 0) { system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member); require_code('ocf_topic_action'); require_code('ocf_posts_action'); $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points)); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $member['id'], $give_to_member, false, 0, NULL, ''); $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $member); send_pt_notification($post_id, $subject, $topic_id, $member, $give_to_member); } } } elseif ($octhief_type == "Members that are in a certain usergroup") { $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); $group_id = 0; foreach ($groups as $id => $group) { if ($octhief_group == $group) { $group_id = $id; } } require_code('ocf_groups2'); $members = ocf_get_group_members_raw($group_id); $octhief_number = count($members) > $octhief_number ? $octhief_number : count($members); $members_to_steal_ids = array_rand($members, $octhief_number); if ($octhief_number == 1) { $members_to_steal_ids = array('0' => $members_to_steal_ids); } foreach ($members_to_steal_ids as $member_rand_key) { // start stealing require_code('points2'); require_lang('octhief'); //echo $members[$member_rand_key]; $total_points = available_points($members[$member_rand_key]); $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points; $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($members[$member_rand_key]) . ' ORDER BY RAND( ) ', 1, NULL, true); $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0; // get THIEF points charge_member($members[$member_rand_key], $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.'); if ($give_to_member != 0) { system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member); require_code('ocf_topics_action'); $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points)); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $members[$member_rand_key], $give_to_member, false, 0, NULL, ''); require_code('ocf_posts_action'); $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, 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, $give_to_member, $octhief_number); send_pt_notification($post_id, $subject, $topic_id, $octhief_number, $give_to_member); } } } }
/** * Standard stage of pointstore item purchase. * * @return tempcode The UI */ function ___text() { if (get_option('is_on_flagrant_buy') == '0') { return new ocp_tempcode(); } $title = get_page_title('TITLE_NEWTEXT'); // Define variables $member_id = get_member(); $message = post_param('message'); $days = post_param_integer('days'); $points_left = available_points($member_id); // First we need to know the price of the number of days we ordered. After that, compare that price with our users current number of points. $dayprice = intval(get_option('text')); $total = $dayprice * $days; if ($points_left < $total && !has_specific_permission(get_member(), 'give_points_self')) { return warn_screen($title, do_lang_tempcode('FLAGRANT_LACK_POINTS', integer_format($days), integer_format($total), integer_format($points_left))); } // Add this to the database $GLOBALS['SITE_DB']->query_insert('text', array('notes' => '', 'activation_time' => NULL, 'active_now' => 0, 'user_id' => $member_id, 'the_message' => insert_lang_comcode($message, 2), 'days' => $days, 'order_time' => time())); // Mail off the notice require_code('notifications'); $_url = build_url(array('page' => 'admin_flagrant'), 'adminzone', NULL, false, false, true); $manage_url = $_url->evaluate(); dispatch_notification('pointstore_request_flagrant', NULL, do_lang('TITLE_NEWTEXT', NULL, NULL, NULL, get_site_default_lang()), do_lang('MAIL_FLAGRANT_TEXT', $message, comcode_escape($manage_url), NULL, get_site_default_lang())); // Now, deduct the points from our user's account require_code('points2'); charge_member($member_id, $total, do_lang('PURCHASED_FLAGRANT')); $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('ORDER_FLAGRANT_DONE')); }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); //if (get_option('is_on_'.$class.'_buy')=='0') return new ocp_tempcode(); $amount = post_param_integer('amount', 0); $bank_dividend = intval(get_option('bank_divident')); $title = get_page_title('BANKING'); // Check points $points_left = available_points(get_member()); if (!has_specific_permission(get_member(), 'give_points_self')) { if ($points_left < $amount) { return warn_screen($title, do_lang_tempcode('_CANT_AFFORD_BANK')); } } // Actuate require_code('points2'); charge_member(get_member(), $amount, do_lang('BANKING')); $GLOBALS['SITE_DB']->query_insert('bank', array('add_time' => time(), 'user_id' => get_member(), 'amount' => strval($amount), 'divident' => $bank_dividend)); // Show message $result = do_lang_tempcode('BANKING_CONGRATULATIONS', integer_format($amount), integer_format($bank_dividend)); $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, $result); }