Exemplo n.º 1
0
function updateUserUrls()
{
    printfnq("Updating user URLs...\n");
    // XXX: only update user URLs where out-of-date
    $qry = "SELECT * FROM profile order by id asc";
    $pflQry = new Profile();
    $pflQry->query($qry);
    $members = array();
    while ($pflQry->fetch()) {
        $members[] = clone $pflQry;
    }
    $pflQry->free();
    foreach ($members as $member) {
        $user = $member->getUser();
        printfv("Updating user {$user->nickname}...");
        try {
            $profile = $user->getProfile();
            updateProfileUrl($profile);
            updateAvatarUrls($profile);
            // Broadcast for remote users
            common_broadcast_profile($profile);
        } catch (Exception $e) {
            printv("Error updating URLs: " . $e->getMessage());
        }
        printfv("DONE.");
    }
}
Exemplo n.º 2
0
 static function getTagged($tagger, $tag)
 {
     $profile = new Profile();
     $profile->query('SELECT profile.* ' . 'FROM profile JOIN profile_tag ' . 'ON profile.id = profile_tag.tagged ' . 'WHERE profile_tag.tagger = ' . $tagger . ' ' . 'AND profile_tag.tag = "' . $tag . '" ');
     $tagged = array();
     while ($profile->fetch()) {
         $tagged[] = clone $profile;
     }
     return $tagged;
 }
Exemplo n.º 3
0
/**
 * Check for profiles in the given id range that are missing, presumed deleted.
 *
 * @param int $start beginning profile.id, inclusive
 * @param int $end final profile.id, inclusive
 * @return array of integer profile.ids
 * @access private
 */
function get_missing_profiles($start, $end)
{
    $query = sprintf("SELECT id FROM profile WHERE id BETWEEN %d AND %d", $start, $end);
    $profile = new Profile();
    $profile->query($query);
    $all = range($start, $end);
    $known = array();
    while ($row = $profile->fetch()) {
        $known[] = intval($profile->id);
    }
    unset($profile);
    $missing = array_diff($all, $known);
    return $missing;
}
Exemplo n.º 4
0
 /**
  * Search for users matching the query and spit the results out
  * as a quick-n-dirty JSON document
  *
  * @return void
  */
 function showResults()
 {
     $people = array();
     $profile = new Profile();
     $search_engine = $profile->getSearchEngine('profile');
     $search_engine->set_sort_mode('nickname_desc');
     $search_engine->limit(0, 10);
     $search_engine->query(strtolower($this->query . '*'));
     $cnt = $profile->find();
     if ($cnt > 0) {
         $sql = 'SELECT profile.* FROM profile, user WHERE profile.id = user.id ' . ' AND LEFT(LOWER(profile.nickname), ' . strlen($this->query) . ') = \'%s\' ' . ' LIMIT 0, 10';
         $profile->query(sprintf($sql, $this->query));
     }
     while ($profile->fetch()) {
         $people[] = $profile->nickname;
     }
     header('Content-Type: application/json; charset=utf-8');
     print json_encode($people);
 }
Exemplo n.º 5
0
 private function archives($q)
 {
     global $db, $current_year;
     if (isset($this->archive_year)) {
         $r = $db["archives"]->select("profiles" . sprintf("%04d", $this->archive_year), "id", $q);
         foreach ($r as $row) {
             $p = new Profile($row["id"], $this->archive_year);
             $this->results[] = $p->fetch();
             unset($p);
         }
     } else {
         $y = $current_year - 101;
         while ($y >= 607) {
             $r = $db["archives"]->select("profiles" . sprintf("%04d", $y), "id", $q);
             foreach ($r as $row) {
                 $p = new Profile($row["id"], $y);
                 $this->results[] = $p->fetch();
                 unset($p);
             }
             $y -= 101;
         }
     }
 }
 function handle($args)
 {
     parent::handle($args);
     $profile = new Profile();
     $profile->find();
     $server = common_config('site', 'server');
     $path = common_config('site', 'path');
     $mainpath = 'http://' . $server . '/' . $path . '/index.php/';
     //'http://192.168.1.123/statusnet_copy/index.php/';
     while ($profile->fetch()) {
         //echo $this->ID;
         //$store[] = $object; // builds an array of object lines.
         $nickname = $profile->nickname;
         $profileurl = $mainpath . $nickname;
         $data = Profile::staticGet('id', $profile->id);
         $orign = clone $data;
         $data->profileurl = $profileurl;
         if (!$data->update($orign)) {
             echo 'profile update error' . $data->id;
             echo '<br>';
         }
     }
 }
Exemplo n.º 7
0
  -i --id       ID of the user to send email
  -n --nickname nickname of the user to send email
  -g --group    Nickname or alias of group to send email
  -G --group-id ID of group to send email
  -a --all      Send email to all members

END_OF_USERROLE_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
// Si tiene la opción all
if (have_option('a', 'all')) {
    $qry = "SELECT * FROM profile order by id asc";
    $pflQry = new Profile();
    $pflQry->query($qry);
    $members = array();
    while ($pflQry->fetch()) {
        $members[] = clone $pflQry;
    }
    $pflQry->free();
} else {
    if (have_option('i', 'id') || have_option('n', 'nickname')) {
        if (have_option('i', 'id')) {
            $id = get_option_value('i', 'id');
            $profile = Profile::staticGet('id', $id);
            if (empty($profile)) {
                print "Can't find user with ID {$id}\n";
                exit(1);
            }
        } else {
            if (have_option('n', 'nickname')) {
                $nickname = get_option_value('n', 'nickname');
Exemplo n.º 8
0
 */
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$shortoptions = 'y';
$longoptions = array('yes');
$helptext = <<<END_OF_HELP
clean_profiles.php [options]
Deletes all profile table entries where the profile does not occur in the
notice table, is not a group and is not a local user. Very MySQL specific I think.

WARNING: This has not been tested thoroughly. Maybe we've missed a table to compare somewhere.

  -y --yes      do not wait for confirmation

END_OF_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
if (!have_option('y', 'yes')) {
    print "About to delete profiles that we think are useless to save. Are you sure? [y/N] ";
    $response = fgets(STDIN);
    if (strtolower(trim($response)) != 'y') {
        print "Aborting.\n";
        exit(0);
    }
}
print "Deleting";
$profile = new Profile();
$profile->query('SELECT * FROM profile WHERE ' . 'NOT (SELECT COUNT(*) FROM notice WHERE profile_id=profile.id) ' . 'AND NOT (SELECT COUNT(*) FROM user WHERE user.id=profile.id) ' . 'AND NOT (SELECT COUNT(*) FROM user_group WHERE user_group.profile_id=profile.id) ' . 'AND NOT (SELECT COUNT(*) FROM subscription WHERE subscriber=profile.id OR subscribed=profile.id) ');
while ($profile->fetch()) {
    echo ' ' . $profile->getID() . ':' . $profile->getNickname();
    $profile->delete();
}
print "\nDONE.\n";
Exemplo n.º 9
0
 /**
  * Look up a Profile by profileurl field.  Profile::staticGet() was
  * not working consistently.
  *
  * @param string $nickname   local nickname of the Twitter user
  * @param string $profileurl the profile url
  *
  * @return mixed value the first Profile with that url, or null
  */
 function getProfileByUrl($nickname, $profileurl)
 {
     $profile = new Profile();
     $profile->nickname = $nickname;
     $profile->profileurl = $profileurl;
     $profile->limit(1);
     if ($profile->find()) {
         $profile->fetch();
         return $profile;
     }
     return null;
 }
Exemplo n.º 10
0
 protected function prepare(array $args = array())
 {
     // If we die, show short error messages.
     GNUsocial::setApi(true);
     parent::prepare($args);
     $this->groups = array();
     $this->profiles = array();
     $term = $this->arg('term');
     $limit = $this->arg('limit');
     if ($limit > 200) {
         $limit = 200;
     }
     //prevent DOS attacks
     if (substr($term, 0, 1) == '@') {
         //profile search
         $term = substr($term, 1);
         $profile = new Profile();
         $profile->limit($limit);
         $profile->whereAdd('nickname like \'' . trim($profile->escape($term), '\'') . '%\'');
         $profile->whereAdd(sprintf('id in (SELECT id FROM user) OR ' . 'id in (SELECT subscribed from subscription' . ' where subscriber = %d)', $this->scoped->id));
         if ($profile->find()) {
             while ($profile->fetch()) {
                 $this->profiles[] = clone $profile;
             }
         }
     }
     if (substr($term, 0, 1) == '!') {
         //group search
         $term = substr($term, 1);
         $group = new User_group();
         $group->limit($limit);
         $group->whereAdd('nickname like \'' . trim($group->escape($term), '\'') . '%\'');
         //Can't post to groups we're not subscribed to...:
         $group->whereAdd(sprintf('id in (SELECT group_id FROM group_member' . ' WHERE profile_id = %d)', $this->scoped->id));
         if ($group->find()) {
             while ($group->fetch()) {
                 $this->groups[] = clone $group;
             }
         }
     }
     return true;
 }
Exemplo n.º 11
0
 public static function fetchQQ($username)
 {
     $cached_profile = Profile::fetch($username);
     return $cached_profile['qq'];
 }
Exemplo n.º 12
0
 function getTaggedSubscribers($tag)
 {
     $qry = 'SELECT profile.* ' . 'FROM profile JOIN (subscription, profile_tag, profile_list) ' . 'ON profile.id = subscription.subscriber ' . 'AND profile.id = profile_tag.tagged ' . 'AND profile_tag.tagger = profile_list.tagger AND profile_tag.tag = profile_list.tag ' . 'WHERE subscription.subscribed = %d ' . 'AND subscription.subscribed != subscription.subscriber ' . 'AND profile_tag.tagger = %d AND profile_tag.tag = "%s" ' . 'AND profile_list.private = false ' . 'ORDER BY subscription.created DESC';
     $profile = new Profile();
     $tagged = array();
     $cnt = $profile->query(sprintf($qry, $this->id, $this->id, $tag));
     while ($profile->fetch()) {
         $tagged[] = clone $profile;
     }
     return $tagged;
 }
Exemplo n.º 13
0
 function getResults()
 {
     $profiles = array();
     $q = $this->arg('q');
     $q = strtolower($q);
     if (strlen($q) < 3) {
         // TRANS: Error message in case a search is shorter than three characters.
         $this->msg = _('The search string must be at least 3 characters long.');
     }
     $page = $this->arg('page');
     $page = (int) (empty($page) ? 1 : $page);
     $profile = new Profile();
     $search_engine = $profile->getSearchEngine('profile');
     if (Event::handle('StartProfileCompletionSearch', array($this, &$profile, $search_engine))) {
         $search_engine->set_sort_mode('chron');
         $search_engine->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
         if (false === $search_engine->query($q)) {
             $cnt = 0;
         } else {
             $cnt = $profile->find();
         }
         Event::handle('EndProfileCompletionSearch', array($this, &$profile, $search_engine));
     }
     while ($profile->fetch()) {
         $profiles[] = clone $profile;
     }
     return $this->filter($profiles);
 }