From ddef800ec94dc9d9c7cdc3a81bb1c1fadaad0db2 Mon Sep 17 00:00:00 2001 From: Christopher Vollick Date: Thu, 18 Feb 2010 12:14:34 -0500 Subject: [PATCH 1/4] Update Avatar URL Did Weird Stuff. It was only finding the first two avatars and then thinking it was done. I'm not entirely sure why it was doing that. I think maybe all the cloning made it forget where it was or something. Either way, it seems to work now, and really uses less memory. --- scripts/updateavatarurl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/updateavatarurl.php b/scripts/updateavatarurl.php index 617c2e24c7..3b6681bae9 100644 --- a/scripts/updateavatarurl.php +++ b/scripts/updateavatarurl.php @@ -94,11 +94,11 @@ function updateAvatars($user) } } - $orig = clone($avatar); + $orig_url = $avatar->url; $avatar->url = Avatar::url($avatar->filename); - if ($avatar->url != $orig->url) { + if ($avatar->url != $orig_url) { $sql = "UPDATE avatar SET url = '" . $avatar->url . "' ". "WHERE profile_id = " . $avatar->profile_id . " ". From e717cba19c1badb97b87e7654e7535d57fa9c9f3 Mon Sep 17 00:00:00 2001 From: Christopher Vollick Date: Thu, 18 Feb 2010 13:44:16 -0500 Subject: [PATCH 2/4] Add Script To Update Group Avatar URLs Similar to scripts/updateavatarurl.php. Works for groups. Again, I had to do some weird thing because using clone screwed up the find() iteration. --- scripts/updateavatarurl_group.php | 99 +++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 scripts/updateavatarurl_group.php diff --git a/scripts/updateavatarurl_group.php b/scripts/updateavatarurl_group.php new file mode 100644 index 0000000000..ada42de202 --- /dev/null +++ b/scripts/updateavatarurl_group.php @@ -0,0 +1,99 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'i:n:a'; +$longoptions = array('id=', 'nickname=', 'all'); + +$helptext = <<find()) { + while ($group->fetch()) { + updateGroupAvatars($group); + } + } + } else { + show_help(); + exit(1); + } +} catch (Exception $e) { + print $e->getMessage()."\n"; + exit(1); +} + +function updateGroupAvatars($group) +{ + if (!have_option('q', 'quiet')) { + print "Updating avatars for group '".$group->nickname."' (".$group->id.")..."; + } + + if (empty($group->original_logo)) { + print "(none found)..."; + } else { + // Using clone here was screwing up the group->find() iteration + $orig = User_group::staticGet('id', $group->id); + + $group->original_logo = Avatar::url(basename($group->original_logo)); + $group->homepage_logo = Avatar::url(basename($group->homepage_logo)); + $group->stream_logo = Avatar::url(basename($group->stream_logo)); + $group->mini_logo = Avatar::url(basename($group->mini_logo)); + + if (!$group->update($orig)) { + throw new Exception("Can't update avatars for group " . $group->nickname . "."); + } + } + + if (have_option('v', 'verbose')) { + print "DONE."; + } + if (!have_option('q', 'quiet') || have_option('v', 'verbose')) { + print "\n"; + } +} From 1e8e1e836d53b357eb1ddd538c0ceb4d8b289f59 Mon Sep 17 00:00:00 2001 From: Christopher Vollick Date: Mon, 22 Feb 2010 11:19:16 -0500 Subject: [PATCH 3/4] Rewrote How Blogspam Plugin Made HTTP Requests. The old way didn't seem to work anymore. It was just sending empty requests. --- plugins/BlogspamNetPlugin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/BlogspamNetPlugin.php b/plugins/BlogspamNetPlugin.php index 51236001aa..9b7ed1c123 100644 --- a/plugins/BlogspamNetPlugin.php +++ b/plugins/BlogspamNetPlugin.php @@ -72,8 +72,10 @@ class BlogspamNetPlugin extends Plugin common_debug("Blogspamnet args = " . print_r($args, TRUE)); $requestBody = xmlrpc_encode_request('testComment', array($args)); - $request = HTTPClient::start(); - $httpResponse = $request->post($this->baseUrl, array('Content-Type: text/xml'), $requestBody); + $request = new HTTPClient($this->baseUrl, HTTPClient::METHOD_POST); + $request->setHeader('Content-Type', 'text/xml'); + $request->setBody($requestBody); + $httpResponse = $request->send(); $response = xmlrpc_decode($httpResponse->getBody()); if (xmlrpc_is_fault($response)) { From a6afc1cfd6e99d83322910d4c1dafb16b1c4ae90 Mon Sep 17 00:00:00 2001 From: Christopher Vollick Date: Mon, 22 Feb 2010 11:20:44 -0500 Subject: [PATCH 4/4] Made Blogspam Plugin Respect textlimit Setting. The Blogspam plugin was setting a max-size to 140. It was therefore rejecting posts with more characters as spam. This kind of defeated the purpose of setting a higher limit... --- plugins/BlogspamNetPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/BlogspamNetPlugin.php b/plugins/BlogspamNetPlugin.php index 9b7ed1c123..d52e6006ac 100644 --- a/plugins/BlogspamNetPlugin.php +++ b/plugins/BlogspamNetPlugin.php @@ -120,7 +120,7 @@ class BlogspamNetPlugin extends Plugin $args['site'] = common_root_url(); $args['version'] = $this->userAgent(); - $args['options'] = "max-size=140,min-size=0,min-words=0,exclude=bayasian"; + $args['options'] = "max-size=" . common_config('site','textlimit') . ",min-size=0,min-words=0,exclude=bayasian"; return $args; }