Exemple #1
1
 /**
  * As a participant, invite another user to an event
  * params :
  *    idEvent : id of the event to invite someone to
  *    idGuest : id of the user to invite to the event
  */
 function invite($idEvent, $idGuest)
 {
     if ($this->session->userdata('logged_in')) {
         $event = $this->event->get_event($idEvent);
         if ($this->event->is_participation($idGuest, $idEvent) == 0) {
             //inviting the user
             if ($event->organizer == $this->session->userdata('logged_in')['id']) {
                 $this->event->send_invitation($idGuest, $idEvent);
                 $aResult['result'] = 'success';
                 send_notification("Invitation : " . $event->name, 'Tu as reçu une invitation à ' . $event->name . '<a class="list_contact" href="' . base_url('details_event/index/' . $idEvent) . '">Voir l\'évènement</a>', $this->session->userdata('logged_in')['id'], $idGuest, true);
                 //sending a proposition of invitation to the organizer
             } else {
                 if ($event->invitation_suggestion_allowed == 1 && $this->event->is_participation($this->session->userdata('logged_in')['id'], $idEvent) == 1) {
                     $this->load->model('user', '', TRUE);
                     $guest = $this->user->get_user($idGuest);
                     $aResult['result'] = 'success';
                     send_notification("Suggestion d'invitation : " . $guest->firstname . ' ' . $guest->surname, $this->session->userdata('logged_in')['firstname'] . ' ' . $this->session->userdata('logged_in')['surname'] . ' te propose d\'inviter ' . $guest->firstname . ' ' . $guest->surname . ' à ton évènement.</br><a href="' . base_url('details_event/invite/' . $idEvent . '/' . $idGuest) . '">Inviter ' . $guest->firstname . ' ' . $guest->surname . '</a><a class="list_contact" href="' . base_url('details_event/index/' . $idEvent) . '">Voir l\'évènement</a>', $this->session->userdata('logged_in')['id'], $event->organizer, true);
                 } else {
                     $aResult['error'] = 'pas autorisé';
                 }
             }
         } else {
             $aResult['error'] = 'pas autorisé';
         }
     } else {
         $aResult['error'] = 'pas connecté';
     }
     echo json_encode($aResult);
 }
Exemple #2
0
 function event_desk_author_user($desk_id)
 {
     // Автор действия не должен получать уведомления о каких-то изменениях;
     if (get_desk_author_user($desk_id) != $_SESSION['user_id'] && get_desk_author_user($desk_id) != '') {
         send_notification(get_desk_author_user($desk_id), 'В заявке №' . $desk_id . ' произошли новые события<br>Нажмите для перехода в список заявок.', 'service_desk', '', '1', $desk_id);
     }
 }
function send_message($message)
{
    if ($message != 'Device Armed' && $message != 'Device Disarmed' && $message != 'Device Unlocked' && $message != 'Device Locked') {
        $message .= ' just opened the door';
    }
    $devices = get_all_device();
    foreach ($devices as $row) {
        $reg_id = $row->gcm_regid;
        $registration_ids = array($reg_id);
        $msg = array('notif' => $message);
        $result = send_notification($registration_ids, $msg);
        echo $result;
    }
}
Exemple #4
0
 function decline($id = FALSE)
 {
     $this->load->helper('notification');
     $data["core_settings"] = Setting::first();
     if ($_POST) {
         $this->view_data['estimate'] = Invoice::find_by_id($_POST['invoice_id']);
         $this->view_data['estimate']->estimate_status = "Declined";
         $this->view_data['estimate']->save();
         send_notification($data["core_settings"]->email, $data["core_settings"]->estimate_prefix . $this->view_data['estimate']->reference . ' - ' . $this->lang->line('application_Declined'), $_POST['reason']);
         redirect('cestimates/view/' . $_POST['invoice_id']);
     } else {
         $this->view_data['estimate'] = Invoice::find($id);
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_Declined');
         $this->view_data['form_action'] = 'cestimates/decline';
         $this->content_view = 'estimates/client_views/_decline';
     }
 }
 function send_post()
 {
     $error = '';
     if ($this->post('title') == '') {
         $error = 'Please enter notification title';
     } elseif ($this->post('message') == '') {
         $error = 'Please enter notification message';
     } elseif ($this->post('registeration_ids') == '') {
         $error = 'Please enter atleast one registeration id';
     } elseif ($this->post('device_token') == '') {
         $error = 'Please enter notification device token';
     } elseif ($this->post('device_type') == '') {
         $error = 'Please send 0 for Android and 1 for IOS';
     }
     if ($error) {
         $this->response(array('status' => 0, 'message' => $error), 200);
     } else {
         $registeration_ids = json_decode($this->post('registeration_ids'));
         send_notification($this->post('device_type'), $registeration_ids, $this->post('title') . "\n" . $this->post('message'));
         $this->response(array('status' => 1, 'message' => 'Sent', 'result' => ''), 201);
     }
 }
			'topic_poster'			=> $row['topic_poster'],
			'topic_first_post_id'	=> $row['topic_first_post_id'],
			'topic_last_post_id'	=> $row['topic_last_post_id'],
			'post_approved'			=> 0,
		);
		$poll = false;
		
		submit_post('edit', $row['mod_hu_title'], $row['topic_first_poster_name'], POST_NORMAL, $poll, $data);
		
		send_notification(array($row['topic_poster']), 'mod_update_error', array(
			'MOD_HU_TITLE'		=> $row['mod_hu_title'],
			'MOD_EN_TITLE'		=> $row['mod_en_title'],
			'MOD_OLD_VERSION'	=> isset($row['mod_old_version']) ? $row['mod_old_version'] : $row['mod_version'],
			'MOD_NEW_VERSION'	=> isset($row['mod_old_version']) ? $row['mod_version'] : $user->lang['VERSION_UNKNOWN'],
			'MOD_DESC'			=> $row['mod_desc'],
			'MOD_AUTHOR'		=> $row['mod_author_name'],
			'ERRORS'			=> implode("\n", $e->getErrors()),
			'U_MOD_AUTHOR'		=> 'http://www.phpbb.com/community/memberlist.php?mode=viewprofile&amp;u=' . $row['mod_author_id'],
			'U_MOD_COM_DB'		=> 'http://www.phpbb.com/mods/db/index.php?i=misc&mode=display&contrib_id=' . $row['mod_db_id'],
			'U_LOC_PACK'		=> generate_board_url() . '/' . $config['mods_loc_store_path'] . $row['mod_filename'] . '.zip',
			'U_MOD_PACK'		=> generate_board_url() . '/' . $config['downloads_path'] . '/mods/' . $row['mod_filename'] . '.zip',
			'U_MOD'				=> generate_board_url() . '/' . $url_rewriter->rewrite("{$phpbb_root_path}mods.{$phpEx}", "mode=mod&id={$row['mod_id']}"),
		));
	}
	
	// Do cleanup
	$mod->cleanup();
	
	// MOD updated
	$sql = 'UPDATE ' . MODS_TABLE . ' SET mod_last_checked = ' . time() . ' WHERE mod_id = ' . $row['mod_id'];
	$db->sql_query($sql);
}

<?php 
// API access key from Google API's Console
//define( 'API_ACCESS_KEY', 'AIzaSyC7enqxiX-zG5RHH2z9m59nz-zCRGVqMLk' );
include 'functions.php';
$registrationIds = array("etTOytTrHFI:APA91bFbeVnRNAc5Om0phyqIMWcF7OeRFTXkYHfoY77phHn-bipKMRZrYtt_b0B978SGNTBZ_kDk9CX3Z0E1xHLyhgvVYQ4mSffQDXRjDQkTPHrPVK6V8nnQ4FAsHxEsM4XgzBLq30VB");
$message = "Sample message";
send_notification($registrationIds, $message);
return;
// prep the bundle
$msg = array('message' => 'This is a sample message');
$fields = array('registration_ids' => $registrationIds, 'data' => $msg);
$headers = array('Authorization: key=' . API_ACCESS_KEY, 'Content-Type: application/json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
echo $result;
Exemple #8
0
 function join_event($id_event, $private)
 {
     $id_user = $session_data = $this->session->userdata('logged_in')['id'];
     $aResult = array();
     if (!isset($aResult['error'])) {
         if ($this->event->can_participate($id_user, $id_event) == 1) {
             if ($private == 1) {
                 $result = $this->event->join_private_event($id_user, $id_event);
             } else {
                 $result = $this->event->join_public_event($id_user, $id_event);
             }
             //sending a notification to the organizer
             if ($this->event->is_participation($id_user, $id_event) == 1) {
                 $event = $this->event->get_event($id_event);
                 send_notification("Inscription d'un participant : " . $event->name, $this->session->userdata('logged_in')['firstname'] . ' ' . $this->session->userdata('logged_in')['surname'] . ' s\'est inscrit à ton événement!<a class="list_contact" href="' . base_url('details_event/index/' . $id_event) . '">Voir l\'évènement</a>', $id_user, $event->organizer, false);
             }
             $aResult['result'] = get_participation_link($id_user, $id_event, $private);
         } else {
             $aResult['error'] = 'Inscription non-autorisée';
         }
     }
     echo json_encode($aResult);
 }
Exemple #9
0
 /**
  * Handler for PayPal IPN queries
  * @author korotkov@ud
  * Full callback URL: http://domain/wp-admin/admin-ajax.php?action=wpi_gateway_server_callback&type=wpi_paypal
  */
 static function server_callback()
 {
     if (empty($_POST)) {
         die(__('Direct access not allowed', WPI));
     }
     $invoice = new WPI_Invoice();
     $invoice->load_invoice("id={$_POST['invoice']}");
     /** Verify callback request */
     if (self::_ipn_verified($invoice)) {
         switch ($_POST['txn_type']) {
             /** New PayPal Subscription */
             case 'subscr_signup':
                 /** PayPal Subscription created */
                 WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['invoice']), 'invoice', 'update', '', __('PayPal Subscription created', WPI));
                 wp_invoice_mark_as_pending($_POST['invoice']);
                 do_action('wpi_paypal_subscr_signup_ipn', $_POST);
                 break;
             case 'subscr_cancel':
                 /** PayPal Subscription cancelled */
                 WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['invoice']), 'invoice', 'update', '', __('PayPal Subscription cancelled', WPI));
                 do_action('wpi_paypal_subscr_cancel_ipn', $_POST);
                 break;
             case 'subscr_failed':
                 /** PayPal Subscription failed */
                 WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['invoice']), 'invoice', 'update', '', __('PayPal Subscription payment failed', WPI));
                 do_action('wpi_paypal_subscr_failed_ipn', $_POST);
                 break;
             case 'subscr_payment':
                 /** Payment of Subscription */
                 switch ($_POST['payment_status']) {
                     case 'Completed':
                         /** Add payment amount */
                         $event_note = sprintf(__('%1s paid for subscription %2s', WPI), WPI_Functions::currency_format(abs($_POST['mc_gross']), $_POST['invoice']), $_POST['subscr_id']);
                         $event_amount = (double) $_POST['mc_gross'];
                         $event_type = 'add_payment';
                         /** Log balance changes */
                         $invoice->add_entry("attribute=balance&note={$event_note}&amount={$event_amount}&type={$event_type}");
                         $invoice->save_invoice();
                         send_notification($invoice->data);
                         break;
                     default:
                         break;
                 }
                 do_action('wpi_paypal_subscr_payment_ipn', $_POST);
                 break;
             case 'subscr_eot':
                 /** PayPal Subscription end of term */
                 WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['invoice']), 'invoice', 'update', '', __('PayPal Subscription term is finished', WPI));
                 wp_invoice_mark_as_paid($_POST['invoice'], $check = false);
                 do_action('wpi_paypal_subscr_eot_ipn', $_POST);
                 break;
             case 'subscr_modify':
                 /** PayPal Subscription modified */
                 WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['invoice']), 'invoice', 'update', '', __('PayPal Subscription modified', WPI));
                 do_action('wpi_paypal_subscr_modify_ipn', $_POST);
                 break;
             case 'web_accept':
                 /** PayPal simple button */
                 switch ($_POST['payment_status']) {
                     case 'Pending':
                         /** Mark invoice as Pending */
                         wp_invoice_mark_as_pending($_POST['invoice']);
                         do_action('wpi_paypal_pending_ipn', $_POST);
                         break;
                     case 'Completed':
                         /** Add payment amount */
                         $event_note = sprintf(__('%s paid via PayPal', WPI), WPI_Functions::currency_format(abs($_POST['mc_gross']), $_POST['invoice']));
                         $event_amount = (double) $_POST['mc_gross'];
                         $event_type = 'add_payment';
                         /** Log balance changes */
                         $invoice->add_entry("attribute=balance&note={$event_note}&amount={$event_amount}&type={$event_type}");
                         /** Log payer email */
                         $payer_email = sprintf(__("PayPal Payer email: %s", WPI), $_POST['payer_email']);
                         $invoice->add_entry("attribute=invoice&note={$payer_email}&type=update");
                         $invoice->save_invoice();
                         /** ... and mark invoice as paid */
                         wp_invoice_mark_as_paid($_POST['invoice'], $check = true);
                         send_notification($invoice->data);
                         do_action('wpi_paypal_complete_ipn', $_POST);
                         break;
                     default:
                         break;
                 }
                 break;
             case 'cart':
                 /** PayPal Cart. Used for SPC */
                 switch ($_POST['payment_status']) {
                     case 'Pending':
                         /** Mark invoice as Pending */
                         wp_invoice_mark_as_pending($_POST['invoice']);
                         do_action('wpi_paypal_pending_ipn', $_POST);
                         break;
                     case 'Completed':
                         /** Add payment amount */
                         $event_note = sprintf(__('%s paid via PayPal', WPI), WPI_Functions::currency_format(abs($_POST['mc_gross']), $_POST['invoice']));
                         $event_amount = (double) $_POST['mc_gross'];
                         $event_type = 'add_payment';
                         /** Log balance changes */
                         $invoice->add_entry("attribute=balance&note={$event_note}&amount={$event_amount}&type={$event_type}");
                         /** Log payer email */
                         $payer_email = sprintf(__("PayPal Payer email: %s", WPI), $_POST['payer_email']);
                         $invoice->add_entry("attribute=invoice&note={$payer_email}&type=update");
                         $invoice->save_invoice();
                         /** ... and mark invoice as paid */
                         wp_invoice_mark_as_paid($_POST['invoice'], $check = true);
                         send_notification($invoice->data);
                         do_action('wpi_paypal_complete_ipn', $_POST);
                         break;
                     default:
                         break;
                 }
                 break;
             default:
                 break;
         }
         echo ' ';
     }
 }
Exemple #10
0
            $users_ids = $db_rs->all($sql);
            // Оправляем всем уведомления о том, что есть касса без оператора;
            foreach ($users_ids as $user) {
                // Перед отправкой надо проверить, быть может этому пользователю мы уже отправляли уведомление сегодня по этому поводу;
                $sql = "SELECT * FROM `notifications` WHERE `user_id` = '" . $user['id'] . "' AND date(`date`) = date(NOW()) AND `parent_id` = '19' AND `status` = '1' AND `type` = '2';";
                $exist_noti = $db_rs->all($sql);
                if (count($exist_noti) == 0) {
                    // Перед отправкой надо проверить, быть может этому пользователю мы уже отправляли уведомление сегодня по этому поводу;
                    send_notification($user['id'], 'Внимание! В вашем офисе есть кассы с не закрытым вовремя операционным днем!!!<br>Нажмите для перехода в раздел управления кассами.', 'cash_operator', '', 2);
                }
            }
            // Перед отправкой надо проверить, быть может этому пользователю мы уже отправляли уведомление сегодня по этому поводу;
            $sql = "SELECT * FROM `notifications` WHERE `user_id` = '" . $_SESSION['user_id'] . "' AND date(`date`) = date(NOW()) AND `parent_id` = '19' AND `status` = '1' AND `type` = '2';";
            $exist_noti = $db_rs->all($sql);
            if (count($exist_noti) == 0) {
                send_notification($_SESSION['user_id'], 'Внимание! В вашем офисе есть кассы с не закрытым вовремя операционным днем!!!<br>Нажмите для перехода в раздел управления кассами.', 'cash_operator', '', 2);
            }
        } else {
            //$already_exist_operator = 1;
        }
    }
} else {
    write_log('ЁБАНЫЙ В РОТ!', 'kassa_alert');
}
write_log('Строим меню');
if ($_SESSION['company'] == 'air') {
    $company_name = 'AIR Сервис';
} else {
    $company_name = 'Ремонтофф';
}
$office_info_html = '';
 public function sendPush($id)
 {
     $post = Post::find($id);
     if ($post) {
         $response_array = array('success' => true, 'description' => $post->meta_des, 'image' => $post->image);
         send_notification($post->title, $response_array);
         return Redirect::back()->with('flash_success', "push notification delivered");
     } else {
         return Redirect::back()->with('flash_error', "Push notification failed, Try again");
     }
 }
Exemple #12
0
 function index()
 {
     $core_settings = Setting::first();
     if ($core_settings->registration != 1) {
         redirect('login');
     }
     if ($_POST) {
         $this->load->library('parser');
         $this->load->helper('file');
         $this->load->helper('notification');
         $client = Client::find_by_email($_POST['email']);
         if ($client->inactive == 1) {
             $client = FALSE;
         }
         $check_company = Company::find_by_name($_POST['name']);
         if (!$client && !$check_company && $_POST['name'] != "" && $_POST['email'] != "" && $_POST['password'] != "" && $_POST['firstname'] != "" && $_POST['lastname'] != "" && $_POST['confirmcaptcha'] != "") {
             $client_attr = array();
             $company_attr['name'] = $_POST['name'];
             $company_attr['website'] = $_POST['website'];
             $company_attr['phone'] = $_POST['phone'];
             $company_attr['mobile'] = $_POST['mobile'];
             $company_attr['address'] = $_POST['address'];
             $company_attr['zipcode'] = $_POST['zipcode'];
             $company_attr['city'] = $_POST['city'];
             $company_attr['country'] = $_POST['country'];
             $company_attr['province'] = $_POST['province'];
             $company_attr['vat'] = $_POST['vat'];
             $company_attr['reference'] = $core_settings->company_reference;
             $core_settings->company_reference = $core_settings->company_reference + 1;
             $core_settings->save();
             $company = Company::create($company_attr);
             if (!$company) {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_error'));
                 redirect('register');
             }
             $lastclient = Client::last();
             $client_attr = array();
             $client_attr['email'] = $_POST['email'];
             $client_attr['firstname'] = $_POST['firstname'];
             $client_attr['lastname'] = $_POST['lastname'];
             $client_attr['phone'] = $_POST['phone'];
             $client_attr['mobile'] = $_POST['mobile'];
             $client_attr['address'] = $_POST['address'];
             $client_attr['zipcode'] = $_POST['zipcode'];
             $client_attr['city'] = $_POST['city'];
             $modules = Module::find('all', array('order' => 'sort asc', 'conditions' => array('type = ?', 'client')));
             $client_attr['access'] = "";
             foreach ($modules as $value) {
                 if ($value->name == "Projects" || $value->name == "Messages" || $value->name == "Tickets" || $value->name == "Invoices") {
                     $client_attr['access'] .= $value->id . ",";
                 }
             }
             $client_attr['company_id'] = $company->id;
             $client = Client::create($client_attr);
             if ($client) {
                 $client->password = $client->set_password($_POST['password']);
                 $client->save();
                 $company->client_id = $client->id;
                 $company->save();
                 $this->email->from($core_settings->email, $core_settings->company);
                 $this->email->to($client_attr['email']);
                 $this->email->subject($this->lang->line('application_your_account_has_been_created'));
                 $parse_data = array('link' => base_url() . 'login/', 'company' => $core_settings->company, 'company_reference' => $company->reference, 'logo' => '<img src="' . base_url() . '' . $core_settings->logo . '" alt="' . $core_settings->company . '"/>', 'invoice_logo' => '<img src="' . base_url() . '' . $core_settings->invoice_logo . '" alt="' . $core_settings->company . '"/>');
                 $email = read_file('./application/views/' . $core_settings->template . '/templates/email_create_account.html');
                 $message = $this->parser->parse_string($email, $parse_data);
                 $this->email->message($message);
                 $this->email->send();
                 send_notification($core_settings->email, $this->lang->line('application_new_client_has_registered'), $this->lang->line('application_new_client_has_registered') . ': <br><strong>' . $company_attr['name'] . '</strong><br>' . $client_attr['firstname'] . ' ' . $client_attr['lastname'] . '<br>' . $client_attr['email']);
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_success'));
                 redirect('login');
             } else {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_error'));
                 redirect('login');
             }
         } else {
             $this->view_data['error'] = $this->lang->line('messages_email_already_taken');
             $this->theme_view = 'login';
             $this->content_view = 'auth/register';
             $this->view_data['form_action'] = 'register';
             $this->view_data['registerdata'] = $_POST;
         }
     } else {
         $this->view_data['error'] = 'false';
         $this->theme_view = 'login';
         $this->content_view = 'auth/register';
         $this->view_data['form_action'] = 'register';
     }
 }
 /**
  * Handle quick add submit
  */
 function quick_add()
 {
     if (array_var($_GET, 'current') == 'overview-panel') {
         ajx_current("reload");
     } else {
         ajx_current("empty");
     }
     //---------- REQUEST PARAMS --------------
     //		$_POST = Array (
     //			[member] => Array (
     //				[name] => pepe 333
     //				[dimension_id] => 1
     //				[parent_member_id] => 0
     //				[dimension_id] => 19
     //			)
     //			[contact] => Array (
     //				[email] => slkdjflksjdflksdf@kldsjflkdf.com
     //				[user] => Array (
     //					[create-user]=>on
     //					[type] => 25
     //					[first_name] =>
     // 					[surname] =>
     //		)
     //----------------------------------------
     // Init variables
     $max_users = config_option('max_users');
     if ($max_users && Contacts::count() >= $max_users) {
         flash_error(lang('maximum number of users reached error'));
         ajx_current("empty");
         return;
     }
     if (!can_manage_security(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $email = trim(array_var(array_var($_POST, 'contact'), 'email'));
     $member = array_var($_POST, 'member');
     $name = array_var($member, 'name');
     $nameArray = explode(" ", $name);
     $firstName = $nameArray[0];
     unset($nameArray[0]);
     $surname = implode(" ", $nameArray);
     $parentMemberId = array_var($member, 'parent_member_id');
     $objectType = ObjectTypes::findById(array_var($member, 'object_type_id'))->getName();
     // 'person', 'company'
     $dimensionId = array_var($member, 'dimension_id');
     $company = array_var(array_var(array_var($_POST, 'contact'), 'user'), 'company_id');
     // Create new instance of Contact and set the basic fields
     $contact = new Contact();
     $contact->setObjectName($name);
     if ($firstName) {
         $contact->setFirstName($firstName);
     } else {
         $contact->setFirstName($name);
     }
     if ($surname) {
         $contact->setSurname($surname);
     }
     $contact->setCompanyId($company);
     $contact->setIsCompany($objectType == "company");
     if ($parentMemberId) {
         if ($companyId = Members::findById($parentMemberId)->getObjectId()) {
             $contact->setCompanyId($companyId);
         }
     }
     // Save Contact
     try {
         DB::beginWork();
         $contact->save();
         if ($email && is_valid_email($email)) {
             if (!Contacts::validateUniqueEmail($email, null, $objectType)) {
                 DB::rollback();
                 flash_error(lang("email address must be unique"));
                 return false;
             } else {
                 if (!array_var(array_var(array_var($_POST, 'contact'), 'user'), 'create-user')) {
                     $contact->addEmail($email, 'personal', true);
                 }
                 flash_success(lang("success add contact", $contact->getObjectName()));
             }
         }
         // User settings
         $user = array_var(array_var($_POST, 'contact'), 'user');
         $user['username'] = str_replace(" ", "", strtolower($name));
         $user_data = $this->createUserFromContactForm($user, $contact->getId(), $email);
         // Reload contact again due to 'createUserFromContactForm' changes
         Hook::fire("after_contact_quick_add", Contacts::instance()->findById($contact->getId()), $ret);
         DB::commit();
         // Send notification
         send_notification($user_data, $contact->getId());
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // Reload
     evt_add("reload dimension tree", array('dim_id' => $dimensionId));
 }
Exemple #14
0
         // Уведомляем исполнителя по telgram;
         $systems->send_telegram($item['user_id'], 'У вас есть новое РКО №' . $rko_code . ' для согласования.');
     }
     // Теперь поучим родителя ношего основания, что бы отправить уведомления остальным;
     try_again:
     $sql = "SELECT `parent_id` FROM `rko_templates` WHERE `id` = '" . $rko_template . "' AND `status` != '0';";
     $temp_id = $db_rs->one($sql);
     if ($temp_id != '') {
         $rko_template = $temp_id;
         goto try_again;
     }
     // Получаем тех, у кого такой родитель стоит для уведомлени;
     $sql = "SELECT * FROM `rko_accepts` WHERE `rko_template_id` = '" . $rko_template . "' AND `status` != '0';";
     $receivers = $db_rs->all($sql);
     foreach ($receivers as $receiver) {
         send_notification($receiver['user_id'], 'У вас есть новое РКО №' . $rko_code . ' для согласования.<br>Нажмите для перехода в раздел РКО.', 'rko', '', 4, $rko_code);
         $systems->send_telegram($receiver['user_id'], 'У вас есть новое РКО №' . $rko_code . ' для согласования.');
     }
     echo 'OK';
 }
 function get_full_rko_template_text($last_id)
 {
     global $db_rs;
     $template_text = '';
     again:
     $sql = "SELECT `parent_id`, `template_text` FROM `rko_templates` WHERE `id` = '" . $last_id . "' AND `status` != '0';";
     //file_put_contents($_SERVER['DOCUMENT_ROOT'].'/123.txt', $sql."\r\n", FILE_APPEND);
     $template_text_temp = $db_rs->row($sql);
     $template_text = str_replace("\r\n", '', $template_text_temp['template_text'] . ' ' . $template_text);
     // Если есть родитель, цепляем его текст тоже;
     if ($template_text_temp['parent_id'] != '') {
 function qid($id = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         $_POST = array_map('htmlspecialchars', $_POST);
         $tfields = explode("||", $_POST["tfields"]);
         unset($_POST['tfields']);
         unset($tfields["section_break"]);
         $counter = 0;
         $form = "";
         foreach ($_POST as $key => $value) {
             if ($key != "captcha" && $key != "confirmcaptcha" && $key != "section_break" && !strpos($key, '_')) {
                 $form .= '<div class="question">' . $tfields[$counter] . '</div>';
                 $form .= '<div class="answer">' . $value . '</div>';
                 $counter = $counter + 1;
             } elseif (strpos($key, '_')) {
                 $checkbox_explode = explode("_", $key);
                 if (isset($check)) {
                     if ($check != $checkbox_explode[0]) {
                         $form .= '<div class="question">' . $tfields[$counter] . '</div>';
                         $check = $checkbox_explode[0];
                         $counter = $counter + 1;
                     }
                 } else {
                     $form .= '<div class="question">' . $tfields[$counter] . '</div>';
                     $check = $checkbox_explode[0];
                     $counter = $counter + 1;
                 }
                 $form .= '<div class="answer"><i class="fa fa-check"></i> ' . $value . '</div>';
             } elseif ($key == "section_break") {
                 $counter = $counter + 1;
                 $form .= "<hr>";
             }
         }
         $attributes = array('form' => $form, 'status' => 'New', 'custom_quotation_id' => $id, 'date' => date("Y-m-d H:i", time()));
         $item = Quoterequest::create($attributes);
         if (!$item) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('quotation_create_error'));
         } else {
             $this->load->helper('notification');
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('quotation_create_success'));
             $admins = User::find('all', array('conditions' => array('admin = ? AND status = ?', '1', 'active')));
             foreach ($admins as &$value) {
                 send_notification($value->email, $this->lang->line('application_notification_quotation_subject'), $this->lang->line('application_notification_quotation'));
             }
         }
         redirect('quotation/qid/' . $id);
     } else {
         $this->theme_view = 'fullpage';
         $this->view_data['quotation'] = Customquote::find_by_id($id);
         $this->view_data['form_action'] = 'quotation/qid/' . $id;
         $json_output = json_decode($this->view_data['quotation']->formcontent);
         $html_fields = "";
         $i = 0;
         foreach ($json_output->fields as $field) {
             $i = $i++;
             $required = '';
             switch ($field->field_type) {
                 case 'text':
                     if ($field->required == true) {
                         $required = 'required';
                     }
                     $html_fields .= '<div class="form-group">';
                     $html_fields .= '<label class="control-label">' . $field->label . '</label>';
                     $html_fields .= '<input type="text" name="' . $field->cid . '" class="form-control ' . $required . '"' . $required . '/>';
                     if (isset($field->field_options->description)) {
                         $html_fields .= '<p class="subline">' . $field->field_options->description . '</p>';
                     }
                     $html_fields .= '</div>';
                     break;
                 case 'email':
                     if ($field->required == true) {
                         $required = 'required';
                     }
                     $html_fields .= '<div class="form-group">';
                     $html_fields .= '<label class="control-label">' . $field->label . '</label>';
                     $html_fields .= '<input type="email" name="' . $field->cid . '" class="form-control email ' . $required . '" ' . $required . '/>';
                     if (isset($field->field_options->description)) {
                         $html_fields .= '<p class="subline">' . $field->field_options->description . '</p>';
                     }
                     $html_fields .= '</div>';
                     break;
                 case 'paragraph':
                     if ($field->required == true) {
                         $required = 'required';
                     }
                     $html_fields .= '<div class="form-group">';
                     $html_fields .= '<label class="control-label">' . $field->label . '</label>';
                     $html_fields .= '<textarea name="' . $field->cid . '" class="form-control ' . $required . '" ' . $required . '></textarea>';
                     if (isset($field->field_options->description)) {
                         $html_fields .= '<p class="subline">' . $field->field_options->description . '</p>';
                     }
                     $html_fields .= '</div>';
                     break;
                 case 'section_break':
                     $html_fields .= '<div class="form-group">';
                     $html_fields .= '<hr>';
                     $html_fields .= '</div>';
                     break;
                 case 'radio':
                     if ($field->required == true) {
                         $required = 'required';
                     }
                     $html_fields .= '<div class="form-group">';
                     $html_fields .= '<label class="control-label">' . $field->label . '</label>';
                     foreach ($field->field_options->options as $value) {
                         $html_fields .= '<input type="radio" class="form-control checkbox" data-labelauty="' . $value->label . '" name="' . $field->cid . '" value="' . $value->label . '" ' . $required . '/>';
                     }
                     if (isset($field->description)) {
                         $html_fields .= '<p class="subline">' . $field->description . '</p>';
                     }
                     $html_fields .= '</div>';
                     break;
                 case 'checkboxes':
                     if ($field->required == true) {
                         $required = 'required';
                     }
                     $html_fields .= '<div class="form-group">';
                     $html_fields .= '<label class="control-label">' . $field->label . '</label>';
                     $recent = false;
                     foreach ($field->field_options->options as $value) {
                         $checked = '';
                         if ($recent != $field->cid) {
                             $i = 0;
                         }
                         $recent = $field->cid;
                         $i = $i + 1;
                         if ($value->checked == true) {
                             $checked = 'checked="checked"';
                         }
                         $html_fields .= '<div class="margin-bottom-10"><input type="checkbox" class="checkbox" data-labelauty="' . $value->label . '" name="' . $field->cid . '_' . $i . '" value="' . $value->label . '" ' . $checked . ' /></div>';
                     }
                     if (isset($field->description)) {
                         $html_fields .= '<p class="subline">' . $field->description . '</p>';
                     }
                     $html_fields .= '</div>';
                     break;
                 case 'dropdown':
                     if ($field->required == true) {
                         $required = 'required';
                     }
                     $html_fields .= '<div class="form-group">';
                     $html_fields .= '<label class="control-label">' . $field->label . '</label>';
                     $html_fields .= '<select width="210px" class="chosen-select" name="' . $field->cid . '">';
                     foreach ($field->field_options->options as $value) {
                         $html_fields .= '<option>' . $value->label . '</option><br>';
                     }
                     $html_fields .= '</select>';
                     if (isset($field->description)) {
                         $html_fields .= '<p class="subline">' . $field->description . '</p>';
                     }
                     $html_fields .= '</div>';
                     break;
             }
         }
         $number1 = rand(1, 10);
         $number2 = rand(1, 10);
         $captcha = $number1 + $number2;
         //captcha
         $html_fields .= '<input type="hidden" id="captcha" name="captcha" value="' . $captcha . '"><div class="form-group">';
         $html_fields .= '<label class="control-label-e">' . $number1 . '+' . $number2 . ' = ?</label>';
         $html_fields .= '<input type="text" id="confirmcaptch" name="confirmcaptcha" data-match="#captcha" class="form-control ' . $required . '" ' . $required . '/></div>';
         $this->view_data['fields'] = $html_fields;
         $this->content_view = 'quotation/_custom';
     }
 }
Exemple #16
0
     $sql = "UPDATE `it_desk` SET `date_last_update` = NOW() WHERE `id` = '" . $_POST['desk_id'] . "';";
     $db_rs->query($sql);
     // Отправляем пользователю уведомление о сообщении;
     send_notification($to_user, 'Новый ответ в IT обращениях.<br>Нажмите для перехода в список обращений.', 'it_service_desk');
     echo 'OK';
 }
 // Создаем в базе новую заявку;
 if (isset($_POST['new_desk']) && $_POST['new_desk'] != '') {
     // Добавляем его в базу добавляем информацию об авторе обращения;
     // Получаем ID пользователя;
     $sql = "SELECT `id` FROM `users_apps` WHERE `user_name` = '" . $_SESSION['user_login'] . "';";
     $author_id = $db_rs->one($sql);
     $sql = "INSERT INTO `it_desk` (`author_user_id`, `message`, `date`, `date_last_update`, `status`) VALUES('" . $author_id . "', '" . $_POST['new_desk'] . "', NOW(), NOW(), '1');";
     $db_rs->query($sql);
     // Отправляем пользователю уведомление о сообщении;
     send_notification('47', 'Внимание! Создано новое обращениях.<br>Нажмите для перехода в список обращений.', 'it_service_desk');
     echo 'OK';
 }
 // Страница для отображения формы создани новой заявки ITж
 if (isset($_POST['new_it_desk']) && $_POST['new_it_desk']) {
     $html = '';
     $html .= '<div class="page_medium_title main_page_title" style="margin-bottom: -0.8em;">Напишите новое обращение в IT</div><br>';
     $html .= '<div style="margin-bottom: 5px; margin-right: 10px;"><div class="menu_button" style="" onclick="send_new_it_desk()">Отправить обращение</div></div>';
     $html .= '<textarea rows="20" cols="80" id="desk_message"></textarea>';
     echo $html;
 }
 // Страница для отображения уже существующий заявок в ITж
 if (isset($_POST['list_it_desk']) && $_POST['list_it_desk']) {
     $html = '';
     $status = $_POST['list_it_desk'];
     if ($_SESSION['user_login'] == 'root' || $_SESSION['user_login'] == '0') {
Exemple #17
0
        $to = $_GET['addr'];
        file_put_contents($file, $to);
    } else {
        if (file_exists("pipes/{$id}.{$player}.mail")) {
            unlink($file);
        }
    }
} else {
    /* Only read the mail-addr file */
    if (file_exists($file)) {
        $to = file_get_contents($file);
        if (isset($_GET['retrieve'])) {
            /* Only retrieve the address */
            echo $to;
        } else {
            /* Send a mail */
            send_notification($to, $id, $player);
        }
    }
}
function send_notification($to, $id, $player)
{
    global $BASEURL;
    $subject = "[Atlantis] It's your turn!";
    $body = "Hi there! This is just to let you know that it's your turn at Atlantis.\n\n" . "Click here to go straight to the game: {$BASEURL}?id={$id}&player={$player} :).\n\n" . "Yours truly,\nAtlantis";
    if (mail($to, $subject, $body)) {
        echo "<p>Message successfully sent!</p>";
    } else {
        echo "<p>Message delivery failed...</p>";
    }
}
Exemple #18
0
        $html .= '</div>';
    }
    echo $html;
} else {
    /*
     * Отпарвка сообщения массовой расслыки
     * */
    if (isset($_POST['send_message']) && $_POST['send_message'] != '') {
        // Создаем запись в базу рассылки что бы запись все сообщения;
        $sql = "INSERT INTO `mass_messages` (`author_user_id`, `date`, `status`) VALUES ('" . $_SESSION['user_id'] . "', NOW(), 1);";
        $db_rs->query($sql);
        $send_id = mysqli_insert_id($db_rs->link_id);
        // Получаем список пользователей;
        $sql = "SELECT `id` FROM `users_apps`" . ($_POST['app_id'] == 'all' ? "" : " WHERE `app_id` = '" . $_POST['app_id'] . "';");
        $users = $db_rs->all($sql);
        foreach ($users as $user) {
            send_notification($user['id'], $_POST['send_message'], 'admin', $send_id, $_POST['mess_type']);
        }
        echo 'OK';
    }
    /*
     * Удаление вообщения массовой рассылки
     * */
    if (isset($_POST['delete_message']) && $_POST['delete_message'] != '') {
        $sql = "UPDATE `notifications` SET `status` = 0 WHERE `send_id` = '" . $_POST['delete_message'] . "';";
        $db_rs->query($sql);
        $sql = "UPDATE `mass_messages` SET `status` = 0 WHERE `id` = '" . $_POST['delete_message'] . "';";
        $db_rs->query($sql);
        echo 'OK';
    }
}
 public function addPostProcess()
 {
     $category = Input::get('category');
     $title = Input::get('title');
     $post_img = Input::file('post_img');
     $url = Input::get('url');
     $title_tag = Input::get('title_tag');
     $meta_des = Input::get('meta_des');
     $share_link = Input::get('share_link');
     $share_cat = Input::get('share_cat');
     $author = Input::get('author');
     $publisher = Input::get('publisher');
     $validator = Validator::make(array('title' => $title, 'url' => $url, 'meta_des' => $meta_des, 'category' => $category, 'author' => $author, 'publisher' => $publisher), array('title' => 'required', 'url' => 'required', 'meta_des' => 'required', 'category' => 'required', 'author' => 'required', 'publisher' => 'required'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         return Redirect::back()->with('flash_errors', $error_messages);
     } else {
         if (Input::get('id') != "") {
             $post = Post::find(Input::get('id'));
             $post->title = $title;
             $post->is_approved = 1;
             $post->des = Input::get('des');
             $post->url = $url;
             $post->meta_des = $meta_des;
             $post->publisher = $publisher;
             $post->author = $author;
             $validator1 = Validator::make(array('post_img' => $post_img), array('post_img' => 'required|mimes:jpeg,bmp,gif,png'));
             if ($validator1->fails()) {
                 //do nothing
             } else {
                 $file_name = seo_url($title) . '-' . time();
                 $post->des = Input::get('des');
                 $ext = Input::file('post_img')->getClientOriginalExtension();
                 Input::file('post_img')->move(public_path() . "/uploads", $file_name . "." . $ext);
                 $local_url = $file_name . "." . $ext;
                 // Upload to S3
                 $s3_url = URL::to('/') . '/uploads/' . $local_url;
                 $post->image = $s3_url;
             }
             $post->category = implode(',', $category);
             $post->save();
             if ($post) {
                 return Redirect::route('moderatePost')->with('flash_success', "Post Updated");
             } else {
                 return Redirect::back()->with('flash_error', "Something went wrong");
             }
         } else {
             $post = new Post();
             $post->title = $title;
             $post->is_approved = 1;
             $post->url = $url;
             $post->des = Input::get('des');
             $post->meta_des = $meta_des;
             $post->user_id = Auth::user()->id;
             $post->publisher = $publisher;
             $post->author = $author;
             $validator1 = Validator::make(array('title_tag' => $title_tag, 'post_img' => $post_img, 'share_link' => $share_link, 'share_cat' => $share_cat), array('title_tag' => 'required', 'share_link' => 'required', 'share_cat' => 'required', 'post_img' => 'required|mimes:jpeg,bmp,gif,png'));
             if ($validator1->fails()) {
                 $error_messages = $validator->messages()->all();
                 return Redirect::back()->with('flash_errors', $error_messages);
             } else {
                 $file_name = seo_url($title) . '-' . seo_url($share_cat) . '-' . time();
                 $ext = Input::file('post_img')->getClientOriginalExtension();
                 Input::file('post_img')->move(public_path() . "/uploads", $file_name . "." . $ext);
                 $local_url = $file_name . "." . $ext;
                 // Upload to S3
                 $s3_url = URL::to('/') . '/uploads/' . $local_url;
                 $post->image = $s3_url;
                 $post->category = implode(',', $category);
                 $post->share_cat = $share_cat;
                 $link = str_replace(" ", "-", Input::get('share_link')) . '-' . rand(0, 99);
                 $post->link = $link;
                 $post->title_tag = $title_tag;
                 $post->save();
                 if (Input::get('push_button') === 'yes') {
                     // checked
                     $response_array = array('success' => true, 'description' => $meta_des, 'image' => $s3_url);
                     send_notification($title, $response_array);
                 }
             }
             if ($post) {
                 return Redirect::route('moderatePost')->with('flash_success', "Post created");
             } else {
                 return Redirect::back()->with('flash_error', "Something went wrong");
             }
         }
     }
 }
 }
 // Preview comment
 if (isset($_POST['preview']) && !empty($comment_data['comment_message'])) {
     $template->assign_vars(array('PREVIEW_TEXT' => $message_parser->format_display($comment_data['enable_bbcode'], $comment_data['enable_magic_url'], $comment_data['enable_smilies'], false), 'S_PREVIEW' => true));
 }
 // Post comment
 if (isset($_POST['submit'])) {
     if (!check_form_key('add_comment')) {
         trigger_error('FORM_INVALID');
     }
     $poll = false;
     $data = array('forum_id' => $report['forum_id'], 'topic_id' => $report['topic_id'], 'topic_title' => $report['report_title'], 'icon_id' => 0, 'post_time' => time(), 'message' => $message_parser->message, 'message_md5' => $message_md5, 'bbcode_uid' => $message_parser->bbcode_uid, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'enable_bbcode' => $comment_data['enable_bbcode'], 'enable_smilies' => $comment_data['enable_smilies'], 'enable_urls' => $comment_data['enable_magic_url'], 'enable_sig' => 0, 'post_edit_locked' => 0, 'enable_indexing' => $report['enable_indexing'], 'forum_name' => $report['project_title'], 'notify' => false, 'notify_set' => false);
     submit_post('reply', $comment_data['comment_subject'], '', $report['topic_type'], $poll, $data);
     // Send out notifications
     $notif_users = get_subscribed_users($report['forum_id'], $report['topic_id']);
     send_notification($notif_users, 'bug_comment_added', array('REPORT_ID' => $report['report_id'], 'REPORT_TITLE' => $report['report_title'], 'PROJECT_TITLE' => $report['project_title'], 'U_REPORT' => generate_board_url() . '/' . $url_rewriter->rewrite("bugs.{$phpEx}", "mode=report&project={$report['project_name']}&report_id={$report_id}"), 'U_COMMENT' => generate_board_url() . '/' . $url_rewriter->rewrite("bugs.{$phpEx}", "mode=report&project={$report['project_name']}&report_id={$report_id}") . '#comment-' . $data['post_id'], 'PERFORMER' => $user->data['username']));
     $redirect_url = append_sid("{$phpbb_root_path}bugs.{$phpEx}", "mode=report&amp;project={$project_name}&amp;report_id={$report_id}#comment-{$data['post_id']}");
     meta_refresh(3, $redirect_url);
     $message = sprintf($user->lang['COMMENT_ADDED'], '<a href="' . $redirect_url . '">', '</a>');
     trigger_error($message);
 }
 // Display forms
 add_form_key('add_comment');
 if (isset($message_parser)) {
     $comment_data['comment_message'] = $message_parser->decode_message($message_parser->bbcode_uid, false);
 }
 $report['bbcode_options'] = ($report['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($report['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($report['enable_magic_url'] ? OPTION_FLAG_LINKS : 0);
 $template->assign_vars(array('COMMENT_SUBJECT' => $comment_data['comment_subject'], 'COMMENT_MESSAGE' => $comment_data['comment_message'], 'S_BBCODE_CHECKED' => $comment_data['enable_bbcode'] ? '' : ' checked="checked"', 'S_SMILIES_CHECKED' => $comment_data['enable_smilies'] ? '' : ' checked="checked"', 'S_MAGIC_URL_CHECKED' => $comment_data['enable_magic_url'] ? '' : ' checked="checked"', 'S_BBCODE_ALLOWED' => $auth->acl_get('f_bbcode', $report['forum_id']), 'S_SMILIES_ALLOWED' => $auth->acl_get('f_smilies', $report['forum_id']), 'S_LINKS_ALLOWED' => $config['allow_post_links'] ? true : false, 'ERROR' => isset($error) && sizeof($error) ? implode('<br />', $error) : false, 'S_PREVIEW_BOLD' => !empty($error) || !isset($_POST['preview']) ? true : false, 'REPORT_TITLE' => $report['report_title'], 'REPORT_TEXT' => generate_text_for_display($report['report_desc'], $report['bbcode_uid'], $report['bbcode_bitfield'], $report['bbcode_options']), 'REPORT_ID' => $report['report_id'], 'PROJECT_TITLE' => $report['project_title'], 'REPORT_COMPONENT' => $report['component_title'], 'REPORT_STATUS' => $report['status_title'], 'REPORT_VERSION' => $report['version_title'], 'ASSIGNED' => $report['assigned_id'] == 0 ? $user->lang['UNASSIGNED'] : get_username_string('username', $report['assigned_id'], $report['assigned_name'], $report['assigned_colour']), 'ASSIGNED_COLOUR' => $report['assigned_id'] == 0 ? $user->lang['UNASSIGNED'] : get_username_string('colour', $report['assigned_id'], $report['assigned_name'], $report['assigned_colour']), 'ASSIGNED_FULL' => $report['assigned_id'] == 0 ? $user->lang['UNASSIGNED'] : get_username_string('full', $report['assigned_id'], $report['assigned_name'], $report['assigned_colour']), 'REPORTED' => get_username_string('username', $report['topic_poster'], $report['topic_first_poster_name'], $report['topic_first_poster_colour']), 'REPORTED_COLOUR' => get_username_string('colour', $report['topic_poster'], $report['topic_first_poster_name'], $report['topic_first_poster_colour']), 'REPORTED_FULL' => get_username_string('full', $report['topic_poster'], $report['topic_first_poster_name'], $report['topic_first_poster_colour']), 'REPORT_TIME' => $user->format_date($report['topic_time']), 'S_IS_CLOSED' => $report['report_closed'] == 1, 'U_BUG_TRACKER' => append_sid("{$phpbb_root_path}bugs.{$phpEx}"), 'U_RETURN' => append_sid("{$phpbb_root_path}bugs.{$phpEx}", "mode=report&amp;project={$report['project_name']}&amp;report_id={$report_id}"), 'U_SUBSCRIBE' => append_sid("{$phpbb_root_path}bugs.{$phpEx}", "mode=report&amp;project={$report['project_name']}&amp;report_id={$report_id}&amp;action=subscribe"), 'U_UNSUBSCRIBE' => append_sid("{$phpbb_root_path}bugs.{$phpEx}", "mode=report&amp;project={$report['project_name']}&amp;report_id={$report_id}&amp;action=unsubscribe"), 'S_IS_SUBSCRIBED' => $is_subscribed, 'S_IS_LOCKED' => $report['topic_status'] == ITEM_LOCKED, 'S_DISPLAY_SUBSCRIBE_INFO' => $is_subscribed || $auth->acl_get('f_subscribe', $report['forum_id'])));
 // Display the page
 site_header($user->lang['BUG_TRACKER'] . ' - ' . $report['report_title'], 'bugs', array(array('bugs.' . $phpEx, 'BUG_TRACKER'), array("bugs.{$phpEx}?mode=project&amp;project={$report['project_name']}", $report['project_title']), array("{$phpbb_root_path}bugs.{$phpEx}?mode=report&amp;project={$report['project_name']}&amp;report_id={$report_id}", sprintf($user->lang['BUG_NO'], $report_id)), array("bugs.{$phpEx}?mode=reply&amp;project={$report['project_name']}&amp;report_id={$report_id}", 'ADD_COMMENT')));
 $template->set_filenames(array('body' => 'bugs_comment_add.html'));
Exemple #21
0
 function write($ajax = FALSE)
 {
     if ($_POST) {
         $config['upload_path'] = './files/media/';
         $config['encrypt_name'] = TRUE;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         $this->load->helper('notification');
         unset($_POST['userfile']);
         unset($_POST['file-name']);
         unset($_POST['send']);
         unset($_POST['note-codable']);
         unset($_POST['files']);
         $message = $_POST['message'];
         $receiverart = substr($_POST['recipient'], 0, 1);
         $receiverid = substr($_POST['recipient'], 1, 9999);
         if ($receiverart == "u") {
             $receiver = User::find($receiverid);
             $receiveremail = $receiver->email;
         } else {
             $receiver = Client::find($receiverid);
             $receiveremail = $receiver->email;
         }
         if (!$this->upload->do_upload()) {
             $error = $this->upload->display_errors('', ' ');
             if ($error != "You did not select a file to upload.") {
                 //$this->session->set_flashdata('message', 'error:'.$error);
             }
         } else {
             $data = array('upload_data' => $this->upload->data());
             $_POST['attachment'] = $data['upload_data']['orig_name'];
             $_POST['attachment_link'] = $data['upload_data']['file_name'];
         }
         $_POST = array_map('htmlspecialchars', $_POST);
         $_POST['message'] = $message;
         $_POST['time'] = date('Y-m-d H:i', time());
         $_POST['sender'] = "u" . $this->user->id;
         $_POST['status'] = "New";
         if (!isset($_POST['conversation'])) {
             $_POST['conversation'] = random_string('sha1');
         }
         if (isset($_POST['previousmessage'])) {
             $status = Privatemessage::find_by_id($_POST['previousmessage']);
             if ($receiveremail == $this->user->email) {
                 $receiverart = substr($status->recipient, 0, 1);
                 $receiverid = substr($status->recipient, 1, 9999);
                 $_POST['recipient'] = $status->recipient;
                 if ($receiverart == "u") {
                     $receiver = User::find($receiverid);
                     $receiveremail = $receiver->email;
                 } else {
                     $receiver = Client::find($receiverid);
                     $receiveremail = $receiver->email;
                 }
             }
             $status->status = 'Replied';
             $status->save();
             unset($_POST['previousmessage']);
         }
         $message = Privatemessage::create($_POST);
         if (!$message) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_write_message_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_write_message_success'));
             $this->load->helper('notification');
             send_notification($receiveremail, $this->lang->line('application_notification_new_message_subject'), $this->lang->line('application_notification_new_message') . '<br><hr style="border-top: 1px solid #CCCCCC; border-left: 1px solid whitesmoke; border-bottom: 1px solid whitesmoke;"/>' . $_POST['message'] . '<hr style="border-top: 1px solid #CCCCCC; border-left: 1px solid whitesmoke; border-bottom: 1px solid whitesmoke;"/>');
         }
         if ($ajax != "reply") {
             redirect('messages');
         } else {
             $this->theme_view = 'ajax';
         }
     } else {
         $this->view_data['clients'] = Client::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['users'] = User::find('all', array('conditions' => array('status=?', 'active')));
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_write_message');
         $this->view_data['form_action'] = 'messages/write';
         $this->content_view = 'messages/_messages';
     }
 }
 $user_name = $result[0];
 $sql = "select ch.chore_name, cha.options, cha.message, cht.assigned_to, cht.chore_activity_track_id from chore ch, chore_activity cha, chore_activity_track cht WHERE ch.chore_id = cha.chore_id AND cha.chore_activity_id = cht.chore_activity_id AND cha.user_id = {$mom_id} AND cht.assigned_to in ({$user_id},0) ORDER BY cht.assigned_to ASC";
 echo_results_as_json($sql, $connection);
 //Send a notification to the mom...
 $query = "select gcm_token from situation_aware_db.user where user_id = {$mom_id}";
 $tokens = array();
 foreach ($connection->query($query) as $v) {
     $tokens[] = $v[0];
 }
 send_notification($tokens, "{$user_name} accepted a task.", "M");
 $query = "select gcm_token from situation_aware_db.user where user_id in (select support_id from user_support where user_id = {$mom_id} and support_id != {$user_id}) and gcm_token is NOT NULL";
 $tokens = array();
 foreach ($connection->query($query) as $v) {
     $tokens[] = $v[0];
 }
 send_notification($tokens, "{$user_name} accepted a task.", "H");
 //Send updated date to all the other helpers...
 /*$query = "select gcm_token,user_id from situation_aware_db.user where user_id in (select support_id from user_support where user_id = $mom_id and support_id != $user_id) and gcm_token is NOT NULL";
 
 
 	
 	foreach($connection->query($query) as $v)
 	{
 		$tokens_helpers = array($v[0]);
 		$user_to_update = $v[1];
 		$sql = "select ch.chore_name, cha.options, cha.message, cht.assigned_to, cht.chore_activity_track_id from chore ch, chore_activity cha, chore_activity_track cht 				WHERE ch.chore_id = cha.chore_id AND cha.chore_activity_id = cht.chore_activity_id AND cha.user_id = $mom_id AND cht.assigned_to in ($user_to_update,0) ORDER BY cht.assigned_to ASC";
 	
 	
 		send_notification($tokens_helpers, echo_results_as_json($sql,$connection),"U");
 
 		
Exemple #23
0
 /**
  * Add an individual proposition to the event
  * params :
  *    id : id of the event
  */
 function add_individual_proposition($id)
 {
     $aResult = array();
     if (!isset($_POST['arguments'])) {
         $aResult['error'] = 'No function arguments!';
     }
     if (!isset($aResult['error'])) {
         if (!is_array($_POST['arguments']) || count($_POST['arguments']) < 1) {
             $aResult['error'] = 'Error in arguments!';
         } else {
             if ($this->session->userdata('logged_in')) {
                 if ($this->event->is_participation($this->session->userdata('logged_in')['id'], $id) == 1) {
                     $event = $this->event->get_event($id);
                     if ($event->individual_proposition_suggestion_allowed == 1) {
                         $individualProposition = $_POST['arguments'][0];
                         $result = $this->event->add_individual_proposition($id, $individualProposition);
                         $aResult['result'] = $result;
                         //sending a notification to the organizer
                         send_notification("Nouvelle proposition individuelle par un participant : " . $event->name, $this->session->userdata('logged_in')['firstname'] . ' ' . $this->session->userdata('logged_in')['surname'] . ' a fait une proposition individuelle<a class="list_contact" href="' . base_url('details_event/index/' . $id) . '">Voir l\'évènement</a>', $this->session->userdata('logged_in')['id'], $event->organizer, false);
                     } else {
                         $aResult['error'] = 'non autorisé';
                     }
                 } else {
                     $aResult['error'] = 'pas inscrit';
                 }
             } else {
                 $aResult['error'] = 'pas connecté';
             }
         }
     }
     echo json_encode($aResult);
 }
$user_id = $_GET['user_id'];
$options = $_GET['options'];
$chore_id = $_GET['chore_id'];
$message = $_GET['message'];
//$query = "INSERT INTO chore_activity (user_id, options, message) VALUES ('$user_id' , '$options' , '$message')";
$query = "INSERT INTO chore_activity (user_id, chore_id, options, message) VALUES ({$user_id}, {$chore_id}, '{$options}', :col1)";
//echo "\n\n query is $query \n\n";
try {
    //$dbh->setAttribute($PDO::FETCH_COLUMN, 'chore_activity_id');
    $stmt = $connection->prepare($query);
    $stmt->bindValue(':col1', $message, PDO::PARAM_STR);
    $result = $stmt->execute();
    $chore_activity_id = $connection->lastInsertId();
    //echo "Chore_activity  $chore_activity_id inserted\n";
    //	$assigned_to = 0;
    $query = "INSERT into chore_activity_track(user_id, chore_activity_id) VALUES ({$user_id}, {$chore_activity_id})";
    $result = $connection->query($query);
    $chore_activity_track_id = $connection->lastInsertId();
    //echo "Chore_activity_track  $chore_activity_track_id inserted\n";
    //get registration_ids of the helper mobile nodes
    $query = "select gcm_token from situation_aware_db.user where user_id in (select support_id from user_support where user_id = {$user_id}) and gcm_token is NOT NULL";
    $tokens = array();
    foreach ($connection->query($query) as $v) {
        $tokens[] = $v[0];
    }
    send_notification($tokens, "A new task has been added.", "H");
    echo "The task has been succesfully added";
} catch (PDOException $e) {
    echo "Server Error!!!\n";
    echo $e;
}
 /**
  * Overrided process payment for Authorize.net
  *
  * @global object $invoice
  * @global array $wpi_settings
  * @param array $data
  */
 static function process_payment($data = null)
 {
     global $invoice, $wpi_settings;
     //** Require our external libraries */
     require_once WPI_Path . '/third-party/authorize.net/authnet.class.php';
     require_once WPI_Path . '/third-party/authorize.net/authnetARB.class.php';
     // Pull in the CCard data from the request, and other variables we'll use
     // If data passed then use it. Otherwise use data from request.
     // It used to make available to do payment processes by WPI_Payment_Api
     $cc_data = is_null($data) ? $_REQUEST['cc_data'] : $data;
     $invoice_id = $invoice['invoice_id'];
     $wp_users_id = $invoice['user_data']['ID'];
     $post_id = wpi_invoice_id_to_post_id($invoice_id);
     //** Recurring */
     $recurring = $invoice['type'] == 'recurring' ? true : false;
     //** Response */
     $response = array('success' => false, 'error' => false, 'data' => null);
     //** Invoice custom id which is sending to authorize.net */
     $cc_data['invoice_id'] = $invoice_id;
     $invoice_obj = new WPI_Invoice();
     $invoice_obj->load_invoice("id={$invoice['invoice_id']}");
     if ($invoice['deposit_amount'] > 0) {
         $amount = (double) $cc_data['amount'];
         if ((double) $cc_data['amount'] > $invoice['net']) {
             $amount = $invoice['net'];
         }
         if ((double) $cc_data['amount'] < $invoice['deposit_amount']) {
             $amount = $invoice['deposit_amount'];
         }
     } else {
         $amount = $invoice['net'];
     }
     //** We assume that all data is good to go, considering we are valadating with JavaScript */
     $payment = new WP_Invoice_Authnet();
     $payment->transaction($cc_data['card_num']);
     //** Billing Info */
     $payment->setParameter("x_card_code", $cc_data['card_code']);
     $payment->setParameter("x_exp_date ", $cc_data['exp_month'] . $cc_data['exp_year']);
     $payment->setParameter("x_amount", $amount);
     $payment->setParameter("x_currency_code", $cc_data['currency_code']);
     if ($recurring) {
         $payment->setParameter("x_recurring_billing", true);
     }
     //** Order Info */
     $payment->setParameter("x_description", $invoice['post_title']);
     $payment->setParameter("x_invoice_id", $invoice['invoice_id']);
     $payment->setParameter("x_duplicate_window", 30);
     //** Customer Info */
     $payment->setParameter("x_first_name", $cc_data['first_name']);
     $payment->setParameter("x_last_name", $cc_data['last_name']);
     $payment->setParameter("x_address", $cc_data['streetaddress']);
     $payment->setParameter("x_city", $cc_data['city']);
     $payment->setParameter("x_state", $cc_data['state']);
     $payment->setParameter("x_country", $cc_data['country']);
     $payment->setParameter("x_zip", $cc_data['zip']);
     $payment->setParameter("x_phone", $cc_data['phonenumber']);
     $payment->setParameter("x_email", $cc_data['user_email']);
     $payment->setParameter("x_cust_id", "WP User - " . $wp_users_id);
     $payment->setParameter("x_customer_ip ", $_SERVER['REMOTE_ADDR']);
     //** Process */
     $payment->process();
     //** Process results */
     if ($payment->isApproved()) {
         update_user_meta($wp_users_id, 'last_name', $cc_data['last_name']);
         update_user_meta($wp_users_id, 'first_name', $cc_data['first_name']);
         update_user_meta($wp_users_id, 'city', $cc_data['city']);
         update_user_meta($wp_users_id, 'state', $cc_data['state']);
         update_user_meta($wp_users_id, 'zip', $cc_data['zip']);
         update_user_meta($wp_users_id, 'streetaddress', $cc_data['streetaddress']);
         update_user_meta($wp_users_id, 'phonenumber', $cc_data['phonenumber']);
         update_user_meta($wp_users_id, 'country', $cc_data['country']);
         do_action('wpi_authorize_user_meta_updated', $cc_data);
         //** Add payment amount */
         $event_note = WPI_Functions::currency_format($amount, $invoice['invoice_id']) . " paid via Authorize.net";
         $event_amount = $amount;
         $event_type = 'add_payment';
         $event_note = urlencode($event_note);
         //** Log balance changes */
         $invoice_obj->add_entry("attribute=balance&note={$event_note}&amount={$event_amount}&type={$event_type}");
         //** Log client IP */
         $success = "Successfully processed by {$_SERVER['REMOTE_ADDR']}";
         $invoice_obj->add_entry("attribute=invoice&note={$success}&type=update");
         //** Log payer email */
         $payer_email = "Authorize.net Payer email: {$cc_data['user_email']}";
         $invoice_obj->add_entry("attribute=invoice&note={$payer_email}&type=update");
         $invoice_obj->save_invoice();
         //** Mark invoice as paid */
         wp_invoice_mark_as_paid($invoice_id, $check = true);
         send_notification($invoice);
         $data['messages'][] = $payment->getResponseText();
         $response['success'] = true;
         $response['error'] = false;
         if ($recurring) {
             $arb = new WP_Invoice_AuthnetARB($invoice);
             //** Customer Info */
             $arb->setParameter('customerId', "WP User - " . $invoice['user_data']['ID']);
             $arb->setParameter('firstName', !empty($cc_data['first_name']) ? $cc_data['first_name'] : '-');
             $arb->setParameter('lastName', !empty($cc_data['last_name']) ? $cc_data['last_name'] : '-');
             $arb->setParameter('address', !empty($cc_data['streetaddress']) ? $cc_data['streetaddress'] : '-');
             $arb->setParameter('city', !empty($cc_data['city']) ? $cc_data['city'] : '-');
             $arb->setParameter('state', !empty($cc_data['state']) ? $cc_data['state'] : '-');
             $arb->setParameter('zip', !empty($cc_data['zip']) ? $cc_data['zip'] : '-');
             $arb->setParameter('country', !empty($cc_data['country']) ? $cc_data['country'] : '-');
             $arb->setParameter('customerEmail', !empty($cc_data['user_email']) ? $cc_data['user_email'] : '-');
             $arb->setParameter('customerPhoneNumber', !empty($cc_data['phonenumber']) ? $cc_data['phonenumber'] : '-');
             //** Billing Info */
             $arb->setParameter('amount', $invoice['net']);
             $arb->setParameter('cardNumber', $cc_data['card_num']);
             $arb->setParameter('expirationDate', $cc_data['exp_month'] . $cc_data['exp_year']);
             //** Subscription Info */
             $arb->setParameter('refID', $invoice['invoice_id']);
             $arb->setParameter('subscrName', $invoice['post_title']);
             $arb->setParameter('interval_length', $invoice['recurring']['wpi_authorize']['length']);
             $arb->setParameter('interval_unit', $invoice['recurring']['wpi_authorize']['unit']);
             //** format: yyyy-mm-dd */
             if ($invoice['recurring']['wpi_authorize']['send_invoice_automatically'] == 'on') {
                 $arb->setParameter('startDate', date("Y-m-d", time()));
             } else {
                 $arb->setParameter('startDate', $invoice['recurring']['wpi_authorize']['start_date']['year'] . '-' . $invoice['recurring']['wpi_authorize']['start_date']['month'] . '-' . $invoice['recurring']['wpi_authorize']['start_date']['day']);
             }
             $arb->setParameter('totalOccurrences', $invoice['recurring']['wpi_authorize']['cycles']);
             $arb->setParameter('trialOccurrences', 1);
             $arb->setParameter('trialAmount', '0.00');
             $arb->setParameter('orderInvoiceNumber', $invoice['invoice_id']);
             $arb->setParameter('orderDescription', $invoice['post_title']);
             $arb->createAccount();
             if ($arb->isSuccessful()) {
                 update_post_meta($post_id, 'subscription_id', $arb->getSubscriberID());
                 WPI_Functions::log_event($post_id, 'invoice', 'update', '', __('Subscription initiated, Subcription ID', WPI) . ' - ' . $arb->getSubscriberID());
                 $data['messages'][] = "Recurring Billing Subscription initiated";
                 $response['success'] = true;
                 $response['error'] = false;
             }
             if ($arb->isError()) {
                 $data['messages'][] = __('One-time credit card payment is processed successfully. However, recurring billing setup failed. ', WPI) . $arb->getResponse();
                 $response['success'] = false;
                 $response['error'] = true;
                 WPI_Functions::log_event($post_id, 'invoice', 'update', '', __('Response Code: ', WPI) . $arb->getResponseCode() . ' | ' . __('Subscription error', WPI) . ' - ' . $arb->getResponse());
             }
         }
     } else {
         $response['success'] = false;
         $response['error'] = true;
         $data['messages'][] = $payment->getResponseText();
     }
     $response['data'] = $data;
     die(json_encode($response));
 }
 function index()
 {
     $this->load->helper('notification');
     $this->theme_view = 'blank';
     $settings = Setting::first();
     log_message('error', "Paypal IPN called");
     $req = 'cmd=_notify-validate';
     foreach ($_POST as $key => $value) {
         $value = urlencode(stripslashes($value));
         $req .= "&{$key}={$value}";
     }
     $header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
     $header .= "Host: www.paypal.com\r\n";
     // www.sandbox.paypal.com for a test site
     $header .= "Content-Length: " . strlen($req) . "\r\n";
     $header .= "Connection: close\r\n\r\n";
     //$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
     $fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30);
     if (!$fp) {
         // HTTP ERROR Failed to connect
         $mail_From = "From: IPN@paypal-tester.com";
         $mail_To = $settings->email;
         $mail_Subject = "HTTP ERROR";
         $mail_Body = $errstr;
         log_message('error', 'Paypal IPN - HTTP ERROR: ' . $errstr);
     } else {
         fputs($fp, $header . $req);
         while (!feof($fp)) {
             $res = fgets($fp, 1024);
             //log_message('error', 'Paypal IPN - fp handler -'.$res);
             if (stripos($res, "VERIFIED") !== false) {
                 log_message('error', 'Paypal IPN - VERIFIED');
                 $item_name = $_POST['item_name'];
                 $item_number = $_POST['item_number'];
                 log_message('error', 'Paypal IPN - Invoice number: #' . $item_number);
                 $custom = explode('-', $_POST['custom']);
                 $payment_currency = $_POST['mc_currency'];
                 $receiver_email = $_POST['receiver_email'];
                 $payer_email = $_POST['payer_email'];
                 if ($custom[0] == "invoice") {
                     $txn_id = $_POST['txn_id'];
                     $payment_amount = $_POST['mc_gross'];
                     $payment_status = $_POST['payment_status'];
                     if (($payment_status == 'Completed' || $payment_status == 'Processed' || $payment_status == 'Sent' || $payment_status == 'Pending') && $receiver_email == $settings->paypal_account && $payment_amount == $custom[1] && $payment_currency == $settings->paypal_currency) {
                         $invoice = Invoice::find_by_reference($item_number);
                         $invoice->paid_date = date("Y-m-d", time());
                         $invoice->status = "Paid";
                         $invoice->save();
                         log_message('error', 'Paypal IPN - Success: Invoice #' . $item_number . ' payment processed via Paypal.');
                         send_notification($settings->email, $this->lang->line('application_notification_payment_processed_subject'), $this->lang->line('application_notification_payment_processed') . ' #' . $item_number);
                     } else {
                         $mail_To = $settings->email;
                         $mail_Subject = "PayPal IPN status not completed or security check fail";
                         $mail_Body = "Something wrong. \n\nThe transaction ID number is: {$txn_id} \n\n Payment status = {$payment_status} \n\n Payment amount = {$payment_amount}";
                         mail($mail_To, $mail_Subject, $mail_Body);
                         log_message('error', 'Paypal IPN - Error: Invoice #' . $item_number . '. PayPal IPN status not completed or security check fail');
                     }
                 } elseif ($custom[0] == "subscription") {
                     $txn_type = $_POST["txn_type"];
                     log_message('error', 'Paypal IPN - ' . $_POST["subscr_id"]);
                     if ($txn_type == "subscr_signup" && $receiver_email == $settings->paypal_account && $_POST['mc_amount3'] == $custom[1] && $payment_currency == $settings->paypal_currency) {
                         $Subscription = Subscription::find_by_reference($item_number);
                         $Subscription->subscribed = date("Y-m-d", time());
                         $Subscription->save();
                         log_message('error', 'Paypal IPN - Success: Subscription #' . $item_number . ' payment processed via Paypal.');
                         send_notification($settings->email, $this->lang->line('application_notification_subscribed_subject'), $this->lang->line('application_notification_subscribed') . ' #' . $item_number);
                     }
                 }
             } else {
                 if (stripos($res, "INVALID") !== false) {
                     if (!$_POST) {
                         echo "IPN cannot be called outside of a paypal reuqest!";
                     } else {
                         log_message('error', 'Paypal IPN - Error: Invoice #' . $item_number . '. We have had an INVALID response. \\n\\nThe transaction ID number is: $txn_id \\n\\n username = $username');
                     }
                 }
             }
         }
         //end of while
         fclose($fp);
     }
 }
 function activity($id = FALSE, $condition = FALSE, $activityID = FALSE)
 {
     $this->load->helper('notification');
     $project = Project::find_by_id($id);
     //$activity = ProjectHasAktivity::find_by_id($activityID);
     switch ($condition) {
         case 'add':
             if ($_POST) {
                 unset($_POST['send']);
                 $_POST['subject'] = htmlspecialchars($_POST['subject']);
                 $_POST['message'] = strip_tags($_POST['message'], '<br><br/><p></p><a></a><b></b><i></i><u></u><span></span>');
                 $_POST['project_id'] = $id;
                 $_POST['client_id'] = $this->client->id;
                 $_POST['type'] = "comment";
                 unset($_POST['files']);
                 $_POST['datetime'] = time();
                 $activity = ProjectHasActivity::create($_POST);
                 if (!$activity) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_success'));
                     foreach ($project->project_has_workers as $workers) {
                         send_notification($workers->user->email, "[" . $project->name . "] " . $_POST['subject'], $_POST['message'] . '<br><strong>' . $project->name . '</strong>');
                     }
                     if (isset($project->company->client->email)) {
                         send_notification($project->company->client->email, "[" . $project->name . "] " . $_POST['subject'], $_POST['message'] . '<br><strong>' . $project->name . '</strong>');
                     }
                 }
                 //redirect('projects/view/'.$id);
             }
             break;
         case 'update':
             break;
         case 'delete':
             break;
     }
 }
Exemple #28
0
 function write($ajax = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['_wysihtml5_mode']);
         $message = $_POST['message'];
         $receiverart = substr($_POST['recipient'], 0, 1);
         $receiverid = substr($_POST['recipient'], 1, 9999);
         if ($receiverart == "u") {
             $receiver = User::find($receiverid);
             $receiveremail = $receiver->email;
         } else {
             $receiver = Client::find($receiverid);
             $receiveremail = $receiver->email;
         }
         $_POST = array_map('htmlspecialchars', $_POST);
         $_POST['message'] = $message;
         $_POST['time'] = date('Y-m-d H:i', time());
         $_POST['sender'] = "u" . $this->user->id;
         $_POST['status'] = "New";
         if (!isset($_POST['conversation'])) {
             $_POST['conversation'] = random_string('sha1');
         }
         $message = Privatemessage::create($_POST);
         if (!$message) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_write_message_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_write_message_success'));
             $this->load->helper('notification');
             send_notification($receiveremail, $this->lang->line('application_notification_new_message_subject'), $this->lang->line('application_notification_new_message') . '<br><hr style="border-top: 1px solid #CCCCCC; border-left: 1px solid whitesmoke; border-bottom: 1px solid whitesmoke;"/>' . $_POST['message'] . '<hr style="border-top: 1px solid #CCCCCC; border-left: 1px solid whitesmoke; border-bottom: 1px solid whitesmoke;"/>');
         }
         if ($ajax != "reply") {
             redirect('messages');
         } else {
             $this->theme_view = 'ajax';
         }
     } else {
         $this->view_data['clients'] = Client::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['users'] = User::find('all', array('conditions' => array('status=?', 'active')));
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_write_message');
         $this->view_data['form_action'] = 'messages/write';
         $this->content_view = 'messages/_messages';
     }
 }
 /**
  * Handler for 2Checkout Callback
  * @author Craig Christenson
  * Full callback URL: http://domain/wp-admin/admin-ajax.php?action=wpi_gateway_server_callback&type=wpi_twocheckout
  */
 static function server_callback()
 {
     if (empty($_REQUEST)) {
         die(__('Direct access not allowed', WPI));
     }
     $invoice = new WPI_Invoice();
     $invoice->load_invoice("id={$_REQUEST['merchant_order_id']}");
     /** Verify callback request */
     if (self::_ipn_verified($invoice)) {
         if ($_REQUEST['key']) {
             $event_note = sprintf(__('%s paid via 2Checkout', WPI), WPI_Functions::currency_format(abs($_REQUEST['total']), $_REQUEST['merchant_order_id']));
             $event_amount = (double) $_REQUEST['total'];
             $event_type = 'add_payment';
             /** Log balance changes */
             $invoice->add_entry("attribute=balance&note={$event_note}&amount={$event_amount}&type={$event_type}");
             /** Log payer email */
             $payer_email = sprintf(__("2Checkout buyer email: %s", WPI), $_REQUEST['email']);
             $invoice->add_entry("attribute=invoice&note={$payer_email}&type=update");
             $invoice->save_invoice();
             /** ... and mark invoice as paid */
             wp_invoice_mark_as_paid($_REQUEST['invoice_id'], $check = true);
             send_notification($invoice->data);
             echo '<script type="text/javascript">window.location="' . get_invoice_permalink($invoice->data['ID']) . '";</script>';
             /** Handle INS messages */
         } elseif ($_POST['md5_hash']) {
             switch ($_POST['message_type']) {
                 case 'FRAUD_STATUS_CHANGED':
                     if ($_POST['fraud_status'] == 'pass') {
                         WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['vendor_order_id']), 'invoice', 'update', '', __('Passed 2Checkout fraud review.', WPI));
                     } elseif (condition) {
                         WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['vendor_order_id']), 'invoice', 'update', '', __('Failed 2Checkout fraud review.', WPI));
                         wp_invoice_mark_as_pending($_POST['vendor_order_id']);
                     }
                     break;
                 case 'RECURRING_STOPPED':
                     WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['vendor_order_id']), 'invoice', 'update', '', __('Recurring billing stopped.', WPI));
                     break;
                 case 'RECURRING_INSTALLMENT_FAILED':
                     WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['vendor_order_id']), 'invoice', 'update', '', __('Recurring installment failed.', WPI));
                     break;
                 case 'RECURRING_INSTALLMENT_SUCCESS':
                     $event_note = sprintf(__('%1s paid for subscription %2s', WPI), WPI_Functions::currency_format(abs($_POST['item_rec_list_amount_1']), $_POST['vendor_order_id']), $_POST['sale_id']);
                     $event_amount = (double) $_POST['item_rec_list_amount_1'];
                     $event_type = 'add_payment';
                     $invoice->add_entry("attribute=balance&note={$event_note}&amount={$event_amount}&type={$event_type}");
                     $invoice->save_invoice();
                     send_notification($invoice->data);
                     break;
                 case 'RECURRING_COMPLETE':
                     WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['vendor_order_id']), 'invoice', 'update', '', __('Recurring installments completed.', WPI));
                     wp_invoice_mark_as_paid($_POST['invoice'], $check = false);
                     break;
                 case 'RECURRING_RESTARTED':
                     WPI_Functions::log_event(wpi_invoice_id_to_post_id($_POST['vendor_order_id']), 'invoice', 'update', '', __('Recurring sale restarted.', WPI));
                     break;
                 default:
                     break;
             }
         }
     }
 }
Exemple #30
-1
 /**
  * Process STRIPE payment
  * @global type $invoice
  */
 static function process_payment()
 {
     global $invoice;
     //** Response */
     $response = array('success' => false, 'error' => false, 'data' => null);
     if (isset($_POST['stripeToken'])) {
         $token = $_POST['stripeToken'];
     } else {
         $response['error'] = true;
         $data['messages'][] = __('The order cannot be processed. You have not been charged. Please confirm that you have JavaScript enabled and try again.', WPI);
         $response['data'] = $data;
         die(json_encode($response));
     }
     try {
         if (!class_exists('Stripe')) {
             require_once WPI_Path . '/third-party/stripe/lib/Stripe.php';
         }
         $pk = trim($invoice['billing']['wpi_stripe']['settings'][$invoice['billing']['wpi_stripe']['settings']['mode']['value'] . '_secret_key']['value']);
         Stripe::setApiKey($pk);
         switch ($invoice['type'] == 'recurring') {
             //** If recurring */
             case true:
                 $plan = Stripe_Plan::create(array("amount" => (double) $invoice['net'] * 100, "interval" => $invoice['recurring']['wpi_stripe']['interval'], "interval_count" => $invoice['recurring']['wpi_stripe']['interval_count'], "name" => $invoice['post_title'], "currency" => strtolower($invoice['default_currency_code']), "id" => $invoice['invoice_id']));
                 $customer = Stripe_Customer::create(array("card" => $token, "plan" => $invoice['invoice_id'], "email" => $invoice['user_email']));
                 if (!empty($plan->id) && !empty($plan->amount) && !empty($customer->id)) {
                     $invoice_obj = new WPI_Invoice();
                     $invoice_obj->load_invoice("id={$invoice['invoice_id']}");
                     $log = sprintf(__("Subscription has been initiated. Plan: %s, Customer: %s", WPI), $plan->id, $customer->id);
                     $invoice_obj->add_entry("attribute=invoice&note={$log}&type=update");
                     $invoice_obj->save_invoice();
                     update_post_meta(wpi_invoice_id_to_post_id($invoice['invoice_id']), '_stripe_customer_id', $customer->id);
                     $data['messages'][] = __('Stripe Subscription has been initiated. Do not pay this invoice again. Thank you.', WPI);
                     $response['success'] = true;
                     $response['error'] = false;
                 } else {
                     $data['messages'][] = __('Could not initiate Stripe Subscription. Contact site Administrator please.', WPI);
                     $response['success'] = false;
                     $response['error'] = true;
                 }
                 break;
                 //** If regular payment */
             //** If regular payment */
             case false:
                 //** Support partial payments */
                 if ($invoice['deposit_amount'] > 0) {
                     $amount = (double) $_REQUEST['amount'];
                     if ((double) $_REQUEST['amount'] > $invoice['net']) {
                         $amount = $invoice['net'];
                     }
                     if ((double) $_REQUEST['amount'] < $invoice['deposit_amount']) {
                         $amount = $invoice['deposit_amount'];
                     }
                 } else {
                     $amount = $invoice['net'];
                 }
                 $charge = Stripe_Charge::create(array("amount" => (double) $amount * 100, "currency" => strtolower($invoice['default_currency_code']), "card" => $token, "description" => $invoice['invoice_id'] . ' [' . $invoice['post_title'] . ' / ' . get_bloginfo('url') . ' / ' . $invoice['user_email'] . ']'));
                 if ($charge->paid) {
                     $invoice_id = $invoice['invoice_id'];
                     $wp_users_id = $invoice['user_data']['ID'];
                     //** update user data */
                     update_user_meta($wp_users_id, 'last_name', !empty($_REQUEST['last_name']) ? $_REQUEST['last_name'] : '');
                     update_user_meta($wp_users_id, 'first_name', !empty($_REQUEST['first_name']) ? $_REQUEST['first_name'] : '');
                     update_user_meta($wp_users_id, 'city', !empty($_REQUEST['city']) ? $_REQUEST['city'] : '');
                     update_user_meta($wp_users_id, 'state', !empty($_REQUEST['state']) ? $_REQUEST['state'] : '');
                     update_user_meta($wp_users_id, 'zip', !empty($_REQUEST['zip']) ? $_REQUEST['zip'] : '');
                     update_user_meta($wp_users_id, 'streetaddress', !empty($_REQUEST['address1']) ? $_REQUEST['address1'] : '');
                     update_user_meta($wp_users_id, 'phonenumber', !empty($_REQUEST['phonenumber']) ? $_REQUEST['phonenumber'] : '');
                     update_user_meta($wp_users_id, 'country', !empty($_REQUEST['country']) ? $_REQUEST['country'] : '');
                     if (!empty($_REQUEST['crm_data'])) {
                         self::user_meta_updated($_REQUEST['crm_data']);
                     }
                     $invoice_obj = new WPI_Invoice();
                     $invoice_obj->load_invoice("id={$invoice['invoice_id']}");
                     $amount = (double) ($charge->amount / 100);
                     //** Add payment amount */
                     $event_note = WPI_Functions::currency_format($amount, $invoice['invoice_id']) . __(" paid via STRIPE", WPI);
                     $event_amount = $amount;
                     $event_type = 'add_payment';
                     $event_note = urlencode($event_note);
                     //** Log balance changes */
                     $invoice_obj->add_entry("attribute=balance&note={$event_note}&amount={$event_amount}&type={$event_type}");
                     //** Log client IP */
                     $success = __("Successfully processed by ", WPI) . $_SERVER['REMOTE_ADDR'];
                     $invoice_obj->add_entry("attribute=invoice&note={$success}&type=update");
                     //** Log payer */
                     $payer_card = __("STRIPE Card ID: ", WPI) . $charge->card->id;
                     $invoice_obj->add_entry("attribute=invoice&note={$payer_card}&type=update");
                     $invoice_obj->save_invoice();
                     //** Mark invoice as paid */
                     wp_invoice_mark_as_paid($invoice_id, $check = true);
                     send_notification($invoice);
                     $data['messages'][] = __('Successfully paid. Thank you.', WPI);
                     $response['success'] = true;
                     $response['error'] = false;
                 } else {
                     $data['messages'][] = $charge->failure_message;
                     $response['success'] = false;
                     $response['error'] = true;
                 }
                 break;
                 //** Other cases */
             //** Other cases */
             default:
                 break;
         }
         $response['data'] = $data;
         die(json_encode($response));
     } catch (Stripe_CardError $e) {
         $e_json = $e->getJsonBody();
         $err = $e_json['error'];
         $response['error'] = true;
         $data['messages'][] = $err['message'];
     } catch (Stripe_ApiConnectionError $e) {
         $response['error'] = true;
         $data['messages'][] = __('Service is currently unavailable. Please try again later.', WPI);
     } catch (Stripe_InvalidRequestError $e) {
         $response['error'] = true;
         $data['messages'][] = __('Unknown error occured. Please contact site administrator.', WPI);
     } catch (Stripe_ApiError $e) {
         $response['error'] = true;
         $data['messages'][] = __('Stripe server is down! Try again later.', WPI);
     } catch (Exception $e) {
         $response['error'] = true;
         $data['messages'][] = $e->getMessage();
     }
     $response['data'] = $data;
     die(json_encode($response));
 }