Commit e7f0ef17 authored by SoftStart Code's avatar SoftStart Code Committed by Ricardo Melo
Browse files

[REF] PSR-12 Migrate from tabs to spaces

phpcbf --standard=phpcs-tiki.xml .  result:
A TOTAL OF 388134 ERRORS WERE FIXED IN 3075 FILES
parent 2583aefd
This diff is collapsed.
......@@ -8,18 +8,18 @@
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
header("location: index.php");
exit;
header("location: index.php");
exit;
}
if (isset($_POST['import']) && $access->checkCsrf()) {
$artlib = TikiLib::lib('art');
$fname = $_FILES['csvlist']['tmp_name'];
$msgs = [];
$result = $artlib->import_csv($fname, $msgs);
if ($result) {
Feedback::success(tr('File %0 succesfully imported.', $_FILES['csvlist']['name']));
} elseif (! empty($msgs)) {
Feedback::error(['mes' => $msgs]);
}
$artlib = TikiLib::lib('art');
$fname = $_FILES['csvlist']['tmp_name'];
$msgs = [];
$result = $artlib->import_csv($fname, $msgs);
if ($result) {
Feedback::success(tr('File %0 succesfully imported.', $_FILES['csvlist']['name']));
} elseif (! empty($msgs)) {
Feedback::error(['mes' => $msgs]);
}
}
......@@ -8,19 +8,19 @@
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
header("location: index.php");
exit;
header("location: index.php");
exit;
}
if (! empty($_POST['assignWikiCategories']) && $prefs['category_defaults'] && $access->checkCsrf()) {
$categlib = TikiLib::lib('categ');
$maxRecords = 100;
// The outer loop attempts to limit memory usage by fetching pages gradually.
for ($offset = 0; $pages = $tikilib->list_pages($offset, $maxRecords), ! empty($pages['data']); $offset += $maxRecords) {
foreach ($pages['data'] as $page) {
$categories = $categlib->get_object_categories('wiki page', $page['pageName']);
$page['href'] = "tiki-index.php?page=" . urlencode($page['pageName']);
$categlib->update_object_categories($categories, $page['pageName'], 'wiki page', $page['description'], $page['pageName'], $page['href']);
}
}
add_feedback('category_defaults', tr('category defaults'), 2);
$categlib = TikiLib::lib('categ');
$maxRecords = 100;
// The outer loop attempts to limit memory usage by fetching pages gradually.
for ($offset = 0; $pages = $tikilib->list_pages($offset, $maxRecords), ! empty($pages['data']); $offset += $maxRecords) {
foreach ($pages['data'] as $page) {
$categories = $categlib->get_object_categories('wiki page', $page['pageName']);
$page['href'] = "tiki-index.php?page=" . urlencode($page['pageName']);
$categlib->update_object_categories($categories, $page['pageName'], 'wiki page', $page['description'], $page['pageName'], $page['href']);
}
}
add_feedback('category_defaults', tr('category defaults'), 2);
}
......@@ -8,8 +8,8 @@
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
header('location: index.php');
exit;
header('location: index.php');
exit;
}
global $prefs, $base_url;
......@@ -20,18 +20,18 @@ $smarty = TikiLib::lib('smarty');
$headerlib->add_jsfile('lib/jquery_tiki/tiki-connect.js');
if (empty($prefs['connect_site_title'])) {
$defaults = json_encode(
[
'connect_site_title' => $prefs['browsertitle'],
'connect_site_email' => $userlib->get_admin_email(),
'connect_site_url' => $base_url,
'connect_site_keywords' => $prefs['metatag_keywords'],
'connect_site_location' => $prefs['gmap_defaultx'] . ',' . $prefs['gmap_defaulty'] . ',' . $prefs['gmap_defaultz'],
]
);
$defaults = json_encode(
[
'connect_site_title' => $prefs['browsertitle'],
'connect_site_email' => $userlib->get_admin_email(),
'connect_site_url' => $base_url,
'connect_site_keywords' => $prefs['metatag_keywords'],
'connect_site_location' => $prefs['gmap_defaultx'] . ',' . $prefs['gmap_defaulty'] . ',' . $prefs['gmap_defaultz'],
]
);
$headerlib->add_jq_onready(
<<<JQ
$headerlib->add_jq_onready(
<<<JQ
$("#connect_defaults_btn a").click(function(){
var connect_defaults = $defaults;
for (var el in connect_defaults) {
......@@ -40,29 +40,29 @@ if (empty($prefs['connect_site_title'])) {
return false;
});
JQ
);
);
}
if ($prefs['connect_server_mode'] === 'y') {
$connectlib = TikiLib::lib('connect_server');
$connectlib = TikiLib::lib('connect_server');
$search_str = '';
$search_str = '';
if (isset($_REQUEST['cserver'])) {
if ($_REQUEST['cserver'] === 'rebuild') {
$connectlib->rebuildIndex();
} elseif (! empty($_REQUEST['cserver_search'])) {
$search_str = $_REQUEST['cserver_search'];
}
}
$smarty->assign('cserver_search_text', $search_str);
$receivedDataStats = $connectlib->getReceivedDataStats();
$smarty->assignByRef('connect_stats', $receivedDataStats);
$matchingConnections = $connectlib->getMatchingConnections(empty($search_str) ? '*' : $search_str);
$smarty->assignByRef('connect_recent', $matchingConnections);
if (isset($_REQUEST['cserver'])) {
if ($_REQUEST['cserver'] === 'rebuild') {
$connectlib->rebuildIndex();
} elseif (! empty($_REQUEST['cserver_search'])) {
$search_str = $_REQUEST['cserver_search'];
}
}
$smarty->assign('cserver_search_text', $search_str);
$receivedDataStats = $connectlib->getReceivedDataStats();
$smarty->assignByRef('connect_stats', $receivedDataStats);
$matchingConnections = $connectlib->getMatchingConnections(empty($search_str) ? '*' : $search_str);
$smarty->assignByRef('connect_recent', $matchingConnections);
} else {
$smarty->assign('connect_stats', null);
$smarty->assign('connect_recent', null);
$smarty->assign('connect_stats', null);
$smarty->assign('connect_recent', null);
}
$smarty->assign('jitsi_url', Services_Suite_Controller::getJitsiUrl());
......@@ -8,6 +8,6 @@
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
header("location: index.php");
exit;
header("location: index.php");
exit;
}
......@@ -8,99 +8,99 @@
// This script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
header('location: index.php');
exit;
header('location: index.php');
exit;
}
$filegallib = TikiLib::lib('filegal');
if (isset($_REQUEST['fgal_use_dir'])) {
// Check for last character being a / or a \
if (substr($_REQUEST["fgal_use_dir"], -1) != "\\" && substr($_REQUEST["fgal_use_dir"], -1) != "/" && $_REQUEST["fgal_use_dir"] != "") {
$_REQUEST["fgal_use_dir"] .= "/";
}
$filegallib->setupDirectory($_REQUEST["fgal_use_dir"]);
// Check for last character being a / or a \
if (substr($_REQUEST["fgal_use_dir"], -1) != "\\" && substr($_REQUEST["fgal_use_dir"], -1) != "/" && $_REQUEST["fgal_use_dir"] != "") {
$_REQUEST["fgal_use_dir"] .= "/";
}
$filegallib->setupDirectory($_REQUEST["fgal_use_dir"]);
}
// Check for last character being a / or a \
if (isset($_REQUEST["fgal_podcast_dir"]) && substr($_REQUEST["fgal_podcast_dir"], -1) != "\\" && substr($_REQUEST["fgal_podcast_dir"], -1) != "/" && $_REQUEST["fgal_podcast_dir"] != "") {
$_REQUEST["fgal_podcast_dir"] .= "/";
$_REQUEST["fgal_podcast_dir"] .= "/";
}
if (isset($_REQUEST["fgal_batch_dir"]) && substr($_REQUEST["fgal_batch_dir"], -1) != "\\" && substr($_REQUEST["fgal_batch_dir"], -1) != "/" && $_REQUEST["fgal_batch_dir"] != "") {
$_REQUEST["fgal_batch_dir"] .= "/";
$_REQUEST["fgal_batch_dir"] .= "/";
}
simple_set_value("fgal_use_dir");
simple_set_value("fgal_podcast_dir");
simple_set_value("fgal_batch_dir");
if (! empty($_REQUEST['fgal_quota']) && ! empty($_REQUEST['fgal_quota_default']) && $_REQUEST['fgal_quota_default'] > $_REQUEST['fgal_quota']) {
$_REQUEST['fgal_quota_default'] = $_REQUEST['fgal_quota'];
$_REQUEST['fgal_quota_default'] = $_REQUEST['fgal_quota'];
}
simple_set_value('fgal_quota_default');
if (! empty($_REQUEST['updateMime'])) {
$files = $filegallib->table('tiki_files');
$rows = $files->fetchAll(['fileId', 'filename', 'filetype'], ['archiveId' => 0, 'filetype' => 'application/octet-stream']);
foreach ($rows as $row) {
$t = $filegallib->fixMime($row['filetype'], $row['filename']);
if ($t != 'application/octet-stream') {
$files->update(['filetype' => $t], ['fileId' => $row['fileId']]);
}
}
$files = $filegallib->table('tiki_files');
$rows = $files->fetchAll(['fileId', 'filename', 'filetype'], ['archiveId' => 0, 'filetype' => 'application/octet-stream']);
foreach ($rows as $row) {
$t = $filegallib->fixMime($row['filetype'], $row['filename']);
if ($t != 'application/octet-stream') {
$files->update(['filetype' => $t], ['fileId' => $row['fileId']]);
}
}
}
if (! empty($_POST['move']) && $access->checkCsrf()) {
if ($_POST['move'] == 'to_fs') {
if (empty($prefs['fgal_use_dir'])) {
$errors[] = tra('You must specify a directory');
} else {
$feedbacks = [];
$errors = $filegallib->moveFiles($_POST['move'], $feedbacks);
}
} elseif ($_POST['move'] == 'to_db') {
$feedbacks = [];
$errors = $filegallib->moveFiles($_REQUEST['move'], $feedbacks);
}
if (! empty($errors)) {
Feedback::error(['mes' => $errors]);
}
if (! empty($feedbacks)) {
Feedback::note(['mes' => $feedbacks]);
}
if ($_POST['move'] == 'to_fs') {
if (empty($prefs['fgal_use_dir'])) {
$errors[] = tra('You must specify a directory');
} else {
$feedbacks = [];
$errors = $filegallib->moveFiles($_POST['move'], $feedbacks);
}
} elseif ($_POST['move'] == 'to_db') {
$feedbacks = [];
$errors = $filegallib->moveFiles($_REQUEST['move'], $feedbacks);
}
if (! empty($errors)) {
Feedback::error(['mes' => $errors]);
}
if (! empty($feedbacks)) {
Feedback::note(['mes' => $feedbacks]);
}
}
if (! empty($_POST['mimes']) && $access->checkCsrf()) {
$mimes = $_POST['mimes'];
foreach ($mimes as $mime => $cmd) {
$mime = trim($mime);
if (empty($cmd)) {
$filegallib->delete_file_handler($mime);
} else {
$filegallib->change_file_handler($mime, $cmd);
}
}
$mimes = $_POST['mimes'];
foreach ($mimes as $mime => $cmd) {
$mime = trim($mime);
if (empty($cmd)) {
$filegallib->delete_file_handler($mime);
} else {
$filegallib->change_file_handler($mime, $cmd);
}
}
}
if (! empty($_POST['newMime']) && ! empty($_POST['newCmd']) && $access->checkCsrf()) {
$filegallib->change_file_handler($_POST['newMime'], $_POST['newCmd']);
$filegallib->change_file_handler($_POST['newMime'], $_POST['newCmd']);
}
if (isset($_REQUEST["filegalfixvndmsfiles"]) && $access->checkCsrf()) {
$filegallib->fix_vnd_ms_files();
$filegallib->fix_vnd_ms_files();
}
//*** end state-changing actions
if (isset($_REQUEST["filegalredosearch"])) {
$searchTextReindexedFilesAmount = $filegallib->reindex_all_files_for_search_text();
Feedback::success(tr("The search text was reindexed for a total of %0 files.", $searchTextReindexedFilesAmount));
$searchTextReindexedFilesAmount = $filegallib->reindex_all_files_for_search_text();
Feedback::success(tr("The search text was reindexed for a total of %0 files.", $searchTextReindexedFilesAmount));
}
$ocr = Tikilib::lib('ocr');
if (isset($_POST["ocrstalledreset"])) {
$ocrCount = $ocr->releaseAllStalled();
if ($ocrCount) {
Feedback::success($ocrCount . tra(' stalled files will attempt to OCR again.'));
} else {
Feedback::error(tra("Was not able to change status of OCR files from stalled to pending."));
}
$ocrCount = $ocr->releaseAllStalled();
if ($ocrCount) {
Feedback::success($ocrCount . tra(' stalled files will attempt to OCR again.'));
} else {
Feedback::error(tra("Was not able to change status of OCR files from stalled to pending."));
}
}
// set the number of stalled OCR files
......@@ -120,12 +120,12 @@ $vnd_ms_files_exist = false;
// check if files can be indexed, or if they will be indexed via an OCR process
$ocr->setMimeTypes();
foreach ($usedTypes as $type) {
if (! $filegallib->get_parse_app($type, true) && ! in_array($type, $ocr->ocrMime)) {
$missingHandlers[] = $type;
if (strpos($type, '/vnd.ms-') !== false) {
$vnd_ms_files_exist = true;
}
}
if (! $filegallib->get_parse_app($type, true) && ! in_array($type, $ocr->ocrMime)) {
$missingHandlers[] = $type;
if (strpos($type, '/vnd.ms-') !== false) {
$vnd_ms_files_exist = true;
}
}
}
$smarty->assign_by_ref('missingHandlers', $missingHandlers);
......
......@@ -7,17 +7,17 @@
// $Id$
if (basename($_SERVER['SCRIPT_NAME']) === basename(__FILE__)) {
die('This script may only be included.');
die('This script may only be included.');
}
require_once('tiki-setup.php');
if (isset($_POST["cleanup"]) && $access->checkCsrf()) {
$freetaglib = TikiLib::lib('freetag');
$result = $freetaglib->cleanup_tags();
if ($result) {
Feedback::success(tr('Tags successfully cleaned up.'));
} else {
Feedback::error(tr('Tag cleanup failed.'));
}
$freetaglib = TikiLib::lib('freetag');
$result = $freetaglib->cleanup_tags();
if ($result) {
Feedback::success(tr('Tags successfully cleaned up.'));
} else {
Feedback::error(tr('Tag cleanup failed.'));
}
}
......@@ -7,27 +7,27 @@
// $Id$
if (basename($_SERVER['SCRIPT_NAME']) === basename(__FILE__)) {
die('This script may only be included.');
die('This script may only be included.');
}
require_once('tiki-setup.php');
$tikilib->set_preference('display_timezone', $tikilib->get_preference('server_timezone'));
if (! empty($_POST['testMail']) && $access->checkCsrf()) {
include_once('lib/webmail/tikimaillib.php');
$mail = new TikiMail();
$mail->setSubject(tra('Tiki Email Test'));
$mail->setText(tra('Tiki Test email from:') . ' ' . $_SERVER['SERVER_NAME']);
if (! $mail->send([$_REQUEST['testMail']])) {
$msg = tra('Unable to send mail');
if ($tiki_p_admin == 'y') {
$mailerrors = print_r($mail->errors, true);
$msg .= '<br>' . $mailerrors;
}
Feedback::warning($msg);
} else {
add_feedback('testMail', tra('Test mail sent to') . ' ' . $_REQUEST['testMail'], 3);
}
include_once('lib/webmail/tikimaillib.php');
$mail = new TikiMail();
$mail->setSubject(tra('Tiki Email Test'));
$mail->setText(tra('Tiki Test email from:') . ' ' . $_SERVER['SERVER_NAME']);
if (! $mail->send([$_REQUEST['testMail']])) {
$msg = tra('Unable to send mail');
if ($tiki_p_admin == 'y') {
$mailerrors = print_r($mail->errors, true);
$msg .= '<br>' . $mailerrors;
}
Feedback::warning($msg);
} else {
add_feedback('testMail', tra('Test mail sent to') . ' ' . $_REQUEST['testMail'], 3);
}
}
$smarty->assign('now', $tikilib->now);
......@@ -8,8 +8,8 @@
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
header('location: index.php');
exit;
header('location: index.php');
exit;
}
// Get list of available languages
......@@ -19,10 +19,10 @@ $languages = $langLib->list_languages(false, null, true);
$smarty->assign_by_ref('languages', $languages);
if (isset($_SESSION['tikifeedback'])) {
foreach ($_SESSION['tikifeedback'] as $item) {
if ($item['name'] === 'available_languages' || $item['name'] === 'restrict_language') {
TikiLib::lib('cache')->empty_cache('temp_cache');
break;
}
}
foreach ($_SESSION['tikifeedback'] as $item) {
if ($item['name'] === 'available_languages' || $item['name'] === 'restrict_language') {
TikiLib::lib('cache')->empty_cache('temp_cache');
break;
}
}
}
......@@ -8,58 +8,58 @@
// This script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
header('location: index.php');
exit;
header('location: index.php');
exit;
}
if (! isset($_REQUEST['interlist'])) {
$_REQUEST['interlist'] = [];
$_REQUEST['interlist'] = [];
}
if (! isset($_REQUEST['known_hosts'])) {
$_REQUEST['known_hosts'] = [];
$_REQUEST['known_hosts'] = [];
}
//*** begin state-changing actions
//TODO Avoid altering $_POST variable directly in this section
if (isset($_POST['del']) && $access->checkCsrf(true)) {
foreach ($prefs['interlist'] as $k => $i) {
if ($k == $_POST['del']) {
unset($_POST['interlist'][$k]);
}
}
simple_set_value('interlist');
//to refresh interlist dropdown - not sure if there's a better way to do this
$access->redirect($_SERVER['REQUEST_URI'], '', 200);
foreach ($prefs['interlist'] as $k => $i) {
if ($k == $_POST['del']) {
unset($_POST['interlist'][$k]);
}
}
simple_set_value('interlist');
//to refresh interlist dropdown - not sure if there's a better way to do this
$access->redirect($_SERVER['REQUEST_URI'], '', 200);
}
if (isset($_POST['delk']) && $access->checkCsrf(true)) {
foreach ($prefs['known_hosts'] as $k => $i) {
if ($k == $_POST['delk']) {
unset($_POST['known_hosts'][$k]);
}
}
simple_set_value('known_hosts');
foreach ($prefs['known_hosts'] as $k => $i) {
if ($k == $_POST['delk']) {
unset($_POST['known_hosts'][$k]);
}
}
simple_set_value('known_hosts');
}
if (isset($_POST['new']) && is_array($_POST['new']) && $_POST['new']['name'] && $access->checkCsrf()) {
$_POST['interlist']["{$_POST['new']['name']}"] = $_POST['new'];
simple_set_value('interlist');
$_POST['interlist']["{$_POST['new']['name']}"] = $_POST['new'];
simple_set_value('interlist');
}
if (isset($_POST['newhost']) && is_array($_POST['newhost']) && $_POST['newhost']['key'] && $access->checkCsrf()) {
$_POST['known_hosts']["{$_POST['newhost']['key']}"] = $_POST['newhost'];
simple_set_value('known_hosts');
$_POST['known_hosts']["{$_POST['newhost']['key']}"] = $_POST['newhost'];
simple_set_value('known_hosts');
}
if (! empty($_POST['known_hosts']) && $access->checkCsrf()) {
foreach ($_POST['known_hosts'] as $k => $v) {
if (isset($_POST['known_hosts'][$k]['allowusersregister'])) {
$_POST['known_hosts'][$k]['allowusersregister'] = 'y';
}
if (
foreach ($_POST['known_hosts'] as $k => $v) {
if (isset($_POST['known_hosts'][$k]['allowusersregister'])) {
$_POST['known_hosts'][$k]['allowusersregister'] = 'y';
}
if (
empty($_POST['known_hosts'][$k]['name'])
&& empty($_POST['known_hosts'][$k]['key'])
&& empty($_POST['known_hosts'][$k]['ip'])
&& empty($_POST['known_hosts'][$k]['contact'])
&& empty($_POST['known_hosts'][$k]['key'])
&& empty($_POST['known_hosts'][$k]['ip'])
&& empty($_POST['known_hosts'][$k]['contact'])
) {
unset($_POST['known_hosts'][$k]);
}
}
simple_set_value('known_hosts');
unset($_POST['known_hosts'][$k]);
}
}
simple_set_value('known_hosts');
}
......@@ -8,75 +8,75 @@
// This script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
header('location: index.php');
exit;
header('location: index.php');
exit;
}
if (empty($_REQUEST['registration_choices'])) {
$_REQUEST['registration_choices'] = [];
$_REQUEST['registration_choices'] = [];
}
$listgroups = $userlib->get_groups(0, -1, 'groupName_asc', '', '', 'n');
$in = [];
$out = [];
foreach ($listgroups['data'] as $gr) {
if ($gr['groupName'] == 'Anonymous') {
continue;
}
if ($gr['registrationChoice'] == 'y' && ! in_array($gr['groupName'], $_REQUEST['registration_choices'])) {
// deselect
$out[] = $gr['groupName'];
} elseif ($gr['registrationChoice'] != 'y' && in_array($gr['groupName'], $_REQUEST['registration_choices'])) {
//select
$in[] = $gr['groupName'];
}
if ($gr['groupName'] == 'Anonymous') {
continue;
}
if ($gr['registrationChoice'] == 'y' && ! in_array($gr['groupName'], $_REQUEST['registration_choices'])) {
// deselect
$out[] = $gr['groupName'];
} elseif ($gr['registrationChoice'] != 'y' && in_array($gr['groupName'], $_REQUEST['registration_choices'])) {
//select
$in[] = $gr['groupName'];
}
}
if (count($in) && $access->checkCsrf()) {
$userlib->set_registrationChoice($in, 'y');
$userlib->set_registrationChoice($in, 'y');
}
if (count($out) && $access->checkCsrf()) {
$userlib->set_registrationChoice($out, null);
$userlib->set_registrationChoice($out, null);
}
if ((count($in) || count($out)) && $access->checkCsrf()) {
add_feedback('registration_choices', tra('registration choices'), 2);
add_feedback('registration_choices', tra('registration choices'), 2);
}
if (! empty($_REQUEST['refresh_email_group']) && $access->checkCsrf(true)) {
$nb = $userlib->refresh_set_email_group();
if ($nb > 0) {
Feedback::success(tra(sprintf(tra("%d users were assigned to groups based on user emails matching the patterns defined for the groups."), $nb)));