Example #1
0
function quickSort($vector)
{
    $pivot = $vector[0];
    $length = intval(count($vector) / 2);
    $aux = $vector[0];
    $vector[0] = $vector[$length];
    $vector[$length] = $aux;
    printv($vector);
}
Example #2
0
function short_realese($name)
{
    global $hide_realese_info;
    if (preg_match('/^(.*)(\\s+\\([^\\)]*(' . $hide_realese_info . ').*)$/iu', $name, $match)) {
        printv('Поиск: вместо названия альбома "' . $name . '" будет использовать "' . $match[1] . '"' . N);
        $name = $match[1];
    }
    return $name;
}
function updateGroupUrls()
{
    printfnq("Updating group URLs...\n");
    $group = new User_group();
    if ($group->find()) {
        while ($group->fetch()) {
            try {
                printfv("Updating group {$group->nickname}...");
                $orig = User_group::staticGet('id', $group->id);
                if (!empty($group->original_logo)) {
                    $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));
                }
                // XXX: this is a hack to see if a group is local or not
                $localUri = common_local_url('groupbyid', array('id' => $group->id));
                if ($group->getUri() != $localUri) {
                    $group->mainpage = common_local_url('showgroup', array('nickname' => $group->nickname));
                }
                $group->update($orig);
                printfv("DONE.");
            } catch (Exception $e) {
                printv("Can't update avatars for group " . $group->nickname . ": " . $e->getMessage());
            }
        }
    }
}
Example #4
0
function initInbox()
{
    printfnq("Ensuring all users have an inbox...");
    $user = new User();
    $user->whereAdd('not exists (select user_id from inbox where user_id = user.id)');
    $user->orderBy('id');
    if ($user->find()) {
        while ($user->fetch()) {
            try {
                $notice = new Notice();
                $notice->selectAdd();
                $notice->selectAdd('id');
                $notice->joinAdd(array('profile_id', 'subscription:subscribed'));
                $notice->whereAdd('subscription.subscriber = ' . $user->id);
                $notice->whereAdd('notice.created >= subscription.created');
                $ids = array();
                if ($notice->find()) {
                    while ($notice->fetch()) {
                        $ids[] = $notice->id;
                    }
                }
                $notice = null;
                $inbox = new Inbox();
                $inbox->user_id = $user->id;
                $inbox->pack($ids);
                $inbox->insert();
            } catch (Exception $e) {
                printv("Error initializing inbox: " . $e->getMessage());
            }
        }
    }
    printfnq("DONE.\n");
}
Example #5
0
function fixupNoticeConversation()
{
    printfnq("Ensuring all notices have a conversation ID...");
    $notice = new Notice();
    $notice->whereAdd('conversation is null');
    $notice->orderBy('id');
    // try to get originals before replies
    $notice->find();
    while ($notice->fetch()) {
        try {
            $cid = null;
            $orig = clone $notice;
            if (empty($notice->reply_to)) {
                $notice->conversation = $notice->id;
            } else {
                $reply = Notice::getKV('id', $notice->reply_to);
                if (empty($reply)) {
                    $notice->conversation = $notice->id;
                } else {
                    if (empty($reply->conversation)) {
                        $notice->conversation = $notice->id;
                    } else {
                        $notice->conversation = $reply->conversation;
                    }
                }
                unset($reply);
                $reply = null;
            }
            $result = $notice->update($orig);
            $orig = null;
            unset($orig);
        } catch (Exception $e) {
            printv("Error setting conversation: " . $e->getMessage());
        }
    }
    printfnq("DONE.\n");
}
Example #6
0
function print_turn($turn)
{
    return $turn['timeStamp'] . ':' . $turn['id'] . $turn['grade'] . printv($turn['random-help']);
}