/** * Private: Send Global Message * Send a message in global display from all players by JoinServer * * @return void */ public function loadSendGlobalMessage() { if ($_GET['write'] == true) { if (empty($_POST['message'])) { $GLOBALS['result_message'] = adminShowMessage($this->lang->words['Server']['GameControl']['SendGlobalMessage']['Messages']['MessageVoid'], 1); } else { if (!$this->MuLib('JoinServer')->SendGlobalMessage($_POST['message'])) { $GLOBALS['result_message'] = sprintf($this->lang->words['Server']['GameControl']['SendGlobalMessage']['Messages']['SendError'], CoreVariables::ErrorsCode()->JoinServerFail); $GLOBALS['result_message'] = adminShowMessage($GLOBALS['result_message'], 2); } else { $GLOBALS['result_message'] = adminShowMessage($this->lang->words['Server']['GameControl']['SendGlobalMessage']['Messages']['Success'], 3); } } } $this->output->setContent("gamecontrol_sendGlobalMessage"); }
/** * 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"); }
/** * Init Module * * @return void */ public function initSection() { switch ($_GET['message']) { case "isClosed": $GLOBALS['result_message'] = adminShowMessage($this->lang->words['EWSupport']['Tickets']['ManageTickets']['Messages']['IsClosed'], 2); break; case "deleted": $GLOBALS['result_message'] = adminShowMessage($this->lang->words['EWSupport']['Tickets']['ManageTickets']['Messages']['Deleted'], 3); break; case "closed": $GLOBALS['result_message'] = adminShowMessage($this->lang->words['EWSupport']['Tickets']['ManageTickets']['Messages']['Closed'], 3); break; } $GLOBALS['all_tickets'] = array(); $find_tickets = $this->DB->Query("SELECT Id, Subject, Departament, Account, [Date], Status FROM CTM_Tickets ORDER BY Id DESC, Status ASC"); if ($this->DB->CountRows($find_tickets) > 0) { while ($ticket = $this->DB->FetchObject($find_tickets)) { $GLOBALS['all_tickets'][$ticket->Id] = array("subject" => $ticket->Subject, "departament" => $this->settings['USERPANEL']['SUPPORT']['TICKETS']['DEPARTAMENTS'][$ticket->Departament], "account" => $ticket->Account, "open_date" => date("d/m/Y G:i a", $ticket->Date), "status" => $ticket->Status); } } $this->output->setContent("tickets_manageTickets"); }
/** * 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']); } }
/** * Private: Edit Poll * Edit a poll from Effect Web * * @return void */ private function loadEditPoll() { $GLOBALS['poll_exists'] = $this->loadCheckPoll($_GET['id']); if ($GLOBALS['poll_exists'] == true) { if ($_GET['write'] == true) { $date = explode("/", $_POST['expiration']); if (empty($_POST['fieldQuestion'])) { $GLOBALS['result_command'] = $this->lang->words['EWMain']['Polls']['EditPoll']['Messages']['FieldsVoid']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } elseif (empty($_POST['answerCount']) || $_POST['answerCount'] < 2) { $GLOBALS['result_command'] = $this->lang->words['EWMain']['Polls']['EditPoll']['Messages']['AnswerError']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif (count($date) != 3) { $GLOBALS['result_command'] = $this->lang->words['EWMain']['Polls']['EditPoll']['Messages']['DateError']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { $expiration = mktime(23, 59, 59, $date[0], $date[1], $date[2]); $break = 0; for ($i = 1; $i <= $_POST['answerCount']; $i++) { if (empty($_POST['Answer_' . $i]) || $_POST['VotesAnswers_' . $i] == NULL) { $break++; } } if ($break > 0) { $GLOBALS['result_command'] = $this->lang->words['EWMain']['Polls']['EditPoll']['Messages']['FieldsVoid']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } else { $prepare = "UPDATE dbo.CTM_Polls SET Question = '%s', EndDate = %d, Status = %d WHERE Id = %d;\n"; for ($i = 1; $i <= $_POST['answerCount']; $i++) { if ($i > $_POST['answerAfterCount']) { $poll_id = intval($_GET['id']); $answer = htmlEncode($_POST['Answer_' . $i]); $votes = (int) $_POST['VotesAnswers_' . $i]; $prepare .= "INSERT INTO dbo.CTM_PollAnswers (PollID, Answer, Votes) VALUES ({$poll_id}, '{$answer}', {$votes});\n"; } else { if ($this->loadCheckAnswer($_POST['IdAnswer_' . $i], $_GET['id']) == true) { $answer_id = intval($_POST['IdAnswer_' . $i]); $poll_id = intval($_GET['id']); $answer = htmlEncode($_POST['Answer_' . $i]); $votes = (int) $_POST['VotesAnswers_' . $i]; $prepare .= "UPDATE dbo.CTM_PollAnswers SET Answer = '{$answer}', Votes = {$votes} WHERE Id = {$answer_id} AND PollID = {$poll_id};\n"; } } } $this->DB->Arguments(htmlEncode($_POST['fieldQuestion']), $expiration, $_POST['PollStatus'], intval($_GET['id'])); $this->DB->Query($prepare); $GLOBALS['result_command'] = $this->lang->words['EWMain']['Polls']['EditPoll']['Messages']['Success']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); } } } $find_poll_q = $this->DB->Query("SELECT * FROM dbo.CTM_Polls WHERE Id = " . intval($_GET['id'])); $find_poll = $this->DB->FetchObject($find_poll_q); $find_answers_q = $this->DB->Query("SELECT * FROM dbo.CTM_PollAnswers WHERE PollID = " . intval($_GET['id'])); $find_answers_c = $this->DB->CountRows($find_answers_q); $answers = array(); $i = 1; while ($find_answers = $this->DB->FetchObject($find_answers_q)) { $answers[$i++] = array("id" => intval($find_answers->Id), "answer" => $find_answers->Answer, "votes" => intval($find_answers->Votes)); } $GLOBALS['edit_poll'] = array("answer_after_count" => intval($find_answers_c), "question" => $find_poll->Question, "end_date" => date("m/d/Y", $find_poll->EndDate), "status" => intval($find_poll->Status), "answers" => $answers); unset($answers, $i); $this->lang->setArguments("EWMain,Polls,EditPoll,Title", $_GET['id']); } }
/** * Private: Manage Character * Manage a character from database * * @return void */ private function loadManageCharacter() { if ($this->loadCheckCharacter($_GET['charname'])) { $char_data = $this->MuLib('Member')->LoadChar($_GET['charname'] = urldecode($_GET['charname'])); switch ($_GET['do']) { case "ban": if ($this->CheckPermissionItem("characters_manageCharacter_ban") == true) { if ($_GET['write'] == true) { if (empty($_POST['banReason']) || empty($_POST['banExpiration'])) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['BanCharacter']['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']['Characters']['ManageCharacter']['BanCharacter']['Messages']['DateInvalid']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif ($char_data['CtlCode'] == 1) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['BanCharacter']['Messages']['CharacterBanned']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { $insert_columns = array("Responsible" => USER_ACCOUNT, "Account" => $char_data['AccountID'], "Character" => $_GET['charname'], "Expiration" => $expiration = mktime(23, 59, 59, $date[0], $date[1], $date[2]), "Reason" => htmlEncode($_POST['banReason'])); $this->DB->Arguments($_GET['charname']); $this->DB->Delete("CTM_CharactersBanneds", "Character = '%s'"); $this->DB->Arguments($_GET['charname']); $this->DB->Update(MUGEN_CORE . "@Character", array("CtlCode" => 1), "Name = '%s'"); $this->DB->Insert("CTM_CharactersBanneds", $insert_columns); $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['BanCharacter']['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("characters_banCharacter"); } break; case "unban": if ($this->CheckPermissionItem("characters_manageCharacter_unban") == true) { if ($_GET['write'] == true) { if ($char_data['CtlCode'] != 1) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['UnbanCharacter']['Messages']['NoBanned']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { $this->DB->Arguments($_GET['charname']); $this->DB->Delete("CTM_CharactersBanneds", "Account = '%s'"); $this->DB->Arguments($_GET['charname']); $this->DB->Update(MUGEN_CORE . "@Character", array("CtlCode" => 0), "Name = '%s'"); if (loadIsAjax() == false) { $_GET['write'] = FALSE; $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['UnbanCharacter']['Messages']['Success']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); if ($_GET['go'] == "banneds") { $this->loadBannedCharacters(); $this->output->setContent("accounts_bannedCharacters"); } else { $this->loadSearchCharacters(); $this->output->setContent("characters_search"); } return NULL; } } if (loadIsAjax() == true) { exit($GLOBALS['result_command']); } } if ($char_data['CtlCode'] == 1) { $this->DB->Arguments($_GET['charname']); $characterBlockInfoQ = $this->DB->Select("Responsible,Expiration,Reason", "CTM_CharactersBanneds", "Character = '%s'"); if ($this->DB->CountRows($characterBlockInfoQ) > 0) { $characterBlockInfo = $this->DB->FetchObject($characterBlockInfoQ); $GLOBALS['block_info']['responsible'] = $characterBlockInfo->Responsible; $GLOBALS['block_info']['expiration'] = date("d/m/Y - H:i", $characterBlockInfo->Expiration); $GLOBALS['block_info']['reason'] = $characterBlockInfo->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("characters_unbanCharacter"); } break; default: if ($this->CheckPermissionItem("characters_manageCharacter_edit") == true) { if ($_GET['write'] == "name" && loadIsAjax() == true) { if (empty($_POST['NewName'])) { exit(adminShowMessage($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['ChangeName']['Messages']['NameVoid'], 1)); } elseif (strlen($_POST['NewName']) > 10) { exit(adminShowMessage($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['ChangeName']['Messages']['MaxLength'], 2)); } elseif (eregi("[^a-zA-Z0-9_!=?&-]", $_POST['NewName'])) { exit(adminShowMessage($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['ChangeName']['Messages']['CaractersInvalid'], 2)); } else { $rename = $this->MuLib('Member')->RenameCharacter($_GET['charname'], $char_data['AccountID'], $_POST['NewName']); if ($rename == "NAME_IN_USE") { exit(adminShowMessage($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['ChangeName']['Messages']['NameInUse'], 2)); } elseif ($rename == "ALL_OK") { exit("<script>editCharacter_writeSuccess('name', '" . str_replace("'", "\\'", $_POST['NewName']) . "');</script>"); } else { exit(adminShowMessage(sprintf($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['ChangeName']['Messages']['Error'], 12), 2)); } } } elseif ($_GET['write'] == "account" && loadIsAjax() == true) { if (empty($_POST['NewAccount'])) { exit(adminShowMessage($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['ChangeAccount']['Messages']['AccountVoid'], 1)); } elseif (strlen($_POST['NewAccount']) > 10) { exit(adminShowMessage($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['ChangeAccount']['Messages']['MaxLength'], 2)); } else { $change_command = $this->MuLib('Member')->ChangeCharacterAccount($_GET['charname'], $char_data['AccountID'], $_POST['NewAccount']); if ($change_command == "ACCOUNT_NO_EXISTS") { exit(adminShowMessage($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['ChangeAccount']['Messages']['AccountNoExists'], 2)); } elseif ($change_command == "ID_ERROR") { exit(adminShowMessage($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['ChangeAccount']['Messages']['NoSlot'], 2)); } else { exit("<script>editCharacter_writeSuccess('account', '" . str_replace("'", "\\'", $_POST['NewAccount']) . "');</script>"); } } } elseif ($_GET['write'] == "save") { if (strlen($_POST['C_Level']) < 1 || strlen($_POST['C_LevelUpPoint']) < 1 || strlen($_POST['C_Class']) < 1 || strlen($_POST['C_Experience']) < 1 || strlen($_POST['C_Money']) < 1 || strlen($_POST['C_MapNumber']) < 1 || strlen($_POST['C_MapPosX']) < 1 || strlen($_POST['C_MapPosY']) < 1 || strlen($_POST['C_PkCount']) < 1 || strlen($_POST['C_PkLevel']) < 1 || strlen($_POST['C_PkTime']) < 1 || strlen($_POST['C_CtlCode']) < 1 || strlen($_POST['C_HeroCount']) < 1 || strlen($_POST['C_Resets']) < 1 || strlen($_POST['C_RDaily']) < 1 || strlen($_POST['C_RWeekly']) < 1 || strlen($_POST['C_RMonthly']) < 1 || strlen($_POST['C_MResets']) < 1 || strlen($_POST['C_MRDaily']) < 1 || strlen($_POST['C_MRWeekly']) < 1 || strlen($_POST['C_MRMonthly']) < 1 || strlen($_POST['C_Strength']) < 1 || strlen($_POST['C_Dexterity']) < 1 || strlen($_POST['C_Vitality']) < 1 || strlen($_POST['C_Energy']) < 1 || strlen($_POST['C_Command']) < 1 && MUSERVER_VERSION >= 1) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['FieldsVoid']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } elseif ($_POST['C_Level'] < 1 || $_POST['C_Level'] > MAX_LEVEL) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['InvalidLevel']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif ($_POST['C_Strength'] > MAX_STRENGTH) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['MaxStrength']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif ($_POST['C_Dexterity'] > MAX_DEXTERITY) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['MaxDexterity']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif ($_POST['C_Vitality'] > MAX_VITALITY) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['MaxVitality']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif ($_POST['C_Energy'] > MAX_ENERGY) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['MaxEnergy']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif ($_POST['C_Command'] > MAX_COMMAND && MUSERVER_VERSION >= 1) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['MaxCommand']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif ($_POST['C_PkLevel'] < 0 || $_POST['C_PkLevel'] > 7) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['InvalidPkLevel']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif (!in_array($_POST['C_CtlCode'], array(0, 1, CTLCODE_GAMEMASTER))) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['InvalidCtlCode']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { $class_index = substr($_POST['C_Class'], 0, 1); $class_id = substr($_POST['C_Class'], 2); $class_number = $this->settings['CLASSCODE'][$class_id][0]; if (!array_key_exists($class_id, $this->settings['CLASSCODE'])) { $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['InvalidClass']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { $update_columns = array("cLevel" => intval($_POST['C_Level']), "LevelUpPoint" => intval($_POST['C_LevelUpPoint']), "Experience" => intval($_POST['C_Experience']), "Strength" => intval($_POST['C_Strength']), "Dexterity" => intval($_POST['C_Dexterity']), "Vitality" => intval($_POST['C_Vitality']), "Energy" => intval($_POST['C_Energy']), "Money" => intval($_POST['C_Money']), "MapNumber" => intval($_POST['C_MapNumber']), "MapPosX" => intval($_POST['C_MapPosX']), "MapPosY" => intval($_POST['C_MapPosY']), "PkLevel" => intval($_POST['C_PkLevel']), "PkTime" => intval($_POST['C_PkTime']), "CtlCode" => intval($_POST['C_CtlCode']), COLUMN_RESET => intval($_POST['C_Resets']), COLUMN_RDAILY => intval($_POST['C_RDaily']), COLUMN_RWEEKLY => intval($_POST['C_RWeekly']), COLUMN_RMONTHLY => intval($_POST['C_RMonthly']), COLUMN_MRESET => intval($_POST['C_MResets']), COLUMN_MRDAILY => intval($_POST['C_MRDaily']), COLUMN_MRWEEKLY => intval($_POST['C_MRWeekly']), COLUMN_MRMONTHLY => intval($_POST['C_MRMonthly']), COLUMN_PKCOUNT => intval($_POST['C_PkCount']), COLUMN_HEROCOUNT => intval($_POST['C_HeroCount'])); if (MUSERVER_VERSION >= 1) { $update_columns[COLUMN_COMMAND] = intval($_POST['C_Command']); } if ($class_number != $char_data['Class']) { $this->MuLib('Quest')->OpenQuest($_GET['charname']); $this->MuLib('Quest')->GetAllQuestStatus($quests); $this->MuLib('Quest')->GetQuestDatabase(-1, $quest_db); switch ($class_index) { case 2: if ($class_id != "LE" && $class_id != "DM" && $class_id != "FM") { $this->MuLib('Quest')->SetQuestStatus(0, 2); $this->MuLib('Quest')->SetQuestStatus(1, 2); if (MUSERVER_VERSION >= 4) { $this->MuLib('Quest')->SetQuestStatus(4, 3); $this->MuLib('Quest')->SetQuestStatus(5, 3); $this->MuLib('Quest')->SetQuestStatus(6, 3); $this->MuLib('Quest')->SetQuestStatus(7, 3); } } break; case 3: if ($class_id != "LE" && $class_id != "DM" && $class_id != "FM") { $this->MuLib('Quest')->SetQuestStatus(0, 2); $this->MuLib('Quest')->SetQuestStatus(1, 2); //$this->MuLib('Quest')->SetQuestStatus(2, 2); } $this->MuLib('Quest')->SetQuestStatus(4, 2); $this->MuLib('Quest')->SetQuestStatus(5, 2); $this->MuLib('Quest')->SetQuestStatus(6, 2); $this->MuLib('Quest')->SetQuestStatus(7, 2); break; default: $this->MuLib('Quest')->SetAllQuestStatus(3); break; } $update_columns['Class'] = $this->settings['CLASSCODE'][$class_id][0]; $update_columns['Quest'] = "0x" . $this->MuLib('Quest')->CloseQuest(false); } $this->MuLib('Member')->UpdateCharacter($_GET['charname'], $update_columns); $GLOBALS['result_command'] = $this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['Save']['Messages']['Success']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); } } } elseif ($_GET['write'] == "delete") { $this->MuLib('Member')->DeleteCharacter($_GET['charname'], $char_data['AccountID'], false); $this->loadSearchCharacters(true, adminShowMessage($this->lang->words['Members']['Characters']['ManageCharacter']['EditCharacter']['DeleteCharacter']['Success'], 3)); $this->output->setContent("characters_search"); return NULL; } $this->DB->Arguments($char_data['AccountID']); $this->DB->Query("SELECT * FROM " . MUACC_CORE . ".dbo.MEMB_STAT WHERE memb___id = '%s'", $stat_query); if ($this->DB->CountRows($stat_query) > 0) { $stat_fetch = $this->DB->FetchObject($stat_query); $stat_array = array("server" => $this->functions->GetServerName($stat_fetch->ServerName), "ip" => $stat_fetch->IP, "date" => date("d/m/Y - h:i a", strtotime($stat_fetch->ConnectTM))); } else { $stat_array = array("server" => $this->lang->words['Words']['None'], "ip" => $this->lang->words['Words']['None'], "date" => $this->lang->words['Words']['Never']); } $class[0] = array(); $class[1] = array(); $clsss[2] = array(); $class[0]['DW'] = $this->settings['CLASSCODE']['DW'][1]; $class[0]['DK'] = $this->settings['CLASSCODE']['DK'][1]; $class[0]['FE'] = $this->settings['CLASSCODE']['FE'][1]; if (MUSERVER_VERSION >= 5) { $class[0]['SU'] = $this->settings['CLASSCODE']['SU'][1]; } $class[1]['SM'] = $this->settings['CLASSCODE']['SM'][1]; $class[1]['BK'] = $this->settings['CLASSCODE']['BK'][1]; $class[1]['ME'] = $this->settings['CLASSCODE']['ME'][1]; if (MUSERVER_VERSION >= 5) { $class[1]['BS'] = $this->settings['CLASSCODE']['BS'][1]; } $class[1]['MG'] = $this->settings['CLASSCODE']['MG'][1]; if (MUSERVER_VERSION >= 1) { $class[1]['DL'] = $this->settings['CLASSCODE']['DL'][1]; } if (MUSERVER_VERSION >= 4) { $class[2]['GM'] = $this->settings['CLASSCODE']['GM'][1]; $class[2]['BM'] = $this->settings['CLASSCODE']['BM'][1]; $class[2]['HE'] = $this->settings['CLASSCODE']['HE'][1]; if (MUSERVER_VERSION >= 5) { $class[2]['DIM'] = $this->settings['CLASSCODE']['DIM'][1]; } $class[2]['DM'] = $this->settings['CLASSCODE']['DM'][1]; $class[2]['LE'] = $this->settings['CLASSCODE']['LE'][1]; } if (MUSERVER_VERSION == 8) { $class[1]['RF'] = $this->settings['CLASSCODE']['RF'][1]; $class[2]['FM'] = $this->settings['CLASSCODE']['FM'][1]; } $GLOBALS['class_info'] = array(0 => $class[0], 1 => $class[1], 2 => $class[2]); $GLOBALS['character_info'] = array("info" => array("photo" => $this->functions->GetCharImage($char_data[COLUMN_CHARIMAGE])), "data" => array("name" => $_GET['charname'], "account" => $char_data['AccountID'], "class" => $char_data['Class'], "level" => $char_data['cLevel'], "experience" => $char_data['Experience'], "points" => $char_data['LevelUpPoint'], "money" => $char_data['Money'], "strength" => $char_data['Strength'], "dexterity" => $char_data['Dexterity'], "vitality" => $char_data['Vitality'], "energy" => $char_data['Energy'], "command" => $char_data[COLUMN_COMMAND] ? $char_data[COLUMN_COMMAND] : 0, "ctlcode" => $char_data['CtlCode'], "map_number" => $char_data['MapNumber'], "map_pos_x" => $char_data['MapPosX'], "map_pos_y" => $char_data['MapPosY'], "pk_level" => $char_data['PkLevel'], "pk_time" => $char_data['PkTime'], "pk_count" => $char_data[COLUMN_PKCOUNT], "hero_count" => $char_data[COLUMN_HEROCOUNT], "resets_general" => $char_data[COLUMN_RESET], "resets_daily" => $char_data[COLUMN_RDAILY], "resets_weekly" => $char_data[COLUMN_RWEEKLY], "resets_monthly" => $char_data[COLUMN_RMONTHLY], "mresets_general" => $char_data[COLUMN_MRESET], "mresets_daily" => $char_data[COLUMN_MRDAILY], "mresets_weekly" => $char_data[COLUMN_MRWEEKLY], "mresets_monthly" => $char_data[COLUMN_MRMONTHLY]), "stat" => $stat_array); $this->output->setContent("characters_editCharacter"); } break; } } }
/** * Private: System Logs * View and manage the system's logs * * @return void */ private function loadSystemLogs() { if (!empty($_GET['load_file']) && !empty($_GET['folder'])) { if (array_key_exists($_GET['folder'], $this->logs_folders)) { $folder = $this->logs_folders[$_GET['folder']][0]; $file = $folder . "-(" . str_replace(EW_LOG_EXT, NULL, $_GET['load_file']) . ")" . EW_LOG_EXT; $_GET['load_file'] = urldecode($_GET['load_file']); $GLOBALS['file_exists'] = file_exists(EW_LOG_PATH . $folder . "/" . $_GET['load_file']); if ($GLOBALS['file_exists'] == true) { $GLOBALS['log_file_content'] = file_get_contents(EW_LOG_PATH . $folder . "/" . $_GET['load_file']); } if ($_GET['do'] == "download") { if ($GLOBALS['file_exists'] == true) { if (CTM_ACP_USE_ZIP == "gzip") { showFileDownload($file . ".gz", gzencode($GLOBALS['log_file_content'], 9)); } elseif (CTM_ACP_USE_ZIP == "zip") { if (class_exists("ZipArchive")) { $zip = new ZipArchive(); $zip->open($filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "log__::" . time() . "__zip") . ".tmp", ZipArchive::CREATE); $zip->addFile(EW_LOG_PATH . $folder . "/" . $_GET['load_file'], $_GET['load_file']); $zip->close(); $content = file_get_contents($filepath); unlink($filepath); } else { $zip = new ZipFile(); $zip->addFile($GLOBALS['log_file_content'], $_GET['load_file'], filemtime(EW_LOG_PATH . $log . "/" . $filename)); $content = $zip->file(); } showFileDownload($file . ".zip", $content); } else { showFileDownload($file, $GLOBALS['log_file_content']); } } } elseif ($_GET['do'] == "delete") { if ($GLOBALS['file_exists'] == true) { if (!unlink(EW_LOG_PATH . $folder . "/" . $_GET['load_file'])) { $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['ShowLogs']['Messages']['DeleteError']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { $url = "?app=core&module=system§ion=analysis&index=logs&load_folder=" . $_GET['folder'] . "&message=file_deleted"; header("Location: " . CTM_URLEngine::URLBase() . $url); exit; } } } $this->lang->setArguments("System,Analysis,SystemLogs,ShowLogs,Title", $_GET['load_file']); return $this->output->setContent("analysis_logsShowFile"); } else { header("Location: " . CTM_URLEngine::URLBase() . "?app=core&module=system§ion=analysis&index=logs"); } } elseif (!empty($_GET['load_folder'])) { if (array_key_exists($_GET['load_folder'], $this->logs_folders)) { $log = $this->logs_folders[$_GET['load_folder']][0]; if (!file_exists(EW_LOG_PATH . $log)) { mkdir(EW_LOG_PATH . $log); $GLOBALS['logs_files'] = array(); } else { if ($_GET['do'] == true) { if ($_POST['DoCommand'] == "deleteFiles") { $count = 0; if (count($_POST) > 0) { foreach ($_POST as $key => $value) { if (substr($key, 0, 6) == "file__" && $value == 1) { $file = substr($key, 6); $file = str_replace("_" . substr(EW_LOG_EXT, 1), EW_LOG_EXT, $file); if (file_exists(EW_LOG_PATH . $log . "/" . $file)) { unlink(EW_LOG_PATH . $log . "/" . $file); $count++; } } } } $GLOBALS['result_command'] = sprintf($this->lang->words['System']['Analysis']['SystemLogs']['CategoryLogs']['Messages']['FilesDeleted'], $count); $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); } elseif ($_POST['DoCommand'] == "downloadFiles") { $files_to_download = array(); if (count($_POST) > 0) { foreach ($_POST as $key => $value) { if (substr($key, 0, 6) == "file__" && $value == 1) { $file = substr($key, 6); $file = str_replace("_" . substr(EW_LOG_EXT, 1), EW_LOG_EXT, $file); if (file_exists(EW_LOG_PATH . $log . "/" . $file)) { $files_to_download[] = $file; } } } } if (count($files_to_download) == 0) { $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['CategoryLogs']['Messages']['SelectFiles']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } else { if (class_exists("ZipArchive")) { $filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "log__::" . time() . "__zip") . ".tmp"; $zip = new ZipArchive(); $zip->open($filepath, ZipArchive::CREATE); } else { $zip = new ZipFile(); } foreach ($files_to_download as $filename) { if (class_exists("ZipArchive")) { $zip->addFile(EW_LOG_PATH . $log . "/" . $filename, $filename); } else { $content = file_get_contents(EW_LOG_PATH . $log . "/" . $filename); $time = filemtime(EW_LOG_PATH . $log . "/" . $filename); $zip->addFile($content, $filename, $time); } } if (class_exists("ZipArchive")) { $zip->close(); $content = file_get_contents($filepath); unlink($filepath); } else { $content = $zip->file(); } showFileDownload($log . "_Logs.zip", $content); } } else { $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['CategoryLogs']['Messages']['SelectAction']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } } $GLOBALS['logs_files'] = array(); if (count($iterator = new DirectoryIterator(EW_LOG_PATH . $log)) > 0) { foreach ($iterator as $fileinfo) { if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) { $extension = strrpos($fileinfo->getFilename(), "."); $extension = substr($fileinfo->getFilename(), $extension); if (($fileinfo->isFile() == true || $fileinfo->isLink() == true) && $extension == EW_LOG_EXT) { $GLOBALS['logs_files'][$fileinfo->getFilename()] = array("change_data" => date("d/m/Y - H:i:s", $fileinfo->getMTime()), "file_size" => realFormatBytes($fileinfo->getSize())); } } } } } $this->lang->setArguments("System,Analysis,SystemLogs,CategoryLogs,Title", $this->logs_folders[$_GET['load_folder']][1]); return $this->output->setContent("analysis_logsFiles"); } else { header("Location: " . CTM_URLEngine::URLBase() . "?app=core&module=system§ion=analysis&index=logs"); } } else { if ($_GET['do_folder'] == true) { if ($_POST['DoCommand'] != "clearFolders" && $_POST['DoCommand'] != "downloadFolders") { $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['SelectAction']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } elseif ($_POST['DoCommand'] == "clearFolders") { $folders_count = 0; $files_count = 0; $select_count = 0; foreach ($_POST as $key => $value) { if (substr($key, 0, 8) == "folder__" && $value == 1) { $folder = substr($key, 8); $tmp_count = 0; $select_count++; if (array_key_exists($folder, $this->logs_folders)) { $folder = $this->logs_folders[substr($key, 8)][0]; if (!file_exists(EW_LOG_PATH . $folder)) { mkdir(EW_LOG_PATH . $folder); } if (count($iterator = new DirectoryIterator(EW_LOG_PATH . $folder)) > 0) { foreach ($iterator as $fileinfo) { if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) { $extension = strrpos($fileinfo->getFilename(), "."); $extension = substr($fileinfo->getFilename(), $extension); if (($fileinfo->isFile() == true || $fileinfo->isLink() == true) && $extension == EW_LOG_EXT) { unlink(EW_LOG_PATH . $folder . "/" . $fileinfo->getFilename()); $files_count++; $tmp_count++; } } } } if ($tmp_count > 0) { $folders_count++; } } } } if ($select_count == 0) { $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['SelectFolders']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } else { $this->lang->setTags("System,Analysis,SystemLogs,DoCommand,Messages,FoldersCleaned", $files_count, $folders_count); $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['FoldersCleaned']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); } } elseif ($_POST['DoCommand'] == "downloadFolders") { $folders_to_download = array(); $select_count = 0; foreach ($_POST as $key => $value) { if (substr($key, 0, 8) == "folder__" && $value == 1) { $folder = substr($key, 8); $select_count++; if (array_key_exists($folder, $this->logs_folders)) { $folder = $this->logs_folders[substr($key, 8)][0]; $folders_to_download[$folder] = array(); if (!file_exists(EW_LOG_PATH . $folder)) { mkdir(EW_LOG_PATH . $folder); } if (count($iterator = new DirectoryIterator(EW_LOG_PATH . $folder)) > 0) { foreach ($iterator as $fileinfo) { if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) { $extension = strrpos($fileinfo->getFilename(), "."); $extension = substr($fileinfo->getFilename(), $extension); if (($fileinfo->isFile() == true || $fileinfo->isLink() == true) && $extension == EW_LOG_EXT) { $folders_to_download[$folder][$fileinfo->getFilename()] = $fileinfo->getMTime(); } } } } } } } if ($select_count == 0) { $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['SelectFolders']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1); } else { if (class_exists("ZipArchive")) { $filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "log__::" . time() . "__zip") . ".tmp"; $zip = new ZipArchive(); $zip->open($filepath, ZipArchive::CREATE); } else { $zip = new ZipFile(); } foreach ($folders_to_download as $folder => $files) { if (class_exists("ZipArchive")) { $zip->addEmptyDir($folder); } else { $zip->addFile(NULL, $folder . "/"); } if (count($files) > 0) { foreach ($files as $filename => $filetime) { if (class_exists("ZipArchive")) { $zip->addFile(EW_LOG_PATH . $folder . "/" . $filename, $folder . "/" . $filename); } else { $content = file_get_contents(EW_LOG_PATH . $folder . "/" . $filename); $zip->addFile($content, $folder . "/" . $filename, $filetime); } } } } if (class_exists("ZipArchive")) { $zip->close(); $content = file_get_contents($filepath); unlink($filepath); } else { $content = $zip->file(); } showFileDownload(sprintf($this->logs_zip_file['name'], date($this->logs_zip_file['date'])) . ".zip", $content); } } } foreach ($this->logs_folders as $key => $value) { $GLOBALS['logs_folders'][$key] = array("name" => $value[1], "count_files" => number_format(intval(count(glob(EW_LOG_PATH . $value[0] . "/*" . EW_LOG_EXT))), 0, false, ".")); } $this->output->setContent("analysis_logs"); if (loadIsAjax() == true) { $this->output->setVariable("no_set_tmp", true); } } }
/** * Private: Edit Task * Edit the task registed * * @return void */ private function loadEditTask() { $GLOBALS['cronTasks'] = array(); $GLOBALS['task_error'] = 0; $this->DB->Arguments($_GET['id']); $this->DB->Query("SELECT 1 FROM dbo.CTM_CronJob WHERE Id = %d", $checkTask); if ($this->DB->CountRows($checkTask) < 1) { return $GLOBALS['task_error'] = 1; } $open_dir = opendir(CTM_ROOT_PATH . "modules/tasks"); $tasks = array(); if (!$open_dir) { return $GLOBALS['task_error'] = 2; } while ($read_dir = readdir($open_dir)) { $extension = substr($read_dir, -9, 9); if ($extension == ".task.php") { $tasks[] = substr($read_dir, 0, strlen($read_dir) - 9); } } if (count($tasks) < 1) { return $GLOBALS['task_error'] = 2; } $GLOBALS['cronTasks'] = $tasks; if ($_GET['write'] == true) { if (empty($_POST['TaskName'])) { $GLOBALS['result_command'] = adminShowMessage($this->lang->words['System']['CronJob']['AddTask']['Messages']['NameVoid'], 1); } elseif (!in_array($_POST['TaskFile'], $tasks)) { $GLOBALS['result_command'] = adminShowMessage($this->lang->words['System']['CronJob']['AddTask']['Messages']['InvalidFile'], 2); } else { if (empty($_POST['EveryDays'])) { $_POST['EveryDays'] = 0; $count++; } if (empty($_POST['EveryWeeks'])) { $_POST['EveryWeeks'] = 0; $count++; } if (empty($_POST['EveryMonths'])) { $_POST['EveryMonths'] = 0; $count++; } if (empty($_POST['EveryHours'])) { $_POST['EveryHours'] = 0; $count++; } if (empty($_POST['EveryMinutes'])) { $_POST['EveryMinutes'] = 0; $count++; } if ($count == 5) { $GLOBALS['result_command'] = adminShowMessage($this->lang->words['System']['CronJob']['AddCronTab']['Messages']['SetOccur'], 2); } else { $time = time(); $occurOptions = $_POST['EveryDays'] . ","; $occurOptions .= $_POST['EveryWeeks'] . ","; $occurOptions .= $_POST['EveryMonths'] . ","; $occurOptions .= $_POST['EveryHours'] . ","; $occurOptions .= $_POST['EveryMinutes']; $beginDate = 0; $endDate = 0; if ($_POST['BeginDate']) { $date = explode("/", $_POST['BeginDate']); $hour = $_POST['BeginHour'] ? explode(":", $_POST['BeginHour']) : array(date("H"), date("i")); $beginDate = mktime($hour[0], $hour[1], 0, $date[0], $date[1], $date[2]); } if ($_POST['EndDate']) { $date = explode("/", $_POST['EndDate']); $hour = $_POST['EndDate'] ? explode(":", $_POST['EndDate']) : array(23, 59); $endDate = mktime($hour[0], $hour[1], 0, $date[0], $date[1], $date[2]); } $beginDate = strlen($beginDate) != 10 ? 0 : $beginDate; $endDate = strlen($endDate) != 10 ? 0 : $endDate; if (!$_POST['EndEnable']) { $endDate = 0; } $update_columns = array("TaskName" => utf8_encode($_POST['TaskName']), "TaskDescription" => utf8_encode($_POST['TaskDescription']), "TaskFile" => $_POST['TaskFile'], "Switch" => $_POST['Switch'] == 1 ? 1 : 0, "NextExecution" => $time, "BeginDate" => $beginDate, "EndDate" => $endDate, "OccurOptions" => $occurOptions); $this->DB->ForceDataType("Switch", "integer"); $this->DB->ForceDataType("NextExecution", "integer"); $this->DB->ForceDataType("BeginDate", "integer"); $this->DB->ForceDataType("EndDate", "integer"); $this->DB->Arguments($_GET['id']); $this->DB->Update("CTM_CronJob", $update_columns, "Id = %d"); if ($_GET['run'] == true) { exit("<script>window.location = '?app=core&module=system§ion=cronjob&index=runTask&id={$id}';</script>"); } $GLOBALS['result_command'] = $this->lang->words['System']['CronJob']['EditTask']['Messages']['Success']; $GLOBALS['result_command'] = sprintf($GLOBALS['result_command'], $_GET['id'], date("d/m/Y - H:i:s", $beginDate)); $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); } } } $this->DB->Arguments($_GET['id']); $findCronTasksQ = $this->DB->Select("*", "CTM_CronJob", "Id = %d"); $findCronTask = $this->DB->FetchObject($findCronTaskQ); $GLOBALS['cron_task'] = array("id" => intval($findCronTask->Id), "name" => utf8_decode(htmlEncode($findCronTask->TaskName)), "description" => utf8_decode(htmlEncode($findCronTask->TaskDescription)), "file" => $findCronTask->TaskFile, "switch" => $findCronTask->Switch, "begin_date" => date("m/d/Y", $findCronTask->BeginDate), "begin_hour" => date("H:i", $findCronTask->BeginDate), "end_date" => strlen($findCronTask->EndDate) == 10 ? date("m/d/Y", $findCronTask->EndDate) : NULL, "end_hour" => strlen($findCronTask->EndDate) == 10 ? date("H:i", $findCronTask->EndDate) : "00:00", "end_enabled" => strlen($findCronTask->EndDate) == 10, "occur_options" => explode(",", $findCronTask->OccurOptions)); }
/** * Private: Set Team Permissions * Set the team permissions * * @return void */ private function loadSetTeamPermissions() { global $appsCache; if ($_GET['do'] != "member" && $_GET['do'] != "group") { exit("<script>window.location = '" . $this->vars['acp_url'] . "?app=core&module=members';</script>"); } if ($_GET['do'] == "member") { if (empty($_GET['username']) || !$this->loadCheckMember(urldecode($_GET['username']))) { $GLOBALS['result_command'] = $this->lang->words['Members']['Team']['Permissions']['ManagePermissions']['Messages']['MemberNoExists']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $this->loadManageTeamPermissions(); $this->output->setContent("team_managePermissions"); return NULL; } $row_type = "member"; $row_value = urldecode($_GET['username']); } elseif ($_GET['do'] == "group") { if (empty($_GET['id']) || !$this->loadCheckGroup(intval($_GET['id']))) { $GLOBALS['result_command'] = $this->lang->words['Members']['Team']['Permissions']['ManagePermissions']['Messages']['GroupNoExists']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $this->loadManageTeamPermissions(); $this->output->setContent("team_managePermissions"); return NULL; } $row_type = "group"; $row_value = intval($_GET['id']); } require_once CTM_ADMINCP_PATH . "sources/includes/permissions.inc.php"; foreach ($appsCache as $key => $value) { if ($key == "core") { continue; } if (!in_array($key, $acp_permissions['applications'])) { $acp_permissions['applications'][] = $key; } if (file_exists(CTM_ROOT_PATH . "modules/applications/apps_ctm/" . strtolower($value['name']) . "/admin/variables/acp_permissions.php")) { require_once CTM_ROOT_PATH . "modules/applications/apps_ctm/" . strtolower($value['name']) . "/admin/variables/acp_permissions.php"; $acp_permissions['modules'] = array_merge($acp_permissions['modules'], $_acp_permissions['modules']); $acp_permissions['items'] = array_merge($acp_permissions['items'], $_acp_permissions['items']); } $this->lang->loadLanguageFile("admincp", $value['name']); } if ($_GET['write'] == true) { $applications = array(); $modules = array(); $items = array(); foreach ($acp_permissions['applications'] as $name) { if ($_POST['app_' . $name] == 1) { $applications[] = $name; } } foreach ($acp_permissions['modules'] as $name) { if ($_POST['mod_' . $name] == 1) { $modules[] = $name; } } foreach ($acp_permissions['items'] as $name) { if ($_POST['ite_' . $name] == 1) { $items[] = $name; } } $cache = array("applications" => $applications, "modules" => $modules, "items" => $items); if ($this->loadCheckPermission($row_type, $row_value)) { $update_columns = array("PermissionCache" => serialize($cache)); $this->DB->Arguments($row_type, $row_value); $this->DB->Update("CTM_TeamPermission", $update_columns, "RowType = '%s' AND RowValue = '%s'"); } else { $insert_columns = array("RowType" => $row_type, "RowValue" => $row_value, "PermissionCache" => serialize($cache)); $this->DB->Insert("CTM_TeamPermission", $insert_columns); } $GLOBALS['result_command'] = $this->lang->words['Members']['Team']['Permissions']['ManagePermissions']['Messages']['Saved']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); $this->loadManageTeamPermissions(); $this->output->setContent("team_managePermissions"); } else { $this->DB->Arguments($row_type, $row_value); $this->DB->Query("SELECT PermissionCache FROM dbo.CTM_TeamPermission WHERE RowType = '%s' AND RowValue = '%s'", $find_permissions_q); $cache = array("applications" => array(), "modules" => array(), "items" => array()); if ($this->DB->CountRows($find_permissions_q) > 0) { $find_permissions = $this->DB->FetchRow($find_permissions_q); if (strlen($find_permissions[0]) > 0) { if ($unserialize = unserialize($find_permissions[0])) { if (count($unserialize['applications']) > 0) { foreach ($unserialize['applications'] as $application) { $cache['applications'][$application] = 1; } } if (count($unserialize['modules']) > 0) { foreach ($unserialize['modules'] as $module) { $cache['modules'][$module] = 1; } } if (count($unserialize['items']) > 0) { foreach ($unserialize['items'] as $item) { $cache['items'][$item] = 1; } } } } } $GLOBALS['permissions'] = $cache; $this->output->setContent("team_setPermissions"); } }
/** * 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"); } } }
/** * Private: Banned Accounts * Manage the banned accounts * * @return void */ private function loadBannedAccounts() { if ($_GET['do'] == "unban") { $count = 0; if (count($_POST) > 0) { foreach ($_POST as $key => $value) { if (substr($key, 0, 9) == "account__" && $value == 1) { $this->DB->Arguments(substr($key, 9)); $this->DB->Update(MUACC_CORE . "@MEMB_INFO", array("bloc_code" => 0), "memb___id = '%s'"); $this->DB->Arguments(substr($key, 9)); $this->DB->Delete("CTM_AccountsBanneds", "Account = '%s'"); $count++; } } } if ($count > 0) { $GLOBALS['result_command'] = sprintf($this->lang->words['Members']['Accounts']['BannedAccounts']['Messages']['Success'], $count); $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); } else { $GLOBALS['result_command'] = $this->lang->words['Members']['Accounts']['BannedAccounts']['Messages']['SelectAccount']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } } $a = "dbo.CTM_AccountsBanneds"; $m = MUACC_CORE . ".dbo.MEMB_INFO"; $GLOBALS['banned_accounts'] = array(); $query = $this->DB->Query("SELECT {$a}.Responsible, {$a}.Expiration, {$a}.Reason, {$m}.memb___id FROM {$m} LEFT JOIN {$a} ON ({$a}.Account = {$m}.memb___id) WHERE {$m}.bloc_code = 1 AND {$m}.MemberStatus = 0 ORDER BY {$a}.BanId DESC"); if ($this->DB->CountRows($query) > 0) { while ($account = $this->DB->FetchObject($query)) { $GLOBALS['banned_accounts'][$account->memb___id] = array("responsible" => strlen($account->Responsible) > 0 ? $account->Responsible : $this->lang->words['Words']['None'], "expiration" => strlen($account->Expiration) > 0 ? date("d/m/Y - h:i a", $account->Expiration) : $this->lang->words['Words']['Never'], "reason" => strlen($account->Reason) > 0 ? $account->Reason : NULL); } } }
/** * Private: Import/Export Templates * Import/Export templates by XML * * @return void */ private function loadImportExportTemplates() { if ($_GET['process']) { switch ($_GET['process']) { case "import": if (empty($_FILES['FileUpload']['name']) && empty($_POST['FilePath'])) { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['SelectFile']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { $break = FALSE; $uploaded = FALSE; $is_zip = FALSE; if (!empty($_FILES['FileUpload']['name'])) { $type = $_FILES['FileUpload']['type']; $is_zip = $type == "application/x-gzip" || $type == "application/gzip" ? "gzip" : ($type == "application/zip" ? "zip" : "none"); if ($type != "text/xml" && $type != "application/x-gzip" && $type != "application/gzip" && $type != "application/zip") { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['InvalidFile']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $break = TRUE; } else { $filepath = CTM_CACHE_PATH . "temp_cache/" . md5(time() . "&ew_template_temp_file&" . mt_rand()) . ".tmp"; if (!copy($_FILES['FileUpload']['tmp_name'], $filepath)) { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UploadError']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $break = TRUE; } else { $uploaded = TRUE; } } } else { $filepath = CTM_ROOT_PATH . $_POST['FilePath']; $find_end = strrpos($filepath, "."); $file_end = substr($filepath, $find_end + 1); if (!file_exists($filepath)) { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['FileNoExists']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $break = TRUE; } elseif ($file_end != "xml" && $file_end != "gz" && $file_end != "zip") { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['InvalidFile']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $break = TRUE; } else { $is_zip = $file_end == "gz" ? "gzip" : ($file_end == "zip" ? "zip" : NULL); } } if ($is_zip == "gzip" && $break == false) { if (!function_exists("gzopen") || !function_exists("gzread") || !function_exists("gzclose")) { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $break = TRUE; } else { if ($gzip = gzopen($filepath, "r")) { $tmp_path = CTM_CACHE_PATH . "temp_cache/" . md5(time() . "&" . EffectWebFiles::TEMPLATE_XML_FILENAME . "&" . mt_rand()) . ".tmp"; $gz_content = gzread($gzip, filesize($filepath) * 2); gzclose($gzip); if ($uploaded == true) { unlink($filepath); } $fp = fopen($tmp_path, "w"); fwrite($fp, $gz_content); fclose($fp); } else { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $break = TRUE; } } } elseif ($is_zip == "zip" && $break == false) { if (!class_exists("ZipArchive")) { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $break = TRUE; } else { $zip = new ZipArchive(); if ($zip->open($filepath)) { $filename = md5(time() . "&" . EffectWebFiles::TEMPLATE_XML_FILENAME . "&" . mt_rand()) . ".tmp"; $tmp_path = CTM_CACHE_PATH . "temp_cache/" . $filename; $zip->renameName(EffectWebFiles::TEMPLATE_XML_FILENAME, $filename); $zip->extractTo(CTM_CACHE_PATH . "temp_cache/", array($filename)); $zip->renameName($filename, EffectWebFiles::TEMPLATE_XML_FILENAME); $zip->close(); if ($uploaded == true) { unlink($filepath); } } else { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); $break = TRUE; } } } else { $tmp_path = $filepath; } if ($break == false) { $xml_content = file_get_contents($tmp_path); if (file_exists($tmp_path) && $tmp_path != $filepath && ($is_zip == "gzip" || $is_zip == "zip")) { unlink($tmp_path); } if ($uploaded == true && $is_zip == "none") { unlink($filepath); } if (!CTM_FileManage::Lib('XML')->IsXML($xml_content) || !strstr($xml_content, "<skin_xml") || !strstr($xml_content, "<skin_info>")) { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['FileCorrupted']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { CTM_Template::Lib('ImportExport')->ImportXML($xml_content, $skin_info); if ($skin_info == "XML_CORRUPTED") { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['FileCorrupted']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif ($skin_info == "INVALID_CODEKEY") { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['InvalidTemplate']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } elseif ($skin_info == "VAR_0_ERROR") { $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['LicenseError']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { $path = "server_cache/db_php/skin_sources/skin_sources.php"; CTM_Controller::UpdateWebCache("effectwebkernelhash", "hash_file:" . $path, "hash_file:" . md5_file(CTM_CACHE_PATH . $path)); $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['Success']; $GLOBALS['result_command'] = sprintf($GLOBALS['result_command'], $skin_info['Name'], $skin_info['SkinSet']); $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3); } } } else { if ($uploaded == true) { if (file_exists($filepath)) { unlink($filepath); } if (file_exists($tmp_path)) { unlink($tmp_path); } } } } break; case "export": CTM_Template::Lib('Sources')->OpenDatabase(); if (!CTM_Template::Lib('Sources')->CheckSkin($_POST['Template'])) { CTM_Template::Lib('Sources')->CloseDatabase(); $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Export']['Messages']['TemplateInvalid']; $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2); } else { CTM_Template::Lib('ImportExport')->ExportXML("ew_template", $_POST['Template'], $this->skin_cache_keys, true, CTM_ACP_USE_ZIP); } break; } } CTM_Template::Lib('Sources')->OpenDatabase(); CTM_Template::Lib('Sources')->GetAllSkins($_templates); CTM_Template::Lib('Sources')->CloseDatabase(); if (count($_templates) > 0) { foreach ($_templates as $key => $value) { $GLOBALS['templates'][$key] = $value['Name']; } } $GLOBALS['template_default_xml_file'] = EffectWebFiles::TEMPLATE_XML_FILENAME; }