summaryrefslogtreecommitdiffstats
path: root/site/common/functions.php
diff options
context:
space:
mode:
authorFrancis Rowe <info@gluglug.org.uk>2015-05-31 17:02:03 (EDT)
committer Francis Rowe <info@gluglug.org.uk>2015-05-31 17:02:03 (EDT)
commit52b5f37d936f2e4d953a2977a31ce6167508f44d (patch)
tree0f99bf49cc54235ad6b97d471062871b25a0dd6c /site/common/functions.php
parentb061bd5b442d84a1c6b0c090ba454770df2de81d (diff)
downloadlibreboot.org-52b5f37d936f2e4d953a2977a31ce6167508f44d.zip
libreboot.org-52b5f37d936f2e4d953a2977a31ce6167508f44d.tar.gz
libreboot.org-52b5f37d936f2e4d953a2977a31ce6167508f44d.tar.bz2
move common resources to common/
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
+ }
+ }
+?>