summaryrefslogtreecommitdiffstats
path: root/site/common/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'site/common/functions.php')
-rw-r--r--site/common/functions.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/site/common/functions.php b/site/common/functions.php
new file mode 100644
index 0000000..e0cda47
--- /dev/null
+++ b/site/common/functions.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ Generic functions used by the rest of the site
+ Copyright (C) 2015 Francis Rowe <info@gluglug.org.uk>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* Functions */
+
+ /* Minified HTML output (note: needs work for <pre> tags) */
+ function miniHtml($strHtml) {
+ return $strHtml = preg_replace(
+ array("/\r|\n/", "/(\s)+/s", "/\>[^\S ]+/s", "/[^\S ]+\</s"),
+ array("", "\\1", ">", "<"),
+ $strHtml
+ );
+ }
+
+ /* Minified CSS output */
+ function miniCss($strCss) {
+ return preg_replace("/\r|\n/", "", $strCss);
+ }
+
+ /* Generic function for showing a list of URLs */
+ function mirrorList($arrayMirrors,$strNotFoundMessage,$forIndexStart,$forIndexbelow) {
+
+ if (count($arrayMirrors)>0) {
+ for ($server=$forIndexStart; $server<$forIndexbelow; $server++) {
+?>
+ <p><a href="<?php echo $arrayMirrors[$server][0]; ?>"><?php echo $arrayMirrors[$server][0]; ?></a> (<?php echo $arrayMirrors[$server][1]; ?>)</p>
+<?php
+ }
+ } else {
+?>
+ <p><?php echo $strNotFoundMessage; ?></p>
+<?php
+ }
+ }
+
+ /* List rsync mirroring instructions */
+ function rsyncList($arrayRsync,$strNotFoundMessage,$forIndexStart,$forIndexBelow) {
+ if (
+ count($arrayRsync)>0 && ($forIndexStart<=count($arrayRsync)-1)
+ && ($forIndexBelow<=count($arrayRsync)) && ($forIndexStart<=$forIndexBelow)) {
+
+ for ($server=$forIndexStart; $server<$forIndexBelow; $server++) {
+?>
+ <h2>
+ <?php echo $arrayRsync[$server][1]; ?>
+ </h2>
+ <p>
+ <b>rsync -avxP --delete --stats <?php echo $arrayRsync[$server][0]; ?> /path/to/docroot/libreboot/</b>
+ </p>
+<?php
+ }
+
+ } else {
+?>
+ <p>
+ <?php echo $strNotFoundMessage; ?>
+ </p>
+<?php
+ }
+ }
+?>