From ad91ef66bd895227de7ae5fc16611f3cdd961045 Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Wed, 18 Sep 2019 17:15:00 +0300 Subject: [PATCH] [SCRIPTS] Set PUBLICDIR in plugin scripts as well --- .../scripts/update_activitypub_profiles.php | 3 +- .../ActivitySpam/scripts/silencespammer.php | 4 +- plugins/ActivitySpam/scripts/testuser.php | 50 +++--- plugins/ActivitySpam/scripts/trainuser.php | 43 ++--- .../scripts/initialize_fave_tallys.php | 38 +++-- plugins/Bookmark/scripts/importbookmarks.php | 51 +++--- .../scripts/installforemail.php | 42 ++--- .../scripts/proposesite.php | 40 ++--- .../scripts/sitefordomain.php | 40 ++--- .../scripts/cancelemailregistration.php | 38 +++-- .../scripts/registeremailuser.php | 38 +++-- .../scripts/sendemailreminder.php | 84 ++++++---- .../EmailSummary/scripts/sendemailsummary.php | 39 +++-- plugins/Embed/scripts/fixup_files.php | 7 +- plugins/Embed/scripts/poll_embed.php | 5 +- plugins/FeedPoller/scripts/pollfeed.php | 38 +++-- plugins/Nodeinfo/scripts/fix_stats.php | 3 +- plugins/OStatus/scripts/fixup-shadow.php | 40 ++--- plugins/OStatus/scripts/gcfeeds.php | 42 ++--- plugins/OStatus/scripts/renew-feeds.php | 38 +++-- plugins/OStatus/scripts/resub-feed.php | 38 +++-- plugins/OStatus/scripts/rm_bad_feedsubs.php | 4 +- plugins/OStatus/scripts/testfeed.php | 38 +++-- .../OStatus/scripts/update-profile-data.php | 3 +- plugins/OStatus/scripts/update-profile.php | 40 ++--- .../scripts/update_ostatus_profiles.php | 84 ++++++---- plugins/Realtime/scripts/cleanupchannels.php | 5 +- .../scripts/registerbyemail.php | 50 +++--- plugins/Sitemap/scripts/updatecounts.php | 38 +++-- plugins/SphinxSearch/scripts/gen_config.php | 64 +++++--- plugins/SphinxSearch/scripts/index_update.php | 38 +++-- .../scripts/removeRemoteMedia.php | 43 +++-- plugins/TwitterBridge/scripts/fakestream.php | 57 +++---- .../scripts/initialize_notice_to_status.php | 5 +- plugins/TwitterBridge/scripts/streamtest.php | 149 ++++++++++-------- 35 files changed, 743 insertions(+), 596 deletions(-) diff --git a/plugins/ActivityPub/scripts/update_activitypub_profiles.php b/plugins/ActivityPub/scripts/update_activitypub_profiles.php index fdaf9f8e7d..47bbb1f588 100755 --- a/plugins/ActivityPub/scripts/update_activitypub_profiles.php +++ b/plugins/ActivityPub/scripts/update_activitypub_profiles.php @@ -25,7 +25,8 @@ * @link http://www.gnu.org/software/social/ */ -define('INSTALLDIR', realpath(__DIR__ . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'u:af'; $longoptions = ['uri=', 'all', 'force']; diff --git a/plugins/ActivitySpam/scripts/silencespammer.php b/plugins/ActivitySpam/scripts/silencespammer.php index d63995d9bb..18775c7696 100644 --- a/plugins/ActivitySpam/scripts/silencespammer.php +++ b/plugins/ActivitySpam/scripts/silencespammer.php @@ -1,3 +1,4 @@ +#!/usr/bin/env php . + +/** + * Description of this file. * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . + * @package GNUsocial + * @copyright 2012 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'i:n:a'; $longoptions = array('id=', 'nickname=', 'all'); @@ -31,15 +38,15 @@ Test user activities against the spam filter -a --all All users END_OF_TESTUSER_HELP; -require_once INSTALLDIR.'/scripts/commandline.inc'; +require_once INSTALLDIR . '/scripts/commandline.inc'; -function testAllUsers($filter) { +function testAllUsers($filter) +{ $found = false; $offset = 0; $limit = 1000; do { - $user = new User(); $user->orderBy('created'); $user->limit($offset, $limit); @@ -56,12 +63,11 @@ function testAllUsers($filter) { } $offset += $found; } - } while ($found > 0); } -function testUser($filter, $user) { - +function testUser($filter, $user) +{ printfnq("Testing user %s\n", $user->nickname); $profile = Profile::getKV('id', $user->id); diff --git a/plugins/ActivitySpam/scripts/trainuser.php b/plugins/ActivitySpam/scripts/trainuser.php index 974048b4c9..18a06b6f44 100644 --- a/plugins/ActivitySpam/scripts/trainuser.php +++ b/plugins/ActivitySpam/scripts/trainuser.php @@ -1,23 +1,28 @@ +#!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2012 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'i:n:t:'; $longoptions = array('id=', 'nickname=', 'category='); @@ -34,8 +39,8 @@ END_OF_TRAINUSER_HELP; require_once INSTALLDIR.'/scripts/commandline.inc'; -function trainUser($filter, $user, $category) { - +function trainUser($filter, $user, $category) +{ printfnq("Training user %s\n", $user->nickname); $profile = Profile::getKV('id', $user->id); diff --git a/plugins/AnonymousFave/scripts/initialize_fave_tallys.php b/plugins/AnonymousFave/scripts/initialize_fave_tallys.php index a955620db5..2b91651f9c 100755 --- a/plugins/AnonymousFave/scripts/initialize_fave_tallys.php +++ b/plugins/AnonymousFave/scripts/initialize_fave_tallys.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $helptext = <<. + /** - * StatusNet - the distributed open-source microblogging tool - * Copyright (C) 2010 StatusNet, Inc. - * - * Import a bookmarks file as notices - * - * PHP version 5 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * * @category Bookmark - * @package StatusNet + * @package GNUsocial * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 - * @link http://status.net/ + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'i:n:f:'; $longoptions = array('id=', 'nickname=', 'file='); @@ -65,19 +61,19 @@ function getBookmarksFile() if (!file_exists($filename)) { // TRANS: Exception thrown when a file upload cannot be found. // TRANS: %s is the file that could not be found. - throw new Exception(sprintf(_m('No such file "%s".'),$filename)); + throw new Exception(sprintf(_m('No such file "%s".'), $filename)); } if (!is_file($filename)) { // TRANS: Exception thrown when a file upload is incorrect. // TRANS: %s is the irregular file. - throw new Exception(sprintf(_m('Not a regular file: "%s".'),$filename)); + throw new Exception(sprintf(_m('Not a regular file: "%s".'), $filename)); } if (!is_readable($filename)) { // TRANS: Exception thrown when a file upload is not readable. // TRANS: %s is the file that could not be read. - throw new Exception(sprintf(_m('File "%s" not readable.'),$filename)); + throw new Exception(sprintf(_m('File "%s" not readable.'), $filename)); } // TRANS: %s is the filename that contains a backup for a user. @@ -95,7 +91,6 @@ try { $qm = QueueManager::get(); $qm->enqueue(array($user, $html), 'dlcsback'); - } catch (Exception $e) { print $e->getMessage()."\n"; exit(1); diff --git a/plugins/DomainStatusNetwork/scripts/installforemail.php b/plugins/DomainStatusNetwork/scripts/installforemail.php index f773094a74..2e336606ab 100755 --- a/plugins/DomainStatusNetwork/scripts/installforemail.php +++ b/plugins/DomainStatusNetwork/scripts/installforemail.php @@ -1,26 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2011 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'wt::'; $longoptions = array('welcome', 'template='); @@ -46,7 +48,6 @@ if ($sendWelcome && have_option('t', 'template')) { } try { - $confirm = DomainStatusNetworkPlugin::registerEmail($email); if ($sendWelcome) { @@ -56,7 +57,6 @@ try { $confirmUrl = common_local_url('register', array('code' => $confirm->code)); print $confirmUrl."\n"; - } catch (Exception $e) { print "ERROR: " . $e->getMessage() . "\n"; } diff --git a/plugins/DomainStatusNetwork/scripts/proposesite.php b/plugins/DomainStatusNetwork/scripts/proposesite.php index 96a722fdab..772ab1785a 100755 --- a/plugins/DomainStatusNetwork/scripts/proposesite.php +++ b/plugins/DomainStatusNetwork/scripts/proposesite.php @@ -1,26 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2011 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $helptext = << diff --git a/plugins/DomainStatusNetwork/scripts/sitefordomain.php b/plugins/DomainStatusNetwork/scripts/sitefordomain.php index 59412cceba..b73c75a819 100755 --- a/plugins/DomainStatusNetwork/scripts/sitefordomain.php +++ b/plugins/DomainStatusNetwork/scripts/sitefordomain.php @@ -1,26 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2011 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $helptext = << diff --git a/plugins/EmailRegistration/scripts/cancelemailregistration.php b/plugins/EmailRegistration/scripts/cancelemailregistration.php index b926ed9a62..90c70ab497 100755 --- a/plugins/EmailRegistration/scripts/cancelemailregistration.php +++ b/plugins/EmailRegistration/scripts/cancelemailregistration.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2011 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'd'; $longoptions = array('dryrun'); diff --git a/plugins/EmailRegistration/scripts/registeremailuser.php b/plugins/EmailRegistration/scripts/registeremailuser.php index 02915240d3..7545710123 100755 --- a/plugins/EmailRegistration/scripts/registeremailuser.php +++ b/plugins/EmailRegistration/scripts/registeremailuser.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2011 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'wt::'; $longoptions = array('welcome', 'template='); diff --git a/plugins/EmailReminder/scripts/sendemailreminder.php b/plugins/EmailReminder/scripts/sendemailreminder.php index 5b5b26dde3..b0a94c5bc9 100755 --- a/plugins/EmailReminder/scripts/sendemailreminder.php +++ b/plugins/EmailReminder/scripts/sendemailreminder.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . -*/ +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +/** + * @package GNUsocial + * @copyright 2011 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ + +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 't:e:auo'; $longoptions = array('type=', 'email=', 'all', 'universe', 'onetime'); @@ -61,22 +65,24 @@ $opts = array(); // special options like "onetime" if (have_option('t', 'type')) { $type = trim(get_option_value('t', 'type')); if (!in_array($type, array_keys($types)) && $type !== 'all') { - print _m("Unknown reminder type: {$type}.\n"); - exit(1); + echo _m('Unknown reminder type: ' . $type . '.' . "\n"); + exit(1); } } else { - show_help(); - exit(1); + show_help(); + exit(1); } if (have_option('o', 'onetime')) { $opts['onetime'] = true; - if (!$quiet) { print "Special one-time reminder mode.\n"; } + if (!$quiet) { + echo 'Special one-time reminder mode.' . "\n"; + } } $reminders = array(); -switch($type) { +switch ($type) { case 'register': $reminders[] = $types['register']; break; @@ -101,19 +107,27 @@ if (have_option('u', 'universe')) { foreach ($reminders as $reminder) { extract($reminder); $qm->enqueue(array($type, $opts), 'siterem'); - if (!$quiet) { print "Sent pending {$type} reminders for {$server}.\n"; } + if (!$quiet) { + echo 'Sent pending ' . $type . ' reminders for ' . $server . '.' . "\n"; + } } } catch (Exception $e) { // keep going common_log(LOG_ERR, "Couldn't init {$server}.\n", __FILE__); - if (!$quiet) { print "Couldn't init {$server}.\n"; } + if (!$quiet) { + echo "Couldn't init " . $server . ".\n"; + } continue; } } - if (!$quiet) { print "Done! Reminders sent to all unconfirmed addresses in the known universe.\n"; } + if (!$quiet) { + echo 'Done! Reminders sent to all unconfirmed addresses in the known universe.' . "\n"; + } } } catch (Exception $e) { - if (!$quiet) { print $e->getMessage() . "\n"; } + if (!$quiet) { + echo $e->getMessage() . "\n"; + } common_log(LOG_ERR, $e->getMessage(), __FILE__); exit(1); } @@ -133,20 +147,26 @@ if (have_option('u', 'universe')) { throw new Exception("No confirmation code found for {$address}."); } $qm->enqueue(array($confirm, $opts), $utransport); - if (!$quiet) { print "Sent all pending {$type} reminder to {$address}.\n"; } + if (!$quiet) { + echo 'Sent all pending ' . $type . ' reminder to ' . $address . '.' . "\n"; + } } - } else if (have_option('a', 'all')) { + } elseif (have_option('a', 'all')) { foreach ($reminders as $reminder) { extract($reminder); $qm->enqueue(array($type, $opts), 'siterem'); - if (!$quiet) { print "Sent pending {$type} reminders to all unconfirmed addresses on the site.\n"; } + if (!$quiet) { + echo 'Sent pending ' . $type . ' reminders to all unconfirmed addresses on the site.' . "\n"; + } } } else { show_help(); exit(1); } } catch (Exception $e) { - if (!$quiet) { print $e->getMessage() . "\n"; } + if (!$quiet) { + echo $e->getMessage() . "\n"; + } common_log(LOG_ERR, $e->getMessage(), __FILE__); exit(1); } diff --git a/plugins/EmailSummary/scripts/sendemailsummary.php b/plugins/EmailSummary/scripts/sendemailsummary.php index 721fede55b..b0ce5d18bd 100644 --- a/plugins/EmailSummary/scripts/sendemailsummary.php +++ b/plugins/EmailSummary/scripts/sendemailsummary.php @@ -1,23 +1,28 @@ +#!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'i:n:au'; $longoptions = array('id=', 'nickname=', 'all', 'universe'); diff --git a/plugins/Embed/scripts/fixup_files.php b/plugins/Embed/scripts/fixup_files.php index eca3902c64..1a4d1ed3dc 100755 --- a/plugins/Embed/scripts/fixup_files.php +++ b/plugins/Embed/scripts/fixup_files.php @@ -25,9 +25,8 @@ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -defined('GNUSOCIAL'); - -define('INSTALLDIR', realpath(__DIR__ . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $longoptions = ['dry-run', 'h-bug', 'broken-oembed', 'limit=']; @@ -129,7 +128,6 @@ while ($fn->fetch()) { echo " (ok, but embedding lookup failed)\n"; } } - } elseif ($broken && (!$data instanceof File_embed || empty($data->title) || @@ -165,7 +163,6 @@ while ($fn->fetch()) { $thumb->decache(); } } - } if (isset($fetch) && $fetch === true && !$dry) { diff --git a/plugins/Embed/scripts/poll_embed.php b/plugins/Embed/scripts/poll_embed.php index 2eb314bc74..6eb7f923a3 100755 --- a/plugins/Embed/scripts/poll_embed.php +++ b/plugins/Embed/scripts/poll_embed.php @@ -25,9 +25,8 @@ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -defined('GNUSOCIAL') || die(); - -define('INSTALLDIR', realpath(__DIR__ . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'u:'; $longoptions = array('url='); diff --git a/plugins/FeedPoller/scripts/pollfeed.php b/plugins/FeedPoller/scripts/pollfeed.php index 58918495bf..51979ac747 100755 --- a/plugins/FeedPoller/scripts/pollfeed.php +++ b/plugins/FeedPoller/scripts/pollfeed.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $helptext = <<. +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $longoptions = array('dry-run'); @@ -162,7 +166,7 @@ while ($oprofile->fetch()) { $nick = ''; } echo "group $id ($nick) hidden by $uri"; - } else if (preg_match('!/user/(\d+)!', $uri, $matches)) { + } elseif (preg_match('!/user/(\d+)!', $uri, $matches)) { $id = intval($matches[1]); $user = User::getKV('id', $id); if ($user) { diff --git a/plugins/OStatus/scripts/gcfeeds.php b/plugins/OStatus/scripts/gcfeeds.php index a95cd54dbc..f9095e407d 100755 --- a/plugins/OStatus/scripts/gcfeeds.php +++ b/plugins/OStatus/scripts/gcfeeds.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $longoptions = array('delete-inactive'); $shortoptions = 'd'; @@ -65,4 +69,6 @@ while ($feedsub->fetch()) { } } -if ($delete_inactive) echo "\nDeleted $delcount inactive feeds.\n"; +if ($delete_inactive) { + echo "\nDeleted $delcount inactive feeds.\n"; +} diff --git a/plugins/OStatus/scripts/renew-feeds.php b/plugins/OStatus/scripts/renew-feeds.php index d63f448827..53f230587c 100755 --- a/plugins/OStatus/scripts/renew-feeds.php +++ b/plugins/OStatus/scripts/renew-feeds.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $helptext = <<. +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $longoptions = array('unsub'); $shortoptions = 'u'; diff --git a/plugins/OStatus/scripts/rm_bad_feedsubs.php b/plugins/OStatus/scripts/rm_bad_feedsubs.php index 81d6eb1bda..c4a3a4dc3a 100755 --- a/plugins/OStatus/scripts/rm_bad_feedsubs.php +++ b/plugins/OStatus/scripts/rm_bad_feedsubs.php @@ -24,8 +24,8 @@ * Run this from INSTALLDIR/plugins/OStatus/scripts */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); - +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'd'; $longoptions = array('dry-run'); diff --git a/plugins/OStatus/scripts/testfeed.php b/plugins/OStatus/scripts/testfeed.php index 52b9765b6c..6dc89edaff 100755 --- a/plugins/OStatus/scripts/testfeed.php +++ b/plugins/OStatus/scripts/testfeed.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $longoptions = array('skip=', 'count='); diff --git a/plugins/OStatus/scripts/update-profile-data.php b/plugins/OStatus/scripts/update-profile-data.php index a6454bca7d..3c27e0c109 100755 --- a/plugins/OStatus/scripts/update-profile-data.php +++ b/plugins/OStatus/scripts/update-profile-data.php @@ -20,7 +20,8 @@ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $longoptions = array('all', 'suspicious', 'quiet'); diff --git a/plugins/OStatus/scripts/update-profile.php b/plugins/OStatus/scripts/update-profile.php index e7e4e2388d..c67b5a2871 100755 --- a/plugins/OStatus/scripts/update-profile.php +++ b/plugins/OStatus/scripts/update-profile.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $helptext = <<discoverFromURL($oprofile->uri); $salmonuri = $discover->getAtomLink(Salmon::REL_SALMON) ?: $discover->getAtomLink(Salmon::NS_REPLIES); // NS_REPLIES is deprecated - if (empty($salmonuri) ) { + if (empty($salmonuri)) { throw new FeedSubNoSalmonException('No salmon upstream URI was found'); } } catch (FeedSubException $e) { diff --git a/plugins/OStatus/scripts/update_ostatus_profiles.php b/plugins/OStatus/scripts/update_ostatus_profiles.php index 45ee856264..3d048c5c8c 100755 --- a/plugins/OStatus/scripts/update_ostatus_profiles.php +++ b/plugins/OStatus/scripts/update_ostatus_profiles.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2011 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'u:af'; $longoptions = array('uri=', 'all', 'force'); @@ -69,7 +73,7 @@ class LooseOstatusProfile extends Ostatus_profile if (!$response->isOk()) { // TRANS: Exception. %s is a profile URL. - throw new Exception(sprintf(_('Could not reach profile page %s.'),$profile_url)); + throw new Exception(sprintf(_('Could not reach profile page %s.'), $profile_url)); } // Check if we have a non-canonical URL @@ -120,7 +124,7 @@ class LooseOstatusProfile extends Ostatus_profile } // TRANS: Exception. %s is a URL. - throw new Exception(sprintf(_m('Could not find a feed URL for profile page %s.'),$finalUrl)); + throw new Exception(sprintf(_m('Could not find a feed URL for profile page %s.'), $finalUrl)); } /** @@ -200,25 +204,25 @@ class LooseOstatusProfile extends Ostatus_profile // will obscure the correct page-keyed profile later on. } } - throw new Exception(sprintf(_m('Could not find a valid profile for "%s".'),$addr)); + throw new Exception(sprintf(_m('Could not find a valid profile for "%s".'), $addr)); } } -function pullOstatusProfile($uri) { - +function pullOstatusProfile($uri) +{ $oprofile = null; $validate = new Validate(); if ($validate->email($uri)) { $oprofile = LooseOstatusProfile::updateWebfinger($uri); - } else if ($validate->uri($uri)) { + } elseif ($validate->uri($uri)) { $oprofile = LooseOstatusProfile::updateProfileURL($uri); } else { print "Sorry, we could not reach the address: $uri\n"; return false; } - return $oprofile; + return $oprofile; } $quiet = have_option('q', 'quiet'); @@ -227,7 +231,7 @@ $lop = new LooseOstatusProfile(); if (have_option('u', 'uri')) { $lop->uri = get_option_value('u', 'uri'); -} else if (!have_option('a', 'all')) { +} elseif (!have_option('a', 'all')) { show_help(); exit(1); } @@ -237,18 +241,26 @@ $forceUpdates = have_option('f', 'force'); $cnt = $lop->find(); if (!empty($cnt)) { - if (!$quiet) { echo "Found {$cnt} OStatus profiles:\n"; } + if (!$quiet) { + echo 'Found ' . $cnt . ' OStatus profiles:' . "\n"; + } } else { if (have_option('u', 'uri')) { - if (!$quiet) { echo "Couldn't find an existing OStatus profile with that URI.\n"; } + if (!$quiet) { + echo "Couldn't find an existing OStatus profile with that URI.\n"; + } } else { - if (!$quiet) { echo "Couldn't find any existing OStatus profiles.\n"; } + if (!$quiet) { + echo "Couldn't find any existing OStatus profiles.\n"; + } } exit(0); } -while($lop->fetch()) { - if (!$quiet) { echo "Updating OStatus profile '{$lop->uri}' ... "; } +while ($lop->fetch()) { + if (!$quiet) { + echo "Updating OStatus profile '" . $lop->uri . "' ... "; + } try { $oprofile = pullOstatusProfile($lop->uri); @@ -257,13 +269,19 @@ while($lop->fetch()) { $lop->avatar = $oprofile->avatar; $lop->update($orig); $lop->updateAvatar($oprofile->avatar, $forceUpdates); - if (!$quiet) { print "Done.\n"; } + if (!$quiet) { + echo 'Done.' . "\n"; + } } } catch (Exception $e) { - if (!$quiet) { print $e->getMessage() . "\n"; } + if (!$quiet) { + echo $e->getMessage() . "\n"; + } common_log(LOG_WARNING, $e->getMessage(), __FILE__); // continue on error } } -if (!$quiet) { echo "OK.\n"; } +if (!$quiet) { + echo 'OK.' . "\n"; +} diff --git a/plugins/Realtime/scripts/cleanupchannels.php b/plugins/Realtime/scripts/cleanupchannels.php index 31ed304d4a..3cdc4aed7d 100755 --- a/plugins/Realtime/scripts/cleanupchannels.php +++ b/plugins/Realtime/scripts/cleanupchannels.php @@ -20,11 +20,12 @@ * * @package Realtime * @author Mikael Nordfeldth - * @copyright 2011, StatusNet, Inc. + * @copyright 2011 StatusNet, Inc. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(__DIR__ . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'u'; $longoptions = array('universe'); diff --git a/plugins/RequireValidatedEmail/scripts/registerbyemail.php b/plugins/RequireValidatedEmail/scripts/registerbyemail.php index c7b4a2af9e..bf0f8ddcc6 100755 --- a/plugins/RequireValidatedEmail/scripts/registerbyemail.php +++ b/plugins/RequireValidatedEmail/scripts/registerbyemail.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2009 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = "e:"; @@ -46,8 +50,10 @@ if (!empty($user)) { $confirm->address_type = 'email'; if ($confirm->find(true)) { - $url = common_local_url('confirmfirstemail', - array('code' => $confirm->code)); + $url = common_local_url( + 'confirmfirstemail', + ['code' => $confirm->code] + ); print "$url\n"; } else { @@ -68,8 +74,10 @@ $confirm->address_type = 'email'; $confirm->insert(); -$url = common_local_url('confirmfirstemail', - array('code' => $confirm->code)); +$url = common_local_url( + 'confirmfirstemail', + ['code' => $confirm->code] +); print "$url\n"; diff --git a/plugins/Sitemap/scripts/updatecounts.php b/plugins/Sitemap/scripts/updatecounts.php index 91bc0ac4e9..cf16be5c54 100755 --- a/plugins/Sitemap/scripts/updatecounts.php +++ b/plugins/Sitemap/scripts/updatecounts.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2010 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $helptext = <<. +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2009 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $longoptions = array('base=', 'network'); @@ -76,15 +80,29 @@ END; */ function sphinx_site_template($sn) { + if (common_config('db', 'type') !== 'mysql') { + $created_ts = sprintf( + '((EXTRACT(DAY %1$s) * 24 + EXTRACT(HOUR %1$s)) * 60 + ' . + 'EXTRACT(MINUTE %1$s)) * 60 + FLOOR(EXTRACT(SECOND %1$s)) AS "created_ts"', + 'FROM ("created" - TIMESTAMP \'1970-01-01 00:00:00\')' + ); + } else { + $created_ts = "timestampdiff(SECOND, '1970-01-01', `created`) AS `created_ts`"; + } + return - sphinx_template($sn, + sphinx_template( + $sn, 'profile', - 'SELECT id, UNIX_TIMESTAMP(created) as created_ts, nickname, fullname, location, bio, homepage FROM profile', - 'SELECT * FROM profile where id = $id') . - sphinx_template($sn, + 'SELECT id, ' . $created_ts . ', nickname, fullname, location, bio, homepage FROM profile', + 'SELECT * FROM profile WHERE id = $id' + ) . + sphinx_template( + $sn, 'notice', - 'SELECT id, UNIX_TIMESTAMP(created) as created_ts, content FROM notice', - 'SELECT * FROM notice where notice.id = $id AND notice.is_local != -2'); + 'SELECT id, ' . $created_ts . ', content FROM notice', + 'SELECT * FROM notice WHERE notice.id = $id AND notice.is_local <> -2' + ); } function sphinx_template($sn, $table, $query, $query_info) diff --git a/plugins/SphinxSearch/scripts/index_update.php b/plugins/SphinxSearch/scripts/index_update.php index abac5434f7..bcf8e56c7b 100755 --- a/plugins/SphinxSearch/scripts/index_update.php +++ b/plugins/SphinxSearch/scripts/index_update.php @@ -1,24 +1,28 @@ #!/usr/bin/env php . +// This file is part of GNU social - https://www.gnu.org/software/social +// +// GNU social is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// GNU social is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with GNU social. If not, see . + +/** + * @package GNUsocial + * @copyright 2009 StatusNet, Inc. + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $longoptions = array('base=', 'network'); diff --git a/plugins/StoreRemoteMedia/scripts/removeRemoteMedia.php b/plugins/StoreRemoteMedia/scripts/removeRemoteMedia.php index 5a4bfce5d5..4e7a0999d5 100755 --- a/plugins/StoreRemoteMedia/scripts/removeRemoteMedia.php +++ b/plugins/StoreRemoteMedia/scripts/removeRemoteMedia.php @@ -1,33 +1,32 @@ #!/usr/bin/env php . + /** - * GNU social - a federating social network - * - * GNU Social - StoreRemoteMediaPlugin - * - * LICENCE: This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . + * StoreRemoteMediaPlugin * * @category Plugin * @package GNUsocial - * @copyright 2018 Free Software Foundation http://fsf.org - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link https://www.gnu.org/software/social/ + * @author Diogo Cordeiro + * @copyright 2018 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -// Script author: Diogo Cordeiro - -define('INSTALLDIR', realpath(__DIR__ . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'l::a::i'; $longoptions = ['limit=', 'all', 'image']; diff --git a/plugins/TwitterBridge/scripts/fakestream.php b/plugins/TwitterBridge/scripts/fakestream.php index 5d965e7394..07a0adda5c 100644 --- a/plugins/TwitterBridge/scripts/fakestream.php +++ b/plugins/TwitterBridge/scripts/fakestream.php @@ -1,31 +1,30 @@ +#!/usr/bin/env php . + /** - * StatusNet, the distributed open-source microblogging tool - * - * PHP version 5 - * - * LICENCE: This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * * @category Plugin - * @package StatusNet + * @package GNUsocial * @author Brion Vibber * @copyright 2010 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'n:'; $longoptions = array('nick=','import','all'); @@ -46,9 +45,9 @@ require_once INSTALLDIR.'/scripts/commandline.inc'; if (have_option('n')) { $nickname = get_option_value('n'); -} else if (have_option('nick')) { +} elseif (have_option('nick')) { $nickname = get_option_value('nickname'); -} else if (have_option('all')) { +} elseif (have_option('all')) { $nickname = null; } else { show_help($helptext); @@ -57,7 +56,7 @@ if (have_option('n')) { /** * - * @param User $user + * @param User $user * @return TwitterOAuthClient */ function twitterAuthForUser(User $user) @@ -115,8 +114,10 @@ foreach ($users as $id) { throw new Exception("No user for id $id"); } $auth = twitterAuthForUser($user); - $flink = Foreign_link::getByUserID($user->id, - TWITTER_SERVICE); + $flink = Foreign_link::getByUserID( + $user->id, + TWITTER_SERVICE + ); $friends->friends = $auth->friendsIds(); dumpMessage($flink, $friends); @@ -127,10 +128,10 @@ foreach ($users as $id) { } } -usort($output, function($a, $b) { +usort($output, function ($a, $b) { if ($a->message->id < $b->message->id) { return -1; - } else if ($a->message->id == $b->message->id) { + } elseif ($a->message->id == $b->message->id) { return 0; } else { return 1; diff --git a/plugins/TwitterBridge/scripts/initialize_notice_to_status.php b/plugins/TwitterBridge/scripts/initialize_notice_to_status.php index 14e56a1191..71496426ed 100755 --- a/plugins/TwitterBridge/scripts/initialize_notice_to_status.php +++ b/plugins/TwitterBridge/scripts/initialize_notice_to_status.php @@ -18,11 +18,12 @@ /** * @package TwitterBridge * @author Evan Prodromou - * @copyright 2010, StatusNet, Inc. + * @copyright 2010 StatusNet, Inc. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $helptext = <<. + /** - * StatusNet, the distributed open-source microblogging tool - * - * PHP version 5 - * - * LICENCE: This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * * @category Plugin - * @package StatusNet + * @package GNUsocial * @author Brion Vibber * @copyright 2010 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +define('INSTALLDIR', dirname(__DIR__, 3)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'n:'; $longoptions = array('nick=','import','all','apiroot='); @@ -43,13 +42,13 @@ data as it comes. ENDOFHELP; -require_once INSTALLDIR.'/scripts/commandline.inc'; +require_once INSTALLDIR . '/scripts/commandline.inc'; require_once dirname(dirname(__FILE__)) . '/lib/jsonstreamreader.php'; require_once dirname(dirname(__FILE__)) . '/lib/twitterstreamreader.php'; if (have_option('n')) { $nickname = get_option_value('n'); -} else if (have_option('nick')) { +} elseif (have_option('nick')) { $nickname = get_option_value('nickname'); } else { show_help($helptext); @@ -58,7 +57,7 @@ if (have_option('n')) { /** * - * @param User $user + * @param User $user * @return TwitterOAuthClient */ function twitterAuthForUser(User $user) @@ -119,47 +118,61 @@ if (have_option('all')) { } -$stream->hookEvent('raw', function($data, $context) { +$stream->hookEvent('raw', function ($data, $context) { common_log(LOG_INFO, json_encode($data) . ' for ' . json_encode($context)); }); -$stream->hookEvent('friends', function($data, $context) { +$stream->hookEvent('friends', function ($data, $context) { printf("Friend list: %s\n", implode(', ', $data->friends)); }); -$stream->hookEvent('favorite', function($data, $context) { - printf("%s favorited %s's notice: %s\n", - $data->source->screen_name, - $data->target->screen_name, - $data->target_object->text); +$stream->hookEvent('favorite', function ($data, $context) { + printf( + "%s favorited %s's notice: %s\n", + $data->source->screen_name, + $data->target->screen_name, + $data->target_object->text + ); }); -$stream->hookEvent('unfavorite', function($data, $context) { - printf("%s unfavorited %s's notice: %s\n", - $data->source->screen_name, - $data->target->screen_name, - $data->target_object->text); +$stream->hookEvent('unfavorite', function ($data, $context) { + printf( + "%s unfavorited %s's notice: %s\n", + $data->source->screen_name, + $data->target->screen_name, + $data->target_object->text + ); }); -$stream->hookEvent('follow', function($data, $context) { - printf("%s friended %s\n", - $data->source->screen_name, - $data->target->screen_name); +$stream->hookEvent('follow', function ($data, $context) { + printf( + '%s friended %s' . "\n", + $data->source->screen_name, + $data->target->screen_name + ); }); -$stream->hookEvent('unfollow', function($data, $context) { - printf("%s unfriended %s\n", - $data->source->screen_name, - $data->target->screen_name); +$stream->hookEvent('unfollow', function ($data, $context) { + printf( + '%s unfriended %s' . "\n", + $data->source->screen_name, + $data->target->screen_name + ); }); -$stream->hookEvent('delete', function($data, $context) { - printf("Deleted status notification: %s\n", - $data->status->id); +$stream->hookEvent('delete', function ($data, $context) { + printf( + 'Deleted status notification: %s' . "\n", + $data->status->id + ); }); -$stream->hookEvent('scrub_geo', function($data, $context) { - printf("Req to scrub geo data for user id %s up to status ID %s\n", - $data->user_id, - $data->up_to_status_id); +$stream->hookEvent('scrub_geo', function ($data, $context) { + printf( + 'Req to scrub geo data for user id %s up to status ID %s' . "\n", + $data->user_id, + $data->up_to_status_id + ); }); -$stream->hookEvent('status', function($data, $context) { - printf("Received status update from %s: %s\n", - $data->user->screen_name, - $data->text); +$stream->hookEvent('status', function ($data, $context) { + printf( + 'Received status update from %s: %s' . "\n", + $data->user->screen_name, + $data->text + ); if (have_option('import')) { $importer = new TwitterImport(); @@ -170,38 +183,40 @@ $stream->hookEvent('status', function($data, $context) { } } }); -$stream->hookEvent('direct_message', function($data) { - printf("Direct message from %s to %s: %s\n", - $data->sender->screen_name, - $data->recipient->screen_name, - $data->text); +$stream->hookEvent('direct_message', function ($data) { + printf( + 'Direct message from %s to %s: %s' . "\n", + $data->sender->screen_name, + $data->recipient->screen_name, + $data->text + ); }); class TwitterManager extends IoManager { - function __construct(TwitterStreamReader $stream) + public function __construct(TwitterStreamReader $stream) { $this->stream = $stream; } - function getSockets() + public function getSockets() { return $this->stream->getSockets(); } - function handleInput($data) + public function handleInput($data) { $this->stream->handleInput($data); return true; } - function start() + public function start() { $this->stream->connect(); return true; } - function finish() + public function finish() { $this->stream->close(); return true; @@ -215,7 +230,7 @@ class TwitterManager extends IoManager class TwitterStreamMaster extends IoMaster { - function __construct($id, $ioManager) + public function __construct($id, $ioManager) { parent::__construct($id); $this->ioManager = $ioManager; @@ -224,7 +239,7 @@ class TwitterStreamMaster extends IoMaster /** * Initialize IoManagers which are appropriate to this instance. */ - function initManagers() + public function initManagers() { $this->instantiate($this->ioManager); }