/** * Load All Notices * * @return void */ private function loadAllNotices() { $query = $this->DB->Query("SELECT Title,Date,Id FROM dbo.CTM_Notices ORDER BY Id DESC"); $GLOBALS['all_notices'] = array(); if ($this->DB->CountRows($query) > 0) { while ($data = $this->DB->FetchArray($query)) { $GLOBALS['all_notices'][$data['Id']] = array("title" => htmlDecode($data['Title'], true), "date" => date("d/m/Y - h:i a", $data['Date'])); } } }
/** * Init Module * * @return void */ public function initSection($id = 0) { $queryString = "SELECT CTM_Notices.*, CTM_TeamMembers.Name, " . MUGEN_CORE . ".dbo.Character." . COLUMN_CHARIMAGE . ""; $queryString .= " FROM dbo.CTM_Notices JOIN dbo.CTM_TeamMembers ON (CTM_TeamMembers.Account = CTM_Notices.Account)"; $queryString .= " LEFT JOIN " . MUGEN_CORE . ".dbo.Character ON ("; $queryString .= MUGEN_CORE . ".dbo.Character.Name = CTM_TeamMembers.Name) WHERE CTM_Notices.Id = %d"; $this->DB->Arguments($id); $this->DB->Query($queryString, $query); if ($this->DB->CountRows($query) < 1) { return $this->output->showError($this->lang->words['ViewNotice']['Error']); } $notice = $this->DB->FetchObject($query); $GLOBALS['view_notice'] = array("id" => $id, "title" => htmlDecode($notice->Title, true), "author" => array("name" => $notice->Name, "image" => self::instance()->functions->GetCharImage($notice->{COLUMN_CHARIMAGE})), "date" => date("d/m/Y - h:i a", $notice->Date), "text" => htmlDecode($notice->Text, true), "comments_switch" => (bool) $notice->CommentSwitch); $this->lang->setTags("ViewNotice,Header", $GLOBALS['view_notice']['author']['name'], $GLOBALS['view_notice']['date']); $this->output->loadSkinCache("notices", "view_notice"); }
/** * Init Module * * @return void */ public function initSection() { $ma = MUACC_CORE . ".dbo."; $mg = MUGEN_CORE . ".dbo."; $queryString = "SELECT CTM_TeamMembers.*, CTM_TeamGroups.Name AS GroupName, CTM_TeamGroups.GroupTitle, CTM_TeamGroups.FormatPrefix, CTM_TeamGroups.FormatSuffix"; $queryString .= ", {$ma}MEMB_STAT.ConnectStat, {$ma}MEMB_STAT.ServerName, {$mg}Character.Class, {$mg}Character." . COLUMN_CHARIMAGE; $queryString .= " FROM " . CTMEW_CORE . ".dbo.CTM_TeamMembers LEFT JOIN " . CTMEW_CORE . ".dbo.CTM_TeamGroups ON (CTM_TeamGroups.Id = CTM_TeamMembers.PrimaryGroup)"; $queryString .= " LEFT JOIN " . MUACC_CORE . ".dbo.MEMB_STAT ON ({$ma}MEMB_STAT.memb___id = CTM_TeamMembers.Account)"; $queryString .= " LEFT JOIN " . MUGEN_CORE . ".dbo.Character ON ({$mg}Character.Name = CTM_TeamMembers.Name) ORDER BY CTM_TeamMembers.Id ASC"; $query = $this->DB->Query($queryString); $members = array(); if ($this->DB->CountRows($query) > 0) { while ($member = $this->DB->FetchObject($query)) { $title = strlen($member->CustomTitle) < 2 ? $member->GroupTitle : $member->CustomTitle; $status = $member->ConnectStat > 0 ? "<font color=\"green\">Online</span>" : "<font color=\"red\">Offline</font>"; $server = $this->functions->GetServerName($member->ServerName); $members[] = array("name" => utf8_decode($member->Name), "contact" => $member->Contact, "group" => utf8_decode($member->GroupName), "title" => utf8_decode($title), "image" => $this->functions->GetCharImage($member->{COLUMN_CHARIMAGE}), "class" => $this->functions->ClassInfo($member->Class), "status" => $status, "server" => $server, "format_prefix" => htmlDecode($member->FormatPrefix, TRUE), "format_suffix" => htmlDecode($member->FormatSuffix, TRUE)); } } $GLOBALS['team_members'] = $members; unset($members); }
/** * 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&module=userpanel&option=supportTickets&section=show&id=" . $ticket_id . "&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; } }
/** * 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§ion=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"); } } }
/** * Private: Edit Notice * Edit the notice from Effect Web * * @return void */ private function loadEditNotice() { $GLOBALS['notice_exists'] = $this->loadCheckNotice($_GET['id']); if ($GLOBALS['notice_exists'] == true) { if ($_GET['write'] == true) { if (empty($_POST['fieldTitle'])) { $GLOBALS['result_command'] = $this->lang->words['EWMain']['Notices']['EditNotice']['Messages']['TitleVoid']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } elseif (empty($_POST['fieldText'])) { $GLOBALS['result_command'] = $this->lang->words['EWMain']['Notices']['EditNotice']['Messages']['TextVoid']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } else { $update_columns = array("Title" => htmlEncode($_POST['fieldTitle']), "Text" => htmlEncode($_POST['fieldText']), "CommentSwitch" => $_POST['enableComments'] == true ? 1 : 0); if ($_POST['refreshDate'] == true) { $update_columns['Date'] = time(); } $this->DB->Update("CTM_Notices", $update_columns, "Id = " . intval($_GET['id'])); $GLOBALS['result_command'] = $this->lang->words['EWMain']['Notices']['EditNotice']['Messages']['Success']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); } } $select_notice = $this->DB->Select("*", "CTM_Notices", "Id = " . intval($_GET['id'])); $fetch_notice = $this->DB->FetchObject($select_notice); $GLOBALS['notice_data'] = array("id" => intval($_GET['id']), "title" => str_replace(array("<", ">"), array("<", ">"), htmlDecode($fetch_notice->Title)), "date" => date("d/m/Y", $fetch_notice->Date), "text" => str_replace(array("<", ">"), array("<", ">"), htmlDecode($fetch_notice->Text)), "comments_enabled" => $fetch_notice->CommentSwitch == 1); $this->lang->setArguments("EWMain,Notices,EditNotice,Title", $_GET['id']); } }
function processEntry($serverID, $e, $sync_mode = SYNC_INSERT_FLIGHT_LINK) { global $CONF; global $DBGcat, $DBGlvl; if ($DBGlvl > 0) { echo "<PRE>"; print_r($e); echo "</PRE>"; } if (is_array($e['ActionXML'])) { $actionData =& $e['ActionXML']; } else { if (is_array($e['actionData'])) { $actionData =& $e['actionData']; } else { if (is_array($e['flight'])) { $actionData =& $e; } else { return array(0, "logReplicator::processEntry : actionData section not found"); } } } // if this log entry is not for a flight of the specific server // then check if we are allowesd to accpet these flights from this server if (isset($actionData['flight']['serverID'])) { $thisEntryServerID = $actionData['flight']['serverID']; } else { if (isset($e['serverID'])) { $thisEntryServerID = $e['serverID']; } else { return array(0, "logReplicator::processEntry : ServerID for Log entry could not be determined "); } } if ($thisEntryServerID != $serverID) { $wrongServer = 1; if (is_array($CONF['servers']['list'][$serverID]['accept_also_servers'])) { if (in_array($thisEntryServerID, $CONF['servers']['list'][$serverID]['accept_also_servers'])) { $wrongServer = 0; } } if ($wrongServer) { return array(0, "logReplicator::processEntry : We dont accept flights originally from server " . $thisEntryServerID); } } if ($e['type'] == '1') { // flight if ($e['action'] == 4) { // delete $flightIDlocal = logReplicator::findFlight($actionData['flight']['serverID'], $actionData['flight']['id']); if (!$flightIDlocal) { return array(0, "logReplicator::processEntry : Flight with serverID " . $actionData['flight']['serverID'] . " and original ID : " . $actionData['flight']['id'] . " is not found in the local DB -> Wont delete it"); } // echo "Will delete flight $flightIDlocal<BR>"; $extFlight = new flight(); $extFlight->getFlightFromDB($flightIDlocal, 0); $extFlight->deleteFlight(); return array(1, "Flight with local ID: {$flightIDlocal} DELETED"); } if ($e['action'] == 16) { // rename tracklog $flightIDlocal = logReplicator::findFlight($e['serverID'], $e['id']); if (!$flightIDlocal) { return array(0, "logReplicator::processEntry : Flight with serverID " . $e['serverID'] . " and original ID : " . $e['id'] . " is not found in the local DB -> Wont rename tracklog<BR>"); } $extFlight = new flight(); $extFlight->getFlightFromDB($flightIDlocal, 0); $extFlight->renameTracklog($actionData['newFilename'], $actionData['oldFilename']); return array(1, "Flight tracklog renamed for local ID {$flightIDlocal}"); } if ($e['action'] == 8) { // scoring info $flightIDlocal = logReplicator::findFlight($e['serverID'], $e['id']); if (!$flightIDlocal) { return array(0, "logReplicator::processEntry : Flight with serverID " . $e['serverID'] . " and original ID : " . $e['id'] . " is not found in the local DB -> Wont update scoring<BR>"); } // echo "Will update scoring info for flight $flightIDlocal<BR>"; // no need to pull flight info //$extFlight=new flight(); //$extFlight->getFlightFromDB($flightIDlocal,0); require_once dirname(__FILE__) . '/CL_flightScore.php'; $flightScore = new flightScore($flightIDlocal); // we have the score array in $actionData['score'] $sArr =& $actionData['score']; $flightScore->fromSyncArray($sArr); //put also in scores table, the flight is sure to be present in flights table $flightScore->putToDB(1, 1); return array(1, "Flight Score was *pulled* for local ID {$flightIDlocal}"); } // now deal with add/update $getValidationData = 1; $getScoreData = 1; // check 'alien' pilot and insert him or update him anyway $userServerID = $actionData['flight']['serverID']; if ($userServerID == 0) { $userServerID = $serverID; } // echo "logReplicator::checkPilot"; list($effectiveServerID, $effectiveUserID) = logReplicator::checkPilot($userServerID, $actionData['flight']['pilot']); //echo "effectiveServerID: $effectiveServerID, effectiveUserID: $effectiveUserID // userServerID: $userServerID, userID: ".$actionData['flight']['pilot']['userID']."<BR>"; // check if a maping took place and LOG it!! if ($effectiveServerID != $userServerID || $effectiveUserID != $actionData['flight']['pilot']['userID']) { $orgUserIDstr = $userServerID + 0 . '_' . $actionData['flight']['pilot']['userID']; } else { $orgUserIDstr = ''; } // $userIDstr=$userServerID.'_'.$actionData['flight']['pilot']['userID']; $userIDstr = $effectiveServerID . '_' . $effectiveUserID; list($nearestTakeoffID, $nearestDistance) = logReplicator::checkLocation($userServerID, $actionData['flight']['location'], $actionData['flight']['bounds']); list($nearestLandingID, $nearestLandingDistance) = findNearestWaypoint($actionData['flight']['bounds']['lastLat'], $actionData['flight']['bounds']['lastLon']); // get only the first 2 bits $externalFlightType = $sync_mode & 0x3; $addFlightNote = ''; // if action ==update check to see if the flight exists ! if ($e['action'] == 2) { $flightIDlocal = logReplicator::findFlight($actionData['flight']['serverID'], $actionData['flight']['id']); if (!$flightIDlocal) { // we then INSERT IT instead echo " [Not found,will insert] "; $e['action'] = 1; } } else { if ($e['action'] == 1) { // if action == insert we make an extra check to see if the fligh is there, if yes we UPDATE instead $flightIDlocal = logReplicator::findFlight($actionData['flight']['serverID'], $actionData['flight']['id']); if ($flightIDlocal) { // we then UPDATE IT instead echo " [Already here,will update] "; $e['action'] = 2; } } } if ($e['action'] == 1) { // add $igcFilename = $actionData['flight']['filename']; $igcFileURL = $actionData['flight']['linkIGC']; $igcZipFileURL = $actionData['flight']['linkIGCzip']; $tempFilename = LEONARDO_ABS_PATH . '/' . $CONF['paths']['tmpigc'] . '/' . $igcFilename; $hash = $actionData['flight']['validation']['hash']; $sameHashIDarray = flight::findSameHash($hash); if (count($sameHashIDarray) > 0) { $isFlightDup = 0; $markFlightAsDisabled = 1; $msg = ''; if ($CONF['servers']['list'][$actionData['flight']['serverID']]['allow_duplicate_flights']) { foreach ($sameHashIDarray as $sameHashFlightInfo) { if ($sameHashFlightInfo['serverID'] == $actionData['flight']['serverID']) { // from same server $isFlightDup = 1; $msg .= " local flight: " . $sameHashFlightInfo['serverID'] . '_' . $sameHashFlightInfo['ID'] . " , new entry:" . $actionData['flight']['serverID'] . '_' . $actionData['flight']['id']; break; } else { // we have a flight with same hash that is not from this specific server. // HERE we must make the decision whether to mark this flight as DISABLED // WE always mark this new flight as DISABLED because : // the local flight takes precedence anyway. // ONE case // we are DHV mirror , the new flight is from DHV and there is a dup from XContest // we should insert, // SO INSERT TAKES PRECEDENCE OVER LINKED FLIGHTS } } } else { $isFlightDup = 1; } if ($isFlightDup) { return array(-1, "Flight already exists : {$msg}"); } } /* if ($CONF['servers']['list'][$actionData['flight']['serverID']]['allow_duplicate_flights']) { $sameHashIDarray=flight::findSameHash( $hash , $actionData['flight']['serverID'] ); if (count($sameHashIDarray)>0 ) { return array(-1,"Flight already exists in local with ID: $sameHashID (dups allowed)"); continue; } else { // $addFlightNote="*(Duplicate Flight)*"; } } else { $sameHashIDarray=flight::findSameHash( $hash ); if (count($sameHashIDarray)>0 ) { return array(-1,"Flight already exists in local with ID: $sameHashID"); continue; } } */ } else { if ($e['action'] == 2) { // update // This is not needed , we have found $flightIDlocal earlier and if it didnt exist we will insert it instead /* $flightIDlocal=logReplicator::findFlight($actionData['flight']['serverID'],$actionData['flight']['id']); if (!$flightIDlocal) { return array(0,"logReplicator::processEntry : Flight with serverID ".$actionData['flight']['serverID']." and original ID : ". $actionData['flight']['id']." is not found in the local DB -> Wont update<BR>"); } */ // echo "Will update flight $flightIDlocal<BR>"; } } $thisCat = $actionData['flight']['info']['cat'] + 0; // when we get data from leonardo servers, we just ignore these fields // since they can be computed on the fly $originalURL = htmlDecode($actionData['flight']['linkDisplay']); $originalKML = htmlDecode($actionData['flight']['linkGE']); if ($actionData['flight']['serverID'] != 0) { global $CONF; if ($CONF['servers']['list'][$actionData['flight']['serverID']]['isLeo'] == 1) { $originalURL = ''; $originalKML = ''; } } $argArray = array("private" => $actionData['flight']['info']['private'] + 0, "cat" => $actionData['flight']['info']['gliderCat'] + 0, "linkURL" => $actionData['flight']['info']['linkURL'], "comments" => $actionData['flight']['info']['comments'], "glider" => $actionData['flight']['info']['glider'], "gliderBrandID" => $actionData['flight']['info']['gliderBrandID'] + 0, "category" => $thisCat >= 0 ? $thisCat : 0, "dateAdded" => $actionData['flight']['dateAdded'], "originalURL" => $originalURL, "originalKML" => $originalKML, "original_ID" => $actionData['flight']['id'], "serverID" => $actionData['flight']['serverID'], "userServerID" => $actionData['flight']['serverID'], "originalUserID" => $orgUserIDstr, "externalFlightType" => $externalFlightType, "allowDuplicates" => $CONF['servers']['list'][$actionData['flight']['serverID']]['allow_duplicate_flights'] + 0); // print_r($argArray); if ($e['action'] == 1 && $sync_mode & SYNC_INSERT_FLIGHT_LOCAL & SYNC_INSERT_FLIGHT_REPROCESS_LOCALLY) { if (!($igcFileStr = fetchURL($igcFileURL, 20))) { return array(0, "logReplicator::processEntry() : Cannot Fetch {$igcFileURL}"); } writeFile($tempFilename, $igcFileStr); list($res, $flightID) = addFlightFromFile($tempFilename, 0, $userIDstr, $argArray); if ($res != 1) { return array(-128, "Problem: " . getAddFlightErrMsg($res, $flightID)); } return array(1, "Flight *pulled* OK with local ID {$flightID}"); } else { // if ( ( $e['action']==1 && $sync_mode & SYNC_INSERT_FLIGHT_LINK ) || $e['action']==2 ){ // inserting in LINK / LOCAL mode or updates - NOT reproccess if ($e['action'] == 1) { $extFlight = new flight(); // get igc if required if ($sync_mode & SYNC_INSERT_FLIGHT_LOCAL) { echo " Geting IGC file : "; if (!$e['tmpDir']) { $e['tmpDir'] = '/tmp'; } $igcFileTmp = $e['tmpDir'] . '/' . $actionData['flight']['id'] . '.igc'; if (!is_file($igcFileTmp)) { echo "igc file: {$igcFileURL}<BR>\n"; echo "tmpfile: {$igcFileTmp}<BR>\n"; echo "NOT in zip -> will fetch ..."; if (!($igcFileStr = fetchURL($igcFileURL, 20))) { return array(0, "logReplicator::processEntry() : Cannot Fetch {$igcFileURL}"); } writeFile($igcFileTmp, $igcFileStr); } else { echo "IN zip -> will use that ..."; } } } else { $extFlight = new flight(); $extFlight->getFlightFromDB($flightIDlocal, 0); } $igcFilename = $actionData['flight']['filename']; $igcFileURL = $actionData['flight']['linkIGC']; if ($CONF['servers']['list'][$actionData['flight']['serverID']]['exclude_from_list']) { $extFlight->excludeFrom |= 3; } if ($CONF['servers']['list'][$actionData['flight']['serverID']]['exclude_from_league']) { $extFlight->excludeFrom |= 2; } foreach ($argArray as $fieldName => $fieldValue) { // if the flight is already present // we must tkae care to honor ONLY // the 1st bit of 'private' , the others are used locally !! if ($fieldName == 'private') { if ($fieldValue & 0x1) { $fieldValue = $extFlight->private | 0x1; } else { if ($fieldValue & 0x4) { // visible to friends $fieldValue = $extFlight->private | 0x4; } else { $fieldValue = $extFlight->private & 0xfa; } } } $extFlight->{$fieldName} = $fieldValue; } // echo " gliderBrandID : $extFlight->gliderBrandID #<BR>"; $extFlight->takeoffID = $nearestTakeoffID; $extFlight->takeoffVinicity = $nearestDistance; $extFlight->landingID = $nearestLandingID; $extFlight->landingVinicity = $nearestLandingDistance; // no userid will be assgined to this flight since it will not be inserted locally // so userID= userServerID; // $extFlight->userID=$extFlight->originalUserID; // now we take care of mapping between users $extFlight->userID = $effectiveUserID; $extFlight->userServerID = $effectiveServerID; $extFlight->dateAdded = $actionData['flight']['dateAdded']; $extFlight->DATE = $actionData['flight']['time']['date']; $extFlight->timezone = $actionData['flight']['time']['Timezone'] + 0; $extFlight->START_TIME = $actionData['flight']['time']['StartTime'] + 0; $extFlight->DURATION = $actionData['flight']['time']['Duration'] + 0; $extFlight->END_TIME = $extFlight->START_TIME + $extFlight->DURATION; $extFlight->forceBounds = $actionData['flight']['bounds']['forceBounds'] + 0; $extFlight->firstLon = $actionData['flight']['bounds']['firstLon'] + 0; $extFlight->firstLat = $actionData['flight']['bounds']['firstLat'] + 0; $extFlight->firstPointTM = $actionData['flight']['bounds']['firstTM'] + 0; $extFlight->lastLon = $actionData['flight']['bounds']['lastLon'] + 0; $extFlight->lastLat = $actionData['flight']['bounds']['lastLat'] + 0; $extFlight->lastPointTM = $actionData['flight']['bounds']['lastTM'] + 0; $firstPoint = new gpsPoint(); $firstPoint->setLon($actionData['flight']['bounds']['firstLon']); $firstPoint->setLat($actionData['flight']['bounds']['firstLat']); $firstPoint->gpsTime = $actionData['flight']['bounds']['firstTM'] % 86400; $lastPoint = new gpsPoint(); $lastPoint->setLon($actionData['flight']['bounds']['lastLon']); $lastPoint->setLat($actionData['flight']['bounds']['lastLat']); $lastPoint->gpsTime = $actionData['flight']['bounds']['lastTM'] % 86400; // $extFlight->FIRST_POINT=$firstPoint->to_IGC_Record(); // $extFlight->LAST_POINT=$lastPoint->to_IGC_Record(); // not used!! /* if ( is_array($actionData['flight']['turnpoints']) ) { foreach ($actionData['flight']['turnpoints'] as $i=>$tp){ $tpNum=$tp['id']; $tpPoint=new gpsPoint(); $tpPoint->setLon($tp['lon']); $tpPoint->setLat($tp['lat']); $varname="turnpoint$tpNum" ; $extFlight->$varname = $tpPoint->getLatMin().' '.$tpPoint->getLonMin() ; } } */ if ($getValidationData) { $extFlight->validated = $actionData['flight']['validation']['validated']; $extFlight->grecord = $actionData['flight']['validation']['grecord']; $extFlight->hash = $actionData['flight']['validation']['hash']; $extFlight->validationMessage = $actionData['flight']['validation']['validationMessage']; $extFlight->airspaceCheck = $actionData['flight']['validation']['airspaceCheck'] + 0; $extFlight->airspaceCheckFinal = $actionData['flight']['validation']['airspaceCheckFinal'] + 0; $extFlight->airspaceCheckMsg = $actionData['flight']['validation']['airspaceCheckMsg']; } $getScoreDataExtra = 0; $getScoreDataExtraMissing = 0; if ($getScoreData) { // we should get these from the [score] section also $extFlight->BEST_FLIGHT_TYPE = $actionData['flight']['stats']['FlightType']; $extFlight->FLIGHT_KM = $actionData['flight']['stats']['XCdistance']; $extFlight->FLIGHT_POINTS = $actionData['flight']['stats']['XCscore']; $extFlight->LINEAR_DISTANCE = $actionData['flight']['stats']['StraightDistance'] + 0; $extFlight->MAX_LINEAR_DISTANCE = $actionData['flight']['stats']['MaxStraightDistance'] + 0; $extFlight->MEAN_SPEED = $actionData['flight']['stats']['MeanGliderSpeed'] + 0; $extFlight->MAX_SPEED = $actionData['flight']['stats']['MaxSpeed'] + 0; $extFlight->MAX_VARIO = $actionData['flight']['stats']['MaxVario'] + 0; $extFlight->MIN_VARIO = $actionData['flight']['stats']['MinVario'] + 0; $extFlight->MAX_ALT = $actionData['flight']['stats']['MaxAltASL'] + 0; $extFlight->MIN_ALT = $actionData['flight']['stats']['MinAltASL'] + 0; $extFlight->TAKEOFF_ALT = $actionData['flight']['stats']['TakeoffAlt'] + 0; if (is_array($actionData['flight']['score']) && count($actionData['flight']['score']) > 0) { require_once dirname(__FILE__) . '/CL_flightScore.php'; $flightScore = new flightScore($extFlight->flightID); // we have the score array in $actionData['score'] $sArr =& $actionData['flight']['score']; $flightScore->fromSyncArray($sArr); $extFlight->flightScore = $flightScore; $getScoreDataExtra = 1; $extFlight->BEST_FLIGHT_TYPE = $flightScore->bestScoreType; $extFlight->FLIGHT_KM = $flightScore->bestDistance * 1000; $extFlight->FLIGHT_POINTS = $flightScore->bestScore; // check for missing linear distance if ($extFlight->LINEAR_DISTANCE == 0 && $extFlight->MAX_LINEAR_DISTANCE > 0) { // echo "compute MAxtakeoffDistance"; $extFlight->LINEAR_DISTANCE = $flightScore->computeMaxTakeoffDistance($firstPoint); } //put also in scores table, the flight is sure to be present in flights table if ($e['action'] == 2) { // update so we already know the flightID $flightScore->putToDB(1, 1); } } else { $getScoreDataExtraMissing = 1; } } // we also have [gliderBrand] => GRADIENT $extFlight->checkGliderBrand($actionData['flight']['info']['gliderBrand']); if ($e['action'] == 1) { if ($sync_mode & SYNC_INSERT_FLIGHT_LOCAL) { $tmpPilot = new pilot($effectiveServerID, $effectiveUserID); $tmpPilot->createDirs(); $extFlight->filename = $igcFilename; $extFlight->checkDirs(); if ($DBGlvl > 0) { echo "Moving file into place: " . $extFlight->getIGCFilename() . "<BR>"; } while (is_file($extFlight->getIGCFilename())) { if ($DBGlvl > 0) { echo "Same filename is already present<BR>"; } $extFlight->filename = '_' . $extFlight->filename; } @rename($igcFileTmp, $extFlight->getIGCFilename()); $opString = '*inserted*'; } else { $opString = '*linked*'; } // insert flight $extFlight->putFlightToDB(0); // take care of sme flights (hide /unhide) $extFlight->hideSameFlights(); if ($getScoreData && $getScoreDataExtra) { $flightScore->flightID = $extFlight->flightID; $flightScore->putToDB(1, 1); } else { if ($getScoreDataExtraMissing && $CONF['servers']['list'][$actionData['flight']['serverID']]['rescore_if_missing'] && $sync_mode & SYNC_INSERT_FLIGHT_LOCAL) { echo " [Re-score] "; $extFlight->computeScore(); } } return array(1, "Flight {$opString} OK {$addFlightNote} with local ID {$extFlight->flightID}"); } else { //update flight $extFlight->putFlightToDB(1); if ($getScoreDataExtraMissing && $CONF['servers']['list'][$actionData['flight']['serverID']]['rescore_if_missing'] && $sync_mode & SYNC_INSERT_FLIGHT_LOCAL) { echo " [Re-score] "; require_once dirname(__FILE__) . '/CL_flightScore.php'; $flightScore = new flightScore($extFlight->flightID); $flightScore->getFromDB(); if ($flightScore->gotValues) { echo "[not needed] "; } else { $extFlight->computeScore(); } } return array(1, "Flight with local ID {$flightIDlocal} UPDATED OK"); } } return array(0, "Unknown error, we should have returned by this far..."); } // if type==1 }
/** * 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; } }
/** * Notices from Site * * @return array Result */ private function loadNotices() { if ($this->settings['HOME']['NOTICES']['SHOW'] == true) { $build = $this->DB->Query("SELECT TOP " . $this->settings['HOME']['NOTICES']['LIMIT'] . " Title,[Date],Id FROM dbo.CTM_Notices ORDER BY Id DESC"); $notices = array(); if ($this->DB->CountRows($build) > 0) { while ($notice = $this->DB->FetchObject($build)) { $notices[] = array("id" => $notice->Id, "title" => htmlDecode($notice->Title, true), "post_date" => date("d/m/Y - h:i a", $notice->Date)); } } return $notices; } }
print $_lang[MailLogsSubject]; ?> </td><td></td></tr> <?php $r = @mysql_query("select * from mail_logs where uid='" . $_SESSION["userId"] . "' order by id desc LIMIT {$start},{$perPage}") or die("File: " . __FILE__ . "<BR>Line: " . __LINE__ . "<BR>MySQL Error: " . mysql_error()); $mailLogUserDelete = GetSetting('mailLogUserDelete'); $cnt = 0; while ($rr = @mysql_fetch_object($r)) { getfont(); $cnt++; if ($mailLogUserDelete) { $delete = "<A class=rootlink href=?do={$do}&sub=delete&id={$rr->id} onclick=\"javascript: return confirm('" . $_lang[MailLogsDeleteAlert] . "');\"><img src=./_rootimages/del.gif border=0 alt='" . $_lang[MailLogsDelete] . "'></a>"; } else { $delete = ""; } $rr->subject = htmlDecode($rr->subject); ?> <tr class="<?php print $font_row; ?> " height=30> <td valign=middle> <?php print $cnt; ?> </td> <td> <?php print $rr->dt; ?> </td> <td> <a class=rootlink href=?do=<?php print $do;
/** * Private: Manage Team Groups * Manage the team groups * * @return void */ private function loadManageTeamGroups() { $load_page = TRUE; if ($_GET['do'] == "delete" && $this->loadCheckGroup($_GET['id'])) { if ($_GET['write'] == true) { if (empty($_POST['NewGroup'])) { $GLOBALS['result_command'] = $this->lang->words['Members']['Team']['Groups']['ManageGroups']['Delete']['Messages']['SelectGroup']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); $load_page = FALSE; } elseif (!$this->loadCheckGroup($_POST['NewGroup'])) { $GLOBALS['result_command'] = $this->lang->words['Members']['Team']['Groups']['ManageGroups']['Delete']['Messages']['GroupNoExists']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $load_page = FALSE; } elseif (in_array($_GET['id'], $this->settings['ADMINCONTROLPANEL']['SADMIN_GROUPS'])) { $GLOBALS['result_command'] = $this->lang->words['Members']['Team']['Groups']['ManageGroups']['Delete']['Messages']['NoDelGroup']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $load_page = FALSE; } else { $query = "DELETE FROM dbo.CTM_TeamGroups WHERE Id = " . intval($_GET['id']) . ";\n"; $query .= "DELETE FROM dbo.CTM_TeamPermission WHERE RowType = 'group' AND RowValue = " . intval($_GET['id'] . ";\n"); $this->DB->Arguments($_GET['id']); $this->DB->Query("SELECT Account, PrimaryGroup, SecondaryGroups FROM dbo.CTM_TeamMembers", $member_q); while ($member = $this->DB->FetchObject($member_q)) { $temp = NULL; $update = FALSE; if ($member->PrimaryGroup == intval($_GET['id'])) { $temp .= "PrimaryGroup = " . intval($_POST['NewGroup']); $update = TRUE; } if (strlen($member->SecondaryGroups) > 0) { $tmp = NULL; $exp = explode(",", $member->SecondaryGroups); foreach ($exp as $v) { if ($v == intval($_GET['id'])) { continue; } $tmp .= $v . ","; } $tmp = rtrim($tmp, ","); $temp .= ($update == true ? ", " : NULL) . "SecondaryGroups = '" . $tmp . "'"; $update = TRUE; } if ($update == true) { $query .= "UPDATE dbo.CTM_TeamMembers SET {$temp} WHERE Account = '" . $member->Account . "';\n"; } } $this->DB->Query($query); $GLOBALS['result_command'] = $this->lang->words['Members']['Team']['Groups']['ManageGroups']['Delete']['Messages']['Success']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); } } else { $load_page = FALSE; } if ($load_page == false) { $this->DB->Query("SELECT Id, Name FROM dbo.CTM_TeamGroups ORDER BY Id ASC", $groups_q); $GLOBALS['groups'] = array(); while ($group = $this->DB->FetchArray($groups_q)) { $GLOBALS['groups'][$group['Id']] = utf8_decode($group['Name']); } $this->lang->setArguments("Members,Team,Groups,ManageGroups,Delete,Title", intval($_GET['id'])); return $this->output->setContent("team_deleteGroup"); } } if ($load_page == true) { $this->DB->Query("SELECT dbo.CTM_TeamGroups.Id AS Id, dbo.CTM_TeamGroups.Name AS Name, dbo.CTM_TeamGroups.FormatPrefix AS FormatPrefix, dbo.CTM_TeamGroups.FormatSuffix AS FormatSuffix, dbo.CTM_TeamGroups.ACP_Access AS ACP_Access FROM dbo.CTM_TeamGroups ORDER BY dbo.CTM_TeamGroups.Id ASC", $find_groups_q); $GLOBALS['team_groups'] = array(); if ($this->DB->CountRows($find_groups_q) > 0) { while ($find_groups = $this->DB->FetchObject($find_groups_q)) { $member_count_q = $this->DB->Query("SELECT 1 FROM dbo.CTM_TeamMembers WHERE dbo.CTM_TeamMembers.PrimaryGroup = " . $find_groups->Id); $member_count = $this->DB->CountRows($member_count_q); $GLOBALS['team_groups'][$find_groups->Id] = array("name" => $find_groups->Name, "format_prefix" => htmlDecode($find_groups->FormatPrefix, true), "format_suffix" => htmlDecode($find_groups->FormatSuffix, true), "count_members" => intval($member_count), "acp_access" => $find_groups->ACP_Access == 1); } } $this->output->setContent("team_manageGroups"); } }
function insertdata($url, $cjtype) { global $db, $action, $rtype, $rpage, $rkey, $rday, $cjurl, $xt, $rid, $cjflag, $backurl; wBreakpoint("../upload/maccjbreakpoint", "admin_maccj.php?action=" . $action . "&xt=" . $xt . "&rid=" . $rid . "&cjflag=" . $cjflag . "&rpage=" . $rpage . "&rtype=" . $rtype . "&rkey=" . $rkey . "&cjurl=" . $cjurl); if ($xt == "1") { $xn_vod = '/<video><last>([\\s\\S]*?)<\\/last><id>([0-9]+)<\\/id><tid>([0-9]+)<\\/tid><name><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/name><type>([\\s\\S]*?)<\\/type><pic>([\\s\\S]*?)<\\/pic><lang>([\\s\\S]*?)<\\/lang><area>([\\s\\S]*?)<\\/area><year>([\\s\\S]*?)<\\/year><state>([\\s\\S]*?)<\\/state><note><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/note><actor><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/actor><director><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/director><dl>([\\s\\S]*?)<\\/dl><des><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/des>([\\s\\S]*?)<\\/video>/'; $xn_url = '/<dd flag="([\\s\\S]*?)"><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/dd>/'; $xn_vod_time = 1; $xn_vod_id = 2; $xn_vod_name = 4; $xn_vod_type = 3; $xn_vod_pic = 6; $xn_vod_language = 7; $xn_vod_area = 8; $xn_vod_year = 9; $xn_vod_state = 10; $xn_vod_remarks = 11; $xn_vod_starring = 12; $xn_vod_directed = 13; $xn_vod_urls = 14; $xn_vod_des = 15; } else { if ($xt == "2") { $xn_vod = '/<video><last>([\\s\\S]*?)<\\/last><id>([0-9]+)<\\/id><tid>([0-9]+)<\\/tid><name><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/name><type>([\\s\\S]*?)<\\/type><dt>([\\s\\S]*?)<\\/dt><pic>([\\s\\S]*?)<\\/pic><lang>([\\s\\S]*?)<\\/lang><area>([\\s\\S]*?)<\\/area><year>([\\s\\S]*?)<\\/year><state>([\\s\\S]*?)<\\/state><note><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/note><actor><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/actor><director><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/director><dl>([\\s\\S]*?)<\\/dl><des><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/des><reurl>([\\s\\S]*?)<\\/reurl><\\/video>/'; $xn_url = '/<dd flag="([\\s\\S]*?)"><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/dd>/'; $xn_vod_time = 1; $xn_vod_id = 2; $xn_vod_name = 4; $xn_vod_type = 3; $xn_vod_pic = 7; $xn_vod_language = 8; $xn_vod_area = 9; $xn_vod_year = 10; $xn_vod_state = 11; $xn_vod_remarks = 12; $xn_vod_starring = 13; $xn_vod_directed = 14; $xn_vod_urls = 15; $xn_vod_des = 16; } else { $xn_vod = '/<vod><id>([0-9]+)<\\/id><name><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/name><note><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/note><state>([\\s\\S]*?)<\\/state><type>([\\s\\S]*?)<\\/type><starring><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/starring><directed><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/directed><pic>([\\s\\S]*?)<\\/pic><time>([\\s\\S]*?)<\\/time><year>([\\s\\S]*?)<\\/year><area><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/area><language><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/language><urls>([\\s\\S]*?)<\\/urls><des><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/des><\\/vod>/'; $xn_url = '/<url from="([\\s\\S]*?)"><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/url>/'; $xn_vod_id = 1; $xn_vod_name = 2; $xn_vod_remarks = 3; $xn_vod_state = 4; $xn_vod_type = 5; $xn_vod_starring = 6; $xn_vod_directed = 7; $xn_vod_pic = 8; $xn_vod_time = 9; $xn_vod_year = 10; $xn_vod_area = 11; $xn_vod_language = 12; $xn_vod_des = 14; $xn_vod_urls = 13; } } $html = getPage($url, "utf-8"); if (html == false) { echo "<table class=\"tb\"><tr><td colspan=2> <a href=\"javascript:void(0)\" onclick=\"location.reload();\">获取数据失败,请点击我重试</a></td></tr></table>"; exit; } if ($xt == "1" || $xt == "2") { $pagecount = intval(getBody($html, "pagecount=\"", "\" pagesize")); } else { $pagecount = intval(getBody($html, "<pagecount>", "</pagecount>")); } if ($pagecount == 0) { echo "<table class=\"tb\"><tr><td><br>没有任何可用数据<script language=\"javascript\">setTimeout(\"gonextpage();\",5000);function gonextpage(){location.href='?action=list&xt=" . $xt . "&rid=" . $rid . "&cjflag=" . $cjflag . "&cjurl=" . $cjurl . "';}</script></td></tr></table>"; exit; } echo "<table class=\"tb\"><tr><td colspan=2>视频采集地址 " . $url . "</td></tr><tr><td colspan=2> 共" . $pagecount . "页,正在采集第" . $rpage . "页</td></tr>"; preg_match_all($xn_vod, $html, $array3); $i = 0; foreach ($array3[1] as $key => $value) { $rc = false; $vodid = $array3[$xn_vod_id][$key]; $vodname = $array3[$xn_vod_name][$key]; $vodremarks = $array3[$xn_vod_remarks][$key]; $vodstate = $array3[$xn_vod_state][$key]; $vodtype = $cjflag . $array3[$xn_vod_type][$key]; $vodstarring = $array3[$xn_vod_starring][$key]; $voddirected = $array3[$xn_vod_directed][$key]; $vodpic = $array3[$xn_vod_pic][$key]; $vodtime = $array3[$xn_vod_time][$key]; $vodyear = $array3[$xn_vod_year][$key]; $vodarea = $array3[$xn_vod_area][$key]; $vodlanguage = $array3[$xn_vod_language][$key]; $voddes = $array3[$xn_vod_des][$key]; $vodurls = $array3[$xn_vod_urls][$key]; preg_match_all($xn_url, $vodurls, $array4); $vodsubname = ""; $vodcolor = ""; $vodhitstime = ""; $voddownurl = ""; $vodplayserver = "0"; $vodfrom = ""; $vodurl = ""; $vodname = replaceStr($vodname, "'", ""); if (strlen($vodname) > 255) { $vodname = substring($vodname, 255); } $vodenname = Hanzi2PinYin($vodname); if (strlen($vodenname) > 255) { $vodenname = substring($vodenname, 255); } if (!isN($vodenname)) { $vodletter = strtoupper(substring($vodenname, 1)); } $vodstate = replaceStr($vodstate, "[", ""); $vodstate = replaceStr($vodstate, "]", ""); if (!isNum($vodstate)) { $vodstate = 0; } $vodstarring = replaceStr($vodstarring, "'", ""); $vodstarring = replaceStr($vodstarring, "、", " "); $vodstarring = replaceStr($vodstarring, ",", " "); $vodstarring = replaceStr($vodstarring, ",", " "); $vodstarring = replaceStr($vodstarring, " ", " "); if (strlen($vodstarring) > 255) { $vodstarring = substring($vodstarring, 255); } $vodyear = replaceStr($vodyear, "'", ""); if (strlen($vodyear) > 32) { $vodyear = substring($vodyear, 32); } $vodlanguage = replaceStr($vodlanguage, "'", ""); if (strlen($vodlanguage) > 32) { $vodlanguage = substring($vodlanguage, 32); } $vodarea = replaceStr($vodarea, "'", ""); if (strlen($vodarea) > 32) { $vodarea = substring($vodarea, 32); } $vodpic = replaceStr($vodpic, "'", ""); if (strlen($vodpic) > 255) { $vodpic = substring($vodpic, 255); } $voddes = htmlDecode($voddes); $voddes = replaceStr($voddes, "'", ""); $vodtype = getTypeID($vodtype); if (!isNum($vodtype)) { $vodtype = 0; } if ($vodtype > 0) { $sql = "SELECT * FROM {pre}vod WHERE d_name ='" . $vodname . "' "; $row = $db->getRow($sql); if (!$row) { foreach ($array4[1] as $key => $value) { if ($rc) { $vodfrom .= "\$\$\$"; $vodurl .= "\$\$\$"; } $vodfrom .= getFrom($value); if ($xt == "1") { $vodurl .= getVUrl($array4[2][$key]); } else { $vodurl .= $array4[2][$key]; } if (substring($vodurl, 1, strlen($vodurl) - 1) == Chr(13)) { $vodurl = substring($vodurl, strlen($vodurl) - 1); } $vodurl = replaceStr($vodurl, Chr(10), "#"); $vodurl = replaceStr($vodurl, Chr(13), "#"); $vodurl = replaceStr($vodurl, "##", "#"); $vodurl = replaceStr($vodurl, "'", "''"); $rc = true; } $db->Add("{pre}vod", array("d_type", "d_name", "d_subname", "d_enname", "d_letter", "d_state", "d_color", "d_content", "d_remarks", "d_pic", "d_level", "d_hits", "d_starring", "d_directed", "d_year", "d_area", "d_language", "d_addtime", "d_time", "d_playurl", "d_downurl", "d_playfrom", "d_playserver"), array($vodtype, $vodname, $vodsubname, $vodenname, $vodletter, $vodstate, $vodcolor, $voddes, $vodremarks, $vodpic, 0, 0, $vodstarring, $voddirected, $vodyear, $vodarea, $vodlanguage, date('Y-m-d H:i:s', time()), date('Y-m-d H:i:s', time()), $vodurl, $voddownurl, $vodfrom, $vodplayserver)); wTips($vodname, "新增数据"); } else { $tmpplayurl = $row["d_playurl"]; $tmpplayfrom = $row["d_playfrom"]; $tmpplayserver = $row["d_playserver"]; foreach ($array4[1] as $key => $value) { $vodfrom = getFrom($value); if ($xt == "1") { $vodurl = getVUrl($array4[2][$key]); } else { $vodurl = $array4[2][$key]; } if (substring($vodurl, 1, strlen($vodurl) - 1) == Chr(13)) { $vodurl = substring($vodurl, strlen($vodurl) - 1); } $vodurl = replaceStr($vodurl, Chr(10), "#"); $vodurl = replaceStr($vodurl, Chr(13), "#"); $vodurl = replaceStr($vodurl, "##", "#"); $vodurl = replaceStr($vodurl, "'", "''"); if ($tmpplayurl == $vodurl) { $resultdes = "无需更新播放地址"; continue; } else { if (isN($vodfrom)) { wTips($vodname, "播放器类型为空,跳过"); continue; } else { if (isN($tmpplayurl) || strpos("," . $row["d_playfrom"], $vodfrom) <= 0) { $resultdes = "新增播放地址组"; $tmpplayurl .= "\$\$\$" . $vodurl; $tmpplayfrom .= "\$\$\$" . $vodfrom; $tmpplayserver .= "\$\$\$" . $vodplayserver; } else { $resultdes = "更新播放地址"; $arr1 = explode("\$\$\$", $tmpplayurl); $arr2 = explode("\$\$\$", $tmpplayfrom); $rc = false; $tmpplayurl = ""; for ($k = 0; $k < count($arr2); $k++) { if ($rc) { $tmpplayurl .= "\$\$\$"; } if ($arr2[$k] == $vodfrom) { $arr1[$k] = $vodurl; } $tmpplayurl .= $arr1[$k]; $rc = true; } } } } } $tmpplayurl = replaceStr($tmpplayurl, Chr(13), "#"); if (strpos("," . $row["d_pic"], "http:") <= 0) { $vodpic = $row["d_pic"]; } $db->Update("{pre}vod", array("d_state", "d_pic", "d_remarks", "d_time", "d_playurl", "d_playfrom", "d_playserver"), array($vodstate, $vodpic, $vodremarks, date('Y-m-d H:i:s', time()), $tmpplayurl, $tmpplayfrom, $tmpplayserver), "d_id=" . $row["d_id"]); wTips($vodname, $resultdes); } unset($row); } else { wTips($vodname, "没有绑定分类、跳过"); } unset($array4); } unset($array3); echo "</table>"; if ($action == "cjday" || $action == "cjall" || $action == "cjtype") { if ($rpage >= $pagecount) { dBreakpoint("../upload/maccjbreakpoint"); echo "<br>数据采集完成<script language=\"javascript\">setTimeout(\"gonextpage();\",3000);function gonextpage(){location.href='?action=list&fa=1&xt=" . $xt . "&rid=" . $rid . "&cjflag=" . $cjflag . "&rtype=" . $rtype . "&cjurl=" . $cjurl . "';}</script>"; } else { echo "<br>暂停3秒后继续采集...<script language=\"javascript\">setTimeout(\"gonextpage();\",3000);function gonextpage(){location.href='?action=" . $action . "&rpage=" . ($rpage + 1) . "&rtype=" . $rtype . "&rday=" . $rday . "&xt=" . $xt . "&rid=" . $rid . "&cjflag=" . $cjflag . "&cjurl=" . $cjurl . "';}</script><a href=\"?action=" . $action . "&rpage=" . ($rpage + 1) . "&rtype=" . $rtype . "&xt=" . $xt . "&rid=" . $rid . "&cjflag=" . $cjflag . "&cjurl=" . $cjurl . "\" >点击进入下一页</a>"; } } else { dBreakpoint("../upload/maccjbreakpoint"); echo "<br>数据采集完成<script language=\"javascript\">setTimeout(\"gonextpage();\",3000);function gonextpage(){location.href='?action=list&fa=1&xt=" . $xt . "&rid=" . $rid . "&cjflag=" . $cjflag . "&rpage=" . $rpage . "&rtype=" . $rtype . "&cjurl=" . $cjurl . "';}</script>"; } }
function get_update_notice($sname, $file_lock, $path, $mail_lock, $remote_git = '', $remote_branch = '') { session_name($sname); session_start(); set_time_limit(300); ignore_user_abort(true); $stime = time(); $work = false; //检测、设置工作标志,存在session里(同一个session_name在一个页面未结束前会保持读写锁状态) if (empty($_SESSION['working'])) { $work = true; } if (file_exists($file_lock)) { $last_work_time = filemtime($file_lock); if ($last_work_time > 0 && time() - $last_work_time < 120) { //上次更新至今有120秒 echo "检测到正在进行工作中,本页面停止载入,请稍后再次访问。"; return false; //exit; } $work = true; unlink($file_lock); } elseif (empty($_SESSION['work_time']) || $stime - $_SESSION['work_time'] > LOCK_TIME) { //保证 LOCK_TIME 秒内只访问一次 $work = true; } if ($work && !file_exists($file_lock)) { $_SESSION['working'] = true; $_SESSION['work_time'] = $stime; file_put_contents($file_lock, $stime); } else { echo "距离上次获取请求时间间隔多短,请稍后再次访问。"; return false; //exit; } echo date("Y-m-d H:i:s") . " 准备中...<br>"; mk_dir($path); if (IS_WIN) { Git::windows_mode(); } if (!file_exists($path . '.git')) { echo date("Y-m-d H:i:s") . " 没有git库,尝试创建...<br>"; if ($remote_git) { //是否设置了远程仓库 echo "尝试从远程仓库克隆数据...<br>"; $ret = Git::clone_remote($path, $remote_git, $remote_branch); //从远程仓库clone(可指定分支) if (!Git::is_repo($ret) || !file_exists($path . '.git') || !$ret) { echo "从远程仓库克隆失败,本地创建...<br>"; $ret = Git::create($path); //如果clone失败,则本地创建 } } else { $ret = Git::create($path); } //直接本地创建 echo date("Y-m-d H:i:s") . " 创建结果:" . (Git::is_repo($ret) ? '成功' : '失败') . "<br>"; } mk_dir($path . 'mp/'); mk_dir($path . 'qy/'); $files = ls_file($path); foreach ($files as $file) { if (!is_dir($path . $file)) { unlink($path . $file); } } $count = 0; $ccount = 0; $ret_mp = get_mp_notice(); if ($ret_mp) { write($path . 'mp_notice.txt', json($ret_mp)); $count++; } $ret_qy = get_qy_notice(); if ($ret_qy) { write($path . 'qy_notice.txt', json($ret_qy)); $count++; } $repo = Git::open($path); if ($count < 2) { echo "由于公告页面可能读取失败,等待下次检测。<br>"; $repo->checkout("."); //撤销所有修改 $_SESSION['work_time'] = $stime - LOCK_TIME; //取消检查时间,让检测可在稍后再次发起 unlink($file_lock); return false; } session_write_close(); //解除session,防止使其他访问页面一直等待session echo date("Y-m-d H:i:s") . " 读取公告列表完毕,开始读取公告内容页...<br>"; $cover_count = 0; if ($ret_mp) { //写出mp平台公告 foreach ($ret_mp as $arr) { $date = strpos($arr['date'], '-') ? $arr['date'] : date('Y-m-d', $arr['date']); $file = $date . '#' . $arr['title'] . '.html'; $file = $path . 'mp/' . preg_replace('/[\\/\\|*?\\\\:<>]/i', '_', $file); $file_exist = is_exist($file); if ($file_exist) { $cover_count++; } if (!$file_exist || $cover_count <= 3) { //只抓取未记录的公告 或已有记录的前3个 $ret = http_get($arr['url']); $search = '/window\\.wxCgi[^=]+=[^{]+{([^}]*)}/s'; preg_match($search, $ret, $strarr); $ret = isset($strarr[1]) ? $strarr[1] : ''; $str_start = stripos($ret, 'content:'); if ($str_start) { $str_start += 9; $str_end = stripos($ret, 'author:'); if ($str_end) { $str_end -= 9; $str = substr($ret, $str_start, stripos($ret, '",', $str_start) - $str_start); if (!empty($str)) { htmlDecode($str); write($file, '<h3 class="announcement_title" style="text-align: center;">' . $arr['title'] . ' # ' . $date . '</h3><div id="content">' . $str . '</div>'); $ccount++; } } } } } } $cover_count = 0; if ($ret_qy) { //写出qy平台公告 foreach ($ret_qy as $arr) { $file = strpos($arr['date'], '-') ? $arr['date'] : date('Y-m-d', $arr['date']); $file .= '#' . $arr['title'] . '.html'; $file = $path . 'qy/' . preg_replace('/[\\/\\|*?\\\\:<>]/i', '_', $file); $file_exist = is_exist($file); if ($file_exist) { $cover_count++; } if (!$file_exist || $cover_count <= 3) { //只抓取未记录的公告 或已有记录的前3个 $ret = http_get($arr['url']); if ($ret) { write($file, $ret); $ccount++; } } } } echo date("Y-m-d H:i:s") . " 读取页面" . $count . "个,抓取公告" . $ccount . "篇<br>"; $ret = $repo->status(true); $no_commit = preg_match('/nothing to commit, working directory clean/', $ret); if ($no_commit) { echo " 未检测到更新,共计用时:" . (time() - $stime) . "秒<br>"; } else { echo "待更新内容:<hr>" . $ret . "<hr>"; $ret0 = $repo->add(); $repo->run('config --global user.email "' . GIT_EMAIL . '"'); //git config --global user.email "*****@*****.**" $repo->run('config --global user.name "' . GIT_NAME . '"'); //git config --global user.name "Your Name" $repo->run('config --global core.quotepath false'); //配置git显示中文不转码 $ret = $repo->commit('check time: ' . date("Y-m-d H:i:s")); echo time() . " 已进行git提交,共计用时:" . (time() - $stime) . "秒<br><br>"; if ($remote_git) { $branch = $repo->active_branch(); echo "检测到远程仓库参数,提交到远程仓库...<br>"; $repo->run("remote add {$stime} " . $remote_git); //添加远程仓库 $repo->run("push -f {$stime} {$branch}:" . (empty($remote_branch) ? 'master' : "{$remote_branch}")); //强制覆盖远程仓库(可指定分支) $repo->run("remote remove {$stime}"); //删除远程仓库 } echo "提交git日志内容如下:<hr>" . nl2br(htmlspecialchars($ret)); $ret2 = $repo->run('log --stat -p -1'); $ret2 = nl2br(htmlspecialchars(substr($ret2, 0, stripos($ret2, "\ndiff --git")))); echo "<hr>其他日志:<br>" . nl2br(htmlspecialchars($ret0)) . $ret2; if (!stripos($ret2, '_notice.txt') && $ccount > 0) { //如果公告列表没有更新,则认为没有更新公告。避免公告内容页不紧要的排版更新。 $no_commit = true; } unlink($mail_lock); } unlink($file_lock); return !$no_commit; }
/** * Init Module * * @return void */ public function initSection() { $this->DB->Arguments($_GET['id']); $find_ticket_q = $this->DB->Query("SELECT * FROM dbo.CTM_Tickets WHERE Id = %d"); if ($this->DB->CountRows($find_ticket_q) > 0) { $ticket = $this->DB->FetchObject($find_ticket_q); define("EDIT_TICKET_ACCESS", $this->CheckPermissionItem("edit_ticket")); define("DELETE_TICKET_ACCESS", $this->CheckPermissionItem("delete_ticket")); switch ($_GET['cmd']) { case "annex": if (!empty($ticket->Annex)) { ini_set("memory_limit", "240M"); ob_end_clean(); $filename = "../" . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['TICKET_ANNEX'] . $ticket->Annex; $fileext = substr($filename, strrpos($filename, ".")); if (preg_match("/\\.([gif|jpg|jpeg|png])/i", $fileext)) { switch ($fileext) { case ".gif": $image = imagecreatefromgif($filename); header("Content-type: image/gif"); imagegif($image); break; case ".png": $image = imagecreatefrompng($filename); header("Content-type: image/png"); imagepng($image); break; case ".jpg": $image = imagecreatefromjpeg($filename); header("Content-type: image/jpeg"); imagejpeg($image); break; case ".jpeg": $image = imagecreatefromjpeg($filename); header("Content-type: image/jpeg"); imagejpeg($image); break; } imagedestroy($image); } else { header("Content-type: text/plain"); readfile($filename); } } exit; break; case "close": if ($ticket->Status == 3) { if ($_GET['return'] == true) { exit("<script>location.href='?app=support&do=tickets&load=isClosed';</script>"); } else { exit(adminShowMessage($this->lang->words['EWSupport']['Tickets']['ViewTicket']['CloseTicket']['Messages']['TicketClosed'], 2)); } } else { $this->DB->Arguments($_GET['id']); $this->DB->Query("UPDATE dbo.CTM_Tickets SET Status = 3 WHERE Id = %d"); if ($_GET['return'] == true) { exit("<script>location.href='?app=support&do=tickets&load=closed';</script>"); } else { exit("<script>closeThisTicket();</script>"); } } break; case "reply": if (empty($_POST['ReplyText'])) { exit(adminShowMessage($this->lang->words['EWSupport']['Tickets']['ViewTicket']['ReplyTicket']['Messages']['TextVold'], 2)); } else { $sendDate = time(); $this->DB->Arguments($_GET['id'], $this->member['account']['data']['Name'], USER_ACCOUNT, $sendDate, htmlEncode($_POST['ReplyText'])); $this->DB->Query("INSERT INTO dbo.CTM_TicketReplies (TicketID, Author, Account, [Date], Message) VALUES (%d, '%s', '%s', %d, '%s')"); $this->DB->Arguments($_GET['id']); $this->DB->Query("UPDATE dbo.CTM_Tickets SET Status = 1 WHERE Id = %d"); $id = $this->DB->GetLastedId(); exit("<script>addReplyTicket('" . str_replace("'", "\\'", $_POST['ReplyText']) . "','" . $this->member['account']['data']['Name'] . "','" . date("d/m/Y - H:i", $sendDate) . "',{$id});</script>"); } break; case "edit": if (EDIT_TICKET_ACCESS) { if (empty($_POST['Subject']) || empty($_POST['Message'])) { exit(adminShowMessage($this->lang->words['EWSupport']['Tickets']['ViewTicket']['EditTicket']['Messages']['FieldsVold'], 1)); } $this->DB->Arguments(htmlEncode($_POST['Subject']), $_POST['Departament'], $_POST['Status'], htmlEncode($_POST['Message']), $_GET['id']); $this->DB->Query("UPDATE dbo.CTM_Tickets SET Subject = '%s',Departament = %d,Status = %d,Text = '%s' WHERE Id = %d"); switch ($_POST['Status']) { case 0: $status = "<span style='color: blue;'>" . $this->lang->words['EWSupport']['Tickets']['Status']['Opened'] . "</span>"; break; case 1: $status = "<span style='color: green;'>" . $this->lang->words['EWSupport']['Tickets']['Status']['Responded'] . "</span>"; break; case 2: $status = "<span style='color: orange;'>" . $this->lang->words['EWSupport']['Tickets']['Status']['Progress'] . "</span>"; break; case 3: $status = "<span style='color: red;'>" . $this->lang->words['EWSupport']['Tickets']['Status']['Closed'] . "</span>"; break; } $return = "<script>completeEditTicket("; $return .= "'" . str_replace("'", "\\'", htmlDecode(htmlEncode($_POST['Subject']), TRUE)) . "',"; $return .= "'" . str_replace("'", "\\'", $this->settings['USERPANEL']['SUPPORT']['TICKETS']['DEPARTAMENTS'][$_POST['Departament']]) . "',"; $return .= "'" . str_replace("'", "\\'", $status) . "',"; $return .= "'" . str_replace("'", "\\'", htmlDecode(htmlEncode($_POST['Message']), TRUE)) . "'"; $return .= ");</script>"; exit($return); } break; case "delete": if (DELETE_TICKET_ACCESS) { $query = "DELETE FROM dbo.CTM_Tickets WHERE Id = %d;\n"; $query .= "DELETE FROM dbo.CTM_TicketReplies WHERE TicketID = %d;"; $this->DB->Arguments($_GET['id'], $_GET['id']); $this->DB->Query($query); if (!empty($ticket->Annex)) { if (file_exists("../" . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['TICKET_ANNEX'] . $ticket->Annex)) { unlink("../" . $this->settings['WEBDATA']['UPLOADS']['DIRECTORY']['TICKET_ANNEX'] . $ticket->Annex); } } exit("<script>location.href='" . $this->acp_vars['acp_url'] . "?app=effectweb&module=support§ion=tickets&message=deleted';</script>"); } break; case "editReply": $this->DB->Arguments($_GET['rid'], $_GET['id']); $query = $this->DB->Query("SELECT Id,Message FROM dbo.CTM_TicketReplies WHERE Id = %d AND TicketID = %d"); if ($this->DB->CountRows($query) > 0) { if ($_GET['write'] == TRUE) { if (empty($_POST['ReplyMessage'])) { exit(adminShowMessage($this->lang->words['EWSupport']['Tickets']['ViewTicket']['EditReply']['Messages']['FieldVoid'], 1)); } $this->DB->Arguments(htmlEncode($_POST['ReplyMessage']), $_GET['rid'], $_GET['id']); $this->DB->Query("UPDATE dbo.CTM_TicketReplies SET Message = '%s' WHERE Id = %d AND TicketID = %d"); exit("<script>editTicketReply('" . str_replace(array("\n", "\r"), NULL, $_POST['ReplyMessage']) . "'," . $_GET['rid'] . ");</script>"); } else { $reply = $this->DB->FetchArray($query); $noOpenCache = TRUE; $GLOBALS['edit_reply']['ticket_id'] = $_GET['id']; $GLOBALS['edit_reply']['reply_id'] = $_GET['rid']; $GLOBALS['edit_reply']['reply_message'] = str_replace(array("\n", "\r"), NULL, htmlDecode($reply['Message'], true)); $this->output->setContent("tickets_viewTicket_editReply"); $this->output->setVariable("no_set_temp", true); } } else { exit; } break; case "deleteReply": $this->DB->Arguments($_GET['rid'], $_GET['id']); $query = $this->DB->Query("SELECT Id FROM dbo.CTM_TicketReplies WHERE Id = %d AND TicketID = %d"); if ($this->DB->CountRows($query) > 0) { $this->DB->Arguments($_GET['rid'], $_GET['id']); $this->DB->Query("DELETE FROM dbo.CTM_TicketReplies WHERE Id = %d AND TicketID = %d"); exit("<script>" . "\$" . "('#replyId-" . $_GET['rid'] . "').hide('slow');</script>"); } exit; break; } $this->DB->Arguments($_GET['id']); $query = $this->DB->Query("SELECT * FROM dbo.CTM_TicketReplies WHERE TicketID = %d"); $replies = array(); if ($this->DB->CountRows($query) > 0) { while ($reply = self::DB()->FetchObject($query)) { $replies[$reply->Id] = array("author" => $reply->Author, "is_team" => $this->functions->CheckTeamACP($reply->Account), "send_date" => date("d/m/Y - G:i a", $reply->Date), "message" => htmlDecode($reply->Message, true)); } } $GLOBALS['view_ticket'] = array("id" => $ticket->Id, "subject" => $ticket->Subject, "departament" => array("id" => $ticket->Departament, "title" => $this->settings['USERPANEL']['SUPPORT']['TICKETS']['DEPARTAMENTS'][$ticket->Departament]), "open_date" => date("d/m/Y - G:i a", $ticket->Date), "account" => $ticket->Account, "character" => $ticket->Character, "message" => nl2br(htmlDecode($ticket->Text)), "status" => $ticket->Status, "protocol" => $ticket->Protocol, "annex" => $ticket->Annex, "replies" => $replies); if ($noOpenCache == false) { $this->output->setContent("tickets_viewTicket"); } } }