Beispiel #1
0
 /**
  *	Init Module
  *
  *	@return	void
  */
 public function initSection()
 {
     switch ($_GET['message']) {
         case "isClosed":
             $GLOBALS['result_message'] = adminShowMessage($this->lang->words['EWFinancial']['Invoices']['ManageInvoices']['Messages']['IsClosed'], 2);
             break;
         case "deleted":
             $GLOBALS['result_message'] = adminShowMessage($this->lang->words['EWFinancial']['Invoices']['ManageInvoices']['Messages']['Deleted'], 3);
             break;
     }
     $GLOBALS['all_invoices'] = array();
     $find_invoices = $this->DB->Query("SELECT Id, Document, Status, StartDate, [Value], CoinQuantity FROM dbo.CTM_Invoices ORDER BY Id DESC, Status ASC");
     if ($this->DB->CountRows($find_invoices) > 0) {
         while ($all_invoices = $this->DB->FetchObject($find_invoices)) {
             $GLOBALS['all_invoices'][$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" => $all_invoices->Status);
         }
     }
     $this->output->setContent("invoices_manageInvoices");
 }
Beispiel #2
0
 /**
  *	Send Mail
  *
  *	@return	boolean
  */
 public function SendMail()
 {
     $this->WriteDebug("Start Mailer");
     if ($this->loadCheckVars() == false) {
         $this->FinishCommand();
         return false;
     }
     if ($this->SendMethod == 1) {
         if ($this->loadSMTPData() == false) {
             $this->FinishCommand();
             return false;
         }
         $this->PHPMailer->IsSMTP();
         $this->PHPMailer->Host = $this->SMTPHost;
         $this->PHPMailer->Port = $this->SMTPPort;
         $this->PHPMailer->Username = $this->SMTPUser;
         $this->PHPMailer->Password = $this->SMTPPass;
         $this->PHPMailer->SMTPKeepAlive = TRUE;
     } else {
         $this->PHPMailer->IsMail();
     }
     $this->PHPMailer->SetFrom($this->FromMail[0], CTM_Text::UTF8Text($this->FromMail[1]));
     $this->WriteDebug("Mailer method: " . ($this->SendMethod == 1 ? "SMTP" : "PHP mail()"));
     $this->WriteDebug("E-Mail subject: " . (!$this->vars['subject'] ? "NULL" : $this->PHPMailer->Subject));
     $this->WriteDebug("E-Mail from: " . ($this->FromMail[1] ? CTM_Text::UTF8Text($this->FromMail[1]) . " <" . $this->FromMail[0] . ">" : $this->FromMail[0]));
     foreach ($this->data['address'] as $value) {
         $this->WriteDebug("Send e-mail to: " . ($value[1] ? $value[1] . " <" . $value[0] . ">" : $value[0]));
     }
     if (!$this->PHPMailer->Send()) {
         $this->WriteDebug($this->PHPMailer->ErrorInfo);
         $this->FinishCommand();
         return false;
     } else {
         $this->WriteDebug("E-Mail(s) sended with success");
         $this->FinishCommand();
         return true;
     }
 }
Beispiel #3
0
 /**
  *	Init Module
  *
  *	@return	void
  */
 public function initSection()
 {
     $this->DB->Arguments($_GET['id']);
     $find_invoice_q = $this->DB->Query("SELECT * FROM dbo.CTM_Invoices WHERE Id = %d");
     if ($this->DB->CountRows($find_ticket_q) > 0) {
         $invoice = $this->DB->FetchObject($find_invoice_q);
         define("EDIT_INVOICE_ACCESS", $this->CheckPermissionItem("edit_ticket"));
         define("DELETE_INVOICE_ACCESS", $this->CheckPermissionItem("delete_ticket"));
         switch ($_GET['cmd']) {
             case "approve":
                 if ($invoice->Status != 0 && $invoice->Status != 1) {
                     exit(adminShowMessage($this->lang->words['EWFinancial']['Invoices']['ViewInvoice']['Messages']['IsClosed'], 2));
                 } else {
                     $quantity = (int) $_GET['quantity'];
                     if ($quantity < 0) {
                         exit(adminShowMessage($this->lang->words['EWFinancial']['Invoices']['ViewInvoice']['ApproveInvoice']['Messages']['SetNumber'], 2));
                     } else {
                         $this->DB->Arguments($invoice->Account, 1, $quantity, intval(COIN_USE_CACHE));
                         $this->DB->Query("EXEC dbo.CTM_PlusAccountCoin '%s', %d, %d, %d");
                         $this->DB->Arguments($_GET['id']);
                         $this->DB->ForceDataType("Status", "integer");
                         $this->DB->Update("CTM_Invoices", array("Status" => 2), "Id = %d");
                         exit("<script>approveThisInvoice('" . $quantity . "', '" . $invoice->Account . "');");
                     }
                 }
                 break;
             case "reject":
                 if ($invoice->Status != 0 && $invoice->Status != 1) {
                     exit(adminShowMessage($this->lang->words['EWFinancial']['Invoices']['ViewInvoice']['Messages']['IsClosed'], 2));
                 } else {
                     $this->DB->Arguments($_GET['id']);
                     $this->DB->ForceDataType("Status", "integer");
                     $this->DB->Update("CTM_Invoices", array("Status" => 3), "Id = %d");
                     exit("<script>rejectThisInvoice();");
                 }
                 break;
             case "edit":
                 if (EDIT_INVOICE_ACCESS == TRUE) {
                     if ($_POST['Quantity'] == NULL || $_POST['Value'] == NULL || $_POST['Status'] == NULL) {
                         exit(adminShowMessage($this->lang->words['EWFinancial']['Invoices']['ViewInvoice']['EditInvoice']['Messages']['FieldsVoid'], 1));
                     } elseif (!is_numeric($_POST['Quantity'])) {
                         exit(adminShowMessage($this->lang->words['EWFinancial']['Invoices']['ViewInvoice']['EditInvoice']['Messages']['InvalidQuantity'], 2));
                     } elseif ($_POST['Status'] != 0 && $_POST['Status'] != 1 && $_POST['Status'] != 2 && $_POST['Status'] != 3 && $_POST['Status'] != 4) {
                         exit(adminShowMessage($this->lang->words['EWFinancial']['Invoices']['ViewInvoice']['EditInvoice']['Messages']['InvalidStatus'], 2));
                     } else {
                         $update = array("CoinQuantity" => $_POST['Quantity'], "Value" => $_POST['Value'], "Status" => $_POST['Status']);
                         $this->DB->ForceDataType("Quantity", "integer");
                         $this->DB->ForceDataType("Value", "string");
                         $this->DB->ForceDataType("Status", "integer");
                         $this->DB->Arguments($_GET['id']);
                         $this->DB->Update("CTM_Invoices", $update, "Id = %d");
                         switch ($_POST['Status']) {
                             case 0:
                                 $status = "<span style='color: #C00;'>" . $this->lang->words['EWFinancial']['Invoices']['Status']['Pending'] . "</span>";
                                 break;
                             case 1:
                                 $status = "<span style='color: blue;'>" . $this->lang->words['EWFinancial']['Invoices']['Status']['InProgress'] . "</span>";
                                 break;
                             case 2:
                                 $status = "<span style='color: green;'>" . $this->lang->words['EWFinancial']['Invoices']['Status']['Paid'] . "</span>";
                                 break;
                             case 3:
                                 $status = "<span style='color: red;'>" . $this->lang->words['EWFinancial']['Invoices']['Status']['Rejected'] . "</span>";
                                 break;
                             case 4:
                                 $status = "<span style='color: #666;'>" . $this->lang->words['EWFinancial']['Invoices']['Status']['Canceled'] . "</span>";
                                 break;
                         }
                         exit("<script>completeEditInvoice('" . $_POST['Quantity'] . "', '" . str_replace("'", "\\'", $_POST['Value']) . "', '" . str_replace("'", "\\'", $status) . "', " . $_POST['Status'] . ");</script>");
                     }
                 }
                 break;
             case "reopen":
                 if ($invoice->Status == 0) {
                     exit(adminShowMessage($this->lang->words['EWFinancial']['Invoices']['ViewInvoice']['Messages']['IsOpened'], 2));
                 } else {
                     $this->DB->Arguments($_GET['id']);
                     $this->DB->ForceDataType("Status", "integer");
                     $this->DB->Update("CTM_Invoices", array("Status" => 0), "Id = %d");
                     exit("<script>reopenThisInvoice();");
                 }
                 break;
             case "delete":
                 if (DELETE_INVOICE_ACCESS) {
                     $query = "DELETE FROM dbo.CTM_Invoices WHERE Id = %d;\n";
                     $query .= "DELETE FROM dbo.CTM_Payments WHERE InvoiceID = %d;";
                     $this->DB->Arguments($_GET['id'], $_GET['id']);
                     $this->DB->Query($query);
                     if (!empty($ticket->Annex)) {
                         if (file_exists("../" . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['PAYMENT_ANNEX'] . $ticket->Annex)) {
                             unlink("../" . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['PAYMENT_ANNEX'] . $ticket->Annex);
                         }
                     }
                     exit("<script>location.href='" . $this->acp_vars['acp_url'] . "?app=effectweb&module=financial&section=invoices&message=deleted';</script>");
                 }
                 break;
         }
         $GLOBALS['view_invoice'] = array("id" => $_GET['id'], "method_key" => $invoice->PaymentMethod, "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), "account" => $invoice->Account, "status" => $invoice->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['EWFinancial']['Invoices']['Methods']['Bank'];
                     $this->DB->Arguments($invoice->Id);
                     $this->DB->Query("SELECT * FROM dbo.CTM_Payments WHERE InvoiceId = %d", $find_payment);
                     if ($this->DB->CountRows($find_payment) > 0) {
                         $payment = $this->DB->FetchObject($find_payment);
                         switch ($payment->Status) {
                             case 0:
                                 $status = "<span style='color: blue;'>" . $this->lang->words['EWFinancial']['Invoices']['PaymentStatus']['Opened'] . "</span>";
                                 break;
                             case 1:
                                 $status = "<span style='color: green;'>" . $this->lang->words['EWFinancial']['Invoices']['PaymentStatus']['Confirmed'] . "</span>";
                                 break;
                             case 2:
                                 $status = "<span style='color: red;'>" . $this->lang->words['EWFinancial']['Invoices']['PaymentStatus']['Rejected'] . "</span>";
                                 break;
                         }
                         if (!($_payment_data = unserialize($payment->ConfirmData))) {
                             $_payment_data = array();
                         }
                         $GLOBALS['view_invoice']['bank_payment'] = array("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['view_invoice']['bank_payment']['annex'] = array("link" => $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['PAYMENT_ANNEX'] . $payment->Annex, "name" => $payment->Annex);
                         }
                     }
                     break;
             }
             $GLOBALS['view_invoice']['payment_method'] = array("method" => $method_name, "data" => $payment_data, "key" => $invoice->PaymentMethod);
         }
         if ($noOpenCache == false) {
             $this->output->setContent("invoices_viewInvoice");
         }
     }
 }
Beispiel #4
0
 /**
  *	Ajax Check Fields
  *
  *	@return	void
  */
 private function loadAjaxCheckFields()
 {
     if ($_GET['do'] == "ajaxCheck") {
         switch ($_GET['command']) {
             case "login":
                 if (empty($_GET['username'])) {
                     setAjaxField($this->lang->words['Register']['Register']['AjaxCheck']['Void'], array("Login", "LoginResult"), 0);
                 } elseif (strlen(urldecode($_GET['username'])) < 4) {
                     setAjaxField($this->lang->words['Register']['Register']['AjaxCheck']['MinLogin'], array("Login", "LoginResult"), 1);
                 } elseif (strlen(urldecode($_GET['username'])) > 10) {
                     setAjaxField($this->lang->words['Register']['Register']['AjaxCheck']['MaxLogin'], array("Login", "LoginResult"), 1);
                 } else {
                     $this->DB->Arguments(urldecode($_GET['username']));
                     $this->DB->Query("SELECT 1 FROM " . MUACC_CORE . ".dbo.MEMB_INFO WHERE LOWER(memb___id) = '%s'");
                     if ($this->DB->CountRows() > 0) {
                         setAjaxField($this->lang->words['Register']['Register']['AjaxCheck']['LoginExists'], array("Login", "LoginResult"), 1);
                     } else {
                         setAjaxField($this->lang->words['Register']['Register']['AjaxCheck']['LoginValid'], array("Login", "LoginResult"), 2);
                     }
                 }
                 break;
             case "mail":
                 if (empty($_GET['email'])) {
                     setAjaxField($this->lang->words['Register']['Register']['AjaxCheck']['Void'], array("Mail", "MailResult"), 0);
                 } elseif (!CTM_Text::checkMail(urldecode($_GET['email']))) {
                     setAjaxField($this->lang->words['Register']['Register']['AjaxCheck']['MailInvalid'], array("Mail", "MailResult"), 1);
                 } else {
                     $this->DB->Arguments(urldecode($_GET['email']));
                     $this->DB->Query("SELECT 1 FROM " . MUACC_CORE . ".dbo.MEMB_INFO WHERE LOWER(mail_addr) = '%s'");
                     if ($this->DB->CountRows() > 0) {
                         setAjaxField($this->lang->words['Register']['Register']['AjaxCheck']['MailExists'], array("Mail", "MailResult"), 1);
                     } else {
                         setAjaxField($this->lang->words['Register']['Register']['AjaxCheck']['MailValid'], array("Mail", "MailResult"), 2);
                     }
                 }
                 break;
         }
         exit;
     }
 }
 /**
  *	Option: Change Mail
  *	Change the e-mail from account
  *
  *	@return	void
  */
 public function ChangeMail()
 {
     switch ($_GET['do']) {
         case "send_code":
             $currentId = $this->DB->GetCurrentId("CTM_ChangeMail") + 1;
             $dechex = create_function("\$integer", "return str_pad(dechex(\$integer >= 255 ? 255 : \$integer), 2, 0, STR_PAD_LEFT);");
             $confirmCode = $dechex($currentId);
             $confirmCode .= ":" . $dechex(0xbb - strlen($this->userData['memb___id']) + mt_rand(0, 50));
             $confirmCode .= ":" . $dechex(strlen($this->userData['mail_addr']) + mt_rand(0, 50));
             $confirmCode .= ":" . $dechex(mt_rand(0, 70));
             $confirmCode .= ":" . $dechex(mt_rand(71, 170));
             $confirmCode .= ":" . $dechex(0xbb / intval(date("d")) + intval(date("H")) + intval(date("m")) + intval(date("s")) + mt_rand(0, 50));
             $confirmCode .= ":" . $dechex(0xbb / intval(date("m")) + intval(date("H")) + intval(date("m")) + intval(date("s")) + mt_rand(0, 50));
             $confirmCode .= ":" . $dechex(intval(date("Y")) / 0xbb + intval(date("H")) + intval(date("m")) + intval(date("s")) + mt_rand(0, 50));
             $confirmCode = strtoupper($confirmCode);
             $link = gerateFullLink("?/userpanel/changeMail");
             $this->DB->Insert("CTM_ChangeMail", array("Account" => $this->userData['info']['memb___id'], "ConfirmCode" => $confirmCode, "Expiration" => strtotime("+ 24 hours")));
             $this->email->arguments = array("NAME" => htmlEncode($this->userData['info']['memb_name']), "CONFIRM_CODE" => $confirmCode, "SYSTEM_LINK" => $link);
             $this->email->LoadTemplate("ChangeMemberMail");
             $this->email->GetMailContent($mail);
             $this->mailer->AddAddress($this->userData['info']['mail_addr'], $this->userData['info']['memb_name']);
             $this->mailer->SetSubject($mail['subject']);
             $this->mailer->SetBody($mail['content']);
             if ($this->mailer->SendMail() == true) {
                 $this->WriteLog(array("option" => "Change Mail", "data" => array("Process: Send Confirm Code", "Result: Success")));
                 return setResult(showMessage($this->lang->words['UserPanel']['ChangeMail']['Messages']['SendCode']['Success'], 3));
             } else {
                 $this->WriteLog(array("option" => "Change Mail", "data" => array("Process: Send Confirm Code", "Result: Error")));
                 $this->lang->setArguments("UserPanel,ChangeMail,Messages,Error_SendMail", CoreVariables::ErrorsCode()->SendMailError);
                 return setResult(showMessage($this->lang->words['UserPanel']['ChangeMail']['Messages']['SendCode']['Error_SendMail'], 2));
             }
             break;
         case "process":
             if (empty($_POST['NewMail']) || empty($_POST['ConfirmCode'])) {
                 return setResult(showMessage($this->lang->words['UserPanel']['ChangeMail']['Messages']['Process']['Void'], 1));
             }
             if (!CTM_Text::CheckMail($_POST['NewMail'])) {
                 return setResult(showMessage($this->lang->words['UserPanel']['ChangeMail']['Messages']['Process']['MailInvalid'], 2));
             }
             $this->DB->Arguments($_POST['ConfirmCode'], USER_ACCOUNT);
             $findConfirmCodeQ = $this->DB->Select("Expiration", "CTM_ChangeMail", "ConfirmCode = '%s' AND Account = '%s'");
             if ($this->DB->CountRows($findConfirmCodeQ) < 1) {
                 return setResult(showMessage($this->lang->words['UserPanel']['ChangeMail']['Messages']['Process']['CodeInvalid'], 2));
             }
             $findConfirmCode = $this->DB->FetchRow($findConfirmCodeQ);
             if (time() >= $findConfirmCode[0]) {
                 return setResult(showMessage($this->lang->words['UserPanel']['ChangeMail']['Messages']['Process']['CodeExpired'], 2));
             }
             $this->MuLib('Member')->UpdateAccount(USER_ACCOUNT, array("info" => array("mail_addr" => $_POST['NewMail'])));
             $this->DB->Arguments(USER_ACCOUNT, $_POST['ConfirmCode']);
             $this->DB->Delete("CTM_ChangeMail", "Account = '%s' AND ConfirmCode = '%s'");
             $this->WriteLog(array("option" => "Change Mail", "data" => array("Process: Change Mail", "New Mail: " . $_POST['NewMail'])));
             return setResult(showMessage($this->lang->words['UserPanel']['ChangeMail']['Messages']['Process']['Success'], 3));
             break;
         default:
             if (loadIsAjax() == true && LOADING_PAGE_AJAX == false) {
                 exit;
             }
             break;
     }
 }
 /**
  *	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;
     }
 }
 /**
  *	Get Server Name
  *	Get the real server name
  *
  *	@param	string	GameServer
  *	@return	string
  */
 public function GetServerName($GameServer)
 {
     $GameServer = !is_numeric($GameServer) ? $this->GetServerID($GameServer) : $GameServer;
     if (!array_key_exists($GameServer, $this->settings['SERVERLIST']['ROOM_LIST'])) {
         return $GameServer;
     } else {
         return CTM_Text::UTF8Text($this->settings['SERVERLIST']['ROOM_LIST'][$GameServer][1]);
     }
 }
 /**
  *	Send Global Message
  *	Send a global message by the JoinServer
  *
  *	@param	string	Message
  *	@return	void
  */
 public function SendGlobalMessage($message)
 {
     if ($this->settings['JoinServer'] != "WZ") {
         return false;
     }
     if (!$this->started) {
         if (!$this->init()) {
             return false;
         }
     }
     if (strlen($message) > 34) {
         $message = substr($message, 0, 34);
     }
     $packet = $this->packetsGlobMsg['WZ'] . "0024000000";
     $packet .= str_pad($this->loadConvertASCIIToHexa(CTM_Text::UTF8Text($message)), 68, 0, STR_PAD_RIGHT);
     $packet = $this->loadConvertHexaToASCII($packet . str_repeat("00", 26));
     $this->socket->WritePack($packet);
     $this->socket->CloseSocket();
     $this->started = false;
     return true;
 }
Beispiel #9
0
 /**
  *	Private: Manage Account
  *	Manage a account from database
  *
  *	@return	void
  */
 private function loadManageAccount()
 {
     if ($this->loadCheckAccount($_GET['username'], "login")) {
         $user_data = $this->MuLib('Member')->Load($_GET['username'] = urldecode($_GET['username']));
         switch ($_GET['do']) {
             case "ban":
                 if ($this->CheckPermissionItem("accounts_manageAccount_ban") == true) {
                     if ($_GET['write'] == true) {
                         if (empty($_POST['banReason']) || empty($_POST['banExpiration'])) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['BanAccount']['Messages']['FieldsVoid'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                         } else {
                             $date = explode("/", $_POST['banExpiration']);
                             if (count($date) != 3 || (strlen($date[0]) != 2 || strlen($date[1]) != 2 || strlen($date[2]) != 4)) {
                                 $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['BanAccount']['Messages']['DateInvalid'];
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             } elseif ($user_data['info']['bloc_code'] == 1 && $user_data['info']['MemberStatus'] == 0) {
                                 $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['BanAccount']['Messages']['AccountBanned'];
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             } else {
                                 $insert_columns = array("Responsible" => USER_ACCOUNT, "Account" => $_GET['username'], "Expiration" => $expiration = mktime(23, 59, 59, $date[0], $date[1], $date[2]), "Reason" => htmlEncode($_POST['banReason']));
                                 $this->DB->Arguments($_GET['username']);
                                 $this->DB->Delete("CTM_AccountsBanneds", "Account = '%s'");
                                 $this->DB->Arguments($_GET['username']);
                                 $this->DB->Update(MUACC_CORE . "@MEMB_INFO", array("bloc_code" => 1), "memb___id = '%s'");
                                 $this->DB->Insert("CTM_AccountsBanneds", $insert_columns);
                                 $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['BanAccount']['Messages']['Success'];
                                 $GLOBALS['result_command'] = adminShowMessage(sprintf($GLOBALS['result_command'], date("d/m/Y", $expiration)), 3);
                             }
                         }
                         if (loadIsAjax() == true) {
                             exit($GLOBALS['result_command']);
                         }
                     }
                     $this->output->setContent("accounts_banAccount");
                 }
                 break;
             case "unban":
                 if ($this->CheckPermissionItem("accounts_manageAccount_unban") == true) {
                     if ($_GET['write'] == true) {
                         if ($user_data['info']['bloc_code'] == 0) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['UnbanAccount']['Messages']['NoBanned'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                         } else {
                             $this->DB->Arguments($_GET['username']);
                             $this->DB->Delete("CTM_AccountsBanneds", "Account = '%s'");
                             $this->DB->Arguments($_GET['username']);
                             $this->DB->Update(MUACC_CORE . "@MEMB_INFO", array("bloc_code" => 0), "memb___id = '%s'");
                             if (loadIsAjax() == false) {
                                 $_GET['write'] = FALSE;
                                 $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['UnbanAccount']['Messages']['Success'];
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                                 if ($_GET['go'] == "banneds") {
                                     $this->loadBannedAccounts();
                                     $this->output->setContent("accounts_bannedAccounts");
                                 } else {
                                     $this->loadSearchAccounts();
                                     $this->output->setContent("accounts_search");
                                 }
                                 return NULL;
                             }
                         }
                         if (loadIsAjax() == true) {
                             exit($GLOBALS['result_command']);
                         }
                     }
                     if ($user_data['info']['bloc_code'] == 1 && $user_data['info']['MemberStatus'] == 0) {
                         $this->DB->Arguments($_GET['username']);
                         $accountBlockInfoQ = $this->DB->Select("Responsible,Expiration,Reason", "CTM_AccountsBanneds", "Account = '%s'");
                         if ($this->DB->CountRows($accountBlockInfoQ) > 0) {
                             $accountBlockInfo = $this->DB->FetchObject($accountBlockInfoQ);
                             $GLOBALS['block_info']['responsible'] = $accountBlockInfo->Responsible;
                             $GLOBALS['block_info']['expiration'] = date("d/m/Y - H:i", $accountBlockInfo->Expiration);
                             $GLOBALS['block_info']['reason'] = $accountBlockInfo->Reason;
                         } else {
                             $GLOBALS['block_info']['responsible'] = $this->lang->words['Words']['None'];
                             $GLOBALS['block_info']['expiration'] = $this->lang->words['Words']['Never'];
                             $GLOBALS['block_info']['reason'] = $this->lang->words['Words']['None'];
                         }
                     }
                     $this->output->setContent("accounts_unbanAccount");
                 }
                 break;
             case "manageVIP":
                 if ($this->CheckPermissionItem("accounts_manageAccount_manageVIP") == true) {
                     if ($_GET['command'] == "write") {
                         if ($_POST['VIPType'] != 1 && $_POST['VIPType'] != 2 && $_POST['VIPType'] != 3 && $_POST['VIPType'] != 4 && $_POST['VIPType'] != 5) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['ManageVIP']['Messages']['VIPInvalid'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                         } else {
                             if (empty($_POST['VIPDays']) || $_POST['VIPDays'] < 0) {
                                 $_POST['VIPDays'] = 0;
                             }
                             $timeVIP = $user_data['vip'][VIP_TIME] + $_POST['VIPDays'];
                             $beginVIP = strlen($user_data['vip'][VIP_BEGIN]) == 10 ? $user_data['vip'][VIP_BEGIN] : time();
                             $commandVIP = "Added";
                             if ($user_data['vip'][VIP_COLUMN] > 0) {
                                 if (strlen($user_data['vip'][VIP_TIME]) == 10) {
                                     $timeVIP = strtotime("+ " . $_POST['VIPDays'] . " days", $user_data['vip'][VIP_TIME]);
                                 }
                                 if ($_POST['VIPDays'] == 0) {
                                     $commandVIP = "Transformed";
                                 } else {
                                     $commandVIP = "Added";
                                 }
                             }
                             $this->DB->Arguments($_POST['VIPType'], $beginVIP, $timeVIP, $_GET['username']);
                             $this->DB->Query("UPDATE " . VIP_CORE . ".dbo." . VIP_TABLE . " SET " . VIP_COLUMN . " = %d, " . VIP_BEGIN . " = %d, " . VIP_TIME . " = %d WHERE " . VIP_LOGIN . " = '%s'");
                             $_timeVIP = $timeVIP;
                             $timeVIP = strlen($timeVIP) == 10 ? $timeVIP : strtotime("+ " . $timeVIP . " days");
                             $result_1 = $this->lang->words['Members']['Accounts']['ManageAccount']['ManageVIP']['Messages']['Success'][$commandVIP];
                             $result_1 = sprintf($result_1, $this->functions->AccountLevel($_POST['VIPType']), $_GET['username']);
                             $result_2 = $this->lang->words['Members']['Accounts']['ManageAccount']['ManageVIP']['Messages']['Success']['Expiration'];
                             $result_2 = sprintf($result_2, date("d/m/Y", $timeVIP), $_POST['VIPDays']);
                             $GLOBALS['result_command'] = "<strong>" . $result_1 . "</strong><br />\n" . $result_2;
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                             if (loadIsAjax() == false) {
                                 $user_data['vip'] = array(VIP_COLUMN => $_POST['VIPType'], VIP_BEGIN => $beginVIP, VIP_TIME => $_timeVIP);
                             }
                         }
                         if (loadIsAjax() == true) {
                             exit($GLOBALS['result_command']);
                         }
                     } elseif ($_GET['command'] == "remove") {
                         self::DB()->Arguments($_GET['username']);
                         self::DB()->Query("UPDATE " . VIP_CORE . ".dbo." . VIP_TABLE . " SET " . VIP_COLUMN . " = 0, " . VIP_BEGIN . " = 0, " . VIP_TIME . " = 0 WHERE " . VIP_LOGIN . " = '%s'");
                         $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['ManageVIP']['Messages']['Success']['Removed'];
                         $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                         if (loadIsAjax() == true) {
                             exit($GLOBALS['result_command']);
                         } else {
                             $user_data['vip'] = array(VIP_COLUMN => 0, VIP_BEGIN => 0, VIP_TIME => 0);
                         }
                     }
                     /*$GLOBALS['vip_info'] = array
                     		(
                     			"type" => $this->functions->AccountLevel($user_data['vip'][VIP_COLUMN]),
                     			"begin" => $this->functions->MakeVIPTime($user_data['vip'][VIP_BEGIN]),
                     			"end" => $this->functions->MakeVIPTime($user_data['vip'][VIP_TIME])
                     		);*/
                     $this->output->setContent("accounts_manageVIP");
                 }
                 break;
             case "manageCoin":
                 if ($this->CheckPermissionItem("accounts_manageAccount_manageCoin") == true) {
                     if ($_GET['command'] == "insert" || $_GET['command'] == "remove") {
                         $_POST['Coin'] = intval($_POST['Coin']);
                         $_POST['Quantity'] = intval($_POST['Quantity']);
                         if (empty($_POST['Quantity'])) {
                             $_POST['Quantity'] = 0;
                         }
                         if ($_POST['Coin'] != 1 && $_POST['Coin'] != 2 && $_POST['Coin'] != 3) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['ManageCoin']['Messages']['CoinInvalid'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                         } else {
                             if ($_GET['command'] == "insert") {
                                 $coin_command = "Insert";
                                 $coin_signal = "+";
                             } elseif ($_GET['command'] == "remove") {
                                 $coin_command = "Remove";
                                 $coin_signal = "-";
                             }
                             $coin_column = $_POST['Coin'];
                             $coin_name = constant("COIN_NAME_" . $_POST['Coin']);
                             if ($user_data['coin'][$coin_column] < $_POST['Quantity'] && $_GET['command'] == "remove") {
                                 $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['ManageCoin']['Messages']['NoCoin'];
                                 $GLOBALS['result_command'] = adminShowMessage(sprintf($GLOBALS['result_command'], $coin_name), 2);
                             } else {
                                 $this->DB->Arguments($_GET['username'], $coin_column, $_POST['Quantity'], intval(COIN_USE_CACHE));
                                 $this->DB->Query("EXEC dbo.CTM_PlusAccountCoin '%s', %d, %d, %d");
                                 $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['ManageCoin']['Messages']['Success'][$coin_command];
                                 $GLOBALS['result_command'] = adminShowMessage(sprintf($GLOBALS['result_command'], $_POST['Quantity'], $coin_name), 3);
                             }
                         }
                         if (loadIsAjax() == true) {
                             exit($GLOBALS['result_command']);
                         }
                     }
                     $this->output->setContent("accounts_manageCoin");
                 }
                 break;
             case "disconnect":
                 if ($user_data['stat']['ConnectStat'] < 1) {
                     $message = $this->lang->words['Members']['Accounts']['ManageAccount']['DisconnectAccount']['Messages']['UserOffline'];
                     $type = 2;
                 } elseif ($this->MuLib('JoinServer')->ForceLogout($_GET['username'])) {
                     $message = $this->lang->words['Members']['Accounts']['ManageAccount']['DisconnectAccount']['Messages']['Success'];
                     $type = 3;
                 } else {
                     $message = sprintf($this->lang->words['Members']['Accounts']['ManageAccount']['DisconnectAccount']['Messages']['Error'], 11);
                     $type = 2;
                 }
                 $this->loadSearchAccounts(true, adminShowMessage($message, $type));
                 $this->output->setContent("accounts_search");
                 break;
             default:
                 if ($this->CheckPermissionItem("accounts_manageAccount_edit") == true) {
                     if ($_GET['write'] == "name" && loadIsAjax() == true) {
                         if (empty($_POST['NewName'])) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangeName']['Messages']['NameVoid'], 1));
                         } elseif (strlen($_POST['NewName']) > 10) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangeName']['Messages']['MaxLength'], 2));
                         } else {
                             $this->DB->Arguments($_GET['username']);
                             $this->DB->Update(MUACC_CORE . "@MEMB_INFO", array("memb_name" => utf8_encode($_POST['NewName'])), "memb___id = '%s'");
                             exit("<script>editAccount_writeSuccess('name', '" . str_replace("'", "\\'", $_POST['NewName']) . "');</script>");
                         }
                     } elseif ($_GET['write'] == "email" && loadIsAjax() == true) {
                         if (empty($_POST['NewMail'])) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangeMail']['Messages']['MailVoid'], 1));
                         } elseif (!CTM_Text::CheckMail($_POST['NewMail'])) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangeMail']['Messages']['InvalidMail'], 2));
                         } else {
                             $this->DB->Arguments($_GET['username']);
                             $this->DB->Update(MUACC_CORE . "@MEMB_INFO", array("mail_addr" => $_POST['NewMail']), "memb___id = '%s'");
                             exit("<script>editAccount_writeSuccess('email', '" . str_replace("'", "\\'", $_POST['NewMail']) . "');</script>");
                         }
                     } elseif ($_GET['write'] == "password" && loadIsAjax() == true) {
                         if (empty($_POST['NewPassword'])) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangePassword']['Messages']['PasswordVoid'], 1));
                         } elseif (empty($_POST['ConfirmNewPassword'])) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangePassword']['Messages']['ConfirmPasswordVoid'], 1));
                         } elseif (eregi("[^a-zA-Z0-9_!=?&-]", $_POST['NewPassword'])) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangePassword']['Messages']['CaractersInvalid'], 2));
                         } elseif ($_POST['NewPassword'] != $_POST['ConfirmNewPassword']) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangePassword']['Messages']['PasswordError'], 2));
                         } else {
                             $this->MuLib('Member')->ChangePassword($_GET['username'], $_POST['NewPassword']);
                             exit("<script>editAccount_writeSuccess('password');</script>");
                         }
                     } elseif ($_GET['write'] == "pid" && loadIsAjax() == true) {
                         if (empty($_POST['NewPID'])) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangePID']['Messages']['PIDVoid'], 1));
                         } elseif (strlen($_POST['NewPID']) != 7) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangePID']['Messages']['ErrorLength'], 2));
                         } elseif (!is_numeric($_POST['NewPID'])) {
                             exit(adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['ChangePID']['Messages']['ErrorCaracters'], 2));
                         } else {
                             $this->DB->Arguments($_GET['username']);
                             $this->DB->Update(MUACC_CORE . "@MEMB_INFO", array("sno__numb" => str_pad($_POST['NewPID'], 13, 1, STR_PAD_LEFT)), "memb___id = '%s'");
                             exit("<script>editAccount_writeSuccess('pid', '" . str_replace("'", "\\'", $_POST['NewPID']) . "');</script>");
                         }
                     } elseif ($_GET['write'] == "save") {
                         if (is_null($_POST['MemberStatus']) || is_null($_POST['AccountLevel']) || empty($_POST['SecureQuestion']) || empty($_POST['SecureAnswer'])) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['Save']['Messages']['FieldsVoid'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                         } elseif (empty($_POST['BirthDay']) || empty($_POST['BirthMonth']) || empty($_POST['BirthYear'])) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['Save']['Messages']['FieldsVoid'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                         } elseif (is_null($_POST['CoinBalance_1']) || is_null($_POST['CoinBalance_2']) && COIN_NUMBER >= 2 || is_null($_POST['CoinBalance_3']) && COIN_NUMBER == 3) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['Save']['Messages']['FieldsVoid'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                         } elseif ($_POST['AccountLevel'] < 0 || $_POST['AccountLevel'] > VIP_NUMBER) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['Save']['Messages']['ErrorAccountLevel'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                         } elseif ($_POST['MemberStatus'] != 0 && $_POST['MemberStatus'] != 1) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['Save']['Messages']['ErrorStatus'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                         } else {
                             $_POST['BirthDay'] = eregi_replace("[^0-9]", NULL, $_POST['BirthDay']);
                             $_POST['BirthMonth'] = eregi_replace("[^0-9]", NULL, $_POST['BirthMonth']);
                             $_POST['BirthYear'] = eregi_replace("[^0-9]", NULL, $_POST['BirthYear']);
                             $save_data = array("info" => array("fpas_ques" => utf8_encode($_POST['SecureQuestion']), "fpas_answ" => utf8_encode($_POST['SecureAnswer']), "MemberBirth" => $_POST['BirthDay'] . "/" . $_POST['BirthMonth'] . "/" . $_POST['BirthYear'], "MemberStatus" => intval($_POST['MemberStatus'])), "vip" => array(VIP_COLUMN => intval($_POST['AccountLevel'])), "coin" => array(COIN_COLUMN_1 => intval($_POST['CoinBalance_1'])));
                             if (COIN_NUMBER >= 2) {
                                 $save_data['coin'][COIN_COLUMN_2] = intval($_POST['CoinBalance_2']);
                                 if (COIN_NUMBER == 3) {
                                     $save_data['coin'][COIN_COLUMN_3] = intval($_POST['CoinBalance_3']);
                                 }
                             }
                             $this->MuLib('Member')->UpdateAccount($_GET['username'], $save_data);
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['Save']['Messages']['Success'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                             $user_data = $this->MuLib('Member')->Load($_GET['username'] = urldecode($_GET['username']));
                         }
                     } elseif ($_GET['write'] == "delete") {
                         if (USER_ACCOUNT == $_GET['username']) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['DeleteAccount']['NoDelSelf'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                         } elseif (in_array($_GET['username'], $this->settings['ADMINCONTROLPANEL']['SADMIN_ACCOUNTS'])) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['DeleteAccount']['NoDelUser'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                         } else {
                             $this->MuLib('Member')->DeleteAccount($_GET['username']);
                             $this->loadSearchAccounts(true, adminShowMessage($this->lang->words['Members']['Accounts']['ManageAccount']['EditAccount']['DeleteAccount']['Success'], 3));
                             $this->output->setContent("accounts_search");
                             return NULL;
                         }
                     } elseif ($_GET['command'] == "disconnect") {
                         if ($user_data['stat']['ConnectStat'] < 1) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['DisconnectAccount']['Messages']['UserOffline'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                         } elseif ($this->MuLib('JoinServer')->ForceLogout($_GET['username'])) {
                             $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['ManageAccount']['DisconnectAccount']['Messages']['Success'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                         } else {
                             $GLOBALS['result_command'] = sprintf($this->lang->words['Members']['Accounts']['ManageAccount']['DisconnectAccount']['Messages']['Error'], 11);
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             $GLOBALS['result_command'] .= "\r\n<script>\$('#userStatus').html(\"<span style='color: red;'>Offline</span>\");</script>";
                         }
                     }
                     $GLOBALS['account_info'] = array("info" => array("register_date" => $user_data['info']['RegisterDate'], "sex" => utf8_decode($user_data['info']['MemberSex'])), "data" => array("name" => utf8_decode($user_data['info']['memb_name']), "mail" => $user_data['info']['mail_addr'], "pid" => substr($user_data['info']['sno__numb'], 6), "status" => $user_data['info']['MemberStatus'], "account_level" => $user_data['vip'][VIP_COLUMN], "coin_1" => $user_data['coin'][COIN_COLUMN_1], "coin_2" => $user_data['coin'][COIN_COLUMN_2], "coin_3" => $user_data['coin'][COIN_COLUMN_3], "secure_question" => utf8_decode($user_data['info']['fpas_ques']), "secure_answer" => utf8_decode($user_data['info']['fpas_answ']), "birth" => explode("/", $user_data['info']['MemberBirth'])), "stat" => array("server" => $this->functions->GetServerName($user_data['stat']['ServerName']), "ip" => $user_data['stat']['IP'], "date" => date("d/m/Y - h:i a", strtotime($user_data['stat']['ConnectTM'])), "status" => $user_data['stat']['ConnectStat'] > 0));
                     $this->output->setContent("accounts_editAccount");
                 }
                 break;
         }
     }
 }
 /**
  *	Board Notices Data
  *	Get notice from Board System
  *
  *	@param	array	Settings
  *	@return	array	Result
  */
 private function loadBoardNoticesData($data)
 {
     $this->DB->settings['mysql']['hostname'] = $this->config['MySQL']['HOST'];
     $this->DB->settings['mysql']['hostport'] = $this->config['MySQL']['PORT'];
     $this->DB->settings['mysql']['username'] = $this->config['MySQL']['USER'];
     $this->DB->settings['mysql']['password'] = $this->config['MySQL']['PASS'];
     $this->DB->settings['mysql']['database'] = $this->config['MySQL']['DATA'];
     $this->DB->settings['mysql']['log_folder'] = "MySQL";
     $this->DB->settings['mysql']['debug'] = in_array("mysql", explode(",", CTM_SQL_DEBUG_MODE));
     $this->DB->settings['mysql']['hideErrors'] = TRUE;
     if ($this->DB->Connect("mysql")) {
         $query = "SELECT * FROM " . $this->config['PREFIX'] . $data['TABLE'] . " WHERE ";
         for ($i = 1; $i <= sizeof($this->config['FORUM_ID']); $i++) {
             $this->DB->MySQL()->Arguments($this->config['FORUM_ID'][$i - 1]);
             if ($i < count($this->config['FORUM_ID'])) {
                 $query .= $data['FORUM_COLUMN'] . " = %d OR ";
             } else {
                 $query .= $data['FORUM_COLUMN'] . " = %d ";
             }
         }
         $query .= "ORDER BY " . $data['ID_COLUMN'] . " DESC LIMIT " . $this->config['LIMIT'];
         $this->DB->MySQL()->Arguments($this->config['LIMIT']);
         if ($topics = $this->DB->MySQL()->Query($query)) {
             if ($this->DB->MySQL()->CountRows($topics) > 0) {
                 $notices = array();
                 while ($notice = $this->DB->MySQL()->FetchObject($topics)) {
                     if (isset($data['POST']) && is_array($data['POST'])) {
                         $this->DB->MySQL()->Arguments($data['POST']['TITLE'], $data['POST']['DATE'], $this->config['PREFIX'] . $data['POST']['TABLE']);
                         $this->DB->MySQL()->Arguments($data['POST']['TOPIC_ID'], $notice->{$data['ID_COLUMN']}, $data['POST']['ID']);
                         $query = $this->DB->MySQL()->Query("SELECT %s,%s FROM %s WHERE %s = %d ORDER BY %s ASC");
                         $fetch = $this->DB->MySQL()->FetchObject($query);
                         $title = $fetch->{$data['POST']['TITLE']};
                         $date = $fetch->{$data['POST']['DATE']};
                     } else {
                         $title = $notice->{$data['TITLE']};
                         $date = $notice->{$data['DATE']};
                     }
                     $link = $this->config['LINK'];
                     $link .= substr($this->config['LINK'], strlen($this->config['LINK']) - 1, 1) != "/" ? "/" : NULL;
                     $link .= $data['LINK'] . "=" . $notice->{$data['ID_COLUMN']};
                     $notices[] = array("title" => $this->config['UTF8_DECODE'] == true ? CTM_Text::UTF8Text($title) : $title, "postDate" => date("d/m/Y - h:i a", $date), "topicLink" => $link);
                 }
                 $this->DB->Clear(true, true);
                 return $notices;
             } else {
                 $this->DB->Clear(true, true);
                 return 255;
             }
         }
         $this->DB->Clear(true, true);
         $this->DB->MySQL()->Close();
     }
     return false;
 }