forked from GNUsocial/gnu-social
Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x
This commit is contained in:
commit
936b099978
@ -18,6 +18,14 @@ $config['site']['server'] = 'localhost';
|
|||||||
$config['site']['path'] = 'laconica';
|
$config['site']['path'] = 'laconica';
|
||||||
// $config['site']['fancy'] = false;
|
// $config['site']['fancy'] = false;
|
||||||
// $config['site']['theme'] = 'default';
|
// $config['site']['theme'] = 'default';
|
||||||
|
// Sets the site's default design values (match it with the values in the theme)
|
||||||
|
// $config['site']['design']['backgroundcolor'] = '#F0F2F5';
|
||||||
|
// $config['site']['design']['contentcolor'] = '#FFFFFF';
|
||||||
|
// $config['site']['design']['sidebarcolor'] = '#CEE1E9';
|
||||||
|
// $config['site']['design']['textcolor'] = '#000000';
|
||||||
|
// $config['site']['design']['linkcolor'] = '#002E6E';
|
||||||
|
// $config['site']['design']['backgroundimage'] = null;
|
||||||
|
// $config['site']['design']['disposition'] = 1;
|
||||||
// To enable the built-in mobile style sheet, defaults to false.
|
// To enable the built-in mobile style sheet, defaults to false.
|
||||||
// $config['site']['mobile'] = true;
|
// $config['site']['mobile'] = true;
|
||||||
// For contact email, defaults to $_SERVER["SERVER_ADMIN"]
|
// For contact email, defaults to $_SERVER["SERVER_ADMIN"]
|
||||||
|
142
scripts/createsim.php
Normal file
142
scripts/createsim.php
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Laconica - a distributed open-source microblogging tool
|
||||||
|
* Copyright (C) 2008, 2009, Control Yourself, 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||||
|
|
||||||
|
$shortoptions = 'u:n:b:t:x:';
|
||||||
|
$longoptions = array('users=', 'notices=', 'subscriptions=', 'tags=', 'prefix=');
|
||||||
|
|
||||||
|
$helptext = <<<END_OF_CREATESIM_HELP
|
||||||
|
Creates a lot of test users and notices to (loosely) simulate a real server.
|
||||||
|
|
||||||
|
-u --users Number of users (default 100)
|
||||||
|
-n --notices Average notices per user (default 100)
|
||||||
|
-b --subscriptions Average subscriptions per user (default no. users/20)
|
||||||
|
-t --tags Number of distinct hash tags (default 10000)
|
||||||
|
-x --prefix User name prefix (default 'testuser')
|
||||||
|
|
||||||
|
END_OF_CREATESIM_HELP;
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||||
|
|
||||||
|
// XXX: make these command-line options
|
||||||
|
|
||||||
|
function newUser($i)
|
||||||
|
{
|
||||||
|
global $userprefix;
|
||||||
|
User::register(array('nickname' => sprintf('%s%d', $userprefix, $i),
|
||||||
|
'password' => sprintf('password%d', $i),
|
||||||
|
'fullname' => sprintf('Test User %d', $i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function newNotice($i, $tagmax)
|
||||||
|
{
|
||||||
|
global $userprefix;
|
||||||
|
|
||||||
|
$n = rand(0, $i - 1);
|
||||||
|
$user = User::staticGet('nickname', sprintf('%s%d', $userprefix, $n));
|
||||||
|
|
||||||
|
$is_reply = rand(0, 4);
|
||||||
|
|
||||||
|
$content = 'Test notice content';
|
||||||
|
|
||||||
|
if ($is_reply == 0) {
|
||||||
|
$n = rand(0, $i - 1);
|
||||||
|
$content = "@$userprefix$n " . $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
$has_hash = rand(0, 2);
|
||||||
|
|
||||||
|
if ($has_hash == 0) {
|
||||||
|
$hashcount = rand(0, 2);
|
||||||
|
for ($j = 0; $j < $hashcount; $j++) {
|
||||||
|
$h = rand(0, $tagmax);
|
||||||
|
$content .= " #tag{$h}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$notice = Notice::saveNew($user->id, $content, 'system');
|
||||||
|
}
|
||||||
|
|
||||||
|
function newSub($i)
|
||||||
|
{
|
||||||
|
global $userprefix;
|
||||||
|
$f = rand(0, $i - 1);
|
||||||
|
|
||||||
|
$fromnick = sprintf('%s%d', $userprefix, $f);
|
||||||
|
|
||||||
|
$from = User::staticGet('nickname', $fromnick);
|
||||||
|
|
||||||
|
if (empty($from)) {
|
||||||
|
throw new Exception("Can't find user '$fromnick'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$t = rand(0, $i - 1);
|
||||||
|
|
||||||
|
if ($t == $f) {
|
||||||
|
$t++;
|
||||||
|
if ($t > $i - 1) {
|
||||||
|
$t = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$tunic = sprintf('%s%d', $userprefix, $t);
|
||||||
|
|
||||||
|
$to = User::staticGet('nickname', $tunic);
|
||||||
|
|
||||||
|
if (empty($from)) {
|
||||||
|
throw new Exception("Can't find user '$tunic'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
subs_subscribe_to($from, $to);
|
||||||
|
}
|
||||||
|
|
||||||
|
function main($usercount, $noticeavg, $subsavg, $tagmax)
|
||||||
|
{
|
||||||
|
$n = 1;
|
||||||
|
|
||||||
|
newUser(0);
|
||||||
|
|
||||||
|
// # registrations + # notices + # subs
|
||||||
|
|
||||||
|
$events = $usercount + ($usercount * ($noticeavg + $subsavg));
|
||||||
|
|
||||||
|
for ($i = 0; $i < $events; $i++)
|
||||||
|
{
|
||||||
|
$e = rand(0, 1 + $noticeavg + $subsavg);
|
||||||
|
|
||||||
|
if ($e == 0) {
|
||||||
|
newUser($n);
|
||||||
|
$n++;
|
||||||
|
} else if ($e < $noticeavg + 1) {
|
||||||
|
newNotice($n, $tagmax);
|
||||||
|
} else {
|
||||||
|
newSub($n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$usercount = (have_option('u', 'users')) ? get_option_value('u', 'users') : 100;
|
||||||
|
$noticeavg = (have_option('n', 'notices')) ? get_option_value('n', 'notices') : 100;
|
||||||
|
$subsavg = (have_option('b', 'subscriptions')) ? get_option_value('b', 'subscriptions') : min($usercount/20, 10);
|
||||||
|
$tagmax = (have_option('t', 'tags')) ? get_option_value('t', 'tags') : 10000;
|
||||||
|
$userprefix = (have_option('x', 'prefix')) ? get_option_value('x', 'prefix') : 'testuser';
|
||||||
|
|
||||||
|
main($usercount, $noticeavg, $subsavg, $tagmax);
|
Loading…
Reference in New Issue
Block a user