summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/inbox_users.php124
-rwxr-xr-x[-rw-r--r--]scripts/sitemap.php0
-rw-r--r--scripts/uncache_users.php59
-rwxr-xr-x[-rw-r--r--]scripts/update_pot.sh0
-rwxr-xr-x[-rw-r--r--]scripts/update_translations.php98
5 files changed, 171 insertions, 110 deletions
diff --git a/scripts/inbox_users.php b/scripts/inbox_users.php
index f907e1584..7d14f0efe 100755
--- a/scripts/inbox_users.php
+++ b/scripts/inbox_users.php
@@ -42,68 +42,70 @@ common_log(LOG_INFO, 'Updating user inboxes.');
$ids = file($id_file);
foreach ($ids as $id) {
-
- $user = User::staticGet('id', $id);
+
+ $user = User::staticGet('id', $id);
- if (!$user) {
- common_log(LOG_WARNING, 'No such user: ' . $id);
- continue;
- }
-
- if ($user->inboxed) {
- common_log(LOG_WARNING, 'Already inboxed: ' . $id);
- continue;
- }
-
+ if (!$user) {
+ common_log(LOG_WARNING, 'No such user: ' . $id);
+ continue;
+ }
+
+ if ($user->inboxed) {
+ common_log(LOG_WARNING, 'Already inboxed: ' . $id);
+ continue;
+ }
+
common_log(LOG_INFO, 'Updating inbox for user ' . $user->id);
-
- $user->query('BEGIN');
-
- $old_inbox = new Notice_inbox();
- $old_inbox->user_id = $user->id;
-
- $result = $old_inbox->delete();
-
- if (is_null($result) || $result === false) {
- common_log_db_error($old_inbox, 'DELETE', __FILE__);
- continue;
- }
+
+ $user->query('BEGIN');
+
+ $old_inbox = new Notice_inbox();
+ $old_inbox->user_id = $user->id;
+
+ $result = $old_inbox->delete();
+
+ if (is_null($result) || $result === false) {
+ common_log_db_error($old_inbox, 'DELETE', __FILE__);
+ continue;
+ }
- $old_inbox->free();
-
- $inbox = new Notice_inbox();
-
- $result = $inbox->query('INSERT INTO notice_inbox (user_id, notice_id, created) ' .
- 'SELECT ' . $user->id . ', notice.id, notice.created ' .
- 'FROM subscription JOIN notice ON subscription.subscribed = notice.profile_id ' .
- 'WHERE subscription.subscriber = ' . $user->id . ' ' .
- 'AND notice.created >= subscription.created ' .
- 'AND now() - notice.created < ' . (7 * 24 * 3600) . ' ' .
- 'AND NOT EXISTS (SELECT user_id, notice_id ' .
- 'FROM notice_inbox ' .
- 'WHERE user_id = ' . $user->id . ' ' .
- 'AND notice_id = notice.id)');
-
- if (is_null($result) || $result === false) {
- common_log_db_error($inbox, 'INSERT', __FILE__);
- continue;
- }
-
- $orig = clone($user);
- $user->inboxed = 1;
- $result = $user->update($orig);
-
- if (!$result) {
- common_log_db_error($user, 'UPDATE', __FILE__);
- continue;
- }
-
- $user->query('COMMIT');
-
- $inbox->free();
- unset($inbox);
-
- if ($cache) {
- $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
- }
+ $old_inbox->free();
+
+ $inbox = new Notice_inbox();
+
+ $result = $inbox->query('INSERT INTO notice_inbox (user_id, notice_id, created) ' .
+ 'SELECT ' . $user->id . ', notice.id, notice.created ' .
+ 'FROM subscription JOIN notice ON subscription.subscribed = notice.profile_id ' .
+ 'WHERE subscription.subscriber = ' . $user->id . ' ' .
+ 'AND notice.created >= subscription.created ' .
+ 'AND NOT EXISTS (SELECT user_id, notice_id ' .
+ 'FROM notice_inbox ' .
+ 'WHERE user_id = ' . $user->id . ' ' .
+ 'AND notice_id = notice.id) ' .
+ 'ORDER BY notice.created DESC ' .
+ 'LIMIT 0, 1000');
+
+ if (is_null($result) || $result === false) {
+ common_log_db_error($inbox, 'INSERT', __FILE__);
+ continue;
+ }
+
+ $orig = clone($user);
+ $user->inboxed = 1;
+ $result = $user->update($orig);
+
+ if (!$result) {
+ common_log_db_error($user, 'UPDATE', __FILE__);
+ continue;
+ }
+
+ $user->query('COMMIT');
+
+ $inbox->free();
+ unset($inbox);
+
+ if ($cache) {
+ $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
+ $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id . ';last'));
+ }
}
diff --git a/scripts/sitemap.php b/scripts/sitemap.php
index 51a9bbd75..51a9bbd75 100644..100755
--- a/scripts/sitemap.php
+++ b/scripts/sitemap.php
diff --git a/scripts/uncache_users.php b/scripts/uncache_users.php
new file mode 100644
index 000000000..fa0fb64cd
--- /dev/null
+++ b/scripts/uncache_users.php
@@ -0,0 +1,59 @@
+#!/usr/bin/env php
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, Controlez-Vous, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+# Abort if called from a web server
+
+if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
+ print "This script must be run from the command line\n";
+ exit();
+}
+
+ini_set("max_execution_time", "0");
+ini_set("max_input_time", "0");
+set_time_limit(0);
+mb_internal_encoding('UTF-8');
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('LACONICA', true);
+
+require_once(INSTALLDIR . '/lib/common.php');
+
+$id_file = ($argc > 1) ? $argv[1] : 'ids.txt';
+
+common_log(LOG_INFO, 'Updating user inboxes.');
+
+$ids = file($id_file);
+
+foreach ($ids as $id) {
+
+ $user = User::staticGet('id', $id);
+
+ if (!$user) {
+ common_log(LOG_WARNING, 'No such user: ' . $id);
+ continue;
+ }
+
+ $user->decache();
+
+ $memc = common_memcache();
+
+ $memc->delete(common_cache_key('user:notices_with_friends:'. $user->id));
+ $memc->delete(common_cache_key('user:notices_with_friends:'. $user->id . ';last'));
+}
diff --git a/scripts/update_pot.sh b/scripts/update_pot.sh
index f3526d514..f3526d514 100644..100755
--- a/scripts/update_pot.sh
+++ b/scripts/update_pot.sh
diff --git a/scripts/update_translations.php b/scripts/update_translations.php
index 8ad07ccca..4d7adafea 100644..100755
--- a/scripts/update_translations.php
+++ b/scripts/update_translations.php
@@ -5,62 +5,62 @@ chdir(dirname(__FILE__) . '/..');
/* Languages to pull */
$languages = array(
- 'da_DK' => 'http://laconi.ca/translate/download.php?file_id=23',
- 'nl_NL' => 'http://laconi.ca/translate/download.php?file_id=39',
- 'en_NZ' => 'http://laconi.ca/translate/download.php?file_id=15',
- 'eo' => 'http://laconi.ca/translate/download.php?file_id=10',
- 'fr_FR' => 'http://laconi.ca/translate/download.php?file_id=19',
- 'de_DE' => 'http://laconi.ca/translate/download.php?file_id=18',
- 'it_IT' => 'http://laconi.ca/translate/download.php?file_id=21',
- 'ko' => 'http://laconi.ca/translate/download.php?file_id=33',
- 'no_NB' => 'http://laconi.ca/translate/download.php?file_id=31',
- 'pt' => 'http://laconi.ca/translate/download.php?file_id=8',
- 'pt_BR' => 'http://laconi.ca/translate/download.php?file_id=72',
- 'ru_RU' => 'http://laconi.ca/translate/download.php?file_id=26',
- 'es' => 'http://laconi.ca/translate/download.php?file_id=9',
- 'tr_TR' => 'http://laconi.ca/translate/download.php?file_id=37',
- 'uk_UA' => 'http://laconi.ca/translate/download.php?file_id=44',
- 'he_IL' => 'http://laconi.ca/translate/download.php?file_id=71',
- 'mk_MK' => 'http://laconi.ca/translate/download.php?file_id=67',
- 'ja_JP' => 'http://laconi.ca/translate/download.php?file_id=43',
- 'cs_CZ' => 'http://laconi.ca/translate/download.php?file_id=63',
- 'ca_ES' => 'http://laconi.ca/translate/download.php?file_id=49',
- 'pl_PL' => 'http://laconi.ca/translate/download.php?file_id=51',
- 'sv_SE' => 'http://laconi.ca/translate/download.php?file_id=55'
+ 'da_DK' => 'http://laconi.ca/translate/download.php?file_id=93',
+ 'nl_NL' => 'http://laconi.ca/translate/download.php?file_id=97',
+ 'en_NZ' => 'http://laconi.ca/translate/download.php?file_id=87',
+ 'eo' => 'http://laconi.ca/translate/download.php?file_id=88',
+ 'fr_FR' => 'http://laconi.ca/translate/download.php?file_id=99',
+ 'de_DE' => 'http://laconi.ca/translate/download.php?file_id=100',
+ 'it_IT' => 'http://laconi.ca/translate/download.php?file_id=101',
+ 'ko' => 'http://laconi.ca/translate/download.php?file_id=102',
+ 'no_NB' => 'http://laconi.ca/translate/download.php?file_id=104',
+ 'pt' => 'http://laconi.ca/translate/download.php?file_id=106',
+ 'pt_BR' => 'http://laconi.ca/translate/download.php?file_id=107',
+ 'ru_RU' => 'http://laconi.ca/translate/download.php?file_id=109',
+ 'es' => 'http://laconi.ca/translate/download.php?file_id=110',
+ 'tr_TR' => 'http://laconi.ca/translate/download.php?file_id=114',
+ 'uk_UA' => 'http://laconi.ca/translate/download.php?file_id=115',
+ 'he_IL' => 'http://laconi.ca/translate/download.php?file_id=116',
+ 'mk_MK' => 'http://laconi.ca/translate/download.php?file_id=103',
+ 'ja_JP' => 'http://laconi.ca/translate/download.php?file_id=117',
+ 'cs_CZ' => 'http://laconi.ca/translate/download.php?file_id=96',
+ 'ca_ES' => 'http://laconi.ca/translate/download.php?file_id=95',
+ 'pl_PL' => 'http://laconi.ca/translate/download.php?file_id=105',
+ 'sv_SE' => 'http://laconi.ca/translate/download.php?file_id=128'
);
/* Update the languages */
foreach ($languages as $code => $file) {
- $lcdir='locale/'.$code;
- $msgdir=$lcdir.'/LC_MESSAGES';
- $pofile=$msgdir.'/laconica.po';
- $mofile=$msgdir.'/laconica.mo';
+ $lcdir='locale/'.$code;
+ $msgdir=$lcdir.'/LC_MESSAGES';
+ $pofile=$msgdir.'/laconica.po';
+ $mofile=$msgdir.'/laconica.mo';
- /* Check for an existing */
- if (!is_dir($msgdir)) {
- mkdir($lcdir);
- mkdir($msgdir);
- $existingSHA1 = '';
- } else {
- $existingSHA1 = file_exists($pofile) ? sha1_file($pofile) : '';
- }
+ /* Check for an existing */
+ if (!is_dir($msgdir)) {
+ mkdir($lcdir);
+ mkdir($msgdir);
+ $existingSHA1 = '';
+ } else {
+ $existingSHA1 = file_exists($pofile) ? sha1_file($pofile) : '';
+ }
- /* Get the remote one */
- $newFile = file_get_contents($file);
+ /* Get the remote one */
+ $newFile = file_get_contents($file);
- // Update if the local .po file is different to the one downloaded, or
- // if the .mo file is not present.
- if(sha1($newFile)!=$existingSHA1 || !file_exists($mofile)) {
- echo "Updating ".$code."\n";
- file_put_contents($pofile, $newFile);
- $prevdir = getcwd();
- chdir($msgdir);
- system('msgmerge -U laconica.po ../../laconica.pot');
- system('msgfmt -f -o laconica.mo laconica.po');
- chdir($prevdir);
- } else {
- echo "Unchanged - ".$code."\n";
- }
+ // Update if the local .po file is different to the one downloaded, or
+ // if the .mo file is not present.
+ if(sha1($newFile)!=$existingSHA1 || !file_exists($mofile)) {
+ echo "Updating ".$code."\n";
+ file_put_contents($pofile, $newFile);
+ $prevdir = getcwd();
+ chdir($msgdir);
+ system('msgmerge -U laconica.po ../../laconica.pot');
+ system('msgfmt -f -o laconica.mo laconica.po');
+ chdir($prevdir);
+ } else {
+ echo "Unchanged - ".$code."\n";
+ }
}
echo "Finished\n";