case 'M_6': $period = construct_phrase($vbphrase['x_months'], 6); break; case 'Y_1': $period = construct_phrase($vbphrase['x_years'], 1); break; case 'Y_2': $period = construct_phrase($vbphrase['x_years'], 2); break; case 'PERMA': $period = $vbphrase['forever']; break; default: $period = ''; } $ban['liftdate'] = convert_date_to_timestamp($ban['period']); eval('$banbits .= "' . fetch_template('userinfraction_banbit') . '";'); $banlist[] = $ban; } if (!($vbulletin->usergroupcache["{$userinfo['usergroupid']}"]['genericoptions'] & $vbulletin->bf_ugp_genericoptions['isnotbannedgroup'])) { $bancheck = $db->query_first("SELECT userid, liftdate FROM " . TABLE_PREFIX . "userban WHERE userid = {$userinfo['userid']}"); if ($bancheck and !$bancheck['liftdate']) { $nocontact = true; } } $show['pm'] = ($vbulletin->options['enablepms'] and $vbulletin->userinfo['permissions']['pmquota'] and !$nocontact); $show['trackpm'] = $cantrackpm = $vbulletin->userinfo['permissions']['pmpermissions'] & $vbulletin->bf_ugp_pmpermissions['cantrackpm']; $showemail = (($userinfo['adminemail'] or $userinfo['showemail']) and $vbulletin->options['enableemail'] and $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canemailmember'] and !$nocontact); } // ######################### REVERSE INFRACTION ########################## if ($_POST['do'] == 'reverse') {
'M_2' => "2 $vbphrase[months]", 'M_3' => "3 $vbphrase[months]", 'M_4' => "4 $vbphrase[months]", 'M_5' => "5 $vbphrase[months]", 'M_6' => "6 $vbphrase[months]", 'Y_1' => "1 $vbphrase[year]", 'Y_2' => "2 $vbphrase[years]", ), $permanent_phrase => array( 'PERMANENT' => "$vbphrase[permanent] - $vbphrase[never_lift_ban]" ) ); foreach ($periodoptions["$temporary_phrase"] AS $thisperiod => $text) { if ($liftdate = convert_date_to_timestamp($thisperiod)) { $periodoptions["$temporary_phrase"]["$thisperiod"] .= ' (' . vbdate($vbulletin->options['dateformat'] . ' ' . $vbulletin->options['timeformat'], $liftdate) . ')'; } } print_form_header('banning', 'dobanuser'); print_table_header($vbphrase['ban_user']); print_input_row($vbphrase['username'], 'username', $vbulletin->GPC['username'], 0); print_select_row($vbphrase['move_user_to_usergroup'], 'usergroupid', $usergroups, $selectedid); print_select_row($vbphrase['lift_ban_after'], 'period', $periodoptions, $vbulletin->GPC['period']); print_input_row($vbphrase['user_ban_reason'], 'reason', '', true, 50, 250); print_submit_row($vbphrase['ban_user']); } if ($_POST['do'] == 'updatereason')
/** * Ban users * * @param array $userids Userids to ban * @param int $banusergroupid Which banned usergroup to move the users to * @param string $period Ban period * @param string $reason Ban reason */ public function banUsers($userids, $banusergroupid, $period, $reason = '') { $loginuser =& vB::getCurrentSession()->fetch_userinfo(); $usercontext =& vB::getUserContext($loginuser['userid']); if (!$usercontext->hasAdminPermission('cancontrolpanel') and !$usercontext->hasPermission('moderatorpermissions', 'canbanusers')) { $forumHome = vB_Library::instance('content_channel')->getForumHomeChannel(); throw new vB_Exception_Api('nopermission_loggedin', array($loginuser['username'], vB_Template_Runtime::fetchStyleVar('right'), vB::getCurrentSession()->get('sessionurl'), $loginuser['securitytoken'], vB5_Route::buildUrl($forumHome['routeid'] . '|fullurl'))); } foreach ($userids as &$userid) { $userid = intval($userid); } $bannedusergroups = vB_Api::instanceInternal('usergroup')->fetchBannedUsergroups(); if (!in_array($banusergroupid, array_keys($bannedusergroups))) { throw new vB_Exception_Api('invalid_usergroup_specified'); } // check that the number of days is valid if ($period != 'PERMANENT' and !preg_match('#^(D|M|Y)_[1-9][0-9]?$#', $period)) { throw new vB_Exception_Api('invalid_ban_period_specified'); } if ($period == 'PERMANENT') { // make this ban permanent $liftdate = 0; } else { // get the unixtime for when this ban will be lifted require_once DIR . '/includes/functions_banning.php'; $liftdate = convert_date_to_timestamp($period); } $user_dms = array(); $current_bans = vB::getDbAssertor()->getRows('user_fetchcurrentbans', array('userids' => $userids)); foreach ($current_bans as $current_ban) { $userinfo = vB_User::fetchUserinfo($current_ban['userid']); $userid = $userinfo['userid']; if ($current_ban['bandate']) { // they already have a ban, check if the current one is being made permanent, continue if its not if ($liftdate and $liftdate < $current_ban['liftdate']) { continue; } // there is already a record - just update this record vB::getDbAssertor()->update('userban', array('bandate' => vB::getRequest()->getTimeNow(), 'liftdate' => $liftdate, 'adminid' => $loginuser['userid'], 'reason' => $reason), array('userid' => $userinfo['userid'])); } else { // insert a record into the userban table /*insert query*/ vB::getDbAssertor()->insert('userban', array('userid' => $userinfo['userid'], 'usergroupid' => $userinfo['usergroupid'], 'displaygroupid' => $userinfo['displaygroupid'], 'customtitle' => $userinfo['customtitle'], 'usertitle' => $userinfo['usertitle'], 'adminid' => $loginuser['userid'], 'bandate' => vB::getRequest()->getTimeNow(), 'liftdate' => $liftdate, 'reason' => $reason)); } // update the user record $user_dms[$userid] = new vB_Datamanager_User(vB_DataManager_Constants::ERRTYPE_SILENT); $user_dms[$userid]->set_existing($userinfo); $user_dms[$userid]->set('usergroupid', $banusergroupid); $user_dms[$userid]->set('displaygroupid', 0); // update the user's title if they've specified a special user title for the banned group if ($bannedusergroups[$banusergroupid]['usertitle'] != '') { $user_dms[$userid]->set('usertitle', $bannedusergroups[$banusergroupid]['usertitle']); $user_dms[$userid]->set('customtitle', 0); } $user_dms[$userid]->pre_save(); } foreach ($user_dms as $userdm) { $userdm->save(); } // and clear perms foreach ($userids as $uid) { vB::getUserContext($uid)->clearChannelPermissions(); } return true; }
switch ($vbulletin->GPC['useraction']) { case 'ban': $vbulletin->input->clean_array_gpc('p', array('usergroupid' => TYPE_UINT, 'period' => TYPE_STR, 'reason' => TYPE_STR)); if (!isset($vbulletin->usergroupcache["{$vbulletin->GPC['usergroupid']}"]) or $vbulletin->usergroupcache["{$vbulletin->GPC['usergroupid']}"]['genericoptions'] & $vbulletin->bf_ugp_genericoptions['isnotbannedgroup']) { eval(standard_error(fetch_error('invalid_usergroup_specified'))); } // check that the number of days is valid if ($vbulletin->GPC['period'] != 'PERMANENT' and !preg_match('#^(D|M|Y)_[1-9][0-9]?$#', $vbulletin->GPC['period'])) { eval(standard_error(fetch_error('invalid_ban_period_specified'))); } if ($vbulletin->GPC['period'] == 'PERMANENT') { // make this ban permanent $liftdate = 0; } else { // get the unixtime for when this ban will be lifted $liftdate = convert_date_to_timestamp($vbulletin->GPC['period']); } $user_dms = array(); $current_bans = $db->query_read("\n\t\t\t\t\tSELECT user.userid, userban.liftdate, userban.bandate\n\t\t\t\t\tFROM " . TABLE_PREFIX . "user AS user\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "userban AS userban ON(userban.userid = user.userid)\n\t\t\t\t\tWHERE user.userid IN (" . implode(',', array_keys($user_cache)) . ")\n\t\t\t\t"); while ($current_ban = $db->fetch_array($current_bans)) { $userinfo = $user_cache["{$current_ban['userid']}"]; $userid = $userinfo['userid']; if ($current_ban['bandate']) { // they already have a ban, check if the current one is being made permanent, continue if its not if ($liftdate and $liftdate < $current_ban['liftdate']) { continue; } // there is already a record - just update this record $db->query_write("\n\t\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "userban SET\n\t\t\t\t\t\t\tbandate = " . TIMENOW . ",\n\t\t\t\t\t\t\tliftdate = {$liftdate},\n\t\t\t\t\t\t\tadminid = " . $vbulletin->userinfo['userid'] . ",\n\t\t\t\t\t\t\treason = '" . $db->escape_string($vbulletin->GPC['reason']) . "'\n\t\t\t\t\t\t\tWHERE userid = {$userinfo['userid']}\n\t\t\t\t\t\t"); } else { // insert a record into the userban table
function do_ban_user() { global $vbulletin, $db, $vbphrase; require_once DIR . '/includes/functions_banning.php'; require_once DIR . '/includes/adminfunctions.php'; $canbanuser = ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] or can_moderate(0, 'canbanusers')) ? true : false; $canunbanuser = ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] or can_moderate(0, 'canunbanusers')) ? true : false; // check banning permissions if (!$canbanuser and !$canunbanuser) { standard_error(fetch_error('no_permission_ban_users')); } $vbulletin->input->clean_array_gpc('p', array('usergroupid' => TYPE_INT, 'period' => TYPE_STR, 'reason' => TYPE_NOHTML, 'userid' => TYPE_INT)); $vbulletin->GPC['reason'] = prepare_remote_utf8_string($vbulletin->GPC['reason']); if (!$canbanuser) { standard_error(fetch_error('no_permission_ban_users')); } /*$liftdate = convert_date_to_timestamp($vbulletin->GPC['period']); echo " <p>Period: {$vbulletin->GPC['period']}</p> <p>Banning <b>{$vbulletin->GPC['username']}</b> into usergroup <i>" . $vbulletin->usergroupcache["{$vbulletin->GPC['usergroupid']}"]['title'] . "</i></p> <table> <tr><td>Time now:</td><td>" . vbdate('g:ia l jS F Y', TIMENOW, false, false) . "</td></tr> <tr><td>Lift date:</td><td>" . vbdate('g:ia l jS F Y', $liftdate, false, false) . "</td></tr> </table>"; exit;*/ // check that the target usergroup is valid if (!isset($vbulletin->usergroupcache["{$vbulletin->GPC['usergroupid']}"]) or $vbulletin->usergroupcache["{$vbulletin->GPC['usergroupid']}"]['genericoptions'] & $vbulletin->bf_ugp_genericoptions['isnotbannedgroup']) { standard_error(fetch_error('invalid_usergroup_specified')); } // check that the user exists $user = $db->query_first("\n\t\tSELECT user.*,\n\t\t\tIF(moderator.moderatorid IS NULL, 0, 1) AS ismoderator\n\t\tFROM " . TABLE_PREFIX . "user AS user\n\t\tLEFT JOIN " . TABLE_PREFIX . "moderator AS moderator ON(moderator.userid = user.userid AND moderator.forumid <> -1)\n\t\tWHERE user.userid = " . $vbulletin->GPC['userid'] . "\n\t"); if (!$user or $user['userid'] == $vbulletin->userinfo['userid']) { standard_error(fetch_error('invalid_user_specified')); } if (is_unalterable_user($user['userid'])) { standard_error(fetch_error('user_is_protected_from_alteration_by_undeletableusers_var')); } cache_permissions($user); // Non-admins can't ban administrators, supermods or moderators if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])) { if ($user['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] or $user['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator'] or $user['ismoderator']) { standard_error(fetch_error('no_permission_ban_non_registered_users')); } } else { if ($user['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) { standard_error(fetch_error('no_permission_ban_non_registered_users')); } } // check that the number of days is valid if ($vbulletin->GPC['period'] != 'PERMANENT' and !preg_match('#^(D|M|Y)_[1-9][0-9]?$#', $vbulletin->GPC['period'])) { standard_error(fetch_error('invalid_ban_period_specified')); } // if we've got this far all the incoming data is good if ($vbulletin->GPC['period'] == 'PERMANENT') { // make this ban permanent $liftdate = 0; } else { // get the unixtime for when this ban will be lifted $liftdate = convert_date_to_timestamp($vbulletin->GPC['period']); } // check to see if there is already a ban record for this user in the userban table if ($check = $db->query_first("SELECT userid, liftdate FROM " . TABLE_PREFIX . "userban WHERE userid = {$user['userid']}")) { if ($liftdate and $liftdate < $check['liftdate']) { if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) and !can_moderate(0, 'canunbanusers')) { standard_error(fetch_error('no_permission_un_ban_users')); } } // there is already a record - just update this record $db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "userban SET\n\t\t\tbandate = " . TIMENOW . ",\n\t\t\tliftdate = {$liftdate},\n\t\t\tadminid = " . $vbulletin->userinfo['userid'] . ",\n\t\t\treason = '" . $db->escape_string($vbulletin->GPC['reason']) . "'\n\t\t\tWHERE userid = {$user['userid']}\n\t\t"); } else { // insert a record into the userban table /*insert query*/ $db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "userban\n\t\t\t(userid, usergroupid, displaygroupid, customtitle, usertitle, adminid, bandate, liftdate, reason)\n\t\t\tVALUES\n\t\t\t({$user['userid']}, {$user['usergroupid']}, {$user['displaygroupid']}, {$user['customtitle']}, '" . $db->escape_string($user['usertitle']) . "', " . $vbulletin->userinfo['userid'] . ", " . TIMENOW . ", {$liftdate}, '" . $db->escape_string($vbulletin->GPC['reason']) . "')\n\t\t"); } // update the user record $userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT); $userdm->set_existing($user); $userdm->set('usergroupid', $vbulletin->GPC['usergroupid']); $userdm->set('displaygroupid', 0); // update the user's title if they've specified a special user title for the banned group if ($vbulletin->usergroupcache["{$vbulletin->GPC['usergroupid']}"]['usertitle'] != '') { $userdm->set('usertitle', $vbulletin->usergroupcache["{$vbulletin->GPC['usergroupid']}"]['usertitle']); $userdm->set('customtitle', 0); } $userdm->save(); unset($userdm); return array('success' => true); }
function check_price($checkin, $checkout, $allotment, $qty = 1) { //echo $checkin; //echo $checkout; $checkin_date = date_parse_from_format('d/m/Y', $checkin); $checkin = mktime(0, 0, 0, $checkin_date['month'], $checkin_date['day'], $checkin_date['year']); $checkout_date = date_parse_from_format('d/m/Y', $checkout); $checkout = mktime(0, 0, 0, $checkout_date['month'], $checkout_date['day'], $checkout_date['year']); $numDays = abs($checkin - $checkout) / 60 / 60 / 24; //echo $numDays; //default price per notte $numDays = $numDays < 1 ? 1 : $numDays; $price = 0; for ($i = 0; $i < $numDays; $i++) { $jobdate = date('d/m/Y', strtotime("+{$i} day", $checkin)); //echo $jobdate.' - '; $entries = get_post_meta($allotment, $prefix . 'prices', true); if ($entries) { foreach ((array) $entries as $key => $entry) { if (convert_date_to_timestamp($jobdate) >= $entry['start_date'] && convert_date_to_timestamp($jobdate) <= $entry['end_date']) { //echo $entry['price'].' - '.$entry['period_name'].'<br />'; $price += $entry['price']; } } } } return $price * $qty; }
function home_booking() { if (!$_POST) { if (!defined("PHP_EOL")) { define("PHP_EOL", "\r\n"); } } $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $checkin = $_POST['checkin']; $checkout = $_POST['checkout']; $room_id = $_POST['room_id']; $room = $_POST['room']; $adults = $_POST['adults']; $children = $_POST['children']; $room_number = $_POST['room_number']; $message = $_POST['message']; $lang = $_POST['current_lang']; //if availability if (!is_available($room_id, $checkin, $checkout)) { echo '<div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>La camera richiesta risulta occupata nelle date richieste!</div>'; exit; } if (trim($email) == '') { echo '<div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>Attention! Please enter a valid email address.</div>'; exit; } else { if (trim($room) == '') { echo '<div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>Attention! Please enter what kind of room.</div>'; exit; } else { if (trim($checkin) == '') { echo '<div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>Attention! Please enter your check-in date.</div>'; exit; } else { if (trim($checkout) == '') { echo '<div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>Attention! Please enter your check-out date.</div>'; exit; } else { if (!isEmail($email)) { echo '<div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>Attention! You have enter an invalid e-mail address, try again.</div>'; exit; } } } } } if (get_magic_quotes_gpc()) { $comments = stripslashes($comments); } //titolo stanza composto da nome hotel + stanza x evitare duplicati... $main_name = 'booking '; $camera = get_the_title($room); // ADD THE FORM INPUT TO $new_post ARRAY $new_booking = array('post_title' => $main_name . ' - ' . $camera, 'post_type' => 'bookings', 'post_status' => 'waiting'); //SAVE THE POST $bid = wp_insert_post($new_booking); $price = check_price($checkin, $checkout, $room, $room_number); $token = uniqid(); $request_page = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; $manager_url = get_bloginfo('siteurl') . '/reservations-system/?token=' . $token; update_post_meta($bid, 'name', $name); update_post_meta($bid, 'email', $email); update_post_meta($bid, 'phone', $phone); update_post_meta($bid, 'room', $room); update_post_meta($bid, 'room_id', $room_id); update_post_meta($bid, 'token', $token); update_post_meta($bid, 'manager_url', $manager_url); update_post_meta($bid, 'checkin', convert_date_to_timestamp($checkin)); update_post_meta($bid, 'checkout', convert_date_to_timestamp($checkout)); update_post_meta($bid, 'adults', $adults); update_post_meta($bid, 'children', $children); update_post_meta($bid, 'room_number', $room_number); update_post_meta($bid, 'message', $message); update_post_meta($bid, 'lang', $lang); if ($price) { update_post_meta($bid, 'price', $price); } $room_type = get_the_title($room); //$address = "*****@*****.**"; $address = mytheme_get_option('email'); $from = mytheme_get_option('place_name') . ' <' . $address . '>'; $email_bcc = get_bloginfo('admin_email'); // Configuration option. $e_subject = 'Booking n # ' . $bid . ' da ' . $email; $e_body = "Richiesta di prenotazione da <b>: {$name} {$email} tel. {$phone}</b>\n\n\t\tRichiesta prenotazione per le seguenti date<br />\n\t\tCheckin: <b>: {$checkin} </b><br />\n\t\tCheck-out <b>: {$checkout} </b><br />\n\t\tmessaggio <b>: {$message} </b><br />\n\n\t\tLa richiesta è di n, <b>{$room_number}</b> <b>{$room_type}</b> per <b>{$adults} Adulti</b> e <b>{$children} bambini</b>.<br />\n\t\tIl prezzo proposto dal sistema in base alle tue impostazioni è di € <b>{$price}</b> .<br />\n\t\tRicevuta da: {$request_page}.<br />\n\t\tin lingua: {$lang}.<br />\n\t\t<hr />\n\t\t<a href='{$manager_url}'>Gestisci</a>" . PHP_EOL . PHP_EOL; $e_reply = "<br />You can contact the customer via email, {$email} or hit 'reply' in your email browser to make the reservation complete."; $msg = wordwrap($e_body . $e_reply, 70); $headers[] = "From: {$from}" . PHP_EOL; $headers[] = "Bcc: {$email_bcc}" . PHP_EOL; //if(mail($address, $e_subject, $msg, $headers)) { if (wp_mail($address, $e_subject, $e_body, $headers)) { //email to customer // Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578 remove_filter('wp_mail_content_type', 'set_html_content_type'); $price = check_price($checkin, $checkout, $room); // Email has sent successfully, echo a success page. //try to understand what kind of booking: instant on-request $booking_type = booking_get_option('booking_type'); if ($booking_type == 'instant') { $confirmation_url = get_bloginfo('siteurl') . '/confirm-reservation?token=' . $token; //stop mostra prezzo per ora.. echo '<div id="success_page" class="alert alert-warning"><h4><i class="fa fa-bolt"></i> ' . __('Secure instant booking', 'bookingwp') . '</h4></div>'; echo '<h5>' . __('Price for your reservation is €', 'bookingwp') . ' <b>' . $price . '</b></h5><br />'; echo __('You can confirm now your reservation by clicking this link and leave your credit card as warranty or paying the entire fee of your booking with Paypal and instantly book the room!', 'bookingwp') . '<br /><hr />'; echo '<a href="' . $confirmation_url . '" class="btn btn-success btn-block">Confirm reservation</a></p>'; } else { echo '<div id="success_page" class="alert alert-success"><p>' . __('Your reservation has been submitted to us and well contact you as quickly as possible to complete your booking. Thank you', 'bookingwp') . '</p></div>'; } exit; } else { echo 'ERROR!'; } }