Skip to content

Enhancement: Enable PSR12 rule set #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
->in(__DIR__)
->name(__FILE__);

$config->setRules([]);
$config->setRules([
'@PSR12' => true,
]);

return $config;
222 changes: 111 additions & 111 deletions ChangeLog-8.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion archive/2004.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ functions starting with the letters you typed in. You can browse the list

<hr>

<?php //news_image("http://www.phpconference.de/2003/index_en.php", "international_conference_2003.gif", "International PHP Conference"); ?>
<?php //news_image("http://www.phpconference.de/2003/index_en.php", "international_conference_2003.gif", "International PHP Conference");?>
<h1>International PHP Conference 2004</h1>
<p>
<span class="newsdate">[18-Jun-2004]</span>
Expand Down
13 changes: 7 additions & 6 deletions archive/index.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

include_once __DIR__ . '/../include/prepend.inc';
$i = 0;
do {
$y = date("Y")-$i;
if (file_exists("./$y.php")) {
mirror_redirect("/archive/$y.php");
break;
}
} while(++$i<3);
$y = date("Y")-$i;
if (file_exists("./$y.php")) {
mirror_redirect("/archive/$y.php");
break;
}
} while (++$i<3);

include_once __DIR__ . '/../include/errors.inc';
error_noservice();
1 change: 1 addition & 0 deletions backend/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

// Simulate a /backend shortcut call (which will lead to a manual page)
$_SERVER['REQUEST_URI'] = '/backend';
include_once __DIR__ . '/../include/prepend.inc';
Expand Down
1 change: 1 addition & 0 deletions bin/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

// Simulate a /bin shortcut call (which will lead to a manual page)
$_SERVER['REQUEST_URI'] = '/bin';
include_once __DIR__ . '/../include/prepend.inc';
Expand Down
2 changes: 1 addition & 1 deletion cached.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$abs = realpath($abs);

if (strncmp($abs, $pwd, strlen($pwd)) != 0) {
header("Location: https://www.php.net/" . strtr($_GET["f"],array("\r"=>"","\n"=>"")));
header("Location: https://www.php.net/" . strtr($_GET["f"], array("\r"=>"","\n"=>"")));
exit;
}

Expand Down
132 changes: 75 additions & 57 deletions cal.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
a fallback to display the actual month/year.
*/

$begun = FALSE; $errors = array();
$begun = false; $errors = array();
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$cy = isset($_GET['cy']) ? (int) $_GET['cy'] : 0;
$cm = isset($_GET['cm']) ? (int) $_GET['cm'] : 0;
Expand All @@ -37,7 +37,7 @@
if ($event = load_event($id)) {
site_header("Event: " . stripslashes(htmlentities($event['sdesc'], ENT_QUOTES | ENT_IGNORE, 'UTF-8')), $site_header_config);
display_event($event, 0);
$begun = TRUE;
$begun = true;
}
// Unable to find event, put this to the error messages' list
else {
Expand All @@ -49,7 +49,7 @@
elseif ($cy && $cm && $cd) {

// Check if date is valid
if (checkdate($cm,$cd,$cy)) {
if (checkdate($cm, $cd, $cy)) {

// Date integer for that day
$date = mktime(0, 0, 1, $cm, $cd, $cy);
Expand All @@ -63,12 +63,12 @@
display_event($event, 0);
echo "<br>";
}
$begun = TRUE;
$begun = true;
}

// Unable to load events for that day
else {
$errors[] = "There are no events for the specified date (".date("F j, Y",$date).").";
$errors[] = "There are no events for the specified date (".date("F j, Y", $date).").";
}
}

Expand All @@ -80,21 +80,24 @@
}

// Check if month and year is valid
if ($cm && $cy && !checkdate($cm,1,$cy)) {
if ($cm && $cy && !checkdate($cm, 1, $cy)) {
$errors[] = "The specified year and month (".htmlentities("$cy, $cm", ENT_QUOTES | ENT_IGNORE, 'UTF-8').") are not valid.";
unset($cm, $cy);
}

// Give defaults for the month and day values if they were invalid
if (empty($cm)) { $cm = date("m"); }
if (empty($cy)) { $cy = date("Y"); }
if (empty($cm)) {
$cm = date("m");
}
if (empty($cy)) {
$cy = date("Y");
}

// Start of the month date
$date = mktime(0, 0, 1, $cm, 1, $cy);

if (!$begun) {
site_header("Events: ".date("F Y", $date), $site_header_config);
?>
site_header("Events: ".date("F Y", $date), $site_header_config); ?>
<div class="tip">
<p>
If you would like to suggest an upcoming event to be listed on this
Expand All @@ -110,10 +113,10 @@
}

// Get events list for a whole month
$events = load_events($date, TRUE);
$events = load_events($date, true);

// If there was an error, or there are no events, this is an error
if ($events === FALSE || count($events) == 0) {
if ($events === false || count($events) == 0) {
$errors[] = "No events found for this month";
}

Expand All @@ -125,11 +128,11 @@
}

// Beginning and end of this month
$bom = mktime(0, 0, 1, $cm, 1, $cy);
$bom = mktime(0, 0, 1, $cm, 1, $cy);
$eom = mktime(0, 0, 1, $cm+1, 0, $cy);

// Link to previous month (but do not link to too early dates)
$prev_link = (function() use ($cm, $cy) {
$prev_link = (function () use ($cm, $cy) {
$lm = mktime(0, 0, 1, $cm, 0, $cy);
$year = date('Y', $lm);
if (!valid_year($year)) {
Expand All @@ -138,15 +141,17 @@

$month = date('m', $lm);
$monthName = date('F', $lm);
return sprintf('<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year));
return sprintf(
'<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year)
);
})();

// Link to next month (but do not link to too early dates)
$next_link = (function() use ($cm, $cy) {
$next_link = (function () use ($cm, $cy) {
$nm = mktime(0, 0, 1, $cm+1, 1, $cy);
$year = date('Y', $nm);
if (!valid_year($year)) {
Expand All @@ -155,11 +160,13 @@

$month = date('m', $nm);
$monthName = date('F', $nm);
return sprintf('<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year));
return sprintf(
'<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year)
);
})();

// Print out navigation links for previous and next month
Expand All @@ -174,26 +181,28 @@

// Print out headers for weekdays
for ($i = 0; $i < 7; $i++) {
echo '<th width="14%">', date("l",mktime(0,0,1,4,$i+1,2001)), "</th>\n";
echo '<th width="14%">', date("l", mktime(0, 0, 1, 4, $i+1, 2001)), "</th>\n";
}
echo "</tr>\n<tr>";

// Generate the requisite number of blank days to get things started
for ($days = $i = date("w",$bom); $i > 0; $i--) {
for ($days = $i = date("w", $bom); $i > 0; $i--) {
echo '<td class="notaday">&nbsp;</td>';
}

// Print out all the days in this month
for ($i = 1; $i <= date("t",$bom); $i++) {
for ($i = 1; $i <= date("t", $bom); $i++) {

// Print out day number and all events for the day
echo '<td><a class="day" href="/cal.php', "?cm=$cm&amp;cd=$i&amp;cy=$cy",
'">',$i,'</a>';
display_events_for_day(date("Y-m-",$bom).sprintf("%02d",$i), $events);
display_events_for_day(date("Y-m-", $bom).sprintf("%02d", $i), $events);
echo '</td>';

// Break HTML table row if at end of week
if (++$days % 7 == 0) echo "</tr>\n<tr>";
if (++$days % 7 == 0) {
echo "</tr>\n<tr>";
}
}

// Generate the requisite number of blank days to wrap things up
Expand All @@ -218,11 +227,11 @@ function date_for_recur($recur, $day, $bom, $eom)
if ($recur > 0) {
$bomd = date("w", $bom) + 1;
$days = (($day - $bomd + 7) % 7) + (($recur - 1) * 7);
return mktime(0,0,1, date("m",$bom), $days + 1, date("Y",$bom));
return mktime(0, 0, 1, date("m", $bom), $days + 1, date("Y", $bom));
}

// ${recur}th to last $day of the month
$eomd = date("w",$eom) + 1;
$eomd = date("w", $eom) + 1;
$days = (($eomd - $day + 7) % 7) + ((abs($recur) - 1) * 7);

return mktime(0, 0, 1, date("m", $bom)+1, -$days, date("Y", $bom));
Expand Down Expand Up @@ -256,57 +265,63 @@ function display_events_for_day($day, $events): void
function load_event($id)
{
// Open events CSV file, return on error
$fp = @fopen("backend/events.csv",'r');
if (!$fp) { return FALSE; }
$fp = @fopen("backend/events.csv", 'r');
if (!$fp) {
return false;
}

// Read as we can, event by event
while (!feof($fp)) {
$event = read_event($fp);

$event = read_event($fp);

// Return with the event, if it's ID is the one
// we search for (also close the file)
if ($event !== FALSE && $event['id'] == $id) {
fclose($fp);
return $event;
}
// Return with the event, if it's ID is the one
// we search for (also close the file)
if ($event !== false && $event['id'] == $id) {
fclose($fp);
return $event;
}
}

// Close file, and return sign of failure
fclose($fp);
return FALSE;
return false;
}

// Load a list of events. Either for a particular day ($from) or a whole
// month (if second parameter specified with TRUE)
function load_events($from, $whole_month = FALSE)
function load_events($from, $whole_month = false)
{
// Take advantage of the equality behavior of this date format
$from_date = date("Y-m-d", $from);
$bom = mktime(0, 0, 1, date("m",$from), 1, date("Y",$from));
$eom = mktime(0, 0, 1, date("m",$from) + 1, 0, date("Y",$from));
$bom = mktime(0, 0, 1, date("m", $from), 1, date("Y", $from));
$eom = mktime(0, 0, 1, date("m", $from) + 1, 0, date("Y", $from));
$to_date = date("Y-m-d", $whole_month ? $eom : $from);

// Set arrays to their default
$events = $seen = array();

// Try to open the events file for reading, return if unable to
$fp = @fopen("backend/events.csv",'r');
if (!$fp) { return FALSE; }
$fp = @fopen("backend/events.csv", 'r');
if (!$fp) {
return false;
}

// For all events, read in the event and check it if fits our scope
while (!feof($fp)) {

// Read the event data into $event, or continue with next
// line, if there was an error with this line
if (($event = read_event($fp)) === FALSE) {
if (($event = read_event($fp)) === false) {
continue;
}

// Keep event's seen list up to date
// (for repeating events with the same ID)
if (!isset($seen[$event['id']])) { $seen[$event['id']] = 1; }
else { continue; }
if (!isset($seen[$event['id']])) {
$seen[$event['id']] = 1;
} else {
continue;
}

// Check if event is in our scope, depending on type
switch ($event['type']) {
Expand All @@ -318,6 +333,7 @@ function load_events($from, $whole_month = FALSE)
// Fall through. Now it is just like a single-day event

// Single-day event
// no break
case 1:
if ($event['start'] >= $from_date && $event['start'] <= $to_date) {
$events[] = $event;
Expand All @@ -329,7 +345,7 @@ function load_events($from, $whole_month = FALSE)
if (($event['start'] >= $from_date && $event['start'] <= $to_date)
|| ($event['end'] >= $from_date && $event['end'] <= $to_date)
|| ($event['start'] <= $from_date && $event['end'] >= $to_date)) {
$events[] = $event;
$events[] = $event;
}
break;
}
Expand All @@ -345,12 +361,14 @@ function load_events($from, $whole_month = FALSE)
function read_event($fp)
{
// We were unable to read a line from the file, return
if (($linearr = fgetcsv($fp, 8192)) === FALSE) {
return FALSE;
if (($linearr = fgetcsv($fp, 8192)) === false) {
return false;
}

// Corrupt line in CSV file
if (count($linearr) < 13) { return FALSE; }
if (count($linearr) < 13) {
return false;
}

// Get components
list(
Expand Down Expand Up @@ -386,11 +404,11 @@ function valid_year($year)

// We only allow this and the next year for displays
if ($year != $current_year && $year != $current_year+1) {
return FALSE;
return false;
}

// The year is all right
return TRUE;
return true;
}

?>
Loading