本文整理汇总了PHP中have_option函数的典型用法代码示例。如果您正苦于以下问题:PHP have_option函数的具体用法?PHP have_option怎么用?PHP have_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了have_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear_jabber
function clear_jabber($id)
{
$user = User::getKV('id', $id);
if ($user && $user->jabber) {
echo "clearing user {$id}'s user.jabber, was: {$user->jabber}";
if (have_option('dry-run')) {
echo " (SKIPPING)";
} else {
$original = clone $user;
$user->jabber = null;
try {
$user->updateWithKeys($original);
} catch (Exception $e) {
echo "WARNING: user update failed (setting jabber to null): " . $e->getMessage() . "\n";
}
}
echo "\n";
} else {
if (!$user) {
echo "Missing user for {$id}\n";
} else {
echo "Cleared jabber already for {$id}\n";
}
}
}
示例2: sphinx_base
function sphinx_base()
{
if (have_option('base')) {
return get_option_value('base');
} else {
return "/usr/local/sphinx";
}
}
示例3: sphinx_index_update
function sphinx_index_update($sn)
{
$base = sphinx_base();
$baseIndexes = array('notice', 'profile');
$params = array();
if (have_option('rotate')) {
$params[] = '--rotate';
}
foreach ($baseIndexes as $index) {
$params[] = "{$sn->dbname}_{$index}";
}
$params = implode(' ', $params);
$cmd = "{$base}/bin/indexer --config {$base}/etc/sphinx.conf {$params}";
print "{$cmd}\n";
system($cmd);
}
示例4: importActivityStream
function importActivityStream($user, $doc)
{
$feed = $doc->documentElement;
$entries = $feed->getElementsByTagNameNS(Activity::ATOM, 'entry');
for ($i = $entries->length - 1; $i >= 0; $i--) {
$entry = $entries->item($i);
$activity = new Activity($entry, $feed);
$object = $activity->objects[0];
if (!have_option('q', 'quiet')) {
print $activity->content . "\n";
}
$html = getTweetHtml($object->link);
$config = array('safe' => 1, 'deny_attribute' => 'class,rel,id,style,on*');
$html = htmLawed($html, $config);
$content = html_entity_decode(strip_tags($html), ENT_QUOTES, 'UTF-8');
$notice = Notice::saveNew($user->id, $content, 'importtwitter', array('uri' => $object->id, 'url' => $object->link, 'rendered' => $html, 'created' => common_sql_date($activity->time), 'replies' => array(), 'groups' => array()));
}
}
示例5: updateProfileURL
function updateProfileURL($user)
{
$profile = $user->getProfile();
if (empty($profile)) {
throw new Exception("Can't find profile for user {$user->nickname} ({$user->id})");
}
$orig = clone $profile;
$profile->profileurl = common_profile_url($user->nickname);
if (!have_option('q', 'quiet')) {
print "Updating profile url for {$user->nickname} ({$user->id}) " . "from {$orig->profileurl} to {$profile->profileurl}...";
}
$result = $profile->update($orig);
if (!$result) {
print "FAIL.\n";
common_log_db_error($profile, 'UPDATE', __FILE__);
throw new Exception("Can't update profile for user {$user->nickname} ({$user->id})");
}
common_broadcast_profile($profile);
print "OK.\n";
}
示例6: clear_jabber
function clear_jabber($id)
{
$user = User::staticGet('id', $id);
if ($user && $user->jabber) {
echo "clearing user {$id}'s user.jabber, was: {$user->jabber}";
if (have_option('dry-run')) {
echo " (SKIPPING)";
} else {
$original = clone $user;
$user->jabber = null;
$result = $user->updateKeys($original);
}
echo "\n";
} else {
if (!$user) {
echo "Missing user for {$id}\n";
} else {
echo "Cleared jabber already for {$id}\n";
}
}
}
示例7: siteStreamForOwner
function siteStreamForOwner(User $user)
{
// The user we auth as must be the owner of the application.
$auth = twitterAuthForUser($user);
if (have_option('apiroot')) {
$stream = new TwitterSiteStream($auth, get_option_value('apiroot'));
} else {
$stream = new TwitterSiteStream($auth);
}
// Pull Twitter user IDs for all users we want to pull data for
$userIds = array();
$flink = new Foreign_link();
$flink->service = TWITTER_SERVICE;
$flink->find();
while ($flink->fetch()) {
if (($flink->noticesync & FOREIGN_NOTICE_RECV) == FOREIGN_NOTICE_RECV) {
$userIds[] = $flink->foreign_id;
}
}
$stream->followUsers($userIds);
return $stream;
}
示例8: MagicEnvelope
print "\n\n";
echo "== Testing local verification ==\n\n";
$magic_env = new MagicEnvelope($envxml);
$activity = new Activity($magic_env->getPayload()->documentElement);
$actprofile = Profile::fromUri($activity->actor->id);
$ok = $magic_env->verify($actprofile);
if ($ok) {
print "OK\n\n";
} else {
print "FAIL\n\n";
}
if (have_option('--verify')) {
$url = 'http://www.madebymonsieur.com/ostatus_discovery/magic_env/validate/';
echo "== Testing remote verification ==\n\n";
print "Sending for verification to {$url} ...\n";
$client = new HTTPClient();
$response = $client->post($url, array(), array('magic_env' => $envxml));
print $response->getStatus() . "\n\n";
print $response->getBody() . "\n\n";
}
if (have_option('--slap')) {
$url = get_option_value('--slap');
echo "== Remote salmon slap ==\n\n";
print "Sending signed Salmon slap to {$url} ...\n";
$ok = Salmon::post($url, $entry, $profile->getUser());
if ($ok) {
print "OK\n\n";
} else {
print "FAIL\n\n";
}
}
示例9: array
$shortoptions = 'i:n:f:a:j';
$longoptions = array('id=', 'nickname=', 'file=', 'after=', 'json');
$helptext = <<<END_OF_EXPORTACTIVITYSTREAM_HELP
exportactivitystream.php [options]
Export a StatusNet user history to a file
-i --id ID of user to export
-n --nickname nickname of the user to export
-j --json Output JSON (default Atom)
-a --after Only activities after the given date
END_OF_EXPORTACTIVITYSTREAM_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
try {
$user = getUser();
if (have_option('a', 'after')) {
$afterStr = get_option_value('a', 'after');
$after = strtotime($afterStr);
$actstr = new UserActivityStream($user, true, UserActivityStream::OUTPUT_RAW, $after);
} else {
$actstr = new UserActivityStream($user, true, UserActivityStream::OUTPUT_RAW);
}
if (have_option('j', 'json')) {
$actstr->writeJSON(STDOUT);
} else {
print $actstr->getString();
}
} catch (Exception $e) {
print $e->getMessage() . "\n";
exit(1);
}
示例10: printfv
if ($e > $st && $e <= $jt) {
printfv("{$i} Making a new group join\n");
newJoin($n, $g);
} else {
printfv("No event for {$i}!");
}
}
}
}
}
}
}
$usercount = have_option('u', 'users') ? get_option_value('u', 'users') : 100;
$groupcount = have_option('g', 'groups') ? get_option_value('g', 'groups') : 20;
$noticeavg = have_option('n', 'notices') ? get_option_value('n', 'notices') : 100;
$subsavg = have_option('b', 'subscriptions') ? get_option_value('b', 'subscriptions') : max($usercount / 20, 10);
$joinsavg = have_option('j', 'joins') ? get_option_value('j', 'joins') : 5;
$tagmax = have_option('t', 'tags') ? get_option_value('t', 'tags') : 10000;
$userprefix = have_option('x', 'prefix') ? get_option_value('x', 'prefix') : 'testuser';
$groupprefix = have_option('z', 'groupprefix') ? get_option_value('z', 'groupprefix') : 'testgroup';
$wordsfile = have_option('w', 'words') ? get_option_value('w', 'words') : '/usr/share/dict/words';
if (is_readable($wordsfile)) {
$words = file($wordsfile);
} else {
$words = null;
}
try {
main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax);
} catch (Exception $e) {
printfv("Got an exception: " . $e->getMessage());
}
示例11: exit
exit(0);
}
$tag = $args[1];
$i = array_search($tag, $tags);
if ($i !== false) {
if (have_option('d', 'delete')) {
// Delete
unset($tags[$i]);
$result = $sn->setTags($tags);
if (!$result) {
print "Couldn't update.\n";
exit(-1);
}
} else {
print "Already set.\n";
exit(-1);
}
} else {
if (have_option('d', 'delete')) {
// Delete
print "No such tag.\n";
exit(-1);
} else {
$tags[] = $tag;
$result = $sn->setTags($tags);
if (!$result) {
print "Couldn't update.\n";
exit(-1);
}
}
}
示例12: main
$from->free();
$to->free();
}
function main($usercount, $noticeavg, $subsavg, $tagmax)
{
global $config;
$config['site']['dupelimit'] = -1;
$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') : max($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);
示例13: array
$longoptions = array('oauth_token=', 'token_secret=');
$helptext = <<<END_OF_VERIFY_HELP
verifycreds.php [options]
Use an access token to verify credentials thru the api
-o --oauth_token access token
-s --token_secret access token secret
END_OF_VERIFY_HELP;
$token = null;
$token_secret = null;
require_once INSTALLDIR . '/scripts/commandline.inc';
if (have_option('o', 'oauth_token')) {
$token = get_option_value('oauth_token');
}
if (have_option('s', 'token_secret')) {
$token_secret = get_option_value('s', 'token_secret');
}
if (empty($token)) {
print "Please specify an access token.\n";
exit(1);
}
if (empty($token_secret)) {
print "Please specify an access token secret.\n";
exit(1);
}
$ini = parse_ini_file("oauth.ini");
$test_consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']);
$endpoint = $ini['apiroot'] . '/account/verify_credentials.xml';
print "{$endpoint}\n";
$at = new OAuthToken($token, $token_secret);
示例14: common_log
Subscription::start($profile, $friend_profile);
common_log(LOG_INFO, $this->name() . ' - Subscribed ' . "{$friend_profile->nickname} to {$profile->nickname}.");
} catch (Exception $e) {
common_debug($this->name() . ' - Tried and failed subscribing ' . "{$friend_profile->nickname} to {$profile->nickname} - " . $e->getMessage());
}
}
}
}
return true;
}
}
$id = null;
$debug = null;
if (have_option('i')) {
$id = get_option_value('i');
} else {
if (have_option('--id')) {
$id = get_option_value('--id');
} else {
if (count($args) > 0) {
$id = $args[0];
} else {
$id = null;
}
}
}
if (have_option('d') || have_option('debug')) {
$debug = true;
}
$syncer = new SyncTwitterFriendsDaemon($id, 60, 2, $debug);
$syncer->runOnce();
示例15: exit
Pull an Atom feed and run items in it as though they were live PuSH updates.
Mainly intended for testing funky feed formats.
--skip=N Ignore the first N items in the feed.
--count=N Only process up to N items from the feed, after skipping.
END_OF_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
if (empty($args[0]) || !Validate::uri($args[0])) {
print "{$helptext}";
exit(1);
}
$feedurl = $args[0];
$skip = have_option('skip') ? intval(get_option_value('skip')) : 0;
$count = have_option('count') ? intval(get_option_value('count')) : 0;
$sub = FeedSub::staticGet('topic', $feedurl);
if (!$sub) {
print "Feed {$feedurl} is not subscribed.\n";
exit(1);
}
$xml = file_get_contents($feedurl);
if ($xml === false) {
print "Bad fetch.\n";
exit(1);
}
$feed = new DOMDocument();
if (!$feed->loadXML($xml)) {
print "Bad XML.\n";
exit(1);
}