]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #4630 from MrPetovan/task/4629-move-executable-to-bin
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Mon, 19 Mar 2018 14:05:53 +0000 (15:05 +0100)
committerGitHub <noreply@github.com>
Mon, 19 Mar 2018 14:05:53 +0000 (15:05 +0100)
Move executable scripts to bin/ (part 1)

39 files changed:
README.translate.md
bin/console [new file with mode: 0755]
bin/console.bat [new file with mode: 0755]
bin/console.php [new file with mode: 0755]
composer.json
composer.lock
doc/Developer-How-To-Move-Classes-to-src.md
doc/FAQ.md
doc/Github.md
doc/de/FAQ.md
doc/translations.md
include/dba.php
index.php
mod/admin.php
scripts/dbstructure.php [deleted file]
src/Core/Console.php [new file with mode: 0644]
src/Core/Console/Config.php [new file with mode: 0644]
src/Core/Console/CreateDoxygen.php [new file with mode: 0644]
src/Core/Console/DatabaseStructure.php [new file with mode: 0644]
src/Core/Console/DocBloxErrorChecker.php [new file with mode: 0644]
src/Core/Console/Extract.php [new file with mode: 0644]
src/Core/Console/GlobalCommunityBlock.php [new file with mode: 0644]
src/Core/Console/GlobalCommunitySilence.php [new file with mode: 0644]
src/Core/Console/Maintenance.php [new file with mode: 0644]
src/Core/Console/PhpToPo.php [new file with mode: 0644]
src/Core/Console/PoToPhp.php [new file with mode: 0644]
src/Core/Console/Typo.php [new file with mode: 0644]
util/README
util/config [deleted file]
util/config.md [deleted file]
util/createdoxygen.php [deleted file]
util/docblox_errorchecker.php [deleted file]
util/extract.php [deleted file]
util/global_community_block.php [deleted file]
util/global_community_silence.php [deleted file]
util/maintenance.php [deleted file]
util/php2po.php [deleted file]
util/po2php.php [deleted file]
util/typo.php [deleted file]

index 83c24e05424022ef7103b9f765efb51ee511a601..8396c9a198e175d2d80fe8848eb9592b513a2349 100644 (file)
@@ -27,17 +27,17 @@ The location of the translated files in the source tree is
     /view/lang/LNG-CODE/
 where LNG-CODE is the language code used, e.g. de for German or fr for French.
 The translated strings come as a "message.po" file from transifex which needs to be translated into the PHP file friendica uses.
-To do so, place the file in the directory mentioned above and use the "po2php" utility from the util directory of your friendica installation.
+To do so, place the file in the directory mentioned above and use the "po2php" command from the console.
 
 Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.
 
     1. Navigate at the command prompt to the base directory of your
        friendica installation
 
-    2. Execute the po2php script, which will place the translation
+    2. Execute the po2php command, which will place the translation
        in the strings.php file that is used by friendica.
 
-       $> php util/po2php.php view/lang/de/messages.po
+       $> php bin/console po2php view/lang/de/messages.po
 
        The output of the script will be placed at view/lang/de/strings.php where
        friendica is expecting it, so you can test your translation immediately.
@@ -62,7 +62,7 @@ Otherwise your work might get lost, when the translation from Transifex is inclu
 Utilities
 ---------
 
-Additional to the po2php script there are some more utilities for translation in the "util" directory of the friendica source tree.
+Additional to the po2php command there are some more utilities for translation in the console.
 If you only want to translate friendica into another language you wont need any of these tools most likely but it gives you an idea how the translation process of friendica works.
 
 For further information see the utils/README file.
@@ -90,9 +90,9 @@ To update the translation files after you have translated strings of e.g. Espera
 
     $> tx pull -l eo
 
-And then use the `po2php` utility described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
+And then use the `po2php` command described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
 
-    $> php util/po2php.php view/lang/eo/messages.po
+    $> php bin/console po2php view/lang/eo/messages.po
 
 Afterwards, just commit the two changed files to a feature branch of your Friendica repository, push the changes to github and open a pull request for your changes.
 
diff --git a/bin/console b/bin/console
new file mode 100755 (executable)
index 0000000..bd0ea97
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+dir=$(cd "${0%[/\\]*}" > /dev/null; pwd)
+
+if [[ -d /proc/cygdrive && $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
+   # We are in Cgywin using Windows php, so the path must be translated
+   dir=$(cygpath -m "$dir");
+fi
+
+php "${dir}/console.php" "$@"
diff --git a/bin/console.bat b/bin/console.bat
new file mode 100755 (executable)
index 0000000..06c41a0
--- /dev/null
@@ -0,0 +1,4 @@
+@echo OFF
+:: in case DelayedExpansion is on and a path contains !
+setlocal DISABLEDELAYEDEXPANSION
+php "%~dp0console.php" %*
diff --git a/bin/console.php b/bin/console.php
new file mode 100755 (executable)
index 0000000..90e4be3
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/env php
+<?php
+
+include_once dirname(__DIR__) . '/boot.php';
+
+$a = new Friendica\App(dirname(__DIR__));
+\Friendica\BaseObject::setApp($a);
+
+(new Friendica\Core\Console())->execute();
index e064a0a6a92f3c3268d2295489de65b19ba6161f..3f3151e5e3893034c42297875d8c6f9eb3f01cef 100644 (file)
@@ -24,6 +24,7 @@
                "pear/Text_LanguageDetect": "1.*",
                "pear/Text_Highlighter": "dev-master",
                "smarty/smarty": "^3.1",
+               "asika/simple-console": "^1.0",
                "fxp/composer-asset-plugin": "~1.3",
                "bower-asset/base64": "^1.0",
                "bower-asset/Chart-js": "^2.7",
index 1bf931ce3cbbf502e39daaecd704a8335511c549..8dd857facb2117880b4be3340f81fe4a9d67bd8b 100644 (file)
@@ -4,8 +4,41 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "3ff4187b4f7167583a3b8caa5f7c2a8a",
+    "content-hash": "6a87e56bade65fa14f5f74e74109b66f",
     "packages": [
+        {
+            "name": "asika/simple-console",
+            "version": "1.0.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/asika32764/php-simple-console.git",
+                "reference": "0b624c1a999849dc6481a47182e58d593bf65068"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/asika32764/php-simple-console/zipball/0b624c1a999849dc6481a47182e58d593bf65068",
+                "reference": "0b624c1a999849dc6481a47182e58d593bf65068",
+                "shasum": ""
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Asika\\SimpleConsole\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Simon Asika",
+                    "email": "asika32764@gmail.com"
+                }
+            ],
+            "description": "One file console framework to help you write build scripts.",
+            "time": "2018-03-08T12:05:40+00:00"
+        },
         {
             "name": "bower-asset/Chart-js",
             "version": "v2.7.1",
index 134c2a1f5ecaaaffa0dd7f6e530eda523816f22f..69e17e9c9e1323a8923f7b45e4583688333ef234 100644 (file)
@@ -94,7 +94,7 @@ Please remove all the `require_once` mentions of the former file, as they will p
 
 ## Miscellaneous tips
 
-When you are done with moving the class, please run `php util/typo.php` from the Friendica base directory to check for obvious mistakes.
+When you are done with moving the class, please run `php bin/console typo` from the Friendica base directory to check for obvious mistakes.
 Howevever, this tool isn't bullet-proof, and a staging install of Friendica is recommended to test your class move without impairing your production server if you host one.
 
 Most of Friendica processes are run in the background, so make sure to turn on your debug log to check for errors that wouldn't show up while simply browsing Friendica.
index ccf81d8a94d8196281b6016b1ca6d42d7af7878f..eb422be2d56a1e24ffc98680731d94bb856e3a65 100644 (file)
@@ -30,7 +30,7 @@ User
 
 SSL (Secure Socket Layer) is a technology to encrypt data transfer between computers.
 Sometimes your browser warns you about a missing or invalid certificate.
-These warnings can have three reasons: 
+These warnings can have three reasons:
 
 1. The server you are connected to doesn't offer SSL encryption.
 2. The server has a self-signed certificate (not recommended).
@@ -49,8 +49,8 @@ Generally, you can attach any kind of file to a post.
 This is possible by using the "paper-clip"-symbol in the editor.
 These files will be linked to your post and can be downloaded by your contacts.
 But it's not possible to get a preview for these items.
-Because of this, this upload method is only recommended for office or zipped files. 
-If you want to share content from Dropbox, Owncloud or any other [filehoster](http://en.wikipedia.org/wiki/Comparison_of_file_hosting_services), use the "link"-button (chain-symbol). 
+Because of this, this upload method is only recommended for office or zipped files.
+If you want to share content from Dropbox, Owncloud or any other [filehoster](http://en.wikipedia.org/wiki/Comparison_of_file_hosting_services), use the "link"-button (chain-symbol).
 
 When you're adding URLs of other webpages with the "link"-button, Friendica tries to create a small preview.
 If this doesn't work, try to add the link by typing: [url=http://example.com]*self-chosen name*[/url].
@@ -58,9 +58,9 @@ If this doesn't work, try to add the link by typing: [url=http://example.com]*se
 You can also add video and audio files to posts.
 However, instead of a direct upload you have to use one of the following methods:
 
-1. Add the video or audio link of a hoster (Youtube, Vimeo, Soundcloud and anyone else with oembed/opengraph-support). Videos will be shown with a preview image you can click on to start. SoundCloud directly inserts a player to your post. 
+1. Add the video or audio link of a hoster (Youtube, Vimeo, Soundcloud and anyone else with oembed/opengraph-support). Videos will be shown with a preview image you can click on to start. SoundCloud directly inserts a player to your post.
 
-2. If you have your own server, you can upload multimedia files via FTP and insert the URL. 
+2. If you have your own server, you can upload multimedia files via FTP and insert the URL.
 
 Friendica uses HTML5 for embedding content.
 Therefore, the supported files are dependent on your browser and operating system.
@@ -130,16 +130,16 @@ If you want to share your public page via rss you can use one of the following l
 
        basic-url.com//feed/[nickname]/posts
 
-Example: Friendica Support 
-       
+Example: Friendica Support
+
        https://forum.friendi.ca/feed/helpers/posts
 
 #### RSS feed of the conversations at your site
 
        basic-url.com/feed/profilename/comments
-       
-Example: Friendica Support 
-       
+
+Example: Friendica Support
+
        https://forum.friendi.ca/feed/helpers/comments
 
 <a name="clients"></a>
@@ -192,7 +192,7 @@ There you will always find the current stable version of friendica.
 
 Addons are listed at [this page](https://github.com/friendica/friendica-addons).
 
-If you are searching for new themes, you can find them at [Friendica-Themes.com](http://friendica-themes.com/) 
+If you are searching for new themes, you can find them at [Friendica-Themes.com](http://friendica-themes.com/)
 
 <a name="adminaccount1"></a>
 ### I've changed my email address now the admin panel is gone?
@@ -213,8 +213,8 @@ The listed emails need to be separated by a comma.
 Please have a look at the Admin panel under [DB updates](/admin/dbsync/) and follow the link to *check database structure*.
 This will start a background process to check if the structure is up to the current definition.
 
-You can manually execute the structure update from the CLI in the base directory of your Friendica installation by running the following script:
+You can manually execute the structure update from the CLI in the base directory of your Friendica installation by running the following command:
 
-    scripts/dbstructure.php update
+    bin/console dbstructure update
 
 if there occur any errors, please contact the [support forum](https://forum.friendi.ca/profile/helpers).
index 7c6233d3127af3eb610933e5abbac37d0d62aa38..92bcfe1667f0e5aac7a1b2c4765aec09c0d6585a 100644 (file)
@@ -68,7 +68,9 @@ If possible get an experienced Friendica developer to review the code.
 Don't hesitate to ask us in case of doubt.
 
 3. Check your code for typos.
-There is a PHP script in the *util* directory called *typos.php* for this.
+There is a console command called *typo* for this.
+
+       $> php bin/console typo
 
 Check out how to work with [our Vagrant](help/Vagrant) to save a lot of setup time!
 
index aa9d01b64d25c2cd6f9dcd84c35ef9ff11a8a5d1..8ea9d762154de77dda048b918970b67a4e2f6431 100644 (file)
@@ -29,10 +29,10 @@ Nutzer
 <a name="ssl"></a>
 ### Warum erhalte ich Warnungen Ã¼ber fehlende Zertifikate?
 
-Manchmal erhältst Du eine Browser-Warnung Ã¼ber fehlende Zertifikate. 
+Manchmal erhältst Du eine Browser-Warnung Ã¼ber fehlende Zertifikate.
 Diese Warnungen können drei Gründe haben:
 
-1. der Server, mit dem Du verbunden bist, nutzt kein SSL; 
+1. der Server, mit dem Du verbunden bist, nutzt kein SSL;
 
 2. der Server hat ein selbst-signiertes Zertifikat (nicht empfohlen)
 
@@ -40,39 +40,39 @@ Diese Warnungen können drei Gründe haben:
 
 *(SSL (Secure Socket Layer) ist eine Technologie, die Daten auf ihrem Weg zwischen zwei Computern verschlüsselt.)*
 
-Wenn Du noch kein SSL-Zertifikat hast, dann gibt es drei Wege, eines zu erhalten: kauf Dir eines, hole Dir ein kostenloses (z.B. bei StartSSL, WoSign, hoffentlich bald auch letsencrypt) oder kreiere Dein eigenes (nicht empfohlen). 
+Wenn Du noch kein SSL-Zertifikat hast, dann gibt es drei Wege, eines zu erhalten: kauf Dir eines, hole Dir ein kostenloses (z.B. bei StartSSL, WoSign, hoffentlich bald auch letsencrypt) oder kreiere Dein eigenes (nicht empfohlen).
 [Weitere Informationen Ã¼ber die Einrichtung von SSL und warum es schlecht ist, selbst-signierte Zertifikate zu nutzen, findest Du hier.](help/SSL)
 
-Sei Dir bewusst, dass Browser-Warnungen Ã¼ber Sicherheitslücken etwas sind, wodurch neue Nutzer schnell das Vertrauen in das gesamte Friendica-Projekt verlieren können. 
-Aus diesem Grund wird Friendica Red nur SSL-Zertifikate eines anerkannten Anbieters (CA, certificate authority) akzeptieren und nicht zu Seiten verbinden, die kein SSL nutzen. 
-Unabhängig von den negativen Aspekten von SSL handelt es sich hierbei um eine notwendige Lösung, solange keine etablierte Alternative existiert. 
+Sei Dir bewusst, dass Browser-Warnungen Ã¼ber Sicherheitslücken etwas sind, wodurch neue Nutzer schnell das Vertrauen in das gesamte Friendica-Projekt verlieren können.
+Aus diesem Grund wird Friendica Red nur SSL-Zertifikate eines anerkannten Anbieters (CA, certificate authority) akzeptieren und nicht zu Seiten verbinden, die kein SSL nutzen.
+Unabhängig von den negativen Aspekten von SSL handelt es sich hierbei um eine notwendige Lösung, solange keine etablierte Alternative existiert.
 
-Abgesehen davon kann es ohne SSL auch Probleme mit der Verbindung zu Diaspora geben, da einige Diaspora-Pods eine zertifizierte Verbindung benötigen. 
+Abgesehen davon kann es ohne SSL auch Probleme mit der Verbindung zu Diaspora geben, da einige Diaspora-Pods eine zertifizierte Verbindung benötigen.
 
-Wenn Du Friendica nur für eine bestimmte Gruppe von Leuten auf einem einzelnen Server nutzt, bei dem keine Verbindung zum restlichen Netzwerk besteht, dann benötigst Du kein SSL. 
-Ebenso benötigst Du SSL nicht, wenn Du ausschließlich Ã¶ffentliche Beiträge auf Deiner Seite veröffentlichst bzw. empfängst. 
+Wenn Du Friendica nur für eine bestimmte Gruppe von Leuten auf einem einzelnen Server nutzt, bei dem keine Verbindung zum restlichen Netzwerk besteht, dann benötigst Du kein SSL.
+Ebenso benötigst Du SSL nicht, wenn Du ausschließlich Ã¶ffentliche Beiträge auf Deiner Seite veröffentlichst bzw. empfängst.
 
-Wenn Du zum jetzigen Zeitpunkt noch keinen Server aufgesetzt hast, ist es sinnvoll, die verschiedenen Anbieter in Bezug auf SSL zu vergleichen. 
-Einige erlauben die Nutzung von freien Zertifikaten oder lassen Dich ihre eigenen Zertifikate mitnutzen. 
-Andere erlauben nur kostenpflichtige Zertifikate als eigenes Angebot bzw. von anderen Anbietern. 
+Wenn Du zum jetzigen Zeitpunkt noch keinen Server aufgesetzt hast, ist es sinnvoll, die verschiedenen Anbieter in Bezug auf SSL zu vergleichen.
+Einige erlauben die Nutzung von freien Zertifikaten oder lassen Dich ihre eigenen Zertifikate mitnutzen.
+Andere erlauben nur kostenpflichtige Zertifikate als eigenes Angebot bzw. von anderen Anbietern.
 
 <a name="upload"></a>
 ### Wie kann ich Bilder, Dateien, Links, Video und Audio in Beiträge einfügen?
 
-Bilder können direkt im [Beitragseditor](help/Text_editor) vom Computer hochgeladen werden. 
-Eine Ãœbersicht aller Bilder, die auf Deinem Server liegen, findest Du unter <i>deineSeite.de/photos/profilname</i>. 
+Bilder können direkt im [Beitragseditor](help/Text_editor) vom Computer hochgeladen werden.
+Eine Ãœbersicht aller Bilder, die auf Deinem Server liegen, findest Du unter <i>deineSeite.de/photos/profilname</i>.
 Dort kannst Du auch direkt Bilder hochladen und festlegen, ob Deine Kontakte eine Nachricht Ã¼ber das neue Bild bekommen.
 
-Alle Arten von Dateien können grundsätzlich als Anhang in Friendica hochgeladen werden. 
-Dafür verwendest Du das Büroklammersymbol im Editor. 
-Sie sind dann direkt an den Beitrag geknüpft, können von den Betrachtern heruntergeladen werden, aber werden nicht als Vorschau angezeigt. 
-Deshalb eignet sich diese Methode vor allem für Office-Dateien oder gepackte Dateien wie ZIPs, aber weniger für Multimediadateien. 
+Alle Arten von Dateien können grundsätzlich als Anhang in Friendica hochgeladen werden.
+Dafür verwendest Du das Büroklammersymbol im Editor.
+Sie sind dann direkt an den Beitrag geknüpft, können von den Betrachtern heruntergeladen werden, aber werden nicht als Vorschau angezeigt.
+Deshalb eignet sich diese Methode vor allem für Office-Dateien oder gepackte Dateien wie ZIPs, aber weniger für Multimediadateien.
 Wer hingegen Dateien Ã¼ber Dropbox, Ã¼ber eine auf dem eigenen Server installierte Owncloud oder Ã¼ber einen anderen [Filehoster](http://en.wikipedia.org/wiki/Comparison_of_file_hosting_services) einfügen will, verwendet den Link-Button.
 
-Wenn Du mit dem Link-Button (Ketten-Symbol) URLs zu anderen Seiten einfügst, versucht Friendica eine kurze Zusammenfassung als Vorschau abzurufen. 
+Wenn Du mit dem Link-Button (Ketten-Symbol) URLs zu anderen Seiten einfügst, versucht Friendica eine kurze Zusammenfassung als Vorschau abzurufen.
 Manchmal klappts das nicht ... dann verlinke den Beitrag einfach per [url=http://example.com]<i>freigewählter Name</i>[/url] im Editor.
 
-Video- und Audiodateien können zwar in Beiträge eingebunden werden, allerdings geht das nicht Ã¼ber einen direkten Upload im Editor wie bei Fotos. 
+Video- und Audiodateien können zwar in Beiträge eingebunden werden, allerdings geht das nicht Ã¼ber einen direkten Upload im Editor wie bei Fotos.
 Du hast zwei Möglichkeiten:
 
 1. Du kannst bei dem Video- oder Audiobutton die URL von einem Hoster eingeben (Youtube, Vimeo, Soundcloud und alle anderen mit oembed/opengraph-Unterstützung). Bei Videos zeigt Friendica dann ein Vorschaubild in Deinem Beitrag an, nach einem Klick Ã¶ffnet sich ein eingebetter Player. Bei Soundcloud wird der Player direkt eingebunden.
@@ -84,57 +84,57 @@ Zum Konvertieren von Videos in das lizenfreie Videoformat WebM gibt es unter Win
 <a name="avatars"></a>
 ### Ist es möglich, bei mehreren Profilen verschiedene Avatare (Nutzerbilder) zu haben?
 
-Ja. 
-Auf Deiner ["Profile verwalten/editieren"-Seite](../profiles) wählst Du zunächst das gewünschte Profil aus. 
-Anschließend siehst Du eine Seite mit allen Infos zu diesem Profil. 
-Klicke nun oben auf den Link "Profilbild Ã¤ndern" und lade im nächsten Fenster ein Bild von Deinem PC hoch. 
+Ja.
+Auf Deiner ["Profile verwalten/editieren"-Seite](../profiles) wählst Du zunächst das gewünschte Profil aus.
+Anschließend siehst Du eine Seite mit allen Infos zu diesem Profil.
+Klicke nun oben auf den Link "Profilbild Ã¤ndern" und lade im nächsten Fenster ein Bild von Deinem PC hoch.
 Um Deine privaten Daten zu schützen, wird in Beiträgen nur das Bild aus Deinem Ã¶ffentlichen Profil angezeigt.
 
 <a name="contacts"></a>
 ### Was ist der Unterschied zwischen blockierten|ignorierten|archivierten|versteckten Kontakten?
 
-Wir verhindern direkte Kommunikation mit blockierten Kontakten. 
-Sie gehören nicht zu den Empfängern beim Versand von Beiträgen und deren Beiträge werden auch nicht importiert. 
-Trotzdem werden deren Unterhaltungen mit Deinen Freunden in Deinem Stream sichtbar sein. 
-Wenn Du einen Kontakt komplett löschst, können sie Dir eine neue Freundschaftsanfrage schicken. 
-Blockierte Kontakte können das nicht machen. 
-Sie können nicht mit Dir direkt kommunizieren, nur Ã¼ber Freunde. 
+Wir verhindern direkte Kommunikation mit blockierten Kontakten.
+Sie gehören nicht zu den Empfängern beim Versand von Beiträgen und deren Beiträge werden auch nicht importiert.
+Trotzdem werden deren Unterhaltungen mit Deinen Freunden in Deinem Stream sichtbar sein.
+Wenn Du einen Kontakt komplett löschst, können sie Dir eine neue Freundschaftsanfrage schicken.
+Blockierte Kontakte können das nicht machen.
+Sie können nicht mit Dir direkt kommunizieren, nur Ã¼ber Freunde.
 
-Ignorierte Kontakte können weiterhin Beiträge und private Nachrichten von Dir erhalten. 
-Deren Beiträge und private Nachrichten werden allerdings nicht importiert. 
-Wie bei blockierten Beiträgen siehst Du auch hier weiterhin die Kommentare dieser Person zu anderen Beiträgen Deiner Freunde. 
+Ignorierte Kontakte können weiterhin Beiträge und private Nachrichten von Dir erhalten.
+Deren Beiträge und private Nachrichten werden allerdings nicht importiert.
+Wie bei blockierten Beiträgen siehst Du auch hier weiterhin die Kommentare dieser Person zu anderen Beiträgen Deiner Freunde.
 
-[Ein Erweiterung namens "blockem" kann installiert werden, um alle Beiträge einer bestimmten Person in Deinem Stream zu verstecken bzw. zu verkürzen. 
+[Ein Erweiterung namens "blockem" kann installiert werden, um alle Beiträge einer bestimmten Person in Deinem Stream zu verstecken bzw. zu verkürzen.
 Dabei werden auch Kommentare dieser Person in Beiträgen Deiner Freunde blockiert.]
 
-Ein archivierter Kontakt bedeutet, dass Kommunikation nicht möglich ist und auch nicht versucht wird (das ist z.B. sinnvoll, wenn eine Person zu einem neuen Server gewechselt ist und das alte Profil gelöscht hat). 
+Ein archivierter Kontakt bedeutet, dass Kommunikation nicht möglich ist und auch nicht versucht wird (das ist z.B. sinnvoll, wenn eine Person zu einem neuen Server gewechselt ist und das alte Profil gelöscht hat).
 Anders als beim Blockieren werden existierende Beiträge, die vor der Archivierung erstellt wurden, weiterhin angezeigt.
 
-Ein versteckter Kontakt wird in keiner "Freundeliste" erscheinen (außer für dich). 
-Trotzdem wird ein versteckter Kontakt normal in Unterhaltungen angezeigt - was für andere Kontakte ein Hinweis sein kann, dass diese Person als versteckter Kontakt in Deiner Liste ist. 
+Ein versteckter Kontakt wird in keiner "Freundeliste" erscheinen (außer für dich).
+Trotzdem wird ein versteckter Kontakt normal in Unterhaltungen angezeigt - was für andere Kontakte ein Hinweis sein kann, dass diese Person als versteckter Kontakt in Deiner Liste ist.
 
 <a name="removed"></a>
 ### Was passiert, wenn ein Account gelöscht ist? Ist dieser richtig gelöscht?
 
-Wenn Du Deinen Account löschst, wird sofort der gesamte Inhalt auf Deinem Server gelöscht und ein Löschbefehl an alle Deine Kontakte verschickt. 
-Dadurch wirst Du ebenfalls aus dem globalen Verzeichnis gelöscht. 
-Dieses Vorgehen setzt voraus, dass Dein Profil für 24 Stunden weiterhin "teilweise" verfügbar sein wird, um eine Verbindung zu allen Deinen Kontakten ermöglicht. 
+Wenn Du Deinen Account löschst, wird sofort der gesamte Inhalt auf Deinem Server gelöscht und ein Löschbefehl an alle Deine Kontakte verschickt.
+Dadurch wirst Du ebenfalls aus dem globalen Verzeichnis gelöscht.
+Dieses Vorgehen setzt voraus, dass Dein Profil für 24 Stunden weiterhin "teilweise" verfügbar sein wird, um eine Verbindung zu allen Deinen Kontakten ermöglicht.
 Wir können also Dein Profil blockieren und es so erscheinen lassen, als wären alle Daten sofort gelöscht, allerdings warten wir 24 Stunden (bzw. bis alle Deine Kontakte informiert wurden), bevor wir die Daten auch physikalisch löschen.
 
 <a name="hashtag"></a>
 ### Kann ich einem hashtag folgen?
 
-Nein. 
-Die Möglichkeit, einem hashtag zu folgen, ist eine interessante Technik, führt aber zu einigen Schwierigkeiten. 
+Nein.
+Die Möglichkeit, einem hashtag zu folgen, ist eine interessante Technik, führt aber zu einigen Schwierigkeiten.
 
-1.) Alle Beiträge, die diesen tag nutzen, müssten zu allen Seiten im Netzwerk kopiert werden. Das erhöht den Speicherbedarf und beeinträchtigt kleine Seiten. Die Nutzung von geteilten Hosting-Angeboten (Shared Hosting) wäre praktisch unmöglich. 
+1.) Alle Beiträge, die diesen tag nutzen, müssten zu allen Seiten im Netzwerk kopiert werden. Das erhöht den Speicherbedarf und beeinträchtigt kleine Seiten. Die Nutzung von geteilten Hosting-Angeboten (Shared Hosting) wäre praktisch unmöglich.
 
 2.) Die Verbreitung von Spam wäre vereinfacht (tag-Spam ist z.B. bei Twitter ein schwerwiegendes Problem)
 
-3.) Der wichtigste Grund der gegen diese Technik spricht ist, dass sie eine natürliche Ausrichtung auf größere Seiten mit mehr getaggten Inhalten zur Folge hat. Dies kann z.B. aufkommen, wenn Dein Netzwerk tags anstelle von anderen Kommunikationsmitteln wie Gruppen oder Foren nutzt. 
+3.) Der wichtigste Grund der gegen diese Technik spricht ist, dass sie eine natürliche Ausrichtung auf größere Seiten mit mehr getaggten Inhalten zur Folge hat. Dies kann z.B. aufkommen, wenn Dein Netzwerk tags anstelle von anderen Kommunikationsmitteln wie Gruppen oder Foren nutzt.
 
-Stattdessen bieten wir andere Mechanismen, um globale Unterhaltungen zu erreichen, dabei aber eine angemesse Basis für kleine und große Seiten zu bieten. 
-Hierzu gehören Foren, Gruppen und geteilte tags. 
+Stattdessen bieten wir andere Mechanismen, um globale Unterhaltungen zu erreichen, dabei aber eine angemesse Basis für kleine und große Seiten zu bieten.
+Hierzu gehören Foren, Gruppen und geteilte tags.
 
 <a name="rss"></a>
 ### Wie kann ich einen RSS-Feed meiner Netzwerkseite (Stream) erstellen?
@@ -145,16 +145,16 @@ Wenn Du die Beiträge Deines Accounts mit RSS teilen willst, dann kannst Du eine
 
        deineSeite.de/feed/[profilname]/posts
 
-Beispiel: Friendica Support 
-       
+Beispiel: Friendica Support
+
        https://forum.friendi.ca/feed/helpers/posts
 
 #### RSS-Feed all deiner Beiträge und Antworten
 
     deineSeite.de/dfrn_poll/feed/[profilname]/comments
-       
-Beispiel: Friendica Support 
-       
+
+Beispiel: Friendica Support
+
     https://forum.friendi.ca/feeds/helpers/comments
 
 #### RSS-Feed all deiner Aktivitäten
@@ -188,8 +188,8 @@ Hier ist eine Liste von Clients bei denen dies möglich ist, bzw. die speziell f
 <a name="help"></a>
 ### Wo finde ich Hilfe?
 
-Wenn Du Probleme mit Deiner Friendica-Seite hast, dann kannst Du die Community in der [Friendica-Support-Gruppe](https://forum.friendi.ca/profile/helpers) oder im [deutschen Friendica-Support-Forum](http://toktan.org/profile/wiki) fragen oder Dir das [deutsche Wiki](http://wiki.toktan.org/doku.php) anschauen. 
-Wenn Du Deinen Account nicht nutzen kannst, kannst Du entweder einen [Testaccount](https://tryfriendica.de) bzw. einen Account auf einer Ã¶ffentlichen Seite ([Liste](https://dir.friendica.social/servers)) nutzen, oder Du wählst die Librelist-mailing-Liste. 
+Wenn Du Probleme mit Deiner Friendica-Seite hast, dann kannst Du die Community in der [Friendica-Support-Gruppe](https://forum.friendi.ca/profile/helpers) oder im [deutschen Friendica-Support-Forum](http://toktan.org/profile/wiki) fragen oder Dir das [deutsche Wiki](http://wiki.toktan.org/doku.php) anschauen.
+Wenn Du Deinen Account nicht nutzen kannst, kannst Du entweder einen [Testaccount](https://tryfriendica.de) bzw. einen Account auf einer Ã¶ffentlichen Seite ([Liste](https://dir.friendica.social/servers)) nutzen, oder Du wählst die Librelist-mailing-Liste.
 Wenn Du die Mailing-Liste nutzen willst, schicke eine Mail an friendica AT librelist PUNKT com.
 
 Wenn Du ein Theme-Entwickler bist, wirst Du in diesem Forum Hilfe finden: [Friendica Theme Developers](https://friendica.eu/profile/ftdevs).
@@ -200,16 +200,16 @@ Admin
 <a name="multiple"></a>
 ### Kann ich mehrere Domains mit den selben Dateien aufsetzen?
 
-Ja, das ist möglich. 
-Es ist allerdings nicht möglich, eine Datenbank durch zwei Domains zu nutzen. 
-Solange Du Deine .htconfig.php allerdings so einrichtest, dass das System nicht versucht, eine Installation durchzuführen, kannst Du die richtige Config-Datei in include/$hostname/.htconfig.php hinterlegen. 
+Ja, das ist möglich.
+Es ist allerdings nicht möglich, eine Datenbank durch zwei Domains zu nutzen.
+Solange Du Deine .htconfig.php allerdings so einrichtest, dass das System nicht versucht, eine Installation durchzuführen, kannst Du die richtige Config-Datei in include/$hostname/.htconfig.php hinterlegen.
 Alle Cache-Aspekte und der Zugriffsschutz können pro Instanz konfiguriert werden.
 
 <a name="sources"></a>
 ### Wo kann ich den Quellcode von Friendica, Addons und Themes finden?
 
-Du kannst den Friendica-Quellcode [hier](https://github.com/friendica/friendica) finden. 
-Dort findest Du immer die aktuellste stabile Version von Friendica. 
+Du kannst den Friendica-Quellcode [hier](https://github.com/friendica/friendica) finden.
+Dort findest Du immer die aktuellste stabile Version von Friendica.
 Der Quellcode von Friendica Red ist [hier](https://github.com/friendica/red) zu finden.
 
 Addons findest Du auf [dieser Seite](https://github.com/friendica/friendica-addons).
@@ -235,8 +235,8 @@ Rufe bitte im Admin Panel den Punkt [DB Updates](/admin/dbsync/) auf und folge d
 Damit wird ein Hintergrundprozess gestartet der die Struktur deiner Datenbank Ã¼berprüft und gegebenenfalls aktualisiert.
 
 Du kannst das Struktur Updatee auch manuell auf der Kommandoeingabe ausführen.
-Starte dazu bitte vom Grundverzeichnis deiner Friendica Instanz folgendes Skript:
+Starte dazu bitte vom Grundverzeichnis deiner Friendica Instanz folgendes Kommand:
 
-    scripts/dbstructure.php update
+    bin/console dbstructure update
 
 sollten bei der Ausführung Fehler auftreten, kontaktiere bitte das [Support Forum](https://forum.friendi.ca/profile/helpers).
index d6b48d9eac3579b3cd9aaf3169ae242a82e87964..02c1a23ea33a873efe26d39198c9a7e424d21233 100644 (file)
@@ -29,17 +29,17 @@ The location of the translated files in the source tree is
     /view/lang/LNG-CODE/
 where LNG-CODE is the language code used, e.g. de for German or fr for French.
 The translated strings come as a "message.po" file from transifex which needs to be translated into the PHP file friendica uses.
-To do so, place the file in the directory mentioned above and use the "po2php" utility from the util directory of your friendica installation.
+To do so, place the file in the directory mentioned above and use the "po2php" command from the Friendica Console.
 
 Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.
 
     1. Navigate at the command prompt to the base directory of your
        friendica installation
 
-    2. Execute the po2php script, which will place the translation
+    2. Execute the po2php command, which will place the translation
        in the strings.php file that is used by friendica.
 
-       $> php util/po2php.php view/lang/de/messages.po
+       $> php bin/console po2php view/lang/de/messages.po
 
        The output of the script will be placed at view/lang/de/strings.php where
        friendica is expecting it, so you can test your translation immediately.
@@ -64,7 +64,7 @@ Otherwise your work might get lost, when the translation from Transifex is inclu
 Utilities
 ---------
 
-Additional to the po2php script there are some more utilities for translation in the "util" directory of the friendica source tree.
+Additional to the po2php command there are some more utilities for translation in the console.
 If you only want to translate friendica into another language you wont need any of these tools most likely but it gives you an idea how the translation process of friendica works.
 
 For further information see the utils/README file.
@@ -92,9 +92,9 @@ To update the translation files after you have translated strings of e.g. Espera
 
     $> tx pull -l eo
 
-And then use the `po2php` utility described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
+And then use the `po2php` command described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
 
-    $> php util/po2php.php view/lang/eo/messages.po
+    $> php bin/console po2php view/lang/eo/messages.po
 
 Afterwards, just commit the two changed files to a feature branch of your Friendica repository, push the changes to github and open a pull request for your changes.
 
index af571f24582182fc70d442d38dd5ea048d35bc1f..586fc092fb764c51b9c54587f167b30570b51c20 100644 (file)
@@ -13,7 +13,7 @@ use Friendica\Util\DateTimeFormat;
  */
 
 class dba {
-       public static $connected = true;
+       public static $connected = false;
 
        private static $_server_info = '';
        private static $db;
@@ -48,8 +48,6 @@ class dba {
                $db = trim($db);
 
                if (!(strlen($server) && strlen($user))) {
-                       self::$connected = false;
-                       self::$db = null;
                        return false;
                }
 
@@ -57,8 +55,6 @@ class dba {
                        if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
                                if (! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
                                        self::$error = L10n::t('Cannot locate DNS info for database server \'%s\'', $server);
-                                       self::$connected = false;
-                                       self::$db = null;
                                        return false;
                                }
                        }
@@ -79,7 +75,6 @@ class dba {
                                self::$db = @new PDO($connect, $user, $pass);
                                self::$connected = true;
                        } catch (PDOException $e) {
-                               self::$connected = false;
                        }
                }
 
@@ -98,13 +93,10 @@ class dba {
                // No suitable SQL driver was found.
                if (!self::$connected) {
                        self::$db = null;
-                       if (!$install) {
-                               System::unavailable();
-                       }
                }
                $a->save_timestamp($stamp1, "network");
 
-               return true;
+               return self::$connected;
        }
 
        /**
index fba16263ab10c230ebb5b7bbc0327033a07509f9..a76057101a2f72596cc5c2b13555a5fd0ef85dc0 100644 (file)
--- a/index.php
+++ b/index.php
@@ -51,9 +51,13 @@ if (!$install) {
 require_once "include/dba.php";
 
 if (!$install) {
-       dba::connect($db_host, $db_user, $db_pass, $db_data, $install);
+       $result = dba::connect($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
 
+       if (!$result) {
+               System::unavailable();
+       }
+
        /**
         * Load configs from db. Overwrite configs from .htconfig.php
         */
index 967893e97479f7638ba1281a4472729d3be9228e..e266d29d7dcc3ce991aa125652cd75b70ad601aa 100644 (file)
@@ -718,7 +718,7 @@ function admin_page_summary(App $a)
        $warningtext = [];
        if (DBM::is_result($r)) {
                $showwarning = true;
-               $warningtext[] = L10n::t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php scripts/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />', 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
+               $warningtext[] = L10n::t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php bin/console dbstructure toinnodb</tt> of your Friendica installation for an automatic conversion.<br />', 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
        }
        // Check if github.com/friendica/master/VERSION is higher then
        // the local version of Friendica. Check is opt-in, source may be master or devel branch
@@ -735,7 +735,7 @@ function admin_page_summary(App $a)
        }
        if (Config::get('system', 'dbupdate') == DB_UPDATE_FAILED) {
                $showwarning = true;
-               $warningtext[] = L10n::t('The database update failed. Please run "php scripts/dbstructure.php update" from the command line and have a look at the errors that might appear.');
+               $warningtext[] = L10n::t('The database update failed. Please run "php bin/console dbstructure update" from the command line and have a look at the errors that might appear.');
        }
 
        $last_worker_call = Config::get('system', 'last_poller_execution', false);
diff --git a/scripts/dbstructure.php b/scripts/dbstructure.php
deleted file mode 100755 (executable)
index ff5b53c..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env php
-<?php
-/**
- * @file scripts/dbstructure.php
- * @brief Does database updates from the command line
- */
-
-use Friendica\App;
-use Friendica\Core\Config;
-use Friendica\Database\DBStructure;
-
-require_once "boot.php";
-require_once "include/dba.php";
-
-$a = new App(dirname(__DIR__));
-BaseObject::setApp($a);
-
-@include ".htconfig.php";
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
-
-if ($_SERVER["argc"] == 2) {
-       switch ($_SERVER["argv"][1]) {
-               case "dryrun":
-                       DBStructure::update(true, false);
-                       return;
-               case "update":
-                       DBStructure::update(true, true);
-
-                       $build = Config::get('system','build');
-                       if (!x($build)) {
-                               Config::set('system', 'build', DB_UPDATE_VERSION);
-                               $build = DB_UPDATE_VERSION;
-                       }
-
-                       $stored = intval($build);
-                       $current = intval(DB_UPDATE_VERSION);
-
-                       // run any left update_nnnn functions in update.php
-                       for ($x = $stored; $x < $current; $x ++) {
-                               $r = run_update_function($x);
-                               if (!$r) {
-                                       break;
-                               }
-                       }
-
-                       Config::set('system','build',DB_UPDATE_VERSION);
-                       return;
-               case "dumpsql":
-                       DBStructure::printStructure();
-                       return;
-               case "toinnodb":
-                       DBStructure::convertToInnoDB();
-                       return;
-       }
-}
-
-// print help
-echo $_SERVER["argv"][0]." <command>\n";
-echo "\n";
-echo "Commands:\n";
-echo "dryrun           show database update schema queries without running them\n";
-echo "update           update database schema\n";
-echo "dumpsql          dump database schema\n";
-echo "toinnodb convert all tables from MyISAM to InnoDB\n";
-killme();
-
diff --git a/src/Core/Console.php b/src/Core/Console.php
new file mode 100644 (file)
index 0000000..63aca93
--- /dev/null
@@ -0,0 +1,123 @@
+<?php\r
+\r
+namespace Friendica\Core;\r
+\r
+/**\r
+ * Description of Console\r
+ *\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class Console extends \Asika\SimpleConsole\Console\r
+{\r
+       // Disables the default help handling\r
+       protected $helpOptions = [];\r
+       protected $customHelpOptions = ['h', 'help', '?'];\r
+\r
+       protected $subConsoles = [\r
+               'config'                 => __NAMESPACE__ . '\Console\Config',\r
+               'createdoxygen'          => __NAMESPACE__ . '\Console\CreateDoxygen',\r
+               'docbloxerrorchecker'    => __NAMESPACE__ . '\Console\DocBloxErrorChecker',\r
+               'dbstructure'            => __NAMESPACE__ . '\Console\DatabaseStructure',\r
+               'extract'                => __NAMESPACE__ . '\Console\Extract',\r
+               'globalcommunityblock'   => __NAMESPACE__ . '\Console\GlobalCommunityBlock',\r
+               'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',\r
+               'maintenance'            => __NAMESPACE__ . '\Console\Maintenance',\r
+               'php2po'                 => __NAMESPACE__ . '\Console\PhpToPo',\r
+               'po2php'                 => __NAMESPACE__ . '\Console\PoToPhp',\r
+               'typo'                   => __NAMESPACE__ . '\Console\Typo',\r
+       ];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]\r
+\r
+Commands:\r
+       config                 Edit site config\r
+       createdoxygen          Generate Doxygen headers\r
+       dbstructure            Do database updates\r
+       docbloxerrorchecker    Check the file tree for DocBlox errors\r
+       extract                Generate translation string file for the Friendica project (deprecated)\r
+       globalcommunityblock   Block remote profile from interacting with this node\r
+       globalcommunitysilence Silence remote profile from global community page\r
+       help                   Show help about a command, e.g (bin/console help config)\r
+       maintenance            Set maintenance mode for this node\r
+       php2po                 Generate a messages.po file from a strings.php file\r
+       po2php                 Generate a strings.php file from a messages.po file\r
+       typo                   Checks for parse errors in Friendica files\r
+\r
+Options:\r
+       -h|--help|-? Show help information\r
+       -v           Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Executable: ' . $this->executable);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               $showHelp = false;\r
+               $subHelp = false;\r
+               $command = null;\r
+\r
+               if ($this->getOption('version')) {\r
+                       $this->out('Friendica Console version ' . FRIENDICA_VERSION);\r
+\r
+                       return 0;\r
+               } elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0\r
+               ) {\r
+                       $showHelp = true;\r
+               } elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') {\r
+                       $command = $this->getArgument(1);\r
+                       $subHelp = true;\r
+                       array_shift($this->args);\r
+                       array_shift($this->args);\r
+               } elseif (count($this->args) >= 1) {\r
+                       $command = $this->getArgument(0);\r
+                       array_shift($this->args);\r
+               }\r
+\r
+               if (is_null($command)) {\r
+                       $this->out($this->getHelp());\r
+                       return 0;\r
+               }\r
+\r
+               $console = $this->getSubConsole($command);\r
+\r
+               if ($subHelp) {\r
+                       $console->setOption($this->customHelpOptions, true);\r
+               }\r
+\r
+               return $console->execute();\r
+       }\r
+\r
+       private function getSubConsole($command)\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Command: ' . $command);\r
+               }\r
+\r
+               if (!isset($this->subConsoles[$command])) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Command ' . $command . ' doesn\'t exist');\r
+               }\r
+\r
+               $subargs = $this->args;\r
+               array_unshift($subargs, $this->executable);\r
+\r
+               $className = $this->subConsoles[$command];\r
+\r
+               $subconsole = new $className($subargs);\r
+\r
+               foreach ($this->options as $name => $value) {\r
+                       $subconsole->setOption($name, $value);\r
+               }\r
+\r
+               return $subconsole;\r
+       }\r
+\r
+}\r
diff --git a/src/Core/Console/Config.php b/src/Core/Console/Config.php
new file mode 100644 (file)
index 0000000..a199fb3
--- /dev/null
@@ -0,0 +1,135 @@
+<?php\r
+\r
+/*\r
+ * To change this license header, choose License Headers in Project Properties.\r
+ * To change this template file, choose Tools | Templates\r
+ * and open the template in the editor.\r
+ */\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+use Asika\SimpleConsole\CommandArgsException;\r
+use dba;\r
+use Friendica\Core;\r
+\r
+require_once 'include/dba.php';\r
+require_once 'include/text.php';\r
+\r
+/**\r
+ * @brief tool to access the system config from the CLI\r
+ *\r
+ * With this script you can access the system configuration of your node from\r
+ * the CLI. You can do both, reading current values stored in the database and\r
+ * set new values to config variables.\r
+ *\r
+ * Usage:\r
+ *   If you specify no parameters at the CLI, the script will list all config\r
+ *   variables defined.\r
+ *\r
+ *   If you specify one parameter, the script will list all config variables\r
+ *   defined in this section of the configuration (e.g. "system").\r
+ *\r
+ *   If you specify two parameters, the script will show you the current value\r
+ *   of the named configuration setting. (e.g. "system loglevel")\r
+ *\r
+ *   If you specify three parameters, the named configuration setting will be\r
+ *   set to the value of the last parameter. (e.g. "system loglevel 0" will\r
+ *   disable logging)\r
+ *\r
+ * @author Tobias Diekershoff\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class Config extends \Asika\SimpleConsole\Console\r
+{\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console config - Manage site configuration\r
+Synopsis\r
+       bin/console config [-h|--help|-?] [-v]\r
+       bin/console config <category> [-h|--help|-?] [-v]\r
+       bin/console config <category> <key> [-h|--help|-?] [-v]\r
+       bin/console config <category> <key> <value> [-h|--help|-?] [-v]\r
+\r
+Description\r
+       bin/console config\r
+               Lists all config values\r
+\r
+       bin/console config <category>\r
+               Lists all config values in the provided category\r
+\r
+       bin/console config <category> <key>\r
+               Shows the value of the provided key in the category\r
+\r
+       bin/console config <category> <key> <value>\r
+               Sets the value of the provided key in the category\r
+\r
+Notes:\r
+       Setting config entries which are manually set in .htconfig.php may result in\r
+       conflict between database settings and the manual startup settings.\r
+\r
+Options\r
+    -h|--help|-? Show help information\r
+    -v           Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Executable: ' . $this->executable);\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) > 3) {\r
+                       throw new CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               require_once '.htconfig.php';\r
+               $result = dba::connect($db_host, $db_user, $db_pass, $db_data);\r
+               unset($db_host, $db_user, $db_pass, $db_data);\r
+\r
+               if (!$result) {\r
+                       throw new \RuntimeException('Unable to connect to database');\r
+               }\r
+\r
+               if (count($this->args) == 3) {\r
+                       Core\Config::set($this->getArgument(0), $this->getArgument(1), $this->getArgument(2));\r
+                       $this->out("config[{$this->getArgument(0)}][{$this->getArgument(1)}] = " . Core\Config::get($this->getArgument(0),\r
+                                       $this->getArgument(1)));\r
+               }\r
+\r
+               if (count($this->args) == 2) {\r
+                       $this->out("config[{$this->getArgument(0)}][{$this->getArgument(1)}] = " . Core\Config::get($this->getArgument(0),\r
+                                       $this->getArgument(1)));\r
+               }\r
+\r
+               if (count($this->args) == 1) {\r
+                       Core\Config::load($this->getArgument(0));\r
+\r
+                       $a = get_app();\r
+                       if (!is_null($a->config[$this->getArgument(0)])) {\r
+                               foreach ($a->config[$this->getArgument(0)] as $k => $x) {\r
+                                       $this->out("config[{$this->getArgument(0)}][{$k}] = " . $x);\r
+                               }\r
+                       } else {\r
+                               $this->out('Config section ' . $this->getArgument(0) . ' returned nothing');\r
+                       }\r
+               }\r
+\r
+               if (count($this->args) == 0) {\r
+                       $configs = dba::select('config');\r
+                       foreach ($configs as $config) {\r
+                               $this->out("config[{$config['cat']}][{$config['k']}] = " . $config['v']);\r
+                       }\r
+               }\r
+\r
+               return 0;\r
+       }\r
+\r
+}\r
diff --git a/src/Core/Console/CreateDoxygen.php b/src/Core/Console/CreateDoxygen.php
new file mode 100644 (file)
index 0000000..17da992
--- /dev/null
@@ -0,0 +1,148 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+/**\r
+ * Description of CreateDoxygen\r
+ *\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class CreateDoxygen extends \Asika\SimpleConsole\Console\r
+{\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console createdoxygen - Generate Doxygen headers\r
+Usage\r
+       bin/console createdoxygen <file> [-h|--help|-?] [-v]\r
+\r
+Description\r
+       Outputs the provided file with added Doxygen headers to functions\r
+\r
+Options\r
+    -h|--help|-? Show help information\r
+    -v           Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) == 0) {\r
+                       $this->out($this->getHelp());\r
+                       return 0;\r
+               }\r
+\r
+               if (count($this->args) > 1) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               $file = $this->getArgument(0);\r
+               if (!file_exists($file)) {\r
+                       throw new \RuntimeException('Unable to find specified file.');\r
+               }\r
+\r
+               $data = file_get_contents($file);\r
+\r
+               $lines = explode("\n", $data);\r
+\r
+               $previous = "";\r
+\r
+               foreach ($lines AS $line) {\r
+                       $line = rtrim(trim($line, "\r"));\r
+\r
+                       if (strstr(strtolower($line), "function")) {\r
+                               $detect = strtolower(trim($line));\r
+                               $detect = implode(" ", explode(" ", $detect));\r
+\r
+                               $found = false;\r
+\r
+                               if (substr($detect, 0, 9) == "function ") {\r
+                                       $found = true;\r
+                               }\r
+\r
+                               if (substr($detect, 0, 19) == "protected function ") {\r
+                                       $found = true;\r
+                               }\r
+\r
+                               if (substr($detect, 0, 17) == "private function ") {\r
+                                       $found = true;\r
+                               }\r
+\r
+                               if (substr($detect, 0, 23) == "public static function ") {\r
+                                       $found = true;\r
+                               }\r
+\r
+                               if (substr($detect, 0, 24) == "private static function ") {\r
+                                       $found = true;\r
+                               }\r
+\r
+                               if (substr($detect, 0, 10) == "function (") {\r
+                                       $found = false;\r
+                               }\r
+\r
+                               if ($found && ( trim($previous) == "*/")) {\r
+                                       $found = false;\r
+                               }\r
+\r
+                               if ($found) {\r
+                                       $this->out($this->addDocumentation($line));\r
+                               }\r
+                       }\r
+                       $this->out($line);\r
+                       $previous = $line;\r
+               }\r
+\r
+               return 0;\r
+       }\r
+\r
+       /**\r
+        * @brief Adds a doxygen header\r
+        *\r
+        * @param string $line The current line of the document\r
+        *\r
+        * @return string added doxygen header\r
+        */\r
+       private function addDocumentation($line)\r
+       {\r
+               $trimmed = ltrim($line);\r
+               $length = strlen($line) - strlen($trimmed);\r
+               $space = substr($line, 0, $length);\r
+\r
+               $block = $space . "/**\n" .\r
+                       $space . " * @brief \n" .\r
+                       $space . " *\n"; /**/\r
+\r
+\r
+               $left = strpos($line, "(");\r
+               $line = substr($line, $left + 1);\r
+\r
+               $right = strpos($line, ")");\r
+               $line = trim(substr($line, 0, $right));\r
+\r
+               if ($line != "") {\r
+                       $parameters = explode(",", $line);\r
+                       foreach ($parameters AS $parameter) {\r
+                               $parameter = trim($parameter);\r
+                               $splitted = explode("=", $parameter);\r
+\r
+                               $block .= $space . " * @param " . trim($splitted[0], "& ") . "\n";\r
+                       }\r
+                       if (count($parameters) > 0) $block .= $space . " *\n";\r
+               }\r
+\r
+               $block .= $space . " * @return \n" .\r
+                       $space . " */\n";\r
+\r
+               return $block;\r
+       }\r
+\r
+}\r
diff --git a/src/Core/Console/DatabaseStructure.php b/src/Core/Console/DatabaseStructure.php
new file mode 100644 (file)
index 0000000..709b972
--- /dev/null
@@ -0,0 +1,110 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+use Friendica\Core;\r
+use Friendica\Database\DBStructure;\r
+\r
+require_once 'boot.php';\r
+require_once 'include/dba.php';\r
+\r
+/**\r
+ * @brief Does database updates from the command line\r
+ *\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class DatabaseStructure extends \Asika\SimpleConsole\Console\r
+{\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console dbstructure - Does database updates\r
+Usage\r
+       bin/console dbstructure <command> [-h|--help|-?] [-v]\r
+\r
+Commands\r
+       dryrun   Show database update schema queries without running them\r
+       update   Update database schema\r
+       dumpsql  Dump database schema\r
+       toinnodb Convert all tables from MyISAM to InnoDB\r
+\r
+Options\r
+    -h|--help|-? Show help information\r
+    -v           Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) == 0) {\r
+                       $this->out($this->getHelp());\r
+                       return 0;\r
+               }\r
+\r
+               if (count($this->args) > 1) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               require_once '.htconfig.php';\r
+               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);\r
+               unset($db_host, $db_user, $db_pass, $db_data);\r
+\r
+               if (!$result) {\r
+                       throw new \RuntimeException('Unable to connect to database');\r
+               }\r
+\r
+               Core\Config::load();\r
+\r
+               switch ($this->getArgument(0)) {\r
+                       case "dryrun":\r
+                               $output = DBStructure::update(true, false);\r
+                               break;\r
+                       case "update":\r
+                               $output = DBStructure::update(true, true);\r
+\r
+                               $build = Core\Config::get('system', 'build');\r
+                               if (empty($build)) {\r
+                                       Core\Config::set('system', 'build', DB_UPDATE_VERSION);\r
+                                       $build = DB_UPDATE_VERSION;\r
+                               }\r
+\r
+                               $stored = intval($build);\r
+                               $current = intval(DB_UPDATE_VERSION);\r
+\r
+                               // run any left update_nnnn functions in update.php\r
+                               for ($x = $stored; $x < $current; $x ++) {\r
+                                       $r = run_update_function($x);\r
+                                       if (!$r) {\r
+                                               break;\r
+                                       }\r
+                               }\r
+\r
+                               Core\Config::set('system', 'build', DB_UPDATE_VERSION);\r
+                               break;\r
+                       case "dumpsql":\r
+                               ob_start();\r
+                               DBStructure::printStructure();\r
+                               $output = ob_get_clean();\r
+                               break;\r
+                       case "toinnodb":\r
+                               ob_start();\r
+                               DBStructure::convertToInnoDB();\r
+                               $output = ob_get_clean();\r
+                               break;\r
+               }\r
+\r
+               $this->out($output);\r
+\r
+               return 0;\r
+       }\r
+\r
+}\r
diff --git a/src/Core/Console/DocBloxErrorChecker.php b/src/Core/Console/DocBloxErrorChecker.php
new file mode 100644 (file)
index 0000000..922a5ed
--- /dev/null
@@ -0,0 +1,192 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+/**\r
+ * When I installed docblox, I had the experience that it does not generate any output at all.\r
+ * This script may be used to find that kind of problems with the documentation build process.\r
+ * If docblox generates output, use another approach for debugging.\r
+ *\r
+ * Basically, docblox takes a list of files to build documentation from. This script assumes there is a file or set of files\r
+ * breaking the build when it is included in that list. It tries to calculate the smallest list containing these files.\r
+ * Unfortunatly, the original problem is NP-complete, so what the script does is a best guess only.\r
+ *\r
+ * So it starts with a list of all files in the project.\r
+ * If that list can't be build, it cuts it in two parts and tries both parts independently. If only one of them breaks,\r
+ * it takes that one and tries the same independently. If both break, it assumes this is the smallest set. This assumption\r
+ * is not necessarily true. Maybe the smallest set consists of two files and both of them were in different parts when\r
+ * the list was divided, but by now it is my best guess. To make this assumption better, the list is shuffled after every step.\r
+ *\r
+ * After that, the script tries to remove a file from the list. It tests if the list breaks and if so, it\r
+ * assumes that the file it removed belongs to the set of erroneous files.\r
+ * This is done for all files, so, in the end removing one file leads to a working doc build.\r
+ *\r
+ * @author Alexander Kampmann\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class DocBloxErrorChecker extends \Asika\SimpleConsole\Console\r
+{\r
+\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console docbloxerrorchecker - Checks the file tree for docblox errors\r
+Usage\r
+       bin/console docbloxerrorchecker [-h|--help|-?] [-v]\r
+\r
+Options\r
+    -h|--help|-? Show help information\r
+    -v           Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) > 0) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               if (!$this->commandExists('docblox')) {\r
+                       throw new \RuntimeException('DocBlox isn\'t available.');\r
+               }\r
+\r
+               //return from util folder to frindica base dir\r
+               $dir = get_app()->get_basepath();\r
+\r
+               //stack for dirs to search\r
+               $dirstack = [];\r
+               //list of source files\r
+               $filelist = [];\r
+\r
+               //loop over all files in $dir\r
+               while ($dh = opendir($dir)) {\r
+                       while ($file = readdir($dh)) {\r
+                               if (is_dir($dir . "/" . $file)) {\r
+                                       //add to directory stack\r
+                                       if (strpos($file, '.') !== 0) {\r
+                                               array_push($dirstack, $dir . "/" . $file);\r
+                                               $this->out('dir ' . $dir . '/' . $file);\r
+                                       }\r
+                               } else {\r
+                                       //test if it is a source file and add to filelist\r
+                                       if (substr($file, strlen($file) - 4) == ".php") {\r
+                                               array_push($filelist, $dir . "/" . $file);\r
+                                               $this->out($dir . '/' . $file);\r
+                                       }\r
+                               }\r
+                       }\r
+                       //look at the next dir\r
+                       $dir = array_pop($dirstack);\r
+               }\r
+\r
+               //check the entire set\r
+               if ($this->runs($filelist)) {\r
+                       throw new \RuntimeException("I can not detect a problem.");\r
+               }\r
+\r
+               //check half of the set and discard if that half is okay\r
+               $res = $filelist;\r
+               $i = count($res);\r
+               do {\r
+                       $this->out($i . '/' . count($filelist) . ' elements remaining.');\r
+                       $res = $this->reduce($res, count($res) / 2);\r
+                       shuffle($res);\r
+                       $i = count($res);\r
+               } while (count($res) < $i);\r
+\r
+               //check one file after another\r
+               $needed = [];\r
+\r
+               while (count($res) != 0) {\r
+                       $file = array_pop($res);\r
+\r
+                       if ($this->runs(array_merge($res, $needed))) {\r
+                               $this->out('needs: ' . $file . ' and file count ' . count($needed));\r
+                               array_push($needed, $file);\r
+                       }\r
+               }\r
+\r
+               $this->out('Smallest Set is: ' . $this->namesList($needed) . ' with ' . count($needed) . ' files. ');\r
+\r
+               return 0;\r
+       }\r
+\r
+       private function commandExists($command)\r
+       {\r
+               $prefix = strpos(strtolower(PHP_OS),'win') > -1 ? 'where' : 'which';\r
+               exec("{$prefix} {$command}", $output, $returnVal);\r
+               return $returnVal === 0;\r
+       }\r
+\r
+       /**\r
+        * This function generates a comma separated list of file names.\r
+        *\r
+        * @package util\r
+        *\r
+        * @param array $fileset Set of file names\r
+        *\r
+        * @return string comma-separated list of the file names\r
+        */\r
+       private function namesList($fileset)\r
+       {\r
+               return implode(',', $fileset);\r
+       }\r
+\r
+       /**\r
+        * This functions runs phpdoc on the provided list of files\r
+        * @package util\r
+        *\r
+        * @param array $fileset Set of filenames\r
+        *\r
+        * @return bool true, if that set can be built\r
+        */\r
+       private function runs($fileset)\r
+       {\r
+               $fsParam = $this->namesList($fileset);\r
+               $this->exec('docblox -t phpdoc_out -f ' . $fsParam);\r
+               if (file_exists("phpdoc_out/index.html")) {\r
+                       $this->out('Subset ' . $fsParam . ' is okay.');\r
+                       $this->exec('rm -r phpdoc_out');\r
+                       return true;\r
+               } else {\r
+                       $this->out('Subset ' . $fsParam . ' failed.');\r
+                       return false;\r
+               }\r
+       }\r
+\r
+       /**\r
+        * This functions cuts down a fileset by removing files until it finally works.\r
+        * it was meant to be recursive, but php's maximum stack size is to small. So it just simulates recursion.\r
+        *\r
+        * In that version, it does not necessarily generate the smallest set, because it may not alter the elements order enough.\r
+        *\r
+        * @package util\r
+        *\r
+        * @param array $fileset set of filenames\r
+        * @param int $ps number of files in subsets\r
+        *\r
+        * @return array a part of $fileset, that crashes\r
+        */\r
+       private function reduce($fileset, $ps)\r
+       {\r
+               //split array...\r
+               $parts = array_chunk($fileset, $ps);\r
+               //filter working subsets...\r
+               $parts = array_filter($parts, [$this, 'runs']);\r
+               //melt remaining parts together\r
+               if (is_array($parts)) {\r
+                       return array_reduce($parts, "array_merge", []);\r
+               }\r
+               return [];\r
+       }\r
+\r
+}\r
diff --git a/src/Core/Console/Extract.php b/src/Core/Console/Extract.php
new file mode 100644 (file)
index 0000000..e6cab06
--- /dev/null
@@ -0,0 +1,140 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+/**\r
+ * Extracts translation strings from the Friendica project's files to be exported\r
+ * to Transifex for translation.\r
+ *\r
+ * Outputs a PHP file with language strings used by Friendica\r
+ *\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class Extract extends \Asika\SimpleConsole\Console\r
+{\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console extract - Generate translation string file for the Friendica project (deprecated)\r
+Usage\r
+       bin/console extract [-h|--help|-?] [-v]\r
+\r
+Description\r
+       This script was used to generate the translation string file to be exported to Transifex,\r
+       please use bin/run_xgettext.sh instead\r
+\r
+Options\r
+    -h|--help|-? Show help information\r
+    -v           Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) > 0) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               $s = '<?php' . PHP_EOL;\r
+               $s .= '\r
+               function string_plural_select($n){\r
+                       return ($n != 1);\r
+               }\r
+\r
+               ';\r
+\r
+               $arr = [];\r
+\r
+               $files = array_merge(\r
+                       ['index.php', 'boot.php'],\r
+                       glob('mod/*'),\r
+                       glob('include/*'),\r
+                       glob('addon/*/*'),\r
+                       $this->globRecursive('src')\r
+               );\r
+\r
+               foreach ($files as $file) {\r
+                       $str = file_get_contents($file);\r
+\r
+                       $pat = '|L10n::t\(([^\)]*+)[\)]|';\r
+                       $patt = '|L10n::tt\(([^\)]*+)[\)]|';\r
+\r
+                       $matches = [];\r
+                       $matchestt = [];\r
+\r
+                       preg_match_all($pat, $str, $matches);\r
+                       preg_match_all($patt, $str, $matchestt);\r
+\r
+                       if (count($matches) || count($matchestt)) {\r
+                               $s .= '// ' . $file . PHP_EOL;\r
+                       }\r
+\r
+                       if (!empty($matches[1])) {\r
+                               foreach ($matches[1] as $long_match) {\r
+                                       $match_arr = preg_split('/(?<=[\'"])\s*,/', $long_match);\r
+                                       $match = $match_arr[0];\r
+                                       if (!in_array($match, $arr)) {\r
+                                               if (substr($match, 0, 1) == '$') {\r
+                                                       continue;\r
+                                               }\r
+\r
+                                               $arr[] = $match;\r
+\r
+                                               $s .= '$a->strings[' . $match . '] = ' . $match . ';' . "\n";\r
+                                       }\r
+                               }\r
+                       }\r
+                       if (!empty($matchestt[1])) {\r
+                               foreach ($matchestt[1] as $match) {\r
+                                       $matchtkns = preg_split("|[ \t\r\n]*,[ \t\r\n]*|", $match);\r
+                                       if (count($matchtkns) == 3 && !in_array($matchtkns[0], $arr)) {\r
+                                               if (substr($matchtkns[1], 0, 1) == '$') {\r
+                                                       continue;\r
+                                               }\r
+\r
+                                               $arr[] = $matchtkns[0];\r
+\r
+                                               $s .= '$a->strings[' . $matchtkns[0] . "] = array(\n";\r
+                                               $s .= "\t0 => " . $matchtkns[0] . ",\n";\r
+                                               $s .= "\t1 => " . $matchtkns[1] . ",\n";\r
+                                               $s .= ");\n";\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+\r
+               $s .= '// Timezones' . PHP_EOL;\r
+\r
+               $zones = timezone_identifiers_list();\r
+               foreach ($zones as $zone) {\r
+                       $s .= '$a->strings[\'' . $zone . '\'] = \'' . $zone . '\';' . "\n";\r
+               }\r
+\r
+               $this->out($s);\r
+\r
+               return 0;\r
+       }\r
+\r
+       private function globRecursive($path) {\r
+               $dir_iterator = new \RecursiveDirectoryIterator($path);\r
+               $iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::SELF_FIRST);\r
+\r
+               $return = [];\r
+               foreach ($iterator as $file) {\r
+                       if ($file->getBasename() != '.' && $file->getBasename() != '..') {\r
+                               $return[] = $file->getPathname();\r
+                       }\r
+               }\r
+\r
+               return $return;\r
+       }\r
+}\r
diff --git a/src/Core/Console/GlobalCommunityBlock.php b/src/Core/Console/GlobalCommunityBlock.php
new file mode 100644 (file)
index 0000000..1516a83
--- /dev/null
@@ -0,0 +1,77 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+use Friendica\Core\L10n;\r
+use Friendica\Model\Contact;\r
+\r
+/**\r
+ * @brief tool to block an account from the node\r
+ *\r
+ * With this tool, you can block an account in such a way, that no postings\r
+ * or comments this account writes are accepted to the node.\r
+ *\r
+ * License: AGPLv3 or later, same as Friendica\r
+ *\r
+ * @author Tobias Diekershoff <mrpetovan@gmail.com>\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class GlobalCommunityBlock extends \Asika\SimpleConsole\Console\r
+{\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console globalcommunityblock - Block remote profile from interacting with this node\r
+Usage\r
+       bin/console globalcommunityblock <profile_url> [-h|--help|-?] [-v]\r
+\r
+Description\r
+       Blocks an account in such a way that no postings or comments this account writes are accepted to this node.\r
+\r
+Options\r
+    -h|--help|-? Show help information\r
+    -v           Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) == 0) {\r
+                       $this->out($this->getHelp());\r
+                       return 0;\r
+               }\r
+\r
+               if (count($this->args) > 1) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               require_once '.htconfig.php';\r
+               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);\r
+               unset($db_host, $db_user, $db_pass, $db_data);\r
+\r
+               if (!$result) {\r
+                       throw new \RuntimeException('Unable to connect to database');\r
+               }\r
+\r
+               $contact_id = Contact::getIdForURL($this->getArgument(0));\r
+               if (!$contact_id) {\r
+                       throw new \RuntimeException(L10n::t('Could not find any contact entry for this URL (%s)', $nurl));\r
+               }\r
+               if(Contact::block($contact_id)) {\r
+                       $this->out(L10n::t('The contact has been blocked from the node'));\r
+               } else {\r
+                       throw new \RuntimeException('The contact block failed.');\r
+               }\r
+\r
+               return 0;\r
+       }\r
+}\r
diff --git a/src/Core/Console/GlobalCommunitySilence.php b/src/Core/Console/GlobalCommunitySilence.php
new file mode 100644 (file)
index 0000000..069750a
--- /dev/null
@@ -0,0 +1,94 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+use Friendica\Core\Protocol;\r
+use Friendica\Database\DBM;\r
+use Friendica\Network\Probe;\r
+\r
+require_once 'include/text.php';\r
+\r
+/**\r
+ * @brief tool to silence accounts on the global community page\r
+ *\r
+ * With this tool, you can silence an account on the global community page.\r
+ * Postings from silenced accounts will not be displayed on the community\r
+ * page. This silencing does only affect the display on the community page,\r
+ * accounts following the silenced accounts will still get their postings.\r
+ *\r
+ * License: AGPLv3 or later, same as Friendica\r
+ *\r
+ * @author Tobias Diekershoff\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class GlobalCommunitySilence extends \Asika\SimpleConsole\Console\r
+{\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console globalcommunitysilence - Silence remote profile from global community page\r
+Usage\r
+       bin/console globalcommunitysilence <profile_url> [-h|--help|-?] [-v]\r
+\r
+Description\r
+       With this tool, you can silence an account on the global community page.\r
+       Postings from silenced accounts will not be displayed on the community page.\r
+       This silencing does only affect the display on the community page, accounts\r
+       following the silenced accounts will still get their postings.\r
+\r
+Options\r
+    -h|--help|-? Show help information\r
+    -v           Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) == 0) {\r
+                       $this->out($this->getHelp());\r
+                       return 0;\r
+               }\r
+\r
+               if (count($this->args) > 1) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               require_once '.htconfig.php';\r
+               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);\r
+               unset($db_host, $db_user, $db_pass, $db_data);\r
+\r
+               if (!$result) {\r
+                       throw new \RuntimeException('Unable to connect to database');\r
+               }\r
+\r
+               /**\r
+                * 1. make nurl from last parameter\r
+                * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID\r
+                * 3. set the flag hidden=1 for the contact entry with the found ID\r
+                * */\r
+               $net = Probe::uri($this->getArgument(0));\r
+               if (in_array($net['network'], [Protocol::PHANTOM, Protocol::MAIL])) {\r
+                       throw new \RuntimeException('This account seems not to exist.');\r
+               }\r
+\r
+               $nurl = normalise_link($net['url']);\r
+               $contact = \dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);\r
+               if (DBM::is_result($contact)) {\r
+                       \dba::update("contact", ["hidden" => true], ["id" => $contact["id"]]);\r
+                       $this->out('NOTICE: The account should be silenced from the global community page');\r
+               } else {\r
+                       throw new \RuntimeException('NOTICE: Could not find any entry for this URL (' . $nurl . ')');\r
+               }\r
+\r
+               return 0;\r
+       }\r
+}\r
diff --git a/src/Core/Console/Maintenance.php b/src/Core/Console/Maintenance.php
new file mode 100644 (file)
index 0000000..1906794
--- /dev/null
@@ -0,0 +1,105 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+use Friendica\Core;\r
+\r
+require_once 'boot.php';\r
+require_once 'include/dba.php';\r
+\r
+/**\r
+ * @brief Sets maintenance mode for this node\r
+ *\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class Maintenance extends \Asika\SimpleConsole\Console\r
+{\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console maintenance - Sets maintenance mode for this node\r
+Usage\r
+       bin/console maintenance <enable> [<reason>] [-h|--help|-?] [-v]\r
+\r
+Description\r
+       <enable> cen be either 0 or 1 to disabled or enable the maintenance mode on this node.\r
+\r
+       <reason> is a quote-enclosed string with the optional reason for the maintenance mode.\r
+\r
+Examples\r
+       bin/console maintenance 1\r
+               Enables the maintenance mode without setting a reason message\r
+\r
+       bin/console maintenance 1 "SSL certification update"\r
+               Enables the maintenance mode with setting a reason message\r
+\r
+       bin/console maintenance 0\r
+               Disables the maintenance mode\r
+\r
+Options\r
+    -h|--help|-? Show help information\r
+    -v           Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) == 0) {\r
+                       $this->out($this->getHelp());\r
+                       return 0;\r
+               }\r
+\r
+               if (count($this->args) > 2) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               require_once '.htconfig.php';\r
+               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);\r
+               unset($db_host, $db_user, $db_pass, $db_data);\r
+\r
+               if (!$result) {\r
+                       throw new \RuntimeException('Unable to connect to database');\r
+               }\r
+\r
+               Core\Config::load();\r
+\r
+               $lang = Core\L10n::getBrowserLanguage();\r
+               Core\L10n::loadTranslationTable($lang);\r
+\r
+               $enabled = intval($this->getArgument(0));\r
+\r
+               Core\Config::set('system', 'maintenance', $enabled);\r
+\r
+               $reason = $this->getArgument(1);\r
+\r
+               if ($enabled && $this->getArgument(1)) {\r
+                       Core\Config::set('system', 'maintenance_reason', $this->getArgument(1));\r
+               } else {\r
+                       Core\Config::set('system', 'maintenance_reason', '');\r
+               }\r
+\r
+               if ($enabled) {\r
+                       $mode_str = "maintenance mode";\r
+               } else {\r
+                       $mode_str = "normal mode";\r
+               }\r
+\r
+               $this->out('System set in ' . $mode_str);\r
+\r
+               if ($enabled && $reason != '') {\r
+                       $this->out('Maintenance reason: ' . $reason);\r
+               }\r
+\r
+               return 0;\r
+       }\r
+\r
+}\r
diff --git a/src/Core/Console/PhpToPo.php b/src/Core/Console/PhpToPo.php
new file mode 100644 (file)
index 0000000..105e6ea
--- /dev/null
@@ -0,0 +1,234 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+/**\r
+ * Read a strings.php file and create messages.po in the same directory\r
+ *\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class PhpToPo extends \Asika\SimpleConsole\Console\r
+{\r
+\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       private $normBaseMsgIds = [];\r
+       const NORM_REGEXP = "|[\\\]|";\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console php2po - Generate a messages.po file from a strings.php file\r
+Usage\r
+       bin/console php2po [-p <n>] [--base <file>] <path/to/strings.php> [-h|--help|-?] [-v]\r
+\r
+Description\r
+       Read a strings.php file and create the according messages.po in the same directory\r
+\r
+Options\r
+       -p <n>        Number of plural forms. Default: 2\r
+       --base <file> Path to base messages.po file. Default: util/messages.po\r
+       -h|--help|-?  Show help information\r
+       -v            Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) == 0) {\r
+                       $this->out($this->getHelp());\r
+                       return 0;\r
+               }\r
+\r
+               if (count($this->args) > 1) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               $a = get_app();\r
+\r
+               $phpfile = realpath($this->getArgument(0));\r
+\r
+               if (!file_exists($phpfile)) {\r
+                       throw new \RuntimeException('Supplied file path doesn\'t exist.');\r
+               }\r
+\r
+               if (!is_writable(dirname($phpfile))) {\r
+                       throw new \RuntimeException('Supplied directory isn\'t writable.');\r
+               }\r
+\r
+               $pofile = dirname($phpfile) . DIRECTORY_SEPARATOR . 'messages.po';\r
+\r
+               // start !\r
+               include_once($phpfile);\r
+\r
+               $out = '';\r
+               $out .= "# FRIENDICA Distributed Social Network\n";\r
+               $out .= "# Copyright (C) 2010, 2011, 2012, 2013 the Friendica Project\n";\r
+               $out .= "# This file is distributed under the same license as the Friendica package.\n";\r
+               $out .= "# \n";\r
+               $out .= 'msgid ""' . "\n";\r
+               $out .= 'msgstr ""' . "\n";\r
+               $out .= '"Project-Id-Version: friendica\n"' . "\n";\r
+               $out .= '"Report-Msgid-Bugs-To: \n"' . "\n";\r
+               $out .= '"POT-Creation-Date: ' . date("Y-m-d H:i:sO") . '\n"' . "\n";\r
+               $out .= '"MIME-Version: 1.0\n"' . "\n";\r
+               $out .= '"Content-Type: text/plain; charset=UTF-8\n"' . "\n";\r
+               $out .= '"Content-Transfer-Encoding: 8bit\n"' . "\n";\r
+\r
+               // search for plural info\r
+               $lang = "";\r
+               $lang_logic = "";\r
+               $lang_pnum = $this->getOption('p', 2);\r
+\r
+               $infile = file($phpfile);\r
+               foreach ($infile as $l) {\r
+                       $l = trim($l);\r
+                       if ($this->startsWith($l, 'function string_plural_select_')) {\r
+                               $lang = str_replace('function string_plural_select_', '', str_replace('($n){', '', $l));\r
+                       }\r
+                       if ($this->startsWith($l, 'return')) {\r
+                               $lang_logic = str_replace('$', '', trim(str_replace('return ', '', $l), ';'));\r
+                               break;\r
+                       }\r
+               }\r
+\r
+               $this->out('Language: ' . $lang);\r
+               $this->out('Plural forms: ' . $lang_pnum);\r
+               $this->out('Plural forms: ' . $lang_logic);\r
+\r
+               $out .= sprintf('"Language: %s\n"', $lang) . "\n";\r
+               $out .= sprintf('"Plural-Forms: nplurals=%s; plural=%s;\n"', $lang_pnum, $lang_logic) . "\n";\r
+               $out .= "\n";\r
+\r
+               $base_path = $this->getOption('base', 'util' . DIRECTORY_SEPARATOR . 'messages.po');\r
+\r
+               // load base messages.po and extract msgids\r
+               $base_msgids = [];\r
+               $base_f = file($base_path);\r
+               if (!$base_f) {\r
+                       throw new \RuntimeException('The base ' . $base_path . ' file is missing or unavailable to read.');\r
+               }\r
+\r
+               $this->out('Loading base file ' . $base_path . '...');\r
+\r
+               $_f = 0;\r
+               $_mid = "";\r
+               $_mids = [];\r
+               foreach ($base_f as $l) {\r
+                       $l = trim($l);\r
+\r
+                       if ($this->startsWith($l, 'msgstr')) {\r
+                               if ($_mid != '""') {\r
+                                       $base_msgids[$_mid] = $_mids;\r
+                                       $this->normBaseMsgIds[preg_replace(self::NORM_REGEXP, "", $_mid)] = $_mid;\r
+                               }\r
+\r
+                               $_f = 0;\r
+                               $_mid = "";\r
+                               $_mids = [];\r
+                       }\r
+\r
+                       if ($this->startsWith($l, '"') && $_f == 2) {\r
+                               $_mids[count($_mids) - 1] .= "\n" . $l;\r
+                       }\r
+                       if ($this->startsWith($l, 'msgid_plural ')) {\r
+                               $_f = 2;\r
+                               $_mids[] = str_replace('msgid_plural ', '', $l);\r
+                       }\r
+\r
+                       if ($this->startsWith($l, '"') && $_f == 1) {\r
+                               $_mid .= "\n" . $l;\r
+                               $_mids[count($_mids) - 1] .= "\n" . $l;\r
+                       }\r
+                       if ($this->startsWith($l, 'msgid ')) {\r
+                               $_f = 1;\r
+                               $_mid = str_replace('msgid ', '', $l);\r
+                               $_mids = [$_mid];\r
+                       }\r
+               }\r
+\r
+               $this->out('Creating ' . $pofile . '...');\r
+\r
+               // create msgid and msgstr\r
+               $warnings = "";\r
+               foreach ($a->strings as $key => $str) {\r
+                       $msgid = $this->massageString($key);\r
+\r
+                       if (preg_match("|%[sd0-9](\$[sn])*|", $msgid)) {\r
+                               $out .= "#, php-format\n";\r
+                       }\r
+                       $msgid = $this->findOriginalMsgId($msgid);\r
+                       $out .= 'msgid ' . $msgid . "\n";\r
+\r
+                       if (is_array($str)) {\r
+                               if (array_key_exists($msgid, $base_msgids) && isset($base_msgids[$msgid][1])) {\r
+                                       $out .= 'msgid_plural ' . $base_msgids[$msgid][1] . "\n";\r
+                               } else {\r
+                                       $out .= 'msgid_plural ' . $msgid . "\n";\r
+                                       $warnings .= "[W] No source plural form for msgid:\n" . str_replace("\n", "\n\t", $msgid) . "\n\n";\r
+                               }\r
+                               foreach ($str as $n => $msgstr) {\r
+                                       $out .= 'msgstr[' . $n . '] ' . $this->massageString($msgstr) . "\n";\r
+                               }\r
+                       } else {\r
+                               $out .= 'msgstr ' . $this->massageString($str) . "\n";\r
+                       }\r
+\r
+                       $out .= "\n";\r
+               }\r
+\r
+               if (!file_put_contents($pofile, $out)) {\r
+                       throw new \RuntimeException('Unable to write to ' . $pofile);\r
+               }\r
+\r
+               if ($warnings != '') {\r
+                       $this->out($warnings);\r
+               }\r
+\r
+               return 0;\r
+       }\r
+\r
+       private function startsWith($haystack, $needle)\r
+       {\r
+               // search backwards starting from haystack length characters from the end\r
+               return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;\r
+       }\r
+\r
+       /**\r
+        * Get a string and retun a message.po ready text\r
+        * - replace " with \"\r
+        * - replace tab char with \t\r
+        * - manage multiline strings\r
+        */\r
+       private function massageString($str)\r
+       {\r
+               $str = str_replace('\\', '\\\\', $str);\r
+               $str = str_replace('"', '\"', $str);\r
+               $str = str_replace("\t", '\t', $str);\r
+               $str = str_replace("\n", '\n"' . "\n" . '"', $str);\r
+               if (strpos($str, "\n") !== false && $str[0] !== '"') {\r
+                       $str = '"' . "\n" . $str;\r
+               }\r
+\r
+               $str = preg_replace("|\n([^\"])|", "\n\"$1", $str);\r
+               return sprintf('"%s"', $str);\r
+       }\r
+\r
+       private function findOriginalMsgId($str)\r
+       {\r
+               $norm_str = preg_replace(self::NORM_REGEXP, "", $str);\r
+               if (array_key_exists($norm_str, $this->normBaseMsgIds)) {\r
+                       return $this->normBaseMsgIds[$norm_str];\r
+               }\r
+\r
+               return $str;\r
+       }\r
+\r
+}\r
diff --git a/src/Core/Console/PoToPhp.php b/src/Core/Console/PoToPhp.php
new file mode 100644 (file)
index 0000000..3a58d9f
--- /dev/null
@@ -0,0 +1,197 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+/**\r
+ * Read a messages.po file and create strings.php in the same directory\r
+ *\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class PoToPhp extends \Asika\SimpleConsole\Console\r
+{\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       const DQ_ESCAPE = "__DQ__";\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console php2po - Generate a strings.php file from a messages.po file\r
+Usage\r
+       bin/console php2po <path/to/messages.po> [-h|--help|-?] [-v]\r
+\r
+Description\r
+       Read a messages.po file and create the according strings.php in the same directory\r
+\r
+Options\r
+       -h|--help|-?  Show help information\r
+       -v            Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) == 0) {\r
+                       $this->out($this->getHelp());\r
+                       return 0;\r
+               }\r
+\r
+               if (count($this->args) > 1) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               $a = get_app();\r
+\r
+               $pofile = realpath($this->getArgument(0));\r
+\r
+               if (!file_exists($pofile)) {\r
+                       throw new \RuntimeException('Supplied file path doesn\'t exist.');\r
+               }\r
+\r
+               if (!is_writable(dirname($pofile))) {\r
+                       throw new \RuntimeException('Supplied directory isn\'t writable.');\r
+               }\r
+\r
+               $outfile = dirname($pofile) . DIRECTORY_SEPARATOR . 'strings.php';\r
+\r
+               if (strstr($outfile, 'util')) {\r
+                       $lang = 'en';\r
+               } else {\r
+                       $lang = str_replace('-', '_', basename(dirname($pofile)));\r
+               }\r
+\r
+               $this->out('Out to ' . $outfile);\r
+\r
+               $out = "<?php\n\n";\r
+\r
+               $infile = file($pofile);\r
+               $k = '';\r
+               $v = '';\r
+               $arr = false;\r
+               $ink = false;\r
+               $inv = false;\r
+               $escape_s_exp = '|[^\\\\]\$[a-z]|';\r
+\r
+               foreach ($infile as $l) {\r
+                       $l = str_replace('\"', self::DQ_ESCAPE, $l);\r
+                       $len = strlen($l);\r
+                       if ($l[0] == "#") {\r
+                               $l = "";\r
+                       }\r
+\r
+                       if (substr($l, 0, 15) == '"Plural-Forms: ') {\r
+                               $match = [];\r
+                               preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match);\r
+                               $cond = str_replace('n', '$n', $match[2]);\r
+                               // define plural select function if not already defined\r
+                               $fnname = 'string_plural_select_' . $lang;\r
+                               $out .= 'if(! function_exists("' . $fnname . '")) {' . "\n";\r
+                               $out .= 'function ' . $fnname . '($n){' . "\n";\r
+                               $out .= '       return ' . $cond . ';' . "\n";\r
+                               $out .= '}}' . "\n";\r
+                       }\r
+\r
+                       if ($k != "" && substr($l, 0, 7) == 'msgstr ') {\r
+                               if ($ink) {\r
+                                       $ink = false;\r
+                                       $out .= '$a->strings["' . $k . '"] = ';\r
+                               }\r
+\r
+                               if ($inv) {\r
+                                       $inv = false;\r
+                                       $out .= '"' . $v . '"';\r
+                               }\r
+\r
+                               $v = substr($l, 8, $len - 11);\r
+                               $v = preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $v);\r
+\r
+                               $inv = true;\r
+                       }\r
+                       if ($k != "" && substr($l, 0, 7) == 'msgstr[') {\r
+                               if ($ink) {\r
+                                       $ink = false;\r
+                                       $out .= '$a->strings["' . $k . '"] = ';\r
+                               }\r
+                               if ($inv) {\r
+                                       $inv = false;\r
+                                       $out .= '"' . $v . '"';\r
+                               }\r
+\r
+                               if (!$arr) {\r
+                                       $arr = True;\r
+                                       $out .= "[\n";\r
+                               }\r
+                               $match = [];\r
+                               preg_match("|\[([0-9]*)\] (.*)|", $l, $match);\r
+                               $out .= "\t"\r
+                                       . preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[1])\r
+                                       . ' => '\r
+                                       . preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[2])\r
+                                       . ",\n";\r
+                       }\r
+\r
+                       if (substr($l, 0, 6) == 'msgid_') {\r
+                               $ink = false;\r
+                               $out .= '$a->strings["' . $k . '"] = ';\r
+                       }\r
+\r
+                       if ($ink) {\r
+                               $k .= trim($l, "\"\r\n");\r
+                               $k = preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $k);\r
+                       }\r
+\r
+                       if (substr($l, 0, 6) == 'msgid ') {\r
+                               if ($inv) {\r
+                                       $inv = false;\r
+                                       $out .= '"' . $v . '"';\r
+                               }\r
+                               if ($k != "") {\r
+                                       $out .= ($arr) ? "];\n" : ";\n";\r
+                               }\r
+                               $arr = false;\r
+                               $k = str_replace("msgid ", "", $l);\r
+                               if ($k != '""') {\r
+                                       $k = trim($k, "\"\r\n");\r
+                               } else {\r
+                                       $k = '';\r
+                               }\r
+\r
+                               $k = preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $k);\r
+                               $ink = true;\r
+                       }\r
+\r
+                       if ($inv && substr($l, 0, 6) != "msgstr") {\r
+                               $v .= trim($l, "\"\r\n");\r
+                               $v = preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $v);\r
+                       }\r
+               }\r
+\r
+               if ($inv) {\r
+                       $inv = false;\r
+                       $out .= '"' . $v . '"';\r
+               }\r
+\r
+               if ($k != '') {\r
+                       $out .= ($arr ? "];\n" : ";\n");\r
+               }\r
+\r
+               $out = str_replace(self::DQ_ESCAPE, '\"', $out);\r
+               if (!file_put_contents($outfile, $out)) {\r
+                       throw new \RuntimeException('Unable to write to ' . $outfile);\r
+               }\r
+\r
+               return 0;\r
+       }\r
+\r
+       private function escapeDollar($match)\r
+       {\r
+               return str_replace('$', '\$', $match[0]);\r
+       }\r
+}\r
diff --git a/src/Core/Console/Typo.php b/src/Core/Console/Typo.php
new file mode 100644 (file)
index 0000000..4213fc8
--- /dev/null
@@ -0,0 +1,119 @@
+<?php\r
+\r
+namespace Friendica\Core\Console;\r
+\r
+/**\r
+ * Tired of chasing typos and finding them after a commit.\r
+ * Run this and quickly see if we've got any parse errors in our application files.\r
+ *\r
+ * @author Hypolite Petovan <mrpetovan@gmail.com>\r
+ */\r
+class Typo extends \Asika\SimpleConsole\Console\r
+{\r
+       protected $helpOptions = ['h', 'help', '?'];\r
+\r
+       protected function getHelp()\r
+       {\r
+               $help = <<<HELP\r
+console typo - Checks for parse errors in Friendica files\r
+Usage\r
+       bin/console typo [-h|--help|-?] [-v]\r
+\r
+Description\r
+       Checks all PHP files in the Friendica file tree for parse errors\r
+\r
+Options\r
+       -h|--help|-?  Show help information\r
+       -v            Show more debug information.\r
+HELP;\r
+               return $help;\r
+       }\r
+\r
+       protected function doExecute()\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Class: ' . __CLASS__);\r
+                       $this->out('Arguments: ' . var_export($this->args, true));\r
+                       $this->out('Options: ' . var_export($this->options, true));\r
+               }\r
+\r
+               if (count($this->args) > 0) {\r
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
+               }\r
+\r
+               $a = get_app();\r
+\r
+               $php_path = $a->getConfigValue('config', 'php_path', 'php');\r
+\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Directory: src');\r
+               }\r
+\r
+               $Iterator = new \RecursiveDirectoryIterator('src');\r
+\r
+               foreach (new \RecursiveIteratorIterator($Iterator) as $file) {\r
+                       if (substr($file, -4) === '.php') {\r
+                               $this->checkFile($php_path, $file);\r
+                       }\r
+               }\r
+\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Directory: mod');\r
+               }\r
+\r
+               $files = glob('mod/*.php');\r
+               $this->checkFiles($php_path, $files);\r
+\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Directory: include');\r
+               }\r
+\r
+               $files = glob('include/*.php');\r
+               $this->checkFiles($php_path, $files);\r
+\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Directory: addon');\r
+               }\r
+\r
+               $dirs = glob('addon/*');\r
+               foreach ($dirs as $dir) {\r
+                       $addon = basename($dir);\r
+                       $files = glob($dir . '/' . $addon . '.php');\r
+                       $this->checkFiles($php_path, $files);\r
+               }\r
+\r
+               if ($this->getOption('v')) {\r
+                       $this->out('String files');\r
+               }\r
+\r
+               $this->checkFile($php_path, 'util/strings.php');\r
+\r
+               $files = glob('view/lang/*/strings.php');\r
+               $this->checkFiles($php_path, $files);\r
+\r
+               $this->out('No errors.');\r
+\r
+               return 0;\r
+       }\r
+\r
+       private function checkFiles($php_path, array $files)\r
+       {\r
+               foreach ($files as $file) {\r
+                       $this->checkFile($php_path, $file);\r
+               }\r
+       }\r
+\r
+       private function checkFile($php_path, $file)\r
+       {\r
+               if ($this->getOption('v')) {\r
+                       $this->out('Checking ' . $file);\r
+               }\r
+\r
+               $output = [];\r
+               $ret = 0;\r
+               exec("$php_path -l $file", $output, $ret);\r
+               if ($ret !== 0) {\r
+                       throw new \RuntimeException('Parse error found in ' . $file . ', scan stopped.');\r
+               }\r
+       }\r
+}\r
index f4f16fb462ac8b48e8af55f4a26c11780dc3b16b..82e9532d8e89d7b507038966467a1d6c13861f96 100644 (file)
@@ -1,6 +1,6 @@
 Utilities
 
-typo.php  - is a crude syntax checker to avoid checking in files with simple
+php bin/console typo - is a crude syntax checker to avoid checking in files with simple
 typos. It basically just loads each of our project files at once. Run from
 cmdline and see if any parsing errors are reported.
 
@@ -8,7 +8,7 @@ cmdline and see if any parsing errors are reported.
 
 Internationalisation
 
-extract.php - extracts translatable strings from our project files. It
+php bin/console extract - extracts translatable strings from our project files. It
 currently doesn't pick up strings in other libraries we might be using such as
 the HTML parsers.
 
@@ -61,7 +61,7 @@ e.g.
 
 Plural
 
-The L10n::tt() function supports plural form. Script extract.php write this in
+The L10n::tt() function supports plural form. The extract command writes this in
 strings.php as an array, one string for every plural form language supports:
 
 $a->string["%d message sent"] = Array(
@@ -72,7 +72,7 @@ $a->string["%d message sent"] = Array(
 The function string_plural_select($n) defined in strings.php, return the string
 index to use, related to the numbers of item (value of $n).
 
-This is modelled after ngettext function of GNU gettext.
+This is modeled after ngettext function of GNU gettext.
 More info at http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html
 
 
@@ -107,7 +107,7 @@ Xgettext and .po workflow
        of the many .po editors out there, like QtLinguist
 
 5. run
-       $ php util/po2php.php view/lang/<language>/messages.po
+       $ php bin/console po2php view/lang/<language>/messages.po
        to create the strings.php file
 
 When strings are added or modified in source, you could run
@@ -117,10 +117,4 @@ When strings are added or modified in source, you could run
 
 If you already translated Friendica using strings.php, you could import your old
 translation to messages.po. Run:
-$ php util/php2po.php view/lang/<language>/strings.php
-
-
-You may also use the util/string_translator.php web interface to translate the string file, but it is disabled for website security reasons. The web server will need write permission to your language directories and the "Deny ..." line in util/.htaccess will need to be modified or commented to use the utility.
-
-
-
+$ php bin/console php2po view/lang/<language>/strings.php
diff --git a/util/config b/util/config
deleted file mode 100755 (executable)
index 7774fb6..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-/**
- * @brief tool to access the system config from the CLI
- *
- * With this script you can access the system configuration of your node from
- * the CLI. You can do both, reading current values stored in the database and
- * set new values to config variables.
- *
- * Usage:
- *   If you specify no parameters at the CLI, the script will list all config
- *   variables defined.
- *
- *   If you specify one parameter, the scipt will list all config variables
- *   defined in this section of the configuration (e.g. "system").
- *
- *   If you specify two parameters, the scipt will show you the current value
- *   of the named configuration setting. (e.g. "system loglevel")
- *
- *   If you specify three parameters, the named configuration setting will be
- *   set to the value of the last parameter. (e.g. "system loglevel 0" will
- *   disable logging)
- **/
-
-use Friendica\Core\Config;
-
-require_once 'boot.php';
-require_once 'include/dba.php';
-require_once 'include/text.php';
-$a = get_app();
-require_once '.htconfig.php';
-
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
-
-if($argc > 3) {
-       Config::set($argv[1],$argv[2],$argv[3]);
-       echo "config[{$argv[1]}][{$argv[2]}] = " . Config::get($argv[1],$argv[2]) . "\n";
-}
-
-if($argc == 3) {
-       echo "config[{$argv[1]}][{$argv[2]}] = " . Config::get($argv[1],$argv[2]) . "\n";
-}
-
-if($argc == 2) {
-       Config::load($argv[1]);
-       if (!is_null($a->config[$argv[1]])) {
-               foreach($a->config[$argv[1]] as $k => $x) {
-                       echo "config[{$argv[1]}][{$k}] = " . $x . "\n";
-               }
-       } else {
-               echo "config section '$argv[1]' returned nothing.\n";
-       }
-}
-
-if($argc == 1) {
-       $r = q("select * from config where 1");
-       if($r) {
-               foreach($r as $rr) {
-                       echo "config[{$rr['cat']}][{$rr['k']}] = " . $rr['v'] . "\n";
-               }
-       }
-}
-
diff --git a/util/config.md b/util/config.md
deleted file mode 100644 (file)
index 3b834fe..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-CLI config utility
-==================
-
-Usage:
-
-
-config
-       displays all config entries
-
-
-config family
-       displays all config entries for family (system, database, etc)
-
-
-config family key
-       displays single config entry for specified family and key
-
-config family key value
-       set config entry for specified family and key to value and display result
-
-
-
-Notes:
-       Setting config entries which are manually set in .htconfig.php may result in 
-conflict between database settings and the manual startup settings. 
-
diff --git a/util/createdoxygen.php b/util/createdoxygen.php
deleted file mode 100755 (executable)
index 798c814..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/php
-<?php
-/**
- * @file util/createdoxygen.php
- * @brief Adds a doxygen header to functions
- */
-
-if (count($_SERVER["argv"]) < 2)
-       die("usage: createdoxygen.php file\n");
-
-$file = $_SERVER["argv"][1];
-$data = file_get_contents($file);
-
-$lines = explode("\n", $data);
-
-$previous = "";
-
-foreach ($lines AS $line) {
-       $line = rtrim(trim($line, "\r"));
-
-       if (strstr(strtolower($line), "function")) {
-               $detect = strtolower(trim($line));
-               $detect = implode(" ", explode(" ", $detect));
-
-               $found = false;
-
-               if (substr($detect, 0, 9) == "function ")
-                       $found = true;
-
-               if (substr($detect, 0, 17) == "private function ")
-                       $found = true;
-
-               if (substr($detect, 0, 23) == "public static function ")
-                       $found = true;
-
-               if (substr($detect, 0, 10) == "function (")
-                       $found = false;
-
-               if ($found and (trim($previous) == "*/"))
-                       $found = false;
-
-               if ($found and !strstr($detect, "{"))
-                       $found = false;
-
-               if ($found) {
-                       echo add_documentation($line);
-               }
-       }
-       echo $line."\n";
-       $previous = $line;
-}
-
-/**
- * @brief Adds a doxygen header
- *
- * @param string $line The current line of the document
- *
- * @return string added doxygen header
- */
-function add_documentation($line) {
-
-       $trimmed = ltrim($line);
-       $length = strlen($line) - strlen($trimmed);
-       $space = substr($line, 0, $length);
-
-       $block = $space."/**\n".
-               $space." * @brief \n".
-               $space." *\n"; /**/
-
-
-       $left = strpos($line, "(");
-       $line = substr($line, $left + 1);
-
-       $right = strpos($line, ")");
-       $line = trim(substr($line, 0, $right));
-
-       if ($line != "") {
-               $parameters = explode(",", $line);
-               foreach ($parameters AS $parameter) {
-                       $parameter = trim($parameter);
-                       $splitted = explode("=", $parameter);
-
-                       $block .= $space." * @param ".trim($splitted[0], "& ")."\n";
-               }
-               if (count($parameters) > 0)
-                       $block .= $space." *\n";
-       }
-
-       $block .= $space." * @return \n".
-               $space." */\n";
-
-       return $block;
-}
diff --git a/util/docblox_errorchecker.php b/util/docblox_errorchecker.php
deleted file mode 100644 (file)
index a67be69..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-<?php
-/**
- * When I installed docblox, I had the experience that it does not generate any output at all.
- * This script may be used to find that kind of problems with the documentation build process.
- * If docblox generates output, use another approach for debugging.
- *
- * Basically, docblox takes a list of files to build documentation from. This script assumes there is a file or set of files
- * breaking the build when it is included in that list. It tries to calculate the smallest list containing these files.
- * Unfortunatly, the original problem is NP-complete, so what the script does is a best guess only.
- *
- * So it starts with a list of all files in the project.
- * If that list can't be build, it cuts it in two parts and tries both parts independently. If only one of them breaks,
- * it takes that one and tries the same independently. If both break, it assumes this is the smallest set. This assumption
- * is not necessarily true. Maybe the smallest set consists of two files and both of them were in different parts when
- * the list was divided, but by now it is my best guess. To make this assumption better, the list is shuffled after every step.
- *
- * After that, the script tries to remove a file from the list. It tests if the list breaks and if so, it
- * assumes that the file it removed belongs to the set of errorneous files.
- * This is done for all files, so, in the end removing one file leads to a working doc build.
- *
- * @package util
- * @author Alexander Kampmann
- */
-
-/**
- * This function generates a comma seperated list of file names.
- *
- * @package util
- *
- * @param array $fileset Set of file names
- *
- * @return string comma-seperated list of the file names
- */
-function namesList($fileset) {
-       $fsparam="";
-       foreach($fileset as $file) {
-               $fsparam=$fsparam.",".$file;
-       }
-       return $fsparam;
-};
-
-/**
- * This functions runs phpdoc on the provided list of files
- * @package util
- *
- * @param array $fileset Set of filenames
- *
- * @return bool true, if that set can be built
- */
-function runs($fileset) {
-       $fsParam=namesList($fileset);
-       exec('docblox -t phpdoc_out -f '.$fsParam);
-       if(file_exists("phpdoc_out/index.html")) {
-               echo "\n Subset ".$fsParam." is okay. \n";
-               exec('rm -r phpdoc_out');
-               return true;
-       } else {
-               echo "\n Subset ".$fsParam." failed. \n";
-               return false;
-       }
-};
-
-/**
- * This functions cuts down a fileset by removing files until it finally works.
- * it was meant to be recursive, but php's maximum stack size is to small. So it just simulates recursion.
- *
- * In that version, it does not necessarily generate the smallest set, because it may not alter the elements order enough.
- *
- * @package util
- *
- * @param array $fileset set of filenames
- * @param int $ps number of files in subsets
- *
- * @return array a part of $fileset, that crashes
- */
-function reduce($fileset, $ps) {
-       //split array...
-       $parts=array_chunk($fileset, $ps);
-       //filter working subsets...
-       $parts=array_filter($parts, "runs");
-       //melt remaining parts together
-       if(is_array($parts)) {
-               return array_reduce($parts, "array_merge", []);
-       }
-       return [];
-};
-
-//return from util folder to frindica base dir
-$dir='..';
-
-//stack for dirs to search
-$dirstack=[];
-//list of source files
-$filelist=[];
-
-//loop over all files in $dir
-while($dh=opendir($dir)) {
-       while($file=readdir($dh)) {
-               if(is_dir($dir."/".$file)) {
-                       //add to directory stack
-                       if($file!=".." && $file!=".") {
-                               array_push($dirstack, $dir."/".$file);
-                               echo "dir ".$dir."/".$file."\n";
-                       }
-               } else  {
-                       //test if it is a source file and add to filelist
-                       if(substr($file, strlen($file)-4)==".php") {
-                               array_push($filelist, $dir."/".$file);
-                               echo $dir."/".$file."\n";
-                       }
-               }
-       }
-       //look at the next dir
-       $dir=array_pop($dirstack);
-}
-
-//check the entire set
-if(runs($filelist)) {
-       echo "I can not detect a problem. \n";
-       exit;
-}
-
-//check half of the set and discard if that half is okay
-$res=$filelist;
-$i=0;
-do {
-       $i=count($res);
-       echo $i."/".count($fileset)." elements remaining. \n";
-       $res=reduce($res, count($res)/2);
-       shuffle($res);
-} while(count($res)<$i);
-
-//check one file after another
-$needed=[];
-
-while(count($res)!=0) {
-       $file=array_pop($res);
-
-       if(runs(array_merge($res, $needed))) {
-               echo "needs: ".$file." and file count ".count($needed);
-               array_push($needed, $file);
-       }
-}
-
-echo "\nSmallest Set is: ".namesList($needed)." with ".count($needed)." files. ";
diff --git a/util/extract.php b/util/extract.php
deleted file mode 100755 (executable)
index 18fbb9d..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-/**
- * @file util/extract.php
- *
- * Extracts translation strings from the Friendica project's files to be exported
- * to Transifex for translation.
- *
- * Outputs a PHP file with language strings used by Friendica
- */
-
-$s = '<?php' . PHP_EOL;
-$s .= '
-function string_plural_select($n){
-       return ($n != 1);
-}
-
-';
-
-$arr = [];
-
-$files = ['index.php', 'boot.php'];
-$files = array_merge(
-       $files,
-       glob('mod/*'),
-       glob('include/*'),
-       glob('addon/*/*'),
-       glob_recursive('src')
-);
-
-foreach ($files as $file) {
-       $str = file_get_contents($file);
-
-       $pat = '|L10n::t\(([^\)]*+)[\)]|';
-       $patt = '|L10n::tt\(([^\)]*+)[\)]|';
-
-       preg_match_all($pat, $str, $matches);
-       preg_match_all($patt, $str, $matchestt);
-
-       if (count($matches) || count($matchestt)) {
-               $s .= '// ' . $file . PHP_EOL;
-       }
-
-       if (count($matches)) {
-               foreach ($matches[1] as $long_match) {
-                       $match_arr = preg_split('/(?<=[\'"])\s*,/', $long_match);
-                       $match = $match_arr[0];
-                       if (!in_array($match, $arr)) {
-                               if (substr($match, 0, 1) == '$') {
-                                       continue;
-                               }
-
-                               $arr[] = $match;
-
-                               $s .= '$a->strings[' . $match . '] = ' . $match . ';' . "\n";
-                       }
-               }
-       }
-       if (count($matchestt)) {
-               foreach ($matchestt[1] as $match) {
-                       $matchtkns = preg_split("|[ \t\r\n]*,[ \t\r\n]*|", $match);
-                       if (count($matchtkns) == 3 && !in_array($matchtkns[0], $arr)) {
-                               if (substr($matchtkns[1], 0, 1) == '$') {
-                                       continue;
-                               }
-
-                               $arr[] = $matchtkns[0];
-
-                               $s .= '$a->strings[' . $matchtkns[0] . "] = array(\n";
-                               $s .= "\t0 => " . $matchtkns[0] . ",\n";
-                               $s .= "\t1 => " . $matchtkns[1] . ",\n";
-                               $s .= ");\n";
-                       }
-               }
-       }
-}
-
-$s .= '// Timezones' . PHP_EOL;
-
-$zones = timezone_identifiers_list();
-foreach ($zones as $zone) {
-       $s .= '$a->strings[\'' . $zone . '\'] = \'' . $zone . '\';' . "\n";
-}
-
-echo $s;
-
-function glob_recursive($path) {
-       $dir_iterator = new RecursiveDirectoryIterator($path);
-       $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
-
-       $return = [];
-       foreach ($iterator as $file) {
-               if ($file->getBasename() != '.' && $file->getBasename() != '..') {
-                       $return[] = $file->getPathname();
-               }
-       }
-
-       return $return;
-}
diff --git a/util/global_community_block.php b/util/global_community_block.php
deleted file mode 100755 (executable)
index 02f0c53..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env php
-<?php
-/**
- * @brief tool to block an account from the node
- *
- * With this tool, you can block an account in such a way, that no postings
- * or comments this account writes are accepted to the node.
- *
- * Usage: pass the URL of the to be blocked account as only parameter
- *        at the command line when running this tool. E.g.
- *
- *        $> util/global_community_block.php http://example.com/profile/bob
- *
- *        will block bob@example.com.
- *
- * Author: Tobias Diekershoff
- *
- * License: AGPLv3 or later, same as Friendica
- */
-if ($argc != 2 || $argv[1] == "-h" || $argv[1] == "--help" || $argv[1] == "-?") {
-       echo "Usage: " . $argv[0] . " [-h|profile_url]\r\n";
-       echo "    -h, -?, --help ... show this help\r\n";
-       echo "    profile_url ...... The URL of the profile you want to silence\r\n";
-       echo "\r\n";
-       echo "Example: block bob@example.com\r\n";
-       echo "$> " . $argv[0] . " https://example.com/profiles/bob\r\n";
-       echo "\r\n";
-       exit(0);
-}
-
-use Friendica\BaseObject;
-use Friendica\Core\L10n;
-use Friendica\Model\Contact;
-
-require_once 'boot.php';
-require_once 'include/dba.php';
-require_once 'include/text.php';
-
-$a = get_app();
-BaseObject::setApp($a);
-
-require_once '.htconfig.php';
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
-
-$contact_id = Contact::getIdForURL($argv[1]);
-if (!$contact_id) {
-       echo L10n::t('Could not find any contact entry for this URL (%s)', $nurl);
-       echo "\r\n";
-       exit(1);
-}
-Contact::block($contact_id);
-echo L10n::t('The contact has been blocked from the node');
-echo "\r\n";
-exit(0);
diff --git a/util/global_community_silence.php b/util/global_community_silence.php
deleted file mode 100755 (executable)
index 2eb76a4..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-/**
- * @brief tool to silence accounts on the global community page
- *
- * With this tool, you can silence an account on the global community page.
- * Postings from silenced accounts will not be displayed on the community
- * page. This silencing does only affect the display on the community page,
- * accounts following the silenced accounts will still get their postings.
- *
- * Usage: pass the URL of the profile to be silenced account as only parameter
- *        at the command line when running this tool. E.g.
- *
- *        $> util/global_community_silence.php http://example.com/profile/bob
- *
- *        will silence bob@example.com so that his postings won't appear at
- *        the global community page.
- *
- * Author: Tobias Diekershoff
- *
- * License: AGPLv3 or later, same as Friendica
- **/
-
-if ($argc != 2 || $argv[1] == "-h" || $argv[1] == "--help" || $argv[1] == "-?") {
-       echo "Usage: ".$argv[0]." [-h|profile_url]\r\n";
-       echo "    -h, -?, --help ... show this help\r\n";
-       echo "    profile_url ...... The URL of the profile you want to silence\r\n";
-       echo "\r\n";
-       echo "Example: Silence bob@example.com\r\n";
-       echo "$> ".$argv[0]." https://example.com/profiles/bob\r\n";
-       echo "\r\n";
-       exit(0);
-}
-
-use Friendica\Database\DBM;
-use Friendica\Network\Probe;
-
-require_once 'boot.php';
-require_once 'include/dba.php';
-require_once 'include/text.php';
-$a = get_app();
-require_once '.htconfig.php';
-
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
-
-/**
- * 1. make nurl from last parameter
- * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID
- * 3. set the flag hidden=1 for the contact entry with the found ID
- **/
-$net = Probe::uri($argv[1]);
-if (in_array($net['network'], [NETWORK_PHANTOM, NETWORK_MAIL])) {
-       echo "This account seems not to exist.";
-       echo "\r\n";
-       exit(1);
-}
-$nurl = normalise_link($net['url']);
-$contact = dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
-if (DBM::is_result($contact)) {
-       dba::update("contact", ["hidden" => true], ["id" => $contact["id"]]);
-       echo "NOTICE: The account should be silenced from the global community page\r\n";
-} else {
-       echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n";
-}
-
-?>
diff --git a/util/maintenance.php b/util/maintenance.php
deleted file mode 100644 (file)
index f0d7777..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * @file util/maintenance.php
- */
-
-use Friendica\App;
-use Friendica\BaseObject;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
-
-require_once 'boot.php';
-require_once 'include/dba.php';
-
-$a = new App(dirname(__DIR__));
-BaseObject::setApp($a);
-
-@include(".htconfig.php");
-
-$lang = L10n::getBrowserLanguage();
-L10n::loadTranslationTable($lang);
-
-dba::connect($db_host, $db_user, $db_pass, $db_data, false);
-unset($db_host, $db_user, $db_pass, $db_data);
-
-Config::load();
-
-$maint_mode = 1;
-if ($argc > 1) {
-       $maint_mode = intval($argv[1]);
-}
-
-Config::set('system', 'maintenance', $maint_mode);
-
-if ($maint_mode && ($argc > 2)) {
-       $reason_arr = $argv;
-       array_shift($reason_arr);
-       array_shift($reason_arr);
-
-       $reason = implode(' ', $reason_arr);
-       Config::set('system', 'maintenance_reason', $reason);
-} else {
-       Config::set('system', 'maintenance_reason', '');
-}
-
-if ($maint_mode) {
-       $mode_str = "maintenance mode";
-} else {
-       $mode_str = "normal mode";
-}
-
-echo "\n\tSystem set in $mode_str\n";
-
-if ($reason != '') {
-       echo "\tMaintenance reason: $reason\n\n";
-} else {
-       echo "\n";
-}
-
-echo "Usage:\n\n";
-echo "\tphp {$argv[0]} [1] [Maintenance reason|redirection url]\n";
-echo "\t\tSet the system in maintenance mode\n\n";
-echo "\t\tIf the optionally entered maintenance reason is an url\n";
-echo "\t\tthe visitor is redirected to that page.\n";
-echo "\n";
-echo "\t\tExamples:\n";
-echo "\t\t\tphp {$argv[0]} 1 System upgrade\n";
-echo "\t\t\tphp {$argv[0]} 1 http://domain.tld/downtime\n";
-echo "\n";
-echo "\tphp {$argv[0]} 0\n";
-echo "\t\tSet the system in normal mode\n\n";
diff --git a/util/php2po.php b/util/php2po.php
deleted file mode 100755 (executable)
index e28c91d..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-#!/usr/bin/env php
-<?php
-/**
- * Read strings.php file and create messages.po
- *
- * php utils/php2po.php <path/to/strings.php>
- *
- * Output to <path/to/messages.po>
- */
-
-DEFINE("NORM_REGEXP", "|[\\\]|");
-
-$a = new stdClass();
-
-if ($argc<2 || in_array('-h', $argv) || in_array('--h', $argv)) {
-       print "Usage: ".$argv[0]." [-p <n>] <strings.php>\n\n";
-       print "Options:\n";
-       print "p\tNumber of plural forms. Default: 2\n";
-       print "\n";
-       return;
-}
-
-$phpfile = $argv[1];
-$pofile = dirname($phpfile)."/messages.po";
-
-if (!file_exists($phpfile)){
-       print "Unable to find '$phpfile'\n";
-       return;
-}
-
-// utility functions
-function startsWith($haystack, $needle) {
-       // search backwards starting from haystack length characters from the end
-       return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
-}
-
-
-// start !
-include_once($phpfile);
-
-$out  = '';
-$out .= "# FRIENDICA Distributed Social Network\n";
-$out .= "# Copyright (C) 2010, 2011, 2012, 2013 the Friendica Project\n";
-$out .= "# This file is distributed under the same license as the Friendica package.\n";
-$out .= "# \n";
-$out .= 'msgid ""' ."\n";
-$out .= 'msgstr ""' ."\n";
-$out .= '"Project-Id-Version: friendica\n"' ."\n";
-$out .= '"Report-Msgid-Bugs-To: \n"' ."\n";
-$out .= '"POT-Creation-Date: '. date("Y-m-d H:i:sO").'\n"' ."\n";
-$out .= '"MIME-Version: 1.0\n"' ."\n";
-$out .= '"Content-Type: text/plain; charset=UTF-8\n"' ."\n";
-$out .= '"Content-Transfer-Encoding: 8bit\n"' ."\n";
-
-// search for plural info
-$lang = "";
-$lang_logic = "";
-$lang_pnum = 2;
-
-$_idx = array_search('-p', $argv);
-if ($_idx !== false) {
-       $lang_pnum = $argv[$_idx+1];
-}
-
-$infile = file($phpfile);
-foreach($infile as $l) {
-       $l = trim($l);
-       if  (startsWith($l, 'function string_plural_select_')) {
-               $lang = str_replace( 'function string_plural_select_' , '', str_replace( '($n){','', $l) );
-       }
-       if (startsWith($l, 'return')) {
-               $lang_logic = str_replace( '$', '', trim( str_replace( 'return ' , '',  $l) , ';') );
-               break;
-       }
-}
-
-echo "Language: $lang\n";
-echo "Plural forms: $lang_pnum\n";
-echo "Plural logic: $lang_logic;\n";
-
-$out .= sprintf('"Language: %s\n"', $lang) ."\n";
-$out .= sprintf('"Plural-Forms: nplurals=%s; plural=%s;\n"', $lang_pnum, $lang_logic)  ."\n";
-$out .= "\n";
-
-print "\nLoading base message.po...";
-
-// load base messages.po and extract msgids
-$base_msgids = [];
-$norm_base_msgids = [];
-$base_f = file("util/messages.po");
-if (!$base_f) {
-       die("No base messages.po\n");
-}
-
-$_f = 0;
-$_mid = "";
-$_mids = [];
-foreach( $base_f as $l) {
-       $l = trim($l);
-       //~ print $l."\n";
-
-       if (startsWith($l, 'msgstr')) {
-               if ($_mid != '""') {
-                       $base_msgids[$_mid] =  $_mids;
-                       $norm_base_msgids[preg_replace(NORM_REGEXP, "", $_mid)] = $_mid;
-                       //~ print "\t\t\t".$_mid. print_r($base_msgids[$_mid], true);
-               }
-
-               $_f = 0;
-               $_mid = "";
-               $_mids = [];
-
-       }
-
-       if (startsWith($l, '"') && $_f==2) {
-               $_mids[count($_mids)-1] .= "\n".$l;
-               //~ print "\t\t+mids: ".print_t($_mids, true);
-       }
-       if (startsWith($l, 'msgid_plural ')) {
-               $_f = 2;
-               $_mids[] = str_replace('msgid_plural ', '' , $l);
-               //~ print "\t\t mids: ".print_r($_mids, true);
-       }
-
-       if (startsWith($l, '"') && $_f==1) {
-               $_mid .= "\n".$l;
-               $_mids[count($_mids)-1] .= "\n".$l;
-               //~ print "\t+mid: $_mid \n";
-       }
-       if (startsWith($l, 'msgid ')) {
-               $_f = 1;
-               $_mid = str_replace('msgid ', '' , $l);
-                       $_mids = [$_mid];
-               //~ print "\t mid: $_mid \n";
-       }
-       //~ print "\t\t\t\t$_f\n\n";
-}
-
-print " done\n";
-print "Creating '$pofile'...";
-// create msgid and msgstr
-
-/**
- * Get a string and retun a message.po ready text
- * - replace " with \"
- * - replace tab char with \t
- * - manage multiline strings
- */
-function massage_string($str) {
-       $str = str_replace('\\','\\\\',$str);
-       $str = str_replace('"','\"',$str);
-       $str = str_replace("\t",'\t',$str);
-       $str = str_replace("\n",'\n"'."\n".'"',$str);
-       if (strpos($str, "\n")!==false  && $str[0]!=='"') $str = '"'."\n".$str;
-       $str = preg_replace("|\n([^\"])|", "\n\"$1", $str);
-       return sprintf('"%s"', $str);
-}
-
-function find_original_msgid($str) {
-       global $norm_base_msgids;
-       $norm_str = preg_replace(NORM_REGEXP, "", $str);
-       if (array_key_exists($norm_str, $norm_base_msgids)) {
-               return $norm_base_msgids[$norm_str];
-       }
-       return $str;
-}
-
-$warnings = "";
-foreach($a->strings as $key=>$str) {
-       $msgid = massage_string($key);
-
-       if (preg_match("|%[sd0-9](\$[sn])*|", $msgid)) {
-               $out .= "#, php-format\n";
-       }
-       $msgid = find_original_msgid($msgid);
-       $out .= 'msgid '. $msgid . "\n";
-
-       if (is_array($str)) {
-               if (array_key_exists($msgid, $base_msgids) && isset($base_msgids[$msgid][1]))  {
-                       $out .= 'msgid_plural '. $base_msgids[$msgid][1] . "\n";
-               } else {
-                       $out .= 'msgid_plural '. $msgid . "\n";
-                       $warnings .= "[W] No source plural form for msgid:\n". str_replace("\n","\n\t", $msgid) . "\n\n";
-               }
-               foreach ( $str as $n => $msgstr) {
-                       $out .= 'msgstr['.$n.'] '. massage_string($msgstr) . "\n";
-               }
-       } else {
-               $out .= 'msgstr '. massage_string($str) . "\n";
-       }
-
-       $out .= "\n";
-
-}
-
-file_put_contents($pofile, $out);
-
-print " done\n";
-
-if ($warnings=="") {
-       print "No warnings.\n";
-} else {
-       print $warnings;
-}
diff --git a/util/po2php.php b/util/po2php.php
deleted file mode 100755 (executable)
index 819f99b..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/env php
-<?php
-define("DQ_ESCAPE", "__DQ__");
-
-function po2php_run(&$argv, &$argc) {
-
-       if ($argc!=2) {
-               print "Usage: ".$argv[0]." <file.po>\n\n";
-               return;
-       }
-
-       $pofile = $argv[1];
-       $outfile = dirname($pofile)."/strings.php";
-
-       if (strstr($outfile, 'util')) {
-               $lang = 'en';
-       } else {
-               $lang = str_replace('-','_',basename(dirname($pofile)));
-       }
-
-       if (!file_exists($pofile)) {
-               print "Unable to find '$pofile'\n";
-               return;
-       }
-
-       print "Out to '$outfile'\n";
-
-       $out = "<?php\n\n";
-
-       $infile = file($pofile);
-       $k = "";
-       $v = "";
-       $arr = false;
-       $ink = false;
-       $inv = false;
-       $escape_s_exp = '|[^\\\\]\$[a-z]|';
-       function escape_s($match) {
-               return str_replace('$','\$',$match[0]);
-       }
-       foreach ($infile as $l) {
-               $l = str_replace('\"', DQ_ESCAPE, $l);
-               $len = strlen($l);
-               if ($l[0] == "#") {
-                       $l = "";
-               }
-               if (substr($l, 0, 15) == '"Plural-Forms: ') {
-                       $match = [];
-                       preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match);
-                       $cond = str_replace('n', '$n', $match[2]);
-                       // define plural select function if not already defined
-                       $fnname = 'string_plural_select_' . $lang;
-                       $out .= 'if(! function_exists("' . $fnname . '")) {' . "\n";
-                       $out .= 'function '. $fnname . '($n){' . "\n";
-                       $out .= '       return ' . $cond . ';' . "\n";
-                       $out .= '}}' . "\n";
-               }
-
-               if ($k != "" && substr($l, 0, 7) == "msgstr ") {
-                       if ($ink) {
-                               $ink = false;
-                               $out .= '$a->strings["' . $k . '"] = ';
-                       }
-                       if ($inv) {
-                               $inv = false;
-                               $out .= '"' . $v . '"';
-                       }
-
-                       $v = substr($l, 8, $len - 10);
-                       $v = preg_replace_callback($escape_s_exp, 'escape_s', $v);
-                       $inv = true;
-                       //$out .= $v;
-               }
-               if ($k != "" && substr($l, 0, 7) == "msgstr[") {
-                       if ($ink) {
-                               $ink = false;
-                               $out .= '$a->strings["' . $k . '"] = ';
-                       }
-                       if ($inv) {
-                               $inv = false;
-                               $out .= '"' . $v . '"';
-                       }
-
-                       if (!$arr) {
-                               $arr=True;
-                               $out .= "[\n";
-                       }
-                       $match = [];
-                       preg_match("|\[([0-9]*)\] (.*)|", $l, $match);
-                       $out .= "\t"
-                               . preg_replace_callback($escape_s_exp, 'escape_s', $match[1])
-                               . " => "
-                               . preg_replace_callback($escape_s_exp, 'escape_s', $match[2])
-                               . ",\n";
-               }
-
-               if (substr($l, 0, 6) == "msgid_") {
-                       $ink = false;
-                       $out .= '$a->strings["' . $k . '"] = ';
-               }
-
-               if ($ink) {
-                       $k .= trim($l, "\"\r\n");
-                       $k = preg_replace_callback($escape_s_exp, 'escape_s', $k);
-                       //$out .= '$a->strings['.$k.'] = ';
-               }
-
-               if (substr($l, 0, 6) == "msgid ") {
-                       if ($inv) {
-                               $inv = false;
-                               $out .= '"' . $v . '"';
-                       }
-                       if ($k != "") {
-                               $out .= ($arr) ? "];\n" : ";\n";
-                       }
-                       $arr = false;
-                       $k = str_replace("msgid ", "", $l);
-                       if ($k != '""') {
-                               $k = trim($k, "\"\r\n");
-                       } else {
-                               $k = "";
-                       }
-
-                       $k = preg_replace_callback($escape_s_exp, 'escape_s', $k);
-                       $ink = true;
-               }
-
-               if ($inv && substr($l, 0, 6) != "msgstr") {
-                       $v .= trim($l, "\"\r\n");
-                       $v = preg_replace_callback($escape_s_exp, 'escape_s', $v);
-                       //$out .= '$a->strings['.$k.'] = ';
-               }
-
-
-       }
-
-       if ($inv) {
-               $inv = false;
-               $out .= '"' . $v . '"';
-       }
-       if ($k != "") {
-               $out .= ($arr ? "];\n" : ";\n");
-       }
-
-       $out = str_replace(DQ_ESCAPE, '\"', $out);
-       file_put_contents($outfile, $out);
-
-}
-
-if (array_search(__FILE__, get_included_files()) === 0) {
-       po2php_run($_SERVER["argv"],$_SERVER["argc"]);
-}
diff --git a/util/typo.php b/util/typo.php
deleted file mode 100755 (executable)
index fba761e..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-// Tired of chasing typos and finding them after a commit.
-// Run this from cmdline in basedir and quickly see if we've
-// got any parse errors in our application files.
-
-
-use Friendica\App;
-use Friendica\BaseObject;
-
-error_reporting(E_ERROR | E_WARNING | E_PARSE);
-ini_set('display_errors', '1');
-ini_set('log_errors', '0');
-
-include 'boot.php';
-
-$a = new App(dirname(__DIR__));
-BaseObject::setApp($a);
-
-@include '.htconfig.php';
-
-$phpath = $a->getConfigValue('config', 'php_path', 'php');
-
-echo 'Directory: src' . PHP_EOL;
-$Iterator = new RecursiveDirectoryIterator('src');
-
-foreach (new RecursiveIteratorIterator($Iterator) as $file) {
-       if (substr($file, -4) === '.php') {
-               passthru("$phpath -l $file", $ret);
-               $ret === 0 || die();
-       }
-}
-
-echo "Directory: mod\n";
-$files = glob('mod/*.php');
-foreach ($files as $file) {
-       passthru("$phpath -l $file", $ret);
-       $ret === 0 || die();
-}
-
-echo "Directory: include\n";
-$files = glob('include/*.php');
-foreach ($files as $file) {
-       passthru("$phpath -l $file", $ret);
-       $ret === 0 || die();
-}
-
-echo "Directory: object\n";
-$files = glob('object/*.php');
-foreach ($files as $file) {
-       passthru("$phpath -l $file", $ret);
-       $ret === 0 || die();
-}
-
-echo "Directory: addon\n";
-$dirs = glob('addon/*');
-
-foreach ($dirs as $dir) {
-       $addon = basename($dir);
-       $files = glob($dir . '/' . $addon . '.php');
-       foreach ($files as $file) {
-               passthru("$phpath -l $file", $ret);
-               $ret === 0 || die();
-       }
-}
-
-echo "String files\n";
-
-echo 'util/strings.php' . "\n";
-passthru("$phpath -l util/strings.php", $ret);
-$ret === 0 || die();
-
-$files = glob('view/lang/*/strings.php');
-foreach ($files as $file) {
-       passthru("$phpath -l $file", $ret);
-       $ret === 0 || die();
-}