Author: Sara Golemon (sgolemon)
Date: 2021-04-18T23:23:55Z
Commit:
https://github.com/php/web-php/commit/ca283e8c0364496b6a6e0d40f1788e4bd941a328
Raw diff:
https://github.com/php/web-php/commit/ca283e8c0364496b6a6e0d40f1788e4bd941a328.diff
Remove defunct usergroup pages
Changed paths:
D ug.php
M include/layout.inc
Diff:
diff --git a/include/layout.inc b/include/layout.inc
index e8e741c3b..1b2c97c25 100644
--- a/include/layout.inc
+++ b/include/layout.inc
@@ -500,9 +500,6 @@ function site_header($title = '', $config = array())
$config["headsup"] = get_news_changes();
- if (!$config["headsup"]) {
- $config["headsup"] = get_near_usergroups();
- }
$lang = language_convert($config["lang"]);
$curr = $config["current"];
@@ -553,59 +550,6 @@ function get_news_changes()
return "<a href='{$link}'>{$title}</a>";
}
}
-function get_near_usergroups()
-{
- global $COUNTRIES, $COUNTRY;
-
- if (!myphpnet_showug()) {
- return false;
- }
- if ($_SERVER["BASE_PAGE"] == "ug.php") {
- return false;
- }
- if (isset($_COOKIE["LAST_UG"]) && $_COOKIE["LAST_UG"] >=
$_SERVER["REQUEST_TIME"]) {
- if (!isset($_GET["showug"])) {
- return false;
- }
- }
-
- $ugs = get_usergroups_in($COUNTRY);
- $count = count($ugs);
- if (!$count) {
- return false;
- }
-
- return sprintf("There %s %d <a href='/ug.php?cc=%s'>PHP User Group%s in
%s</a>, are you a member of your local UG?",
- $count == 1 ? "is" : "are",
- $count,
- $COUNTRY,
- $count == 1 ? "" : "s",
- $COUNTRIES[$COUNTRY]
- );
-
-
-}
-function get_usergroups_in($country, &$allcountries = array()) {
- global $COUNTRY_ALPHA_2_TO_3;
-
- $filename = $_SERVER["DOCUMENT_ROOT"] . "/backend/usergroups.json";
-
- $matches = array();
- $data = json_decode(file_get_contents($filename), true);
- foreach($data["groups"] as $group) {
- if (isset($group["country"])) {
- $allcountries[$COUNTRY_ALPHA_2_TO_3[$group["country"]]] = 1;
- if ($group["country"] == $country) {
- $matches[] = $group;
- }
- }
- }
- usort($matches, function($first, $second){
- return strnatcasecmp($first['name'], $second['name']);
- });
-
- return $matches;
-}
function news_toc($sections = null) {
include __DIR__ . "/pregen-news.inc";
diff --git a/ug.php b/ug.php
deleted file mode 100644
index c55c52ad3..000000000
--- a/ug.php
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-$_SERVER['BASE_PAGE'] = 'ug.php';
-include_once __DIR__ . '/include/prepend.inc';
-
-mirror_setcookie("LAST_UG", $_SERVER["REQUEST_TIME"]+60*60*24, 60*60*24);
-site_header("Hypertext Preprocessor",
- array(
- 'current' => 'community',
- )
-);
-
-
-function print_cc_header($country) {
- global $COUNTRIES;
- ?>
- <div class="country" id="<?php echo $country ?>">
- <h2 class="title countrytitle">User Groups in <?php echo
$COUNTRIES[$country] ?>
- <img height="25" width="45" src="/images/flags/beta/<?php echo
strtolower($country) ?>.png">
- </h2>
- <ul class="ugs">
- <?php
-}
-function ug_get_more_info($group) {
- if (! trim($group["icalendar_url"])) {
- return null;
- }
- $url = $group["icalendar_url"];
-
- $filename = "backend/events/" . md5($url);
-
- /* Broken icalendar link */
- if (!file_exists($filename)) {
- return null;
- }
- $data = file($filename, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
- $retval = ug_get_next_even_from_ical_array($data);
-
- return $retval;
-}
-function ug_get_next_even_from_ical_array($ical) {
- $ok = false;
- $data = array();
- foreach($ical as $line) {
- if ($line == "BEGIN:VEVENT") {
- foreach ($ical as $n => $line) {
- if ("END:VEVENT" == $line) {
- break;
- }
-
- if ($line[0] == " ") {
- // data continued from previous key
- $data[$lastkey] .= ltrim($line);
- } else {
- list($lastkey, $value) = explode(":", $line, 2);
- $data[$lastkey] = $value;
- }
- }
-
- break;
- }
- }
- if (!isset($data["DTSTAMP"])) {
- /* There is no scheduled next meeting */
- return array();
- }
- /* Meetup.com seems to have fetish for injecting the TZ into the keyname */
- if (isset($data["TZID"])) {
- $data["STARTSAT"] = $data["DTSTART;TZID={$data["TZID"]}"];
- } else {
- $data["STARTSAT"] = $data["DTSTART"];
- }
-
- // Yes.. Replace literal '\n' with new line
- $data["DESCRIPTION"] = str_replace('\n', "\n", $data["DESCRIPTION"]);
- return array("event" => $data);
-}
-function print_ug_matches($matches) {
- global $COUNTRIES, $country;
- $content = "";
- echo '<dl>';
- foreach($matches as $group) {
- $data = ug_get_more_info($group);
- $details = "";
- if ($data && $data["event"]) {
- $d = date(DATE_RSS, strtotime($data["event"]["STARTSAT"],
$_SERVER["REQUEST_TIME"]));
- $url = isset($data["event"]["URL"]) ?
addslashes($data["event"]["URL"]) : "";
- $summary = htmlspecialchars($data["event"]["SUMMARY"]);
- /* The icalendar has all sorts of weird trailing slashes and
totally weirdo
- * newlines making this look like geocities */
- //$description =
nl2br(htmlspecialchars($data["event"]["DESCRIPTION"]), false);
- if ($url) { /* Google Calendar doesn't have this */
- $details = "{$d} - <a href='$url'>{$summary}</a>"; //<br>" .
$description;
- } else {
- $details = "{$d} - $summary";// . $description;
- }
- }
- echo '<dt class="ug"><a href="'. $group["url"].'">' . $group["name"] .
"</a></dt><dd>$details</dd>";
- }
- if (!$matches) {
- echo "<dt>Sorry</dt><dd>There are no known User Groups in
{$COUNTRIES[$country]} at this time :(</dd>";
- }
- echo "</dl>";
-}
-
-$country = isset($_GET["cc"]) ? $_GET["cc"] : $COUNTRY;
-$country_alpha_2 = isset($COUNTRY_ALPHA_3_TO_2[$country]) ?
$COUNTRY_ALPHA_3_TO_2[$country] : "NA";
-$allcountries = array();
-$matches = get_usergroups_in($country_alpha_2, $allcountries);
-if (isset($COUNTRIES[$country])) {
- print_cc_header($country);
- print_ug_matches($matches);
-} else {
- echo "<h1>Unknown country</h1>";
-}
-
-uksort($allcountries, function($first, $second){
- global $COUNTRIES;
- return strnatcasecmp($COUNTRIES[$first], $COUNTRIES[$second]);
-});
-
-$SIDEBAR_DATA = <<< EOF
- <p class="panel"><a href="http://php.ug/ug/promote">Register new UG</a></p>
-EOF;
-foreach($allcountries as $country => $nada) {
- $SIDEBAR_DATA .= '<p class="panel"><a href="/ug.php?cc=' . $country . '">'
. $COUNTRIES[$country] . '</a></p>';
-}
-
-// Print the common footer.
-site_footer(
- array(
- "atom" => "/feed.atom", // Add a link to the feed at the bottom
- "sidebar" => $SIDEBAR_DATA,
- )
-);
--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php