diff --git a/app/extensions/extension_download.php b/app/extensions/extension_download.php index 7858c141ba..506b85ab7e 100644 --- a/app/extensions/extension_download.php +++ b/app/extensions/extension_download.php @@ -25,19 +25,19 @@ */ //includes - include "root.php"; + require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; require_once "resources/paging.php"; //check permissions - if (permission_exists('extension_export')) { - //access granted - } - else { - echo "access denied"; - exit; - } + if (permission_exists('extension_export')) { + //access granted + } + else { + echo "access denied"; + exit; + } //add multi-lingual support $language = new text; @@ -131,8 +131,17 @@ //get the extensions from the database and send them as output if (is_array($_REQUEST["column_group"]) && @sizeof($_REQUEST["column_group"]) != 0) { + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: extension_download.php'); + exit; + } + //validate submitted columns - foreach($_REQUEST["column_group"] as $column_name) { + foreach ($_REQUEST["column_group"] as $column_name) { if (in_array($column_name, $available_columns)) { $selected_columns[] = $column_name; } @@ -145,73 +154,60 @@ $extensions = $database->select($sql, $parameters, 'all'); unset($sql, $parameters, $selected_columns); - download_send_headers("data_export_".date("Y-m-d").".csv"); + download_send_headers("extension_export_".date("Y-m-d").".csv"); echo array2csv($extensions); exit; } } -//set the row styles - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); -//begin the page content +//include the header $document['title'] = $text['title-extension_export']; require_once "resources/header.php"; - echo "
\n"; +//show the content + echo "\n"; - echo "
\n"; - echo "\n"; - echo "\n"; + echo "
\n"; + echo "
".$text['header-extension_export']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'extensions.php']); + echo button::create(['type'=>'submit','label'=>$text['button-export'],'icon'=>$_SESSION['theme']['button_icon_export'],'style'=>'margin-left: 15px;']); + echo "
\n"; + echo "
\n"; echo "
\n"; - echo "".$text['header-extension_export']."\n"; - echo "

\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; + echo "
".$text['label-column_name']."
\n"; + echo "\n"; + echo " \n"; + echo " \n"; echo "\n"; - foreach ($available_columns as $column_name) { - $tr_link = "onclick=\"document.getElementById('checkbox_".$column_name."').checked = document.getElementById('checkbox_".$column_name."').checked ? false : true;\""; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - $c = $c ? 0 : 1; + if (is_array($available_columns) && @sizeof($available_columns) != 0) { + $x = 0; + foreach ($available_columns as $column_name) { + $list_row_onclick = "if (!this.checked) { document.getElementById('checkbox_all').checked = false; }"; + echo "\n"; + echo " \n"; + echo " "; + echo ""; + $x++; + } } - echo "\n"; - echo " \n"; - echo "\n"; - echo "
\n"; + echo " \n"; + echo " ".$text['label-column_name']."
".$column_name."
\n"; + echo " \n"; + echo " ".$column_name."
\n"; - echo "
\n"; - echo " \n"; - echo "
\n"; - echo "

\n"; + echo "
\n"; + echo "\n"; echo "\n"; - //define the checkbox_toggle function - echo "\n"; - //include the footer require_once "resources/footer.php"; -?> + +?> \ No newline at end of file diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index 0bbac78d8d..24a39310f2 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -872,39 +872,39 @@ echo ""; echo "
\n"; - if (is_numeric($page)) { - echo "\n"; - } - echo "\n"; - echo "\n"; + + echo "
\n"; + echo "
"; if ($action == "add") { - echo "
\n"; + echo "".$text['header-extension-add'].""; } if ($action == "update") { - echo "\n"; + echo "".$text['header-extension-edit'].""; } - echo "\n"; - echo "\n"; + echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;']); + echo " \n"; + echo "
\n"; + echo "\n"; + + echo "
".$text['header-extension-add']."".$text['header-extension-edit']."\n"; - echo " \n"; + echo "\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'extensions.php'.(is_numeric($page) ? '?page='.$page : null)]); if ($action == 'update' && permission_exists('xml_cdr_view')) { - echo " \n"; + echo button::create(['type'=>'button','label'=>$text['button-cdr'],'icon'=>'info-circle','link'=>'../xml_cdr/xml_cdr.php?extension_uuid='.urlencode($extension_uuid)]); } - if ($action == 'update' && (permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb'))) { - echo " \n"; + echo button::create(['type'=>'button','label'=>$text['button-call_routing'],'icon'=>'project-diagram','link'=>'../calls/call_edit.php?id='.urlencode($extension_uuid)]); } if ($action == "update" && permission_exists('extension_copy')) { - echo " \n"; + echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"copy_extension();"]); } - echo " \n"; - echo "

\n"; - echo "
\n"; echo "\n"; - echo "\n"; - echo "\n"; echo " \n"; echo "
\n"; + echo "\n"; echo " ".$text['label-extension']."\n"; echo "\n"; + echo "\n"; echo " \n"; echo "
\n"; echo $text['description-extension']."\n"; @@ -1006,8 +1006,7 @@ echo " \n"; } echo " "; - echo " \n"; - + echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]); echo "
\n"; echo " ".$text['description-user_list']."\n"; echo "
\n"; @@ -1178,7 +1177,7 @@ echo "\n"; echo "
\n"; - echo " \n"; + echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]); echo "
\n"; echo "
\n"; @@ -1719,7 +1718,8 @@ echo " \n"; echo "  \n"; echo " \n"; - echo " \n"; + echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','onclick'=>'show_advanced_config();']); +// echo " \n"; echo " \n"; echo " \n"; echo " \n"; @@ -1955,27 +1955,27 @@ echo $text['description-description']."\n"; echo "\n"; echo "\n"; - echo " \n"; - echo " \n"; - if ($action == "update") { - echo " \n"; - echo " "; - if (!permission_exists('extension_domain')) { - echo " "; - } - echo " "; - echo " "; - } - echo " \n"; - echo "
"; - echo " \n"; - echo " \n"; - echo " "; + echo ""; echo "

"; + + if (is_numeric($page)) { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + echo ""; + if (!permission_exists('extension_domain')) { + echo ""; + } + echo ""; + echo ""; + } + echo "\n"; + echo "
"; //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/extensions/extension_imports.php b/app/extensions/extension_imports.php index 6eb64f8795..21493fb76a 100644 --- a/app/extensions/extension_imports.php +++ b/app/extensions/extension_imports.php @@ -43,7 +43,7 @@ $text = $language->get(); //built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher - if(!function_exists('str_getcsv')) { + if (!function_exists('str_getcsv')) { function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") { $fp = fopen("php://memory", 'r+'); fputs($fp, $input); @@ -90,9 +90,9 @@ //get the schema $x = 0; - include ("app/extensions/app_config.php"); + include "app/extensions/app_config.php"; $i = 0; - foreach($apps[0]['db'] as $table) { + foreach ($apps[0]['db'] as $table) { //get the table name and parent name $table_name = $table["table"]['name']; $parent_name = $table["table"]['parent']; @@ -109,7 +109,7 @@ if ($table_name == "extensions") { $schema[$i]['table'] = $table_name; $schema[$i]['parent'] = $parent_name; - foreach($table['fields'] as $row) { + foreach ($table['fields'] as $row) { if ($row['deprecated'] !== 'true') { if (is_array($row['name'])) { $field_name = $row['name']['text']; @@ -133,45 +133,49 @@ //match the column names to the field names if (strlen($delimiter) > 0 && file_exists($_SESSION['file']) && $action != 'import') { - //form to match the fields to the column names + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: extension_imports.php'); + exit; + } + + //create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); + + //include header $document['title'] = $text['title-extension_import']; require_once "resources/header.php"; - echo "
\n"; + //form to match the fields to the column names + echo "\n"; + + echo "
\n"; + echo "
".$text['header-import']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'extension_imports.php']); + echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import']]); + echo "
\n"; + echo "
\n"; + echo "
\n"; + + echo $text['description-import']."\n"; + echo "

\n"; + echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - - //echo "\n"; - //echo "\n"; - //echo "\n"; - //echo "\n"; - //loop through user columns $x = 0; foreach ($line_fields as $line_field) { $line_field = trim(trim($line_field), $enclosure); echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "
\n"; - echo " ".$text['header-import']."
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['description-import']."\n"; - echo "
".$text['header-import']."\n"; - //echo " \n"; - //echo "
\n"; + echo " \n"; //echo " ".$text['label-zzz']."\n"; echo $line_field; echo " \n"; + echo " \n"; echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + require_once "resources/footer.php"; //normalize the column names @@ -234,8 +236,13 @@ //upload the csv if (file_exists($_SESSION['file']) && $action == 'import') { - //form to match the fields to the column names - //require_once "resources/header.php"; + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: extension_imports.php'); + exit; + } //user selected fields $fields = $_POST['fields']; @@ -345,28 +352,30 @@ } } +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); + //include the header $document['title'] = $text['title-extension_import']; require_once "resources/header.php"; -//begin the content - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['header-extension_import']."
\n"; - echo " ".$text['description-import']."\n"; - echo "
\n"; - echo " \n"; - //echo " \n"; - echo "
"; - - echo "
\n"; - +//show content echo "
\n"; - echo " \n"; + + echo "
\n"; + echo "
".$text['header-extension_import']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'extensions.php']); + echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload']]); + echo "
\n"; + echo "
\n"; + echo "
\n"; + + echo $text['description-import']."\n"; + echo "

\n"; + + echo "
\n"; echo "\n"; echo "\n"; echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; @@ -435,21 +444,15 @@ echo "
\n"; - echo "  \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " \n"; - echo "
\n"; + echo "\n"; echo "

"; + + echo "\n"; + echo "\n"; + echo "
"; //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file