Ejemplo n.º 1
0
 /**
  *	Option: Change Avatar [Not finished]
  *	Upload or remove the avatar
  *
  *	@return	void
  */
 public function ChangeAvatar()
 {
     if ($_GET['write'] == true) {
         switch ($_POST['c_command']) {
             case "upload":
                 switch ($_POST['u_command']) {
                     case "begin":
                         if (empty($_POST['u_imageChanged'])) {
                             setResult(showMessage($this->lang->words['UserPanel']['ChangeAvatar']['Messages']['NoImage'], 1));
                         } else {
                             $name = str_replace("-", NULL, crc32(sha1(time() . rand()) . gerateRandText() . md5($this->character)));
                             $size = $this->settings['WEBDATA']['UPLOADS']['FILESIZE']['CHARIMAGE'];
                             $dir = CTM_ROOT_PATH . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['CHARIMAGE'];
                             if (file_exists($dir . $name)) {
                                 while (file_exists($dir . $name)) {
                                     $name = str_replace("-", NULL, crc32(sha1(time() . rand()) . gerateRandText() . md5($this->character)));
                                 }
                             }
                             Uploadify::set("Filedata", $size, array("gif", "jpg", "jpeg", "png"), $name, $dir, $session);
                             exit("<script>startUpload('" . $name . "', '" . $session . "');</script>");
                         }
                         break;
                     case "finish":
                         if (empty($_POST['u_imageUploaded'])) {
                             exit(showMessage($this->lang->words['UserPanel']['ChangeAvatar']['Messages']['NoImage'], 1));
                         } else {
                             $image = unserialize(base64_decode($_POST['u_imageUploaded']));
                             if (!$image) {
                                 exit(showMessage($this->lang->words['UserPanel']['ChangeAvatar']['Messages']['ImageError'], 2));
                             } elseif ($image['error_no'] == 2) {
                                 $this->lang->setArguments("UserPanel,ChangeAvatar,Messages,ErrorFormat", "<b>JPEG</b>, <b>GIF</b>, <b>PNG</b>");
                                 exit(showMessage($this->lang->words['UserPanel']['ChangeAvatar']['Messages']['ErrorFormat'], 2));
                             } elseif ($image['error_no'] == 3) {
                                 $this->lang->setArguments("UserPanel,ChangeAvatar,Messages,ErrorSize", "<b>" . $data['max_file_size'] . "</b>");
                                 exit(showMessage($this->lang->words['UserPanel']['ChangeAvatar']['Messages']['ErrorSize'], 2));
                             } elseif ($image['error_no'] != 0) {
                                 exit(showMessage($this->lang->words['UserPanel']['ChangeAvatar']['Messages']['ImageError'], 2));
                             } else {
                                 $this->DB->Arguments(str_replace(CTM_ROOT_PATH, NULL, $image['parsed_file_name']), $this->character, USER_ACCOUNT);
                                 $this->DB->Query("UPDATE " . MUGEN_CORE . ".dbo.Character SET " . COLUMN_CHARIMAGE . " = '%s' WHERE Name = '%s' AND AccountID = '%s'");
                                 $this->WriteLog(array("option" => "Change Avatar", "character" => true, "data" => array("Command: Change Avatar", "File name: " . $image[0] . "." . $image[1])));
                                 exit(showMessage($this->lang->words['UserPanel']['ChangeAvatar']['Messages']['Success'], 3));
                             }
                         }
                         break;
                 }
                 break;
             case "no_image":
                 $find_image = $this->MuLib('Member')->LoadChar($this->character, COLUMN_CHARIMAGE);
                 if (strlen($find_image[COLUMN_CHARIMAGE]) > 1) {
                     $this->DB->Arguments($this->character, USER_ACCOUNT);
                     $this->DB->ForceDataType(COLUMN_CHARIMAGE, "null");
                     $this->DB->Update(MUGEN_CORE . "@Character", array(COLUMN_CHARIMAGE => NULL), "Name = '%s' AND AccountID = '%s'");
                     unlink(CTM_ROOT_PATH . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['CHARIMAGE'] . $find_image[COLUMN_CHARIMAGE]);
                 }
                 $this->WriteLog(array("option" => "Change Avatar", "character" => true, "data" => array("Command: Remove Avatar", "File name: " . (strlen($find_image[COLUMN_CHARIMAGE]) > 1 ? $find_image[COLUMN_CHARIMAGE] : "Not Found"))));
                 exit(showMessage($this->lang->words['UserPanel']['ChangeAvatar']['Messages']['Success'], 3));
                 break;
             default:
                 exit(showMessage($this->lang->words['UserPanel']['ChangeAvatar']['Messages']['SetCommand'], 1));
                 break;
         }
     }
     $find_image = $this->MuLib('Member')->LoadChar($this->character, COLUMN_CHARIMAGE);
     $GLOBALS['userpanel']['change_avatar']['with_avatar'] = strlen($find_image[COLUMN_CHARIMAGE]) > 1;
     $GLOBALS['userpanel']['change_avatar']['c_command'] = strlen($find_image[COLUMN_CHARIMAGE]) > 1 ? "upload" : "no_image";
 }
Ejemplo n.º 2
0
 /**
  *	Option: Tickets
  *	Tickets for support
  *
  *	@return	void
  */
 public function SupportTickets()
 {
     switch ($_GET['section'] ? $_GET['section'] : $this->URLData[2]) {
         case "list":
             $this->DB->Arguments(USER_ACCOUNT);
             $this->DB->Query("SELECT Id, Departament, Subject, Status, [Date] FROM dbo.CTM_Tickets WHERE Account = '%s' ORDER BY Id DESC", $all_tickets_q);
             $tickets_opened = array();
             $tickets_progress = array();
             $tickets_closed = array();
             if ($this->DB->CountRows($all_tickets_q) > 0) {
                 while ($all_tickets = $this->DB->FetchObject($all_tickets_q)) {
                     switch ($all_tickets->Status) {
                         case 0:
                             $var_name = "tickets_opened";
                             $status = "<span style='color: blue;'>" . $this->lang->words['UserPanel']['SupportTickets']['Status']['Opened'] . "</span>";
                             break;
                         case 1:
                             $var_name = "tickets_progress";
                             $status = "<span style='color: green;'>" . $this->lang->words['UserPanel']['SupportTickets']['Status']['Responded'] . "</span>";
                             break;
                         case 2:
                             $var_name = "tickets_progress";
                             $status = "<span style='color: orange;'>" . $this->lang->words['UserPanel']['SupportTickets']['Status']['Progress'] . "</span>";
                             break;
                         case 3:
                             $var_name = "tickets_closed";
                             $status = "<span style='color: red;'>" . $this->lang->words['UserPanel']['SupportTickets']['Status']['Closed'] . "</span>";
                             break;
                     }
                     ${$var_name}[$all_tickets->Id] = array("departament" => htmlEncode($this->settings['USERPANEL']['SUPPORT']['TICKETS']['DEPARTAMENTS'][$all_tickets->Departament]), "subject" => htmlEncode($all_tickets->Subject), "date" => date("d/m/Y - h:i a", $all_tickets->Date), "status" => $status);
                 }
             }
             $GLOBALS['userpanel']['support_tickets']['auto_load_ticket'] = $_GET['showticket'] ? $_GET['showticket'] : $this->URLData[3];
             $GLOBALS['userpanel']['support_tickets']['list_tickets'] = array("opened" => $tickets_opened, "progress" => $tickets_progress, "closed" => $tickets_closed);
             unset($tickets_opened);
             unset($tickets_progress);
             unset($tickets_closed);
             return $this->LoadPage("option_supportTickets_list", true);
             break;
         case "show":
             $ticket_id = intval($_GET['id']);
             $this->DB->Arguments($ticket_id, USER_ACCOUNT);
             $this->DB->Query("SELECT * FROM dbo.CTM_Tickets WHERE Id = %d AND Account = '%s'", $get_ticket);
             if ($this->DB->CountRows($get_ticket) < 1) {
                 return exit(showMessage(sprintf($this->lang->words['UserPanel']['SupportTickets']['ErrorMessage'], CoreVariables::ErrorsCode()->TicketNotFound), 2));
             }
             $ticket = $this->DB->FetchObject($get_ticket);
             switch ($_GET['do']) {
                 case "show_annex":
                     if (!empty($ticket->Annex)) {
                         $filename = $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['TICKET_ANNEX'] . $ticket->Annex;
                         if (preg_match("/\\.([gif|jpg|jpeg|png])/i", substr($filename, strrpos($filename, ".")))) {
                             header("Location: " . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['TICKET_ANNEX'] . $ticket->Annex);
                         } else {
                             header("Content-type: text/plain");
                             readfile($filename);
                         }
                     }
                     exit;
                     break;
                 case "reply":
                     if (empty($_POST['ReplyMessage'])) {
                         exit(showMessage($this->lang->words['UserPanel']['SupportTickets']['ShowTicket']['Messages']['ReplyVoid'], 1));
                     } else {
                         $message = htmlEncode(nl2br(strip_tags($_POST['ReplyMessage'])));
                         $insert_columns = array("TicketID" => $ticket_id, "Author" => "%s", "Account" => "%s", "Date" => time(), "Message" => "%s");
                         $this->DB->Arguments($ticket->Character, USER_ACCOUNT, htmlEncode(nl2br(strip_tags($_POST['ReplyMessage']))));
                         $this->DB->Insert("CTM_TicketReplies", $insert_columns);
                         $this->DB->Arguments($ticket_id, USER_ACCOUNT);
                         $this->DB->Update("CTM_Tickets", array("Status" => 2), "Id = %d AND Account = '%s'");
                         exit("<script>CTM.AjaxLoad('?app=core&module=userpanel&option=supportTickets&showticket=" . $ticket_id . "', 'showTicket');</script>");
                     }
                     break;
                 case "close":
                     if ($ticket->Status == 3) {
                         exit(showMessage($this->lang->words['UserPanel']['SupportTickets']['ShowTicket']['Messages']['IsClosed'], 2));
                     } else {
                         $this->DB->Arguments($ticket_id, USER_ACCOUNT);
                         $this->DB->Query("UPDATE dbo.CTM_Tickets SET Status = 3 WHERE Id = %d AND Account = '%s'");
                         $string = "<script>changeTicketStatus(";
                         $string .= "'" . $ticket->Id . "','";
                         $string .= str_replace("'", "\\'", htmlEncode($this->settings['USERPANEL']['SUPPORT']['TICKETS']['DEPARTAMENTS'][$ticket->Departament])) . "',";
                         $string .= "'" . str_replace("'", "\\'", $ticket->Subject) . "',";
                         $string .= "'" . date("d/m/Y - H:i", $ticket->Date) . "',";
                         $string .= "'<span style=\\'color: red;\\'>";
                         $string .= str_replace("'", "\\'", $this->lang->words['UserPanel']['SupportTickets']['Status']['Closed']);
                         $string .= "</span>',3);</script>" . showMessage($this->lang->words['UserPanel']['SupportTickets']['ShowTicket']['Messages']['Closed'], 3);
                         exit($string);
                     }
                     break;
             }
             switch ($ticket->Status) {
                 case 0:
                     $status = "<span style='color: blue;'>" . $this->lang->words['UserPanel']['SupportTickets']['Status']['Opened'] . "</span>";
                     break;
                 case 1:
                     $status = "<span style='color: green;'>" . $this->lang->words['UserPanel']['SupportTickets']['Status']['Responded'] . "</span>";
                     break;
                 case 2:
                     $status = "<span style='color: orange;'>" . $this->lang->words['UserPanel']['SupportTickets']['Status']['Progress'] . "</span>";
                     break;
                 case 3:
                     $status = "<span style='color: red;'>" . $this->lang->words['UserPanel']['SupportTickets']['Status']['Closed'] . "</span>";
                     break;
             }
             $this->DB->Arguments($ticket_id);
             $this->DB->Query("SELECT * FROM dbo.CTM_TicketReplies WHERE TicketID = %d ORDER BY Id DESC", $get_replies);
             $replies = array();
             if ($this->DB->CountRows($get_replies) > 0) {
                 while ($_reply = $this->DB->FetchObject($get_replies)) {
                     $replies[] = array("author" => $_reply->Author, "date" => date("d/m/Y - h:i a", $_reply->Date), "message" => htmlDecode($_reply->Message));
                 }
             }
             $GLOBALS['userpanel']['support_tickets']['show_ticket'] = array("id" => $ticket_id, "departament" => htmlEncode($this->settings['USERPANEL']['SUPPORT']['TICKETS']['DEPARTAMENTS'][$ticket->Departament]), "subject" => htmlDecode($ticket->Subject), "character" => $ticket->Character, "status" => $status, "date" => date("d/m/Y - h:i a", $ticket->Date), "message" => htmlDecode($ticket->Text), "_replies" => $replies, "_opened" => $ticket->Status < 3);
             if (strlen($ticket->Annex) > 1) {
                 $GLOBALS['userpanel']['support_tickets']['show_ticket']['annex'] = array("link" => "?app=core&amp;module=userpanel&amp;option=supportTickets&amp;section=show&amp;id=" . $ticket_id . "&amp;do=show_annex", "name" => $ticket->Annex);
             }
             $this->lang->setArguments("UserPanel,SupportTickets,ShowTicket,Title", "#" . $ticket_id);
             return $this->LoadPage("option_supportTickets_show", true);
             break;
         case "open":
             $departament = !is_null($_GET['departament']) ? $_GET['departament'] : $this->URLData[3];
             if (is_null($departament) || !array_key_exists($departament, $this->settings['USERPANEL']['SUPPORT']['TICKETS']['DEPARTAMENTS'])) {
                 if ($_GET['write'] == true) {
                     exit(showMessage($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['SelectDepartament'], 2));
                 }
                 return $this->LoadPage("option_supportTickets_open", true);
             } else {
                 if ($_GET['write'] == true) {
                     $error = $this->LoadClass("Error", "class_sources");
                     if (empty($_POST['Subject'])) {
                         $error->addError($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['SubjectVoid'], 0);
                     }
                     if (empty($_POST['Character'])) {
                         $error->addError($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['SelectCharacter'], 0);
                     }
                     if (empty($_POST['Text'])) {
                         $error->addError($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['MessageVoid'], 0);
                     }
                     if ($error->count[0] > 0) {
                         $_error = "<strong>" . $this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['VoidMessage'] . "<strong><br />";
                         exit(showMessage($_error . "<br />" . $error->showError(0), 1));
                     } else {
                         if ($this->settings['USERPANEL']['SUPPORT']['TICKETS']['LIMIT_OPEN'] > 0) {
                             $this->DB->Arguments(USER_ACCOUNT);
                             $this->DB->Query("SELECT 1 FROM dbo.CTM_Tickets WHERE Account = '%s' AND Status < 3");
                             if ($this->DB->CountRows() >= $this->settings['USERPANEL']['SUPPORT']['TICKETS']['LIMIT_OPEN']) {
                                 exit(showMessage($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['LimitReached'], 2));
                             }
                         }
                         $current_id = $this->DB->Query("SELECT Id FROM dbo.CTM_Tickets ORDER BY Id DESC");
                         $current_id = $this->DB->FetchRow($current_id);
                         $current_id = strlen($current_id[0]) < 1 ? 0 : $current_id[0];
                         $protocol = date("Y") . str_pad($current_id, 6, "1", STR_PAD_LEFT);
                         if ($_POST['u_sendFile'] == 1) {
                             if ($_POST['u_ready'] == 1) {
                                 $size = $this->settings['WEBDATA']['UPLOADS']['FILESIZE']['TICKET_ANNEX'];
                                 $dir = CTM_ROOT_PATH . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['TICKET_ANNEX'];
                                 Uploadify::set("Filedata", $size, array("gif", "jpg", "jpeg", "png", "txt", "log"), $protocol, $dir, $session);
                                 exit("<script>startUpload('{$protocol}', '{$session}');</script>");
                             }
                         }
                         if ($_POST['u_sendFile'] == 1) {
                             $data = unserialize(base64_decode($_POST['u_fileUploaded']));
                             $annex = $data['parsed_file_name'];
                             if (!$data) {
                                 exit(showMessage($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['AnnexError'], 2));
                             } elseif ($data['error_no'] == 2) {
                                 $this->lang->setArguments("UserPanel,SupportTickets,OpenTicket,Messages,ErrorFormat", "<b>JPEG</b>, <b>GIF</b>, <b>PNG</b>, <b>TXT/LOG</b>");
                                 exit(showMessage($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['ErrorFormat'], 2));
                             } elseif ($data['error_no'] == 3) {
                                 $this->lang->setArguments("UserPanel,ChangeAvatar,Messages,ErrorSize", "<b>" . $data['max_file_size'] . "</b>");
                                 exit(showMessage($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['ErrorSize'], 2));
                             } elseif ($data['error_no'] != 0) {
                                 exit(showMessage($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['AnnexError'], 2));
                             }
                         }
                         $columns_insert = array("Account" => USER_ACCOUNT, "Character" => $_POST['Character'], "Protocol" => $protocol, "Status" => 0, "Subject" => htmlEncode($_POST['Subject']), "Departament" => intval($_GET['departament']), "Date" => time(), "Text" => htmlEncode(nl2br(strip_tags($_POST['Text']))), "Annex" => $annex);
                         //$this->DB->ForceDataType("Protocol", "integer");
                         $this->DB->ForceDataType("Status", "integer");
                         $this->DB->ForceDataType("Departament", "integer");
                         $this->DB->ForceDataType("Date", "integer");
                         $this->DB->ForceDataType("Annex", empty($annex) ? "null" : "string");
                         $this->DB->Insert("CTM_Tickets", $columns_insert);
                         $this->WriteLog(array("option" => "Support Tickets", "character" => false, "data" => array("Protocol: " . $protocol, "Subject: " . strip_tags($_POST['Subject']), "Departament: " . $this->settings['USERPANEL']['SUPPORT']['TICKETS']['DEPARTAMENTS'][intval($_GET['departament'])], "Character: " . $_POST['Character'], "Annex: " . (!empty($annex) ? $annex : "None"))));
                         exit(showMessage(sprintf($this->lang->words['UserPanel']['SupportTickets']['OpenTicket']['Messages']['Success'], $protocol), 3));
                     }
                 }
                 $GLOBALS['userpanel']['support_tickets']['open_ticket']['departament'] = !is_null($_GET['departament']) ? $_GET['departament'] : $this->URLData[3];
                 $GLOBALS['userpanel']['support_tickets']['open_ticket']['characters'] = array();
                 $this->DB->Arguments(USER_ACCOUNT);
                 $this->DB->Query("SELECT Name FROM " . MUGEN_CORE . ".dbo.Character WHERE AccountID = '%s'", $find_characters_q);
                 if ($this->DB->CountRows($find_characters_q) > 0) {
                     while ($find_characters = $this->DB->FetchObject($find_characters_q)) {
                         $GLOBALS['userpanel']['support_tickets']['open_ticket']['characters'][] = $find_characters->Name;
                     }
                 }
                 return $this->LoadPage("option_supportTickets_open_form", true);
             }
             break;
         default:
             if ($_GET['showticket']) {
                 $GLOBALS['userpanel']['support_tickets']['auto_load_ticket'] = $_GET['showticket'];
             } elseif (strstr($this->URLData[2], "showticket-")) {
                 $GLOBALS['userpanel']['support_tickets']['auto_load_ticket'] = str_replace("showticket-", NULL, $this->URLData[2]);
             }
             break;
     }
 }
Ejemplo n.º 3
0
 /**
  *	Option: Invoices
  *	Invoices of payments
  *
  *	@return	void
  */
 public function Invoices()
 {
     switch ($_GET['section'] ? $_GET['section'] : $this->URLData[2]) {
         case "list":
             $this->DB->Arguments(USER_ACCOUNT);
             $this->DB->Query("SELECT Id, Document, Status, StartDate, [Value], CoinQuantity FROM dbo.CTM_Invoices WHERE Account = '%s' ORDER BY Id DESC", $all_invoices_q);
             $invoices_opened = array();
             $invoices_finalized = array();
             $invoices_canceled = array();
             if ($this->DB->CountRows($all_invoices_q) > 0) {
                 while ($all_invoices = $this->DB->FetchObject($all_invoices_q)) {
                     switch ($all_invoices->Status) {
                         case 0:
                             $var_name = "invoices_opened";
                             $status = "<span style='color: #C00;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['Pending'] . "</span>";
                             break;
                         case 1:
                             $var_name = "invoices_opened";
                             $status = "<span style='color: blue;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['InProgress'] . "</span>";
                             break;
                         case 2:
                             $var_name = "invoices_finalized";
                             $status = "<span style='color: green;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['Paid'] . "</span>";
                             break;
                         case 3:
                             $var_name = "invoices_finalized";
                             $status = "<span style='color: red;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['Rejected'] . "</span>";
                             break;
                         case 4:
                             $var_name = "invoices_canceled";
                             $status = "<span style='color: #CCC;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['Canceled'] . "</span>";
                             break;
                     }
                     ${$var_name}[$all_invoices->Id] = array("document" => $all_invoices->Document, "quantity" => number_format($all_invoices->CoinQuantity, 0, false, ".") . " " . COIN_NAME_1, "value" => CTM_Text::MoneyFormat(MONEY_SYMBOL, $all_invoices->Value), "date" => date("d/m/Y - h:i a", $all_invoices->StartDate), "status" => $status);
                 }
             }
             $GLOBALS['userpanel']['invoices']['auto_load_invoice'] = $_GET['showinvoice'] ? $_GET['showinvoice'] : $this->URLData[3];
             $GLOBALS['userpanel']['invoices']['list_invoices'] = array("opened" => $invoices_opened, "finalized" => $invoices_finalized, "canceled" => $invoices_canceled);
             unset($invoices_opened);
             unset($invoices_finalized);
             unset($invoices_canceled);
             return $this->LoadPage("option_invoices_list", true);
             break;
         case "show":
             $invoice_id = intval($_GET['id'] ? $_GET['id'] : $this->URLData[3]);
             $section = $_GET['do'] ? $_GET['do'] : $this->URLData[4];
             $this->DB->Arguments($invoice_id, USER_ACCOUNT);
             $this->DB->Query("SELECT * FROM dbo.CTM_Invoices WHERE Id = %d AND Account = '%s'", $get_invoice);
             if ($this->DB->CountRows($get_invoice) < 1) {
                 return exit(showMessage(sprintf($this->lang->words['UserPanel']['Invoices']['ErrorMessage'], CoreVariables::ErrorsCode()->PaymentNotFound), 2));
             }
             $invoice = $this->DB->FetchObject($get_invoice);
             if ($section) {
                 switch ($section) {
                     case "payment":
                         $this->DB->Arguments($invoice_id, USER_ACCOUNT);
                         $this->DB->Query("SELECT * FROM dbo.CTM_Payments WHERE InvoiceId = %d AND Account = '%s'", $get_payment);
                         if ($this->DB->CountRows($get_payment) < 1) {
                             if ($invoice->Status != 0 && $invoice->Status != 3) {
                                 exit(showMessage($this->lang->words['UserPanel']['Invoices']['ShowInvoice']['Messages']['InvoiceInProgress'], 0));
                             }
                             $method = strlen($_GET['method']) > 0 ? $_GET['method'] : $this->URLData[5];
                             if (strlen($method) < 1 || !array_key_exists($method, $this->settings['PAYMENTMETHOD']['FORM'])) {
                                 $GLOBALS['userpanel']['payments']['confirm_payment']['invoice_id'] = $invoice_id;
                                 if ($_GET['write'] == true) {
                                     exit(showMessage($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['SelectMethod'], 2));
                                 }
                                 return $this->LoadPage("option_payments_confirm", true);
                             } else {
                                 $error = $this->LoadClass("Error", "class_sources");
                                 $method = intval($method);
                                 if ($_GET['write'] == true) {
                                     if (empty($_POST['Date'])) {
                                         $error->addError($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['DateVoid'], 0);
                                     }
                                     if (empty($_POST['Hour'])) {
                                         $error->addError($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['HourVoid'], 0);
                                     }
                                     if (empty($_POST['Value'])) {
                                         $error->addError($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['ValueVoid'], 0);
                                     }
                                     if (empty($_POST['Local'])) {
                                         $error->addError($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['LocalVoid'], 0);
                                     }
                                     foreach ($this->settings['PAYMENTMETHOD']['FORM'][$method][1] as $key => $value) {
                                         if (empty($_POST[$key])) {
                                             $error->addError(htmlEncode($value), 0);
                                         }
                                     }
                                     if ($error->count[0] > 0) {
                                         $_error = "<strong>" . $this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['VoidMessage'] . "<strong><br />";
                                         exit(showMessage($_error . "<br />" . $error->showError(0), 1));
                                     } else {
                                         if ($_POST['u_sendFile'] == 1) {
                                             if ($_POST['u_ready'] == 1) {
                                                 $name = str_pad($this->DB->GetCurrentId("CTM_Payments") + 1, 10, 0, STR_PAD_LEFT);
                                                 $size = $this->settings['WEBDATA']['UPLOADS']['FILESIZE']['PAYMENT_ANNEX'];
                                                 $dir = CTM_ROOT_PATH . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['PAYMENT_ANNEX'];
                                                 Uploadify::set("Filedata", $size, array("gif", "jpg", "jpeg", "png"), $name, $dir, $session);
                                                 exit("<script>startUpload('{$name}', '{$session}');</script>");
                                             } else {
                                                 $data = unserialize(base64_decode($_POST['u_fileUploaded']));
                                                 $annex = $data['parsed_file_name'];
                                                 if (!$data) {
                                                     exit(showMessage($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['AnnexError'], 2));
                                                 } elseif ($data['error_no'] == 2) {
                                                     $this->lang->setArguments("UserPanel,Payments,ConfirmPayment,Messages,ErrorFormat", "<b>JPEG</b>, <b>GIF</b>, <b>PNG</b>");
                                                     exit(showMessage($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['ErrorFormat'], 2));
                                                 } elseif ($data['error_no'] == 3) {
                                                     $this->lang->setArguments("UserPanel,Payments,ConfirmPayment,Messages,ErrorSize", "<b>" . $data['max_file_size'] . "</b>");
                                                     exit(showMessage($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['ErrorSize'], 2));
                                                 } elseif ($data['error_no'] != 0) {
                                                     exit(showMessage($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['AnnexError'], 2));
                                                 }
                                             }
                                         }
                                         $payment_data = array();
                                         foreach ($this->settings['PAYMENTMETHOD']['FORM'][$method][1] as $key => $value) {
                                             $payment_data[$key] = utf8_encode($_POST[$key]);
                                         }
                                         $columns_insert = array("Account" => USER_ACCOUNT, "InvoiceId" => $invoice_id, "Status" => 0, "ConfirmDate" => time(), "Method" => $method, "Date" => $_POST['Date'], "Hour" => $_POST['Hour'], "Value" => $_POST['Value'], "Local" => utf8_encode($_POST['Local']), "ConfirmData" => serialize($payment_data), "Message" => htmlEncode(nl2br(strip_tags($_POST['Message']))), "Annex" => $annex);
                                         $this->DB->ForceDataType("InvoiceId", "integer");
                                         $this->DB->ForceDataType("Status", "integer");
                                         $this->DB->ForceDataType("ConfirmDate", "integer");
                                         $this->DB->ForceDataType("Method", "integer");
                                         $this->DB->ForceDataType("Message", empty($_POST['Message']) ? "null" : "string");
                                         $this->DB->ForceDataType("Annex", empty($annex) ? "null" : "string");
                                         $this->DB->Insert("CTM_Payments", $columns_insert);
                                         $this->DB->Arguments($invoice_id);
                                         $this->DB->ForceDataType("Status", "integer");
                                         $this->DB->Update("CTM_Invoices", array("Status" => 1, "PaymentMethod" => "bank"), "Id = %d");
                                         return exit(showMessage($this->lang->words['UserPanel']['Payments']['ConfirmPayment']['Messages']['Success'], 3));
                                     }
                                 }
                                 $inputs = array();
                                 foreach ($this->settings['PAYMENTMETHOD']['FORM'][$method][1] as $key => $value) {
                                     $inputs[$key] = htmlEncode($value);
                                 }
                                 $GLOBALS['userpanel']['payments']['confirm_payment'] = array("invoice_id" => $invoice_id, "method_name" => htmlEncode($this->settings['PAYMENTMETHOD']['FORM'][$method][0]), "method_id" => $method, "method_fields" => $inputs);
                                 return $this->LoadPage("option_payments_confirm_form", true);
                             }
                         } else {
                             $payment = $this->DB->FetchObject($get_payment);
                             switch ($payment->Status) {
                                 case 0:
                                     $status = "<span style='color: blue;'>" . $this->lang->words['UserPanel']['Payments']['Status']['Opened'] . "</span>";
                                     break;
                                 case 1:
                                     $status = "<span style='color: green;'>" . $this->lang->words['UserPanel']['Payments']['Status']['Confirmed'] . "</span>";
                                     break;
                                 case 2:
                                     $status = "<span style='color: red;'>" . $this->lang->words['UserPanel']['Payments']['Status']['Rejected'] . "</span>";
                                     break;
                             }
                             if (!($payment_data = unserialize($payment->ConfirmData))) {
                                 $payment_data = array();
                             }
                             $GLOBALS['userpanel']['payments']['show_payment'] = array("id" => $payment_id, "method" => htmlEncode($this->settings['PAYMENTMETHOD']['FORM'][$payment->Method][0]), "confirm_date" => date("d/m/Y - h:i a", $payment->ConfirmDate), "status" => $status, "quantity" => number_format($payment->Quantity, 0, false, ".") . " " . COIN_NAME_1, "date" => $payment->Date, "hour" => $payment->Hour, "value" => $payment->Value, "local" => utf8_decode($payment->Local), "message" => htmlDecode($payment->Message), "payment_data" => $payment_data);
                             if (strlen($payment->Annex) > 1) {
                                 $GLOBALS['userpanel']['payments']['show_payment']['annex'] = array("link" => $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['PAYMENT_ANNEX'] . $payment->Annex, "name" => $payment->Annex);
                             }
                             return $this->LoadPage("option_payments_show", true);
                         }
                         break;
                 }
             }
             switch ($invoice->Status) {
                 case 0:
                     $status = "<span style='color: #C00;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['Pending'] . "</span>";
                     break;
                 case 1:
                     $status = "<span style='color: blue;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['InProgress'] . "</span>";
                     break;
                 case 2:
                     $status = "<span style='color: green;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['Paid'] . "</span>";
                     break;
                 case 3:
                     $status = "<span style='color: red;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['Rejected'] . "</span>";
                     break;
                 case 4:
                     $status = "<span style='color: #CCC;'>" . $this->lang->words['UserPanel']['Invoices']['Status']['Canceled'] . "</span>";
                     break;
             }
             $GLOBALS['userpanel']['invoices']['show_invoice'] = array("id" => $invoice_id, "document" => $invoice->Document, "start_date" => date("d/m/Y - h:i a", $invoice->StartDate), "quantity" => number_format($invoice->CoinQuantity, 0, false, "."), "value" => CTM_Text::MoneyFormat(MONEY_SYMBOL, $invoice->Value), "status" => $status, "canceled" => $invoice->Status == 4);
             if ($invoice->Status > 0 && $invoice->PaymentMethod != "none") {
                 if (!($payment_data = unserialize($invoice->PaymentData))) {
                     $payment_data = array();
                 }
                 switch ($invoice->PaymentMethod) {
                     case "bank":
                         $method_name = $this->lang->words['UserPanel']['Invoices']['Methods']['Bank'];
                         break;
                 }
                 $GLOBALS['userpanel']['invoices']['show_invoice']['payment_method'] = array("method" => $method_name, "data" => $payment_data, "key" => $invoice->PaymentMethod);
             }
             $this->lang->setArguments("UserPanel,Invoices,ShowInvoice,Title", $invoice_id);
             return $this->LoadPage("option_invoices_show", true);
             break;
         case "open":
             if ($this->settings['USERPANEL']['FINANCIAL']['INVOICES']['LIMIT_OPENED'] > 0) {
                 $this->DB->Arguments(USER_ACCOUNT);
                 $this->DB->Query("SELECT 1 FROM dbo.CTM_Invoices WHERE Account = '%s' AND Status < 2", $count_invoices);
                 if ($this->DB->CountRows($count_invoices) >= $this->settings['USERPANEL']['FINANCIAL']['INVOICES']['LIMIT_OPENED']) {
                     $limit = $this->settings['USERPANEL']['FINANCIAL']['INVOICES']['LIMIT_OPENED'];
                     exit(showMessage(sprintf($this->lang->words['UserPanel']['Invoices']['OpenInvoice']['Messages']['LimitReached'], $limit), 2));
                 }
             }
             if ($_GET['write'] == true) {
                 if (empty($_POST['Quantity'])) {
                     exit(showMessage($this->lang->words['UserPanel']['Invoices']['OpenInvoice']['Messages']['QuantityVoid'], 1));
                 }
                 if (!is_numeric($_POST['Quantity'])) {
                     exit(showMessage($this->lang->words['UserPanel']['Invoices']['OpenInvoice']['Messages']['QuantitySyntax'], 2));
                 }
                 $_POST['Quantity'] = ltrim($_POST['Quantity'], 0);
                 $money_value = COIN_PRICE * $_POST['Quantity'];
                 if (strstr($money_value, ".")) {
                     list($note, $coin) = explode(".", $money_value);
                     if (strlen($coin) > 2) {
                         $coin = substr($coin, 0, 2);
                     }
                     while ($coin % 5 != 0 && $coin > 0) {
                         if ($coin < 5 && $coin > 0) {
                             $coin = 5;
                         } else {
                             $coin++;
                         }
                     }
                     if (strlen($coin) == 1) {
                         $coin = "0" . $coin;
                     }
                     $final_money = $note . "." . $coin;
                 } else {
                     $final_money = $money_value . ".00";
                 }
                 if ($_GET['confirm'] == true) {
                     $insert_columns = array("Account" => USER_ACCOUNT, "StartDate" => time(), "EndDate" => 0, "Value" => $final_money, "CoinQuantity" => $_POST['Quantity'], "Status" => 0);
                     $this->DB->Insert("CTM_Invoices", $insert_columns);
                     $last_id = $this->DB->GetLastedId();
                     $this->DB->Update("CTM_Invoices", array("Document" => INVOICE_PREFIX . $last_id), "Id = " . $last_id);
                     exit("<script>runOpenInvoice({$last_id});</script>");
                 } else {
                     exit("<script>showConfirmMessage('" . CTM_Text::MoneyFormat(MONEY_SYMBOL, $final_money) . "');</script>");
                 }
             }
             $GLOBALS['default_value'] = str_replace(MONEY_SYMBOL . " ", NULL, CTM_Text::MoneyFormat(MONEY_SYMBOL, COIN_PRICE));
             return $this->LoadPage("option_invoices_open", true);
             break;
         default:
             if ($_GET['showinvoice']) {
                 $GLOBALS['userpanel']['invoices']['auto_load_invoice'] = $_GET['showinvoice'];
             } elseif (strstr($this->URLData[2], "showinvoice-")) {
                 $GLOBALS['userpanel']['invoices']['auto_load_invoice'] = str_replace("showinvoice-", NULL, $this->URLData[2]);
             }
             break;
     }
 }