Example #1
0
                trashCommentInOwner($blogid, $comment['id']);
            }
        }
    }
    POD::free($result);
}
if ($result = POD::query("SELECT id, url, site, subject, excerpt FROM {$database['prefix']}RemoteResponses WHERE blogid = {$blogid}")) {
    while ($trackback = POD::fetch($result)) {
        setProgress($item++ / $items * 100, _t('걸린 글 데이터를 교정하고 있습니다.'));
        $correction = '';
        if (!Utils_Unicode::validate($trackback['url'])) {
            $correction .= ' url = \'' . POD::escapeString(Utils_Unicode::correct($trackback['url'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['site'])) {
            $correction .= ' site = \'' . POD::escapeString(Utils_Unicode::correct($trackback['site'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['subject'])) {
            $correction .= ' subject = \'' . POD::escapeString(Utils_Unicode::correct($trackback['subject'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['excerpt'])) {
            $correction .= ' excerpt = \'' . POD::escapeString(Utils_Unicode::correct($trackback['excerpt'], '?')) . '\'';
        }
        if (strlen($correction) > 0) {
            POD::query("UPDATE {$database['prefix']}RemoteResponses SET {$correction} WHERE blogid = {$blogid} AND id = {$trackback['id']}");
            $corrected++;
        }
    }
    POD::free($result);
}
setProgress(100, _t('완료되었습니다.') . "({$corrected})");
finish();
Example #2
0
function importer($path, $node, $line)
{
    global $blogid, $migrational, $items, $item;
    switch ($path) {
        case '/blog/setting':
            setProgress($item++ / $items * 100, _t('블로그 설정을 복원하고 있습니다.'));
            $setting = new BlogSetting();
            if (isset($node['title'][0]['.value'])) {
                $setting->title = $node['title'][0]['.value'];
            }
            if (isset($node['description'][0]['.value'])) {
                $setting->description = $node['description'][0]['.value'];
            }
            if (isset($node['banner'][0]['name'][0]['.value'])) {
                $setting->banner = $node['banner'][0]['name'][0]['.value'];
            }
            if (isset($node['useSloganOnPost'][0]['.value'])) {
                $setting->useSloganOnPost = $node['useSloganOnPost'][0]['.value'];
            }
            if (isset($node['postsOnPage'][0]['.value'])) {
                $setting->postsOnPage = $node['postsOnPage'][0]['.value'];
            }
            if (isset($node['postsOnList'][0]['.value'])) {
                $setting->postsOnList = $node['postsOnList'][0]['.value'];
            }
            if (isset($node['postsOnFeed'][0]['.value'])) {
                $setting->postsOnFeed = $node['postsOnFeed'][0]['.value'];
            }
            if (isset($node['publishWholeOnFeed'][0]['.value'])) {
                $setting->publishWholeOnFeed = $node['publishWholeOnFeed'][0]['.value'];
            }
            if (isset($node['acceptGuestComment'][0]['.value'])) {
                $setting->acceptGuestComment = $node['acceptGuestComment'][0]['.value'];
            }
            if (isset($node['acceptcommentOnGuestComment'][0]['.value'])) {
                $setting->acceptcommentOnGuestComment = $node['acceptcommentOnGuestComment'][0]['.value'];
            }
            if (isset($node['language'][0]['.value'])) {
                $setting->language = $node['language'][0]['.value'];
            }
            if (isset($node['timezone'][0]['.value'])) {
                $setting->timezone = $node['timezone'][0]['.value'];
            }
            if (!$setting->save()) {
                user_error(__LINE__ . $setting->error);
            }
            if (!empty($setting->banner) && !empty($node['banner'][0]['content'][0]['.stream'])) {
                Attachment::confirmFolder();
                Utils_Base64Stream::decode($node['banner'][0]['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                fclose($node['banner'][0]['content'][0]['.stream']);
                unset($node['banner'][0]['content'][0]['.stream']);
            }
            return true;
        case '/blog/category':
            setProgress($item++ / $items * 100, _t('분류를 복원하고 있습니다.'));
            $category = new Category();
            $category->name = $node['name'][0]['.value'];
            $category->priority = $node['priority'][0]['.value'];
            if (isset($node['root'][0]['.value'])) {
                $category->id = 0;
            }
            if (!$category->add()) {
                user_error(__LINE__ . $category->error);
            }
            if (isset($node['category'])) {
                for ($i = 0; $i < count($node['category']); $i++) {
                    $childCategory = new Category();
                    $childCategory->parent = $category->id;
                    $cursor =& $node['category'][$i];
                    $childCategory->name = $cursor['name'][0]['.value'];
                    $childCategory->priority = $cursor['priority'][0]['.value'];
                    if (!$childCategory->add()) {
                        user_error(__LINE__ . $childCategory->error);
                    }
                }
            }
            return true;
        case '/blog/post':
            setProgress($item++ / $items * 100, _t('글을 복원하고 있습니다.'));
            $post = new Post();
            $post->id = $node['id'][0]['.value'];
            $post->slogan = @$node['.attributes']['slogan'];
            $post->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $post->starred = $node['starred'][0]['.value'];
            } else {
                $post->starred = 0;
            }
            $post->title = $node['title'][0]['.value'];
            $post->content = $node['content'][0]['.value'];
            $post->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : 'ttml';
            $post->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : 'modern';
            $post->location = $node['location'][0]['.value'];
            $post->password = isset($node['password'][0]['.value']) ? $node['password'][0]['.value'] : null;
            $post->acceptcomment = $node['acceptComment'][0]['.value'];
            $post->accepttrackback = $node['acceptTrackback'][0]['.value'];
            $post->published = $node['published'][0]['.value'];
            if (isset($node['longitude'][0]['.value'])) {
                $post->longitude = $node['longitude'][0]['.value'];
            }
            if (isset($node['latitude'][0]['.value'])) {
                $post->latitude = $node['latitude'][0]['.value'];
            }
            $post->created = @$node['created'][0]['.value'];
            $post->modified = @$node['modified'][0]['.value'];
            if ($post->visibility == 'private' && intval($post->published) > $_SERVER['REQUEST_TIME'] || !empty($node['appointed'][0]['.value']) && $node['appointed'][0]['.value'] == 'true') {
                // for compatibility of appointed entries
                $post->visibility = 'appointed';
            }
            if ($post->slogan == '') {
                $post->slogan = 'Untitled' . $post->id;
            }
            if (!empty($node['category'][0]['.value'])) {
                $post->category = Category::getId($node['category'][0]['.value']);
            }
            if (isset($node['tag'])) {
                $post->tags = array();
                for ($i = 0; $i < count($node['tag']); $i++) {
                    if (!empty($node['tag'][$i]['.value'])) {
                        array_push($post->tags, $node['tag'][$i]['.value']);
                    }
                }
            }
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $post->content = nl2brWithHTML($post->content);
            }
            if (!$post->add()) {
                user_error(__LINE__ . $post->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $post->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (!$attachment->add()) {
                        user_error(__LINE__ . $attachment->error);
                    } else {
                        if ($cursor['name'][0]['.value'] != $attachment->name) {
                            $post2 = new Post();
                            if ($post2->open($post->id, 'id, content')) {
                                $post2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $post2->content);
                                $post2->loadTags();
                                $post2->update();
                                $post2->close();
                            }
                            unset($post2);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            if (isset($node['comment'])) {
                for ($i = 0; $i < count($node['comment']); $i++) {
                    $comment = new Comment();
                    $comment->entry = $post->id;
                    $cursor =& $node['comment'][$i];
                    $comment->name = $cursor['commenter'][0]['name'][0]['.value'];
                    if (!empty($cursor['id'][0]['.value'])) {
                        $comment->id = $cursor['id'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                        $comment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                    }
                    if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                        $comment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                        $comment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
                        $comment->openid = $cursor['commenter'][0]['openid'][0]['.value'];
                    }
                    $comment->password = $cursor['password'][0]['.value'];
                    $comment->secret = $cursor['secret'][0]['.value'];
                    $comment->written = $cursor['written'][0]['.value'];
                    if (isset($cursor['longitude'][0]['.value'])) {
                        $comment->longitude = $cursor['longitude'][0]['.value'];
                    }
                    if (isset($cursor['latitude'][0]['.value'])) {
                        $comment->latitude = $cursor['latitude'][0]['.value'];
                    }
                    $comment->content = $cursor['content'][0]['.value'];
                    if (!empty($cursor['isFiltered'][0]['.value'])) {
                        $comment->isfiltered = $cursor['isFiltered'][0]['.value'];
                    }
                    if (!$comment->add()) {
                        user_error(__LINE__ . $comment->error);
                    }
                    if (isset($node['comment'][$i]['comment'])) {
                        for ($j = 0; $j < count($node['comment'][$i]['comment']); $j++) {
                            $childComment = new Comment();
                            $childComment->entry = $post->id;
                            $childComment->parent = $comment->id;
                            $cursor =& $node['comment'][$i]['comment'][$j];
                            if (!empty($cursor['id'][0]['.value'])) {
                                $childComment->id = $cursor['id'][0]['.value'];
                            }
                            if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                                $childComment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                            }
                            $childComment->name = $cursor['commenter'][0]['name'][0]['.value'];
                            if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                                $childComment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                            }
                            if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                                $childComment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                            }
                            if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
                                $childComment->openid = $cursor['commenter'][0]['openid'][0]['.value'];
                            }
                            $childComment->password = $cursor['password'][0]['.value'];
                            $childComment->secret = $cursor['secret'][0]['.value'];
                            $childComment->written = $cursor['written'][0]['.value'];
                            if (isset($cursor['longitude'][0]['.value'])) {
                                $comment->longitude = $cursor['longitude'][0]['.value'];
                            }
                            if (isset($cursor['latitude'][0]['.value'])) {
                                $comment->latitude = $cursor['latitude'][0]['.value'];
                            }
                            $childComment->content = $cursor['content'][0]['.value'];
                            if (!empty($cursor['isFiltered'][0]['.value'])) {
                                $childComment->isfiltered = $cursor['isFiltered'][0]['.value'];
                            }
                            if (!$childComment->add()) {
                                user_error(__LINE__ . $childComment->error);
                            }
                        }
                    }
                }
            }
            if (isset($node['trackback'])) {
                for ($i = 0; $i < count($node['trackback']); $i++) {
                    $trackback = new Trackback();
                    $trackback->entry = $post->id;
                    $cursor =& $node['trackback'][$i];
                    $trackback->url = $cursor['url'][0]['.value'];
                    $trackback->site = $cursor['site'][0]['.value'];
                    $trackback->title = $cursor['title'][0]['.value'];
                    $trackback->excerpt = @$cursor['excerpt'][0]['.value'];
                    if (!empty($cursor['ip'][0]['.value'])) {
                        $trackback->ip = $cursor['ip'][0]['.value'];
                    }
                    if (!empty($cursor['received'][0]['.value'])) {
                        $trackback->received = $cursor['received'][0]['.value'];
                    }
                    if (!empty($cursor['isFiltered'][0]['.value'])) {
                        $trackback->isFiltered = $cursor['isFiltered'][0]['.value'];
                    }
                    if (!$trackback->add()) {
                        user_error(__LINE__ . $trackback->error);
                    }
                }
            }
            if (isset($node['logs'][0]['trackback'])) {
                for ($i = 0; $i < count($node['logs'][0]['trackback']); $i++) {
                    $log = new TrackbackLog();
                    $log->entry = $post->id;
                    $cursor =& $node['logs'][0]['trackback'][$i];
                    $log->url = $cursor['url'][0]['.value'];
                    if (!empty($cursor['sent'][0]['.value'])) {
                        $log->sent = $cursor['sent'][0]['.value'];
                    }
                    if (!$log->add()) {
                        user_error(__LINE__ . $log->error);
                    }
                }
            }
            return true;
        case '/blog/page':
            setProgress($item++ / $items * 100, _t('페이지를 복원하고 있습니다.'));
            $page = new Page();
            $page->id = $node['id'][0]['.value'];
            $page->slogan = @$node['.attributes']['slogan'];
            $page->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $page->starred = $node['starred'][0]['.value'];
            } else {
                $page->starred = 0;
            }
            $page->title = $node['title'][0]['.value'];
            $page->content = $node['content'][0]['.value'];
            $page->contentformatter = isset($node['content']['.attributes']['formatter']) ? $node['content']['.attributes']['formatter'] : getDefaultFormatter();
            $page->contenteditor = isset($node['content']['.attributes']['editor']) ? $node['content']['.attributes']['editor'] : getDefaultEditor();
            $page->published = $node['published'][0]['.value'];
            $page->created = @$node['created'][0]['.value'];
            $page->modified = @$node['modified'][0]['.value'];
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $page->content = nl2brWithHTML($page->content);
            }
            if (!$page->add()) {
                user_error(__LINE__ . $page->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $page->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (Attachment::doesExist($attachment->name)) {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                        $page2 = new Page();
                        if ($page2->open($page->id, 'id, content')) {
                            $page2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $page2->content);
                            $page2->update();
                            $page2->close();
                        }
                        unset($page2);
                    } else {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            return true;
        case '/blog/notice':
            setProgress($item++ / $items * 100, _t('공지를 복원하고 있습니다.'));
            $notice = new Notice();
            $notice->id = $node['id'][0]['.value'];
            $notice->slogan = @$node['.attributes']['slogan'];
            $notice->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $notice->starred = $node['starred'][0]['.value'];
            } else {
                $notice->starred = 0;
            }
            $notice->title = $node['title'][0]['.value'];
            $notice->content = $node['content'][0]['.value'];
            $notice->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : getDefaultFormatter();
            $notice->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : getDefaultEditor();
            $notice->published = intval($node['published'][0]['.value']);
            $notice->created = @$node['created'][0]['.value'];
            $notice->modified = @$node['modified'][0]['.value'];
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $notice->content = nl2brWithHTML($notice->content);
            }
            if (!$notice->add()) {
                user_error(__LINE__ . $notice->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $notice->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (Attachment::doesExist($attachment->name)) {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                        $notice2 = new Notice();
                        if ($notice2->open($notice->id, 'id, content')) {
                            $notice2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $notice2->content);
                            $notice2->update();
                            $notice2->close();
                        }
                        unset($notice2);
                    } else {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            return true;
        case '/blog/keyword':
            setProgress($item++ / $items * 100, _t('키워드를 복원하고 있습니다.'));
            $keyword = new Keyword();
            $keyword->id = $node['id'][0]['.value'];
            $keyword->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $keyword->starred = $node['starred'][0]['.value'];
            } else {
                $keyword->starred = 0;
            }
            $keyword->name = $node['name'][0]['.value'];
            $keyword->description = $node['description'][0]['.value'];
            $keyword->descriptionEditor = isset($node['description'][0]['.attributes']['editor']) ? $node['description'][0]['.attributes']['editor'] : getDefaultEditor();
            $keyword->descriptionFormatter = isset($node['description'][0]['.attributes']['formatter']) ? $node['description'][0]['.attributes']['formatter'] : getDefaultFormatter();
            $keyword->published = intval($node['published'][0]['.value']);
            $keyword->created = @$node['created'][0]['.value'];
            $keyword->modified = @$node['modified'][0]['.value'];
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $keyword->description = nl2brWithHTML($keyword->description);
            }
            if (!$keyword->add()) {
                user_error(__LINE__ . $keyword->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $keyword->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (Attachment::doesExist($attachment->name)) {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                        $keyword2 = new Keyword();
                        if ($keyword2->open($keyword->id, 'id, content')) {
                            $keyword2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $keyword2->content);
                            $keyword2->update();
                            $keyword2->close();
                        }
                        unset($keyword2);
                    } else {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            return true;
        case '/blog/linkCategories':
            setProgress($item++ / $items * 100, _t('링크 카테고리를 복원하고 있습니다.'));
            $linkCategory = new LinkCategories();
            $linkCategory->name = $node['name'][0]['.value'];
            $linkCategory->priority = $node['priority'][0]['.value'];
            $linkCategory->visibility = !isset($node['visibility'][0]['.value']) || empty($node['visibility'][0]['.value']) ? 2 : $node['visibility'][0]['.value'];
            $linkCategory->id = LinkCategories::getId($linkCategory->name);
            if ($linkCategory->id) {
                if (!$linkCategory->update()) {
                    user_error(__LINE__ . $linkCategory->error);
                }
            } else {
                if (!$linkCategory->add()) {
                    user_error(__LINE__ . $linkCategory->error);
                }
            }
            return true;
        case '/blog/link':
            setProgress($item++ / $items * 100, _t('링크를 복원하고 있습니다.'));
            $link = new Link();
            $link->category = empty($node['category'][0]['.value']) ? 0 : $node['category'][0]['.value'];
            $link->url = $node['url'][0]['.value'];
            $link->title = $node['title'][0]['.value'];
            if (!empty($node['feed'][0]['.value'])) {
                $link->feed = $node['feed'][0]['.value'];
            }
            if (!empty($node['registered'][0]['.value'])) {
                $link->registered = $node['registered'][0]['.value'];
            }
            if (!empty($node['xfn'][0]['.value'])) {
                $link->xfn = $node['xfn'][0]['.value'];
            }
            $link->id = Link::getId($link->url);
            if ($link->id) {
                if (!$link->update()) {
                    user_error(__LINE__ . $link->error);
                }
            } else {
                if (!$link->add()) {
                    user_error(__LINE__ . $link->error);
                }
            }
            return true;
        case '/blog/logs/referer':
            setProgress($item++ / $items * 100, _t('리퍼러 로그를 복원하고 있습니다.'));
            $log = new RefererLog();
            if (isset($node['path'][0]['.value'])) {
                $log->url = $node['path'][0]['.value'];
            } else {
                $log->url = $node['url'][0]['.value'];
            }
            $log->referred = $node['referred'][0]['.value'];
            if (!$log->add(false)) {
                user_error(__LINE__ . $log->error);
            }
            return true;
        case '/blog/commentsNotified/comment':
            setProgress($item++ / $items * 100, _t('댓글 알리미 내용을 복원하고 있습니다.'));
            $cmtNotified = new CommentNotified();
            $cmtNotified->id = $node['id'][0]['.value'];
            $cursor =& $node['commenter'][0];
            $cmtNotified->name = $cursor['name'][0]['.value'];
            $cmtNotified->homepage = $cursor['homepage'][0]['.value'];
            $cmtNotified->ip = $cursor['ip'][0]['.value'];
            $cmtNotified->entry = $node['entry'][0]['.value'];
            $cmtNotified->password = $node['password'][0]['.value'];
            $cmtNotified->content = $node['content'][0]['.value'];
            $cmtNotified->parent = $node['parent'][0]['.value'];
            $cmtNotified->secret = $node['secret'][0]['.value'];
            $cmtNotified->written = $node['written'][0]['.value'];
            $cmtNotified->modified = $node['modified'][0]['.value'];
            $cmtNotified->url = $node['url'][0]['.value'];
            $cmtNotified->isnew = $node['isNew'][0]['.value'];
            $site = new CommentNotifiedSiteInfo();
            if (!$site->open("url = '{$node['site'][0]['.value']}'")) {
                $site->title = '';
                $site->name = '';
                $site->modified = 31536000;
                $site->url = $node['site'][0]['.value'];
                $site->add();
            }
            $cmtNotified->siteid = $site->id;
            $site->close();
            $cmtNotified->remoteid = $node['remoteId'][0]['.value'];
            $cmtNotified->entrytitle = !isset($node['entryTitle'][0]['.value']) || empty($node['entryTitle'][0]['.value']) ? 'No title' : $node['entryTitle'][0]['.value'];
            $cmtNotified->entryurl = $node['entryUrl'][0]['.value'];
            if (!$cmtNotified->add()) {
                user_error(__LINE__ . $cmtNotified->error);
            }
            return true;
        case '/blog/commentsNotifiedSiteInfo/site':
            setProgress($item++ / $items * 100, _t('댓글 알리미 내용을 복원하고 있습니다.'));
            $cmtNotifiedSite = new CommentNotifiedSiteInfo();
            if ($cmtNotifiedSite->open("url = '{$node['url'][0]['.value']}'")) {
                if (intval($node['modified'][0]['.value']) > intval($cmtNotifiedSite->modified)) {
                    $cmtNotifiedSite->title = $node['title'][0]['.value'];
                    $cmtNotifiedSite->name = $node['name'][0]['.value'];
                    $cmtNotifiedSite->modified = $node['modified'][0]['.value'];
                }
                if (!$cmtNotifiedSite->update()) {
                    user_error(__LINE__ . $cmtNotifiedSite->error);
                }
            } else {
                $cmtNotifiedSite->url = $node['url'][0]['.value'];
                $cmtNotifiedSite->title = $node['title'][0]['.value'];
                $cmtNotifiedSite->name = $node['name'][0]['.value'];
                $cmtNotifiedSite->modified = $node['modified'][0]['.value'];
                if (!$cmtNotifiedSite->add()) {
                    user_error(__LINE__ . $cmtNotifiedSite->error);
                }
            }
            return true;
        case '/blog/statistics/referer':
            setProgress($item++ / $items * 100, _t('리퍼러 통계를 복원하고 있습니다.'));
            $statistics = new RefererStatistics();
            $statistics->host = $node['host'][0]['.value'];
            $statistics->count = $node['count'][0]['.value'];
            if (!$statistics->add()) {
                user_error(__LINE__ . $statistics->error);
            }
            return true;
        case '/blog/statistics/visits':
            setProgress($item++ / $items * 100, _t('블로그 통계 정보를 복원하고 있습니다.'));
            $statistics = new BlogStatistics();
            $statistics->visits = $node['.value'];
            if (!$statistics->add()) {
                user_error(__LINE__ . $statistics->error);
            }
            return true;
        case '/blog/statistics/daily':
            setProgress($item++ / $items * 100, _t('일별 통계 정보를 복원하고 있습니다.'));
            $statistics = new DailyStatistics();
            $statistics->date = $node['date'][0]['.value'];
            $statistics->visits = $node['visits'][0]['.value'];
            if (!$statistics->add()) {
                user_error(__LINE__ . $statistics->error);
            }
            return true;
        case '/blog/skin':
            setProgress($item++ / $items * 100, _t('스킨 설정을 복원하고 있습니다.'));
            $setting = new SkinSetting();
            if (false) {
                $setting->skin = $node['name'][0]['.value'];
                if (!$setting->save()) {
                    user_error(__LINE__ . $setting->error);
                }
                $setting->skin = null;
            }
            $setting->entriesOnRecent = $node['entriesOnRecent'][0]['.value'];
            $setting->commentsOnRecent = $node['commentsOnRecent'][0]['.value'];
            $setting->trackbacksOnRecent = $node['trackbacksOnRecent'][0]['.value'];
            $setting->commentsOnGuestbook = $node['commentsOnGuestbook'][0]['.value'];
            $setting->tagsOnTagbox = $node['tagsOnTagbox'][0]['.value'];
            $setting->alignOnTagbox = $node['alignOnTagbox'][0]['.value'];
            $setting->expandComment = $node['expandComment'][0]['.value'];
            $setting->expandTrackback = $node['expandTrackback'][0]['.value'];
            if (!empty($node['recentNoticeLength'][0]['.value'])) {
                $setting->recentNoticeLength = $node['recentNoticeLength'][0]['.value'];
            }
            $setting->recentEntryLength = $node['recentEntryLength'][0]['.value'];
            $setting->recentTrackbackLength = $node['recentTrackbackLength'][0]['.value'];
            $setting->linkLength = $node['linkLength'][0]['.value'];
            $setting->showListOnCategory = $node['showListOnCategory'][0]['.value'];
            $setting->showListOnArchive = $node['showListOnArchive'][0]['.value'];
            if (isset($node['tree'])) {
                $cursor =& $node['tree'][0];
                $setting->tree = $cursor['name'][0]['.value'];
                $setting->colorOnTree = $cursor['color'][0]['.value'];
                $setting->bgcolorOnTree = $cursor['bgColor'][0]['.value'];
                $setting->activecolorOnTree = $cursor['activeColor'][0]['.value'];
                $setting->activebgcolorOnTree = $cursor['activeBgColor'][0]['.value'];
                $setting->labelLengthOnTree = $cursor['labelLength'][0]['.value'];
                $setting->showValueOnTree = $cursor['showValue'][0]['.value'];
            }
            if (!$setting->save()) {
                user_error(__LINE__ . $setting->error);
            }
            return true;
        case '/blog/plugin':
            //			setProgress($item++ / $items * 100, _t('플러그인 설정을 복원하고 있습니다.'));
            //			$setting = new PluginSetting();
            //			$setting->name = $node['name'][0]['.value'];
            //			$setting->setting = $node['setting'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            return true;
        case '/blog/personalization':
            //			setProgress($item++ / $items * 100, _t('사용자 편의 설정을 복원하고 있습니다.'));
            //			$setting = new UserSetting();
            //			$setting->name = 'rowsPerPage';
            //			$setting->value = $node['rowsPerPage'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            //			$setting->name = 'readerPannelVisibility';
            //			$setting->value = $node['readerPannelVisibility'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            //			$setting->name = 'readerPannelHeight';
            //			$setting->value = $node['readerPannelHeight'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            //			$setting->name = 'lastVisitNotifiedPage';
            //			$setting->value = $node['lastVisitNotifiedPage'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            return true;
        case '/blog/userSetting':
            //			setProgress($item++ / $items * 100, _t('사용자 편의 설정을 복원하고 있습니다'));
            //			$setting = new UserSetting();
            //			$setting->name = $node['name'][0]['.value'];
            //			$setting->value = $node['value'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            return true;
        case '/blog/guestbook/comment':
            setProgress($item++ / $items * 100, _t('방명록을 복원하고 있습니다.'));
            $comment = new GuestComment();
            $comment->name = $node['commenter'][0]['name'][0]['.value'];
            if (!empty($node['id'][0]['.value'])) {
                $comment->id = $node['id'][0]['.value'];
            }
            if (!empty($node['commenter'][0]['.attributes']['id'])) {
                $comment->commenter = $node['commenter'][0]['.attributes']['id'];
            }
            if (!empty($node['commenter'][0]['homepage'][0]['.value'])) {
                $comment->homepage = $node['commenter'][0]['homepage'][0]['.value'];
            }
            if (!empty($node['commenter'][0]['ip'][0]['.value'])) {
                $comment->ip = $node['commenter'][0]['ip'][0]['.value'];
            }
            if (!empty($node['commenter'][0]['openid'][0]['.value'])) {
                $comment->openid = $node['commenter'][0]['openid'][0]['.value'];
            }
            $comment->password = $node['password'][0]['.value'];
            $comment->secret = @$node['secret'][0]['.value'];
            $comment->written = $node['written'][0]['.value'];
            $comment->content = $node['content'][0]['.value'];
            if (!$comment->add()) {
                user_error(__LINE__ . $comment->error);
            }
            if (isset($node['comment'])) {
                for ($j = 0; $j < count($node['comment']); $j++) {
                    $childComment = new GuestComment();
                    $childComment->parent = $comment->id;
                    $cursor =& $node['comment'][$j];
                    $childComment->name = $cursor['commenter'][0]['name'][0]['.value'];
                    if (!empty($cursor['id'][0]['.value'])) {
                        $comment->id = $cursor['id'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                        $childComment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                    }
                    if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                        $childComment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                        $childComment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
                        $childComment->openid = $cursor['commenter'][0]['openid'][0]['.value'];
                    }
                    $childComment->password = $cursor['password'][0]['.value'];
                    $childComment->secret = @$cursor['secret'][0]['.value'];
                    $childComment->written = $cursor['written'][0]['.value'];
                    $childComment->content = $cursor['content'][0]['.value'];
                    if (!$childComment->add()) {
                        user_error(__LINE__ . $childComment->error);
                    }
                }
            }
            return true;
        case '/blog/filter':
            setProgress($item++ / $items * 100, _t('필터 설정을 복원하고 있습니다.'));
            $filter = new Filter();
            $filter->type = $node['.attributes']['type'];
            $filter->pattern = $node['pattern'][0]['.value'];
            if (!$filter->add()) {
                user_error(__LINE__ . $filter->error);
            }
            return true;
        case '/blog/feed':
            setProgress($item++ / $items * 100, _t('리더 데이터를 복원하고 있습니다.'));
            $feed = new Feed();
            if (!empty($node['group'][0]['.value'])) {
                $feed->group = FeedGroup::getId($node['group'][0]['.value'], true);
            }
            $feed->url = $node['url'][0]['.value'];
            if (!$feed->add()) {
                user_error(__LINE__ . $feed->error);
            }
            return true;
        case '/blog/line':
            setProgress($item++ / $items * 100, _t('라인을 복원하고 있습니다.'));
            $line = Model_Line::getInstance();
            $line->reset();
            if (!empty($node['author'][0]['.value'])) {
                $line->author = $node['author'][0]['.value'];
            }
            if (!empty($node['category'][0]['.value'])) {
                $line->category = $node['category'][0]['.value'];
            }
            if (!empty($node['root'][0]['.value'])) {
                $line->root = $node['root'][0]['.value'];
            }
            if (!empty($node['permalink'][0]['.value'])) {
                $line->permalink = $node['permalink'][0]['.value'];
            }
            if (!empty($node['content'][0]['.value'])) {
                $line->content = $node['content'][0]['.value'];
            }
            if (!empty($node['created'][0]['.value'])) {
                $line->created = intval($node['created'][0]['.value']);
            }
            if ($line->add()) {
                return true;
            } else {
                user_error(__LINE__ . $line->_error);
            }
    }
}
Example #3
0
# MAIN - the beginning of execution for this page
############################################################################
$modelID = $_SESSION['bgjob']['modelID'];
$model = $_SESSION['models'][$modelID];
$pdbDir = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS;
$pdb = $pdbDir . '/' . $model['pdb'];
// Set up progress message
$tasks['convert'] = "Convert pdb with <code>remediator -oldout</code>";
$tasks['notebook'] = "Add entry to lab notebook";
setProgress($tasks, 'convert');
// updates the progress display if running as a background job
if (!file_exists($pdbDir)) {
    mkdir($pdbDir, 0777);
}
// shouldn't ever happen, but might...
$outpdb = $pdbDir . '/' . $modelID . "v23.pdb";
downgradePDB($pdb, $outpdb);
setProgress($tasks, 'notebook');
$outpdburl = $_SESSION['dataURL'] . '/' . MP_DIR_MODELS . '/' . $modelID . "v23.pdb";
$entry = "remediator was run on {$model['pdb']} to convert its atoms to PDB v2.3 format.\n";
$entry .= "<p>You can now <a href='{$outpdburl}'>download the converted PDB file with hydrogens</a> ";
$entry .= "or <a href='download_trimmed.php?{$_SESSION['sessTag']}&file={$outpdb}'>without hydrogens</a>.</p>\n";
$entry .= $pdbEntries;
//$entry .= "<p>A kinemage of all of the fragments is ready for viewing in KiNG: ".linkKinemage($modelID.'.kin')."</p>\n";
$_SESSION['bgjob']['labbookEntry'] = addLabbookEntry("Converted {$model['pdb']} to {$modelID}" . "v23.pdb.", $entry, "{$modelID}|{$newModel['id']}", "auto", "downgrade.gif");
setProgress($tasks, null);
############################################################################
// Clean up and go home
unset($_SESSION['bgjob']['processID']);
$_SESSION['bgjob']['endTime'] = time();
$_SESSION['bgjob']['isRunning'] = false;
}
$sql = "SELECT * FROM computers_deploy_tasks WHERE task_type=1 AND status=1";
$q = new mysql();
$q = new mysql();
$results = $q->QUERY_SQL($sql, "artica_backup");
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
    $GLOBALS[__FILE__]["TASKID"] = $ligne["ID"];
    $GLOBALS[__FILE__]["storage_id"] = $ligne["storage_id"];
    $GLOBALS[__FILE__]["group_id"] = $ligne["group_id"];
    echo "Find {$GLOBALS[__FILE__]["TASKID"]} task id\n";
    if (EXPLODE_COMPUTERS()) {
        setStatus(2);
        setProgress(1);
    } else {
        setStatus(-1);
        setProgress(0);
    }
}
ScanComputers();
function setProgress($pource)
{
    $sql = "UPDATE computers_deploy_tasks SET progress={$pource} WHERE ID={$GLOBALS[__FILE__]["TASKID"]}";
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "{$sql} {$q->mysql_error}\n";
    }
}
function setStatus($status)
{
    $sql = "UPDATE computers_deploy_tasks SET status={$status} WHERE ID={$GLOBALS[__FILE__]["TASKID"]}";
Example #5
0
function removeHydrogens($inpath, $outpath)
{
    $tasks = getProgressTasks();
    $tasks['reducetrim'] = "Remove hydrogens to avoid possible conflict with hydrogen lengths";
    $tmp1 = mpTempfile("tmp_pdb_");
    setProgress($tasks, 'reducetrim');
    reduceTrim($inpath, $tmp1);
    copy($tmp1, $outpath);
    // Clean up temp files
    unlink($tmp1);
    setProgress($tasks, null);
    // all done
}
Example #6
0
/**
* This is the uber-validation function that calls everything below.
* It is suited for use from either the web or command line interface.
* This only makes sense in terms of an active session.
*   modelID             ID code for model to process
*   opts                has the following keys mapped to boolean flags:
*     doKinemage        make the multi-criterion kinemage at all?
*       kinClashes      show clash dots?
*       kinHbonds       show H-bond dots?
*       kinContacts     show contact dots?
*       kinRama         show Rama outliers?
*       kinRota         show rotamer outliers?
*       kinGeom         show bond length and angle outliers?
*       kinCBdev        show C-beta deviations?
*       kinBaseP        show base-phosphate perpendiculars?
*       kinSuite        show RNA backbone conformational outliers?
*       kinAltConfs     show alternate conformations?
*       kinBfactor      show B-factor color model?
*       kinOccupancy    show occupancy color model?
*       kinRibbons      show ribbons?
*       kinForceViews   force running clashlist, etc to provide @views of bad spots?
*     doCharts          make the multi-criterion chart and other plots/tables/lists?
*       chartClashlist  run clashlistcluster?
*       chartRama       do Rama plots and analysis?
*       chartRota       do rotamer analysis?
*       chartGeom       do bond length and angle outliers?
*       chartCBdev      do CB dev plots and analysis?
*       chartBaseP      check base-phosphate perpendiculars?
*       chartSuite      check RNA backbone conformations?
*       chartHoriz      do horizontal chart?
*       chartCoot       do coot chart?
*       chartMulti      do html multi chart?
*       chartNotJustOut include residues that have no problems in the list?
*       chartAltloc     remove redundant residue rows when altlocs present?
*       chartImprove    compare to reduce -(no)build results to show improvement?
*
* This function returns some HTML suitable for using in a lab notebook entry.
*/
function runAnalysis($modelID, $opts)
{
    //{{{ Set up file/directory vars and the task list
    // If doKinemage or doCharts is off, turn off all their subordinates
    if (!$opts['doKinemage']) {
        foreach ($opts as $k => $v) {
            if (startsWith($k, 'kin')) {
                $opts[$k] = false;
            }
        }
    }
    if (!$opts['doCharts']) {
        foreach ($opts as $k => $v) {
            if (startsWith($k, 'chart')) {
                $opts[$k] = false;
            }
        }
    }
    if ($opts['kinForceViews']) {
        foreach ($opts as $k => $v) {
            if (startsWith($k, 'chart')) {
                $opts[$k] = true;
            }
        }
    }
    $model = $_SESSION['models'][$modelID];
    $modelDir = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS;
    $modelURL = $_SESSION['dataURL'] . '/' . MP_DIR_MODELS;
    $kinDir = $_SESSION['dataDir'] . '/' . MP_DIR_KINS;
    $kinURL = $_SESSION['dataURL'] . '/' . MP_DIR_KINS;
    if (!file_exists($kinDir)) {
        mkdir($kinDir, 0777);
    }
    $rawDir = $_SESSION['dataDir'] . '/' . MP_DIR_RAWDATA;
    if (!file_exists($rawDir)) {
        mkdir($rawDir, 0777);
    }
    $chartDir = $_SESSION['dataDir'] . '/' . MP_DIR_CHARTS;
    $chartURL = $_SESSION['dataURL'] . '/' . MP_DIR_CHARTS;
    if (!file_exists($chartDir)) {
        mkdir($chartDir, 0777);
    }
    $xrayDir = $_SESSION['dataDir'] . '/' . MP_DIR_XRAYDATA;
    $infile = "{$modelDir}/{$model['pdb']}";
    $reduce_blength = $_SESSION['reduce_blength'];
    if (isset($model['mtz_file'])) {
        $mtz_file = $model['mtz_file'];
    } else {
        $mtz_file = $_SESSION['models'][$model['parent']]['mtz_file'];
    }
    if ($opts['chartRama']) {
        $tasks['rama'] = "Do Ramachandran analysis and make plots (<code>ramalyze</code>)";
    }
    if ($opts['chartRota']) {
        $tasks['rota'] = "Do rotamer analysis (<code>rotalyze</code>)";
    }
    if ($opts['chartCBdev']) {
        $tasks['cbeta'] = "Do C&beta; deviation analysis and make kins (<code>cbetadev</code>)";
    }
    if ($opts['chartOmega']) {
        $tasks['omega'] = "Do cis-peptide analysis (<code>omegalyze</code>)";
    }
    if ($opts['chartCablamLow']) {
        $tasks['cablam'] = "Do CaBLAM analysis (<code>cablam_validate</code>)";
    }
    if ($opts['chartBaseP']) {
        $tasks['base-phos'] = "Do RNA sugar pucker analysis";
    }
    if ($opts['chartSuite']) {
        $tasks['suitename'] = "Do RNA backbone conformations analysis";
    }
    if ($model['stats']['use_cdl']) {
        $geomsg = "Using CDL";
    } else {
        $geomsg = "";
    }
    if ($opts['chartGeom']) {
        $tasks['geomValidation'] = "Do bond length and angle geometry analysis (<code>mp_geo</code>) {$geomsg}";
    }
    if ($opts['chartClashlist']) {
        $tasks['clashlist'] = "Run <code>clashscore</code> to find bad clashes and clashscore";
    }
    if ($opts['chartImprove']) {
        $tasks['improve'] = "Suggest / report on fixes";
    }
    if ($opts['doCharts'] && !$opts['chartMulti']) {
        $tasks['chartsummary'] = "Create summary chart";
    }
    if ($opts['chartMulti']) {
        $tasks['multichart'] = "Create multi-criterion chart";
    }
    if ($opts['chartHoriz']) {
        $tasks['runRSCC'] = "Run real-space correlation";
        $tasks['charthoriz'] = "Create horizontal RSCC chart";
    }
    if ($opts['chartCoot']) {
        $tasks['cootchart'] = "Create chart for use in Coot";
    }
    if ($opts['doKinemage']) {
        $tasks['multikin'] = "Create multi-criterion kinemage";
    }
    //if($opts['doLowRes'])       $tasks['lowResKin'] = "Create low-resolution multi-criterion kinemage";
    //$doRem40 = $opts['chartClashlist'] || $opts['chartRama'] || $opts['chartRota'];
    //if($doRem40)                $tasks['remark40'] = "Create REMARK  40 record for the PDB file";
    //}}} Set up file/directory vars and the task list
    //{{{ Run geometry programs and offer kins to user
    //{{{ Ramachandran
    if ($opts['chartRama']) {
        $startTime = time();
        setProgress($tasks, 'rama');
        // updates the progress display if running as a background job
        $outfile = "{$rawDir}/{$model['prefix']}rama.data";
        runRamachandran($infile, $outfile);
        $rama = loadRamachandran($outfile);
        makeRamachandranKin($infile, "{$kinDir}/{$model['prefix']}rama.kin");
        $tasks['rama'] .= " - preview <a href='viewking.php?{$_SESSION['sessTag']}&url={$kinURL}/{$model['prefix']}rama.kin' target='_blank'>kinemage</a>";
        setProgress($tasks, 'rama');
        // so the preview link is visible
        makeRamachandranPDF($infile, "{$chartDir}/{$model['prefix']}rama.pdf");
        $tasks['rama'] .= " | <a href='{$chartURL}/{$model['prefix']}rama.pdf' target='_blank'>PDF</a>\n";
        setProgress($tasks, 'rama');
        // so the preview link is visible
        echo "Ramachandran ran for " . (time() - $startTime) . " seconds\n";
    }
    //}}}
    //{{{ Rotamers
    if ($opts['chartRota']) {
        $startTime = time();
        setProgress($tasks, 'rota');
        // updates the progress display if running as a background job
        $outfile = "{$rawDir}/{$model['prefix']}rota.data";
        runRotamer($infile, $outfile);
        $rota = loadRotamer($outfile);
        echo "Rotamers ran for " . (time() - $startTime) . " seconds\n";
    }
    //}}}
    //{{{ C-beta deviations
    if ($opts['chartCBdev']) {
        $startTime = time();
        setProgress($tasks, 'cbeta');
        // updates the progress display if running as a background job
        $outfile = "{$rawDir}/{$model['prefix']}cbdev.data";
        runCbetaDev($infile, $outfile);
        $cbdev = loadCbetaDev($outfile);
        makeCbetaDevPlot($infile, "{$kinDir}/{$model['prefix']}cbetadev.kin");
        $tasks['cbeta'] .= " - <a href='viewking.php?{$_SESSION['sessTag']}&url={$kinURL}/{$model['prefix']}cbetadev.kin' target='_blank'>preview</a>";
        setProgress($tasks, 'cbeta');
        // so the preview link is visible
        echo "C-beta ran for " . (time() - $startTime) . " seconds\n";
    }
    //}}}
    //{{{ Omega peptides
    if ($opts['chartOmega']) {
        $startTime = time();
        setProgress($tasks, 'omega');
        $outfile = "{$rawDir}/{$model['prefix']}omega.data";
        //$outfile = "$rawDir/$model[prefix]omega-clashlist.txt";
        runOmegalyze($infile, $outfile);
        $omega = loadOmegalyze($outfile);
        echo "Omegalyze ran for " . (time() - $startTime) . " seconds\n";
    }
    //}}}
    //{{{ CaBLAM
    if ($opts['chartCablamLow']) {
        setProgress($tasks, 'cablam');
        $outfile = "{$rawDir}/{$model['prefix']}cablam.data";
        runCablam($infile, $outfile);
        $cablam = loadCablam($outfile);
    }
    //}}}
    //{{{ Run nucleic acid geometry programs and offer kins to user
    //{{{ Base-phosphate perpendiculars
    if ($opts['chartBaseP']) {
        setProgress($tasks, 'base-phos');
        // updates the progress display if running as a background job
        $outfile = "{$rawDir}/{$model['prefix']}pperp.data";
        runBasePhosPerp($infile, $outfile);
        $pperp = loadBasePhosPerp($outfile);
    }
    //}}}
    //{{{ Suitename
    if ($opts['chartSuite']) {
        setProgress($tasks, 'suitename');
        // updates the progress display if running as a background job
        $outfile = "{$chartDir}/{$model['prefix']}suitename.txt";
        runSuitenameReport($infile, $outfile);
        $suites = loadSuitenameReport($outfile);
        $tasks['suitename'] .= " - <a href='viewtext.php?{$_SESSION['sessTag']}&file={$outfile}&mode=plain' target='_blank'>preview</a>\n";
        setProgress($tasks, 'suitename');
        // so the preview link is visible
        $outfile = "{$chartDir}/{$model['prefix']}suitestring.txt";
        runSuitenameString($infile, $outfile);
        makeSuitenameKin($infile, "{$kinDir}/{$model['prefix']}suitename.kin");
    }
    //}}}
    //}}} Run nucleic acid geometry programs and offer kins to user
    //{{{ Bonds and Angles
    if ($opts['chartGeom']) {
        setProgress($tasks, 'geomValidation');
        // updates the progress display if running as a background job
        $geomfile = "{$rawDir}/{$model['prefix']}geomvalidation.data";
        runValidationReport($infile, $geomfile, $model['stats']['use_cdl']);
        //$protfile = "$rawDir/$model[prefix]protvalidation.data";
        //runValidationReport($infile, $protfile, "protein");
        //$rnafile = "$rawDir/$model[prefix]rnavalidation.data";
        //runValidationReport($infile, $rnafile, "rna");
        //$validate_bond  = loadValidationBondReport($protfile,"protein");
        //if (is_array($validate_bond))
        $validate_bond = array_merge(loadValidationBondReport($geomfile, "protein"), loadValidationBondReport($geomfile, "rna"));
        if (count($validate_bond) == 0) {
            $validate_bond = null;
        }
        $validate_angle = array_merge(loadValidationAngleReport($geomfile, "protein"), loadValidationAngleReport($geomfile, "rna"));
        if (count($validate_angle) == 0) {
            $validate_angle = null;
        }
    }
    //}}}
    //}}} Run programs and offer kins to user
    //{{{ Run all-atom contact programs and offer kins to user
    // Clashes
    if ($opts['chartClashlist']) {
        $startTime = time();
        setProgress($tasks, 'clashlist');
        // updates the progress display if running as a background job
        $outfile = "{$chartDir}/{$model['prefix']}clashlist.txt";
        #runClashlist($infile, $outfile, $reduce_blength);
        runClashscore($infile, $outfile, $reduce_blength);
        #$clash = loadClashlist($outfile);
        $clash = loadClashscore($outfile);
        //$clashPct = runClashStats($model['stats']['resolution'], $clash['scoreAll'], $clash['scoreBlt40']);
        $tasks['clashlist'] .= " - <a href='viewtext.php?{$_SESSION['sessTag']}&file={$outfile}&mode=plain' target='_blank'>preview</a>\n";
        setProgress($tasks, 'clashlist');
        // so the preview link is visible
        echo "chartClashlist ran for " . (time() - $startTime) . " seconds\n";
    }
    //}}} Run all-atom contact programs and offer kins to user
    //{{{ Run real-space correlation
    $model['raw_rscc_name'] = "{$model['parent']}_raw.rscc";
    $model['rscc_name'] = "{$model['parent']}.rscc";
    $rscc_out = "{$xrayDir}/{$model['parent']}.rscc";
    $rscc_prequel_out = "{$xrayDir}/{$model['parent']}_prequel.rscc";
    if ($opts['chartHoriz']) {
        $startTime = time();
        setProgress($tasks, 'runRSCC');
        runRscc($infile, $mtz_file, $rscc_out, $rscc_prequel_out);
        echo "runRscc ran for " . (time() - $startTime) . " seconds\n";
        echo $mtz_file;
        echo isset($mtz_file);
    }
    //}}}
    //{{{ Report on improvements (that could be) made by MolProbity
    $improveText = "";
    if ($opts['chartImprove'] && ($clash || $rota)) {
        $startTime = time();
        setProgress($tasks, 'improve');
        // updates the progress display if running as a background job
        $altpdb = mpTempfile("tmp_altH_pdb_");
        $mainClashscore = $clash ? $clash['scoreAll'] : 0;
        $mainRotaCount = $rota ? count(findRotaOutliers($rota)) : 0;
        $improvementList = array();
        if ($model['isBuilt']) {
            $altInpath = $modelDir . '/' . $_SESSION['models'][$model['parent']]['pdb'];
            reduceNoBuild($altInpath, $altpdb, $reduce_blength);
            // Rotamers
            $outfile = mpTempfile("tmp_rotamer_");
            runRotamer($altpdb, $outfile);
            $altrota = loadRotamer($outfile);
            $altRotaCount = count(findRotaOutliers($altrota));
            if ($altRotaCount > $mainRotaCount) {
                if ($altRotaCount - $mainRotaCount > 1) {
                    $improvementList[] = "fixed " . ($altRotaCount - $mainRotaCount) . " bad rotamers";
                } else {
                    $improvementList[] = "fixed " . ($altRotaCount - $mainRotaCount) . " bad rotamer";
                }
            }
            unlink($outfile);
            // Clashes
            $outfile = mpTempfile("tmp_clashlist_");
            #runClashlist($altpdb, $outfile, $reduce_blength);
            runClashscore($altpdb, $outfile, $reduce_blength);
            #$altclash = loadClashlist($outfile);
            $altclash = loadClashscore($outfile);
            if ($altclash['scoreAll'] - $mainClashscore >= 0.005) {
                //0.005 is the smallest change that will still be reported by the sprintf("%.2f") below
                $improvementList[] = "improved your clashscore by " . sprintf("%.2f", $altclash['scoreAll'] - $mainClashscore) . " points";
            }
            unlink($outfile);
            if (count($improvementList) > 0) {
                $improveText .= "<div class='feature'>By adding H to this model and allowing Asn/Gln/His flips, you have already ";
                $improveText .= implode(" and ", $improvementList);
                $improveText .= ".  <br /><b>Make sure you download the modified PDB to take advantage of these improvements! <br />NOTE: Atom positions have changed, so refinement to idealize geometry is necessary.</b></div>\n";
            }
        } elseif ($mainClashscore > 0 || $mainRotaCount > 0) {
            if ($model['parent']) {
                $altInpath = $_SESSION['models'][$model['parent']]['pdb'];
            } else {
                $altInpath = $model['pdb'];
            }
            $altInpath = "{$modelDir}/{$altInpath}";
            reduceBuild($altInpath, $altpdb, $reduce_blength);
            if ($mainRotaCount > 0) {
                $outfile = mpTempfile("tmp_rotamer_");
                runRotamer($altpdb, $outfile);
                $altrota = loadRotamer($outfile);
                $altRotaCount = count(findRotaOutliers($altrota));
                if ($altRotaCount < $mainRotaCount) {
                    $improvementList[] = "fix " . ($mainRotaCount - $altRotaCount) . " bad rotamers";
                }
                unlink($outfile);
            }
            if ($mainClashscore > 0) {
                $outfile = mpTempfile("tmp_clashlist_");
                #runClashlist($altpdb, $outfile, $reduce_blength);
                runClashscore($altpdb, $outfile, $reduce_blength);
                #$altclash = loadClashlist($outfile);
                $altclash = loadClashscore($outfile);
                if ($mainClashscore - $altclash['scoreAll'] >= 0.005) {
                    //0.005 is the smallest change that will still be reported by the sprintf("%.2f") below
                    $improvementList[] = "improve your clashscore by " . sprintf("%.2f", $mainClashscore - $altclash['scoreAll']) . " points";
                }
                unlink($outfile);
            }
            if (count($improvementList) > 0) {
                $improveText .= "<div class='feature'>By adding H to this model and allowing Asn/Gln/His flips, we could <i>automatically</i> ";
                $improveText .= implode(" and ", $improvementList);
                $improveText .= ".</div>\n";
            }
        }
        unlink($altpdb);
        echo "chart Improve ran for " . (time() - $startTime) . " seconds\n";
    }
    //}}} Report on improvements (that could be) made by by MolProbity
    //{{{ Build multi-criterion chart, kinemage, horizontal, chart
    if ($opts['doCharts']) {
        $startTime = time();
        if ($opts['chartMulti']) {
            setProgress($tasks, 'multichart');
            // updates the progress display if running as a background job
        } else {
            setProgress($tasks, 'chartsummary');
        }
        $outfile = "{$rawDir}/{$model['prefix']}multi.table";
        $snapfile = "{$chartDir}/{$model['prefix']}multi.html";
        $resout = "{$rawDir}/{$model['prefix']}multi_res.table";
        writeMulticritChart($infile, $outfile, $snapfile, $resout, $clash, $rama, $rota, $cbdev, $pperp, $suites, $validate_bond, $validate_angle, $cablam, $omega, !$opts['chartNotJustOut'], $opts['chartMulti'], $opts['chartAltloc']);
        if ($opts['chartMulti']) {
            $tasks['multichart'] .= " - <a href='viewtable.php?{$_SESSION['sessTag']}&file={$outfile}' target='_blank'>preview</a>\n";
            setProgress($tasks, 'multichart');
            // so the preview link is visible
        } else {
            $tasks['chartsummary'] .= " - <a href='viewtable.php?{$_SESSION['sessTag']}&file={$outfile}' target='_blank'>preview</a>\n";
            setProgress($tasks, 'chartsummary');
            // so the preview link is visible
        }
        if ($opts['chartHoriz']) {
            setProgress($tasks, 'charthoriz');
            $horiz_table_file = "{$rawDir}/{$model['prefix']}horiz.table";
            writeHorizontalChart($resout, $rscc_out, $outfile, $horiz_table_file, $rscc_prequel_out);
        }
        if ($opts['chartCoot']) {
            setProgress($tasks, 'cootchart');
            $outfile = "{$chartDir}/{$model['prefix']}multi-coot.scm";
            $outfile_py = "{$chartDir}/{$model['prefix']}multi-coot.py";
            #makeCootMulticritChart($infile, $outfile, $clash, $rama, $rota, $cbdev, $pperp);
            makeCootClusteredChart($infile, $outfile, $outfile_py, $clash, $rama, $rota, $cbdev, $pperp);
        }
        echo "do Charts ran for " . (time() - $startTime) . " seconds\n";
    }
    if ($opts['doKinemage']) {
        $startTime = time();
        setProgress($tasks, 'multikin');
        // updates the progress display if running as a background job
        $mcKinOpts = array('ribbons' => $opts['kinRibbons'], 'Bscale' => $opts['kinBfactor'], 'Qscale' => $opts['kinOccupancy'], 'altconf' => $opts['kinAltConfs'], 'rama' => $opts['kinRama'], 'rota' => $opts['kinRota'], 'geom' => $opts['kinGeom'], 'cbdev' => $opts['kinCBdev'], 'omega' => $opts['kinOmega'], 'cablam' => $opts['kinCablamLow'], 'pperp' => $opts['kinBaseP'], 'clashdots' => $opts['kinClashes'], 'hbdots' => $opts['kinHbonds'], 'vdwdots' => $opts['kinContacts']);
        $outfile = "{$kinDir}/{$model['prefix']}multi.kin";
        $viewRes = array();
        //echo "kinForceViews = ".$opts['kinForceViews']."\n";
        if ($opts['kinForceViews']) {
            //echo "Ran calcLocalBadness\n";
            $viewRes = array_keys(calcLocalBadness($infile, 10, $clash, $rama, $rota, $cbdev, $pperp));
        }
        makeMulticritKin2(array($infile), $outfile, $mcKinOpts, $viewRes);
        // EXPERIMENTAL: gzip compress large multikins
        if (filesize($outfile) > MP_KIN_GZIP_THRESHOLD) {
            destructiveGZipFile($outfile);
        }
        echo "do Kinemage ran for " . (time() - $startTime) . " seconds\n";
    }
    //}}} Build multi-criterion chart, kinemage
    //{{{ Low-resolution-specific analyses
    //Low-res kinemage is being simplified and merged into main kinemage
    //if($opts['doLowRes'])
    //{
    //  if($opts['kinCablamLow'] || $opts['other'])
    //  {
    //      $startTime = time();
    //      setProgress($tasks, 'lowResKin');
    //      $lowResKinOpts = array(//first column is opts, second column sets true-false
    //          'ribbons'    =>  $opts['kinRibbons'],//pass pdb w/HELIX+SHEET for this
    //          'rama'       =>  $opts['kinRama'],
    //          'geom'       =>  $opts['kinGeom'],
    //          'cbdev'      =>  $opts['kinCBdev'],
    //          'omega'      =>  $opts['kinOmega'],
    //          'cablam'     =>  $opts['kinCablamLow'],
    //          'clashdots'  =>  $opts['kinClashes']
    //      );
    //      $outfile = "$kinDir/$model[prefix]low_multi.kin";
    //      $cablamSecStrucFile = "$modelDir/$model[prefix]cablam_sec_struc_records.pdb";
    //      //$viewRes = array(); //Used with opts[kinForceViews], not necessary argument for makeMulticritKin2
    //      makeMulticritKinLowRes(array($infile), $outfile, $cablamSecStrucFile, $lowResKinOpts);
    //      if(filesize($outfile) > MP_KIN_GZIP_THRESHOLD)  destructiveGZipFile($outfile);
    //      echo "do low-res Kinemage ran for ".(time() - $startTime)." seconds\n";
    //  }
    //}
    //}}}
    //{{{ Create REMARK  40 and insert into PDB file
    //if(is_array($clash) || is_array($rama) || is_array($rota))
    //{
    //    setProgress($tasks, 'remark40'); // updates the progress display if running as a background job
    //    $remark40 = makeRemark40($clash, $rama, $rota);
    //    replacePdbRemark($infile, $remark40,  40);
    //}
    //}}} Create REMARK  40 and insert into PDB file
    //{{{ Create lab notebook entry
    $entry = "";
    if (is_array($clash) || is_array($rama) || is_array($rota) || is_array($cbdev) || is_array($pperp) || is_array($suites)) {
        $entry .= "<h3>Summary statistics</h3>\n";
        $entry .= makeSummaryStatsTable($model['stats']['resolution'], $clash, $rama, $rota, $cbdev, $pperp, $suites, $validate_bond, $validate_angle, $cablam, $omega);
    }
    $entry .= $improveText;
    if ($opts['doKinemage'] || $opts['doCharts']) {
        $entry .= "<h3>Multi-criterion visualizations</h3>\n";
        $entry .= "<div class='indent'>\n";
        $entry .= "<table width='100%' border='0'><tr valign='top'>\n";
        if ($opts['doKinemage']) {
            $entry .= "<td>" . linkAnyFile("{$model['prefix']}multi.kin", "Kinemage", "img/multikin.jpg") . "</td>\n";
        }
        if ($opts['doCharts']) {
            $entry .= "<td>" . linkAnyFile("{$model['prefix']}multi.table", "Chart", "img/multichart.jpg") . "</td>\n";
            if ($opts['chartCoot']) {
                $entry .= "<td>" . linkAnyFile("{$model['prefix']}multi-coot.scm", "To-do list for Coot", "img/multichart-coot.jpg") . "<br><small><i>Open this in Coot 0.1.2 or later using Calculate | Run Script...</i></small></td>\n";
                #$entry .= "<td>".linkAnyFile("$model[prefix]multi-coot.py", "To-do list for Coot Python", "img/multichart-coot.jpg")."<br><small><i>Open this in Coot 0.1.2 or later using Calculate | Run Script...</i></small></td>\n";
            }
            if ($opts['chartHoriz']) {
                $entry .= "<td>" . linkAnyFile("{$model['prefix']}horiz.table", "Horizontal Chart", "img/multichart_horiz.jpg") . "</td>\n";
            }
        }
        //if($opts['doLowRes']) {
        //    if($opts['kinCablamLow'] || $opts['other']) {
        //        $entry .= "<td>".linkAnyFile("$model[prefix]low_multi.kin", "LowRes MultiKin", "img/low_multikin.jpg")."</td>\n";
        //    }
        //}
        $entry .= "</tr></table>\n";
        $entry .= "</div>\n";
    }
    if ($opts['chartClashlist'] || $opts['chartRama'] || $opts['chartCBdev'] || $opts['chartSuite']) {
        $entry .= "<h3>Single-criterion visualizations</h3>";
        $entry .= "<ul>\n";
        if ($opts['chartClashlist']) {
            $entry .= "<li>" . linkAnyFile("{$model['prefix']}clashlist.txt", "Clash list") . "</li>\n";
        }
        if ($opts['chartRama']) {
            $entry .= "<li>" . linkAnyFile("{$model['prefix']}rama.kin", "Ramachandran plot kinemage") . "</li>\n";
            $entry .= "<li>" . linkAnyFile("{$model['prefix']}rama.pdf", "Ramachandran plot PDF") . "</li>\n";
        }
        if ($opts['chartCBdev']) {
            $entry .= "<li>" . linkAnyFile("{$model['prefix']}cbetadev.kin", "C&beta; deviation scatter plot") . "</li>\n";
        }
        if ($opts['chartSuite']) {
            $entry .= "<li>" . linkAnyFile("{$model['prefix']}suitename.txt", "RNA backbone report") . "</li>\n";
            $entry .= "<li>" . linkAnyFile("{$model['prefix']}suitestring.txt", "RNA backbone conformation \"sequence\"") . "</li>\n";
            $entry .= "<li>" . linkAnyFile("{$model['prefix']}suitename.kin", "RNA backbone multi-D plot of conformations") . "</li>\n";
        }
        $entry .= "</ul>\n";
    }
    if ($remark40) {
        $entry .= "<h3>REMARK  40</h3>";
        $url = "{$modelURL}/{$model['pdb']}";
        $entry .= "You can <a href='{$url}'>download your PDB file with REMARK  40</a> inserted, or the same <a href='download_trimmed.php?{$_SESSION['sessTag']}&file={$infile}'> without hydrogens</a>.\n";
        $entry .= "<p><pre>{$remark40}</pre></p>";
    }
    //}}} Create lab notebook entry
    setProgress($tasks, null);
    // everything is finished
    return $entry;
}
if (!defined('__DIR__')) {
    define('__DIR__', dirname(__FILE__));
}
ini_set('max_execution_time', 60);
// The bigger this number, the longer the request will take
$max = 100000000;
/**
 * Store the current progress in a file to be read by status.php
 * @param $progress
 */
function setProgress($progress)
{
    $file = __DIR__ . '/p';
    if (!is_file($file)) {
        touch($file);
    }
    file_put_contents($file, $progress);
}
// Loop to delay the request a lot
for ($i = 0; $i < $max; $i++) {
    /**
     * Each 100'000 runs, the progress will be "recorded"
     * This is where you should learn what number is good for your loop that won't affect
     * the requests' performance.
     */
    if ($i % 100000 === 0) {
        setProgress($i * 100 / $max);
    }
}
echo rand(1, 100);
Example #8
0
function setProgressOf($i, $total)
{
    setProgress(percentOf($i, $total));
}
for ($i = 0; $i <= 99; $i++) {
    $num = str_pad($i, 2, "0", STR_PAD_LEFT);
    exec("cd {$path_something} && " . $downloader . "http://symbol.yr.no/grafikk/sym/b100/mf/01n.{$num}.png > /dev/null 2>&1 &");
    usleep($sleep_time);
    setProgress(++$counter, "moon");
    exec("cd {$path_something} && " . $downloader . "http://symbol.yr.no/grafikk/sym/b100/mf/02n.{$num}.png > /dev/null 2>&1 &");
    usleep($sleep_time);
    setProgress(++$counter, "moon");
    exec("cd {$path_something} && " . $downloader . "http://symbol.yr.no/grafikk/sym/b100/mf/03n.{$num}.png > /dev/null 2>&1 &");
    usleep($sleep_time);
    setProgress(++$counter, "moon");
    exec("cd {$path_something} && " . $downloader . "http://symbol.yr.no/grafikk/sym/b100/mf/05n.{$num}.png > /dev/null 2>&1 &");
    usleep($sleep_time);
    setProgress(++$counter, "moon");
    exec("cd {$path_something} && " . $downloader . "http://symbol.yr.no/grafikk/sym/b100/mf/06n.{$num}.png > /dev/null 2>&1 &");
    usleep($sleep_time);
    setProgress(++$counter, "moon");
    exec("cd {$path_something} && " . $downloader . "http://symbol.yr.no/grafikk/sym/b100/mf/07n.{$num}.png > /dev/null 2>&1 &");
    usleep($sleep_time);
    setProgress(++$counter, "moon");
    exec("cd {$path_something} && " . $downloader . "http://symbol.yr.no/grafikk/sym/b100/mf/08n.{$num}.png > /dev/null 2>&1 &");
    usleep($sleep_time);
    setProgress(++$counter, "moon");
}
echo "\nDone! Downloaded {$counter} files\n";
// A function to update counter
function setProgress($current, $thing)
{
    global $max;
    echo "\r" . chr(27) . "[K" . "Downloading... ({$thing}) ({$current} files) " . (int) ($current / $max * 100) . "%";
}
Example #10
0
 * @apiPermission Anonymous User
 *
 * @apiParamExample {json} Request-Example:
 *     {
 *       "unit": "42"
 *     }
 *
 * @apiSuccessExample {json} Success-Response:
 *     HTTP/1.1 200 OK
 * 
 * @apiErrorExample {json} Error-Response:
 *     HTTP/1.1 401 Unauthorized
 *     {
 *       "error": "You are not logged in!"
 *     }
 *
 */
$app->post('/progress/unit', function () {
    $progress = json_decode(file_get_contents("php://input"), true);
    setProgressViewed($progress['unit']);
});
$app->post('/progress/layer', function () {
    $progress = json_decode(file_get_contents("php://input"), true);
    setProgress($progress['layer'], $progress['time'], $progress['success'], $progress['score']);
});
$app->get('/progress/channel/:id', function ($id) {
    getProgressChannel($id);
});
$app->get('/progress/unit/:id(/details)', function ($id) {
    getProgressUnit($id, isset($_GET['details']) && $_GET['details'] == 1 ? true : false);
});
Example #11
0
        $diff .= 'pts.innerHTML = "(' . $sub . ')";';
    }
    if (!empty($diff)) {
        ?>
<script type="text/javascript">
	//<![CDATA[
		<?php 
        echo $diff;
        ?>
	//]]>
</script>
<?php 
        flush();
    }
}
setProgress(0, _t('최적화 작업을 진행할 테이블을 확인하고 있습니다.'));
$items = 0;
set_time_limit(0);
$item = 0;
$optimized = 0;
$tcTables = getDefinedTableNames();
$tcPluginTables = getPluginTableName();
$workarounds = array_merge($tcTables, $tcPluginTables);
$items = $items + count($tcTables) + count($tcPluginTables);
foreach ($workarounds as $work) {
    setProgress($item++ / ($items * 100), _f('%1 테이블을 최적화하고 있습니다.', $work));
    POD::query("OPTIMIZE TABLE {$work}");
    $optimized++;
}
setProgress(100, _t('완료되었습니다.') . "({$optimized})");
finish();
Example #12
0
function getMaps($code)
{
    global $map_notebook_msg;
    $map_notebook_msg = "";
    $prog = getProgressTasks();
    if ($_SESSION['bgjob']['eds_2fofc']) {
        $prog['2fofc'] = "Download 2Fo-Fc map from the EDS";
    }
    if ($_SESSION['bgjob']['eds_fofc']) {
        $prog['fofc'] = "Download Fo-Fc (difference) map from the EDS";
    }
    $mapDir = "{$_SESSION['dataDir']}/" . MP_DIR_EDMAPS;
    if (!file_exists($mapDir)) {
        mkdir($mapDir, 0777);
    }
    if ($_SESSION['bgjob']['eds_2fofc']) {
        setProgress($prog, '2fofc');
        $mapName = "{$code}.omap.gz";
        $mapPath = "{$mapDir}/{$mapName}";
        if (!file_exists($mapPame)) {
            $tmpMap = getEdsMap($code, 'omap', '2fofc');
            if ($tmpMap && copy($tmpMap, $mapPath)) {
                unlink($tmpMap);
                $_SESSION['edmaps'][$mapName] = $mapName;
                mpLog("edmap-eds:User requested 2Fo-Fc map for {$code} from the EDS");
                $map_notebook_msg .= "<p>The 2Fo-Fc map for {$code} was successfully retrieved from the EDS.</p>\n";
            } else {
                $map_notebook_msg .= "<p><div class='alert'>The 2Fo-Fc map for {$code} could not be retrieved from the EDS.</div></p>\n";
            }
        } else {
            echo "Map file already exists";
        }
    }
    if ($_SESSION['bgjob']['eds_fofc']) {
        setProgress($prog, 'fofc');
        $mapName = "{$code}-diff.omap.gz";
        $mapPath = "{$mapDir}/{$mapName}";
        if (!file_exists($mapPame)) {
            $tmpMap = getEdsMap($code, 'omap', 'fofc');
            if ($tmpMap && copy($tmpMap, $mapPath)) {
                unlink($tmpMap);
                $_SESSION['edmaps'][$mapName] = $mapName;
                mpLog("edmap-eds:User requested Fo-Fc map for {$code} from the EDS");
                $map_notebook_msg .= "<p>The Fo-Fc map for {$code} was successfully retrieved from the EDS.</p>\n";
            } else {
                $map_notebook_msg .= "<p><div class='alert'>The Fo-Fc map for {$code} could not be retrieved from the EDS.</div></p>\n";
            }
        }
    }
    setProgress($prog, null);
}