コード例 #1
0
function smarty_modifier_sp($str, $args)
{
    if ($args != 1) {
        return $str;
    }
    $mt = MT::get_instance();
    $ctx =& $mt->context();
    $websiteId = $ctx->__stash['blog']->blog_parent_id || 0;
    if ($websiteId) {
        $website = $mt->db()->fetch_blog($websiteId);
        $websiteUrl = $website->site_url;
        $cfg = $mt->db()->fetch_plugin_data('ModifyURL', 'configuration:blog:' . $websiteId);
        $path = $cfg['path_setting'];
    } else {
        $websiteUrl = $ctx->__stash['blog']->site_url;
        $cfg = $mt->db()->fetch_plugin_data('ModifyURL', 'configuration:blog:' . $ctx->__stash['blog_id']);
        $path = $cfg['path_setting'];
    }
    if (strpos($str, 'http') === FALSE) {
        $blog_path = preg_replace('/https?:\\/\\/[^\\/]+/', '', $websiteUrl);
        if ($blog_path === '/') {
            $str = $blog_path . $path . $str;
        } else {
            if (preg_match('/\\/$/', $blog_path)) {
                $str = $blog_path . $path . '/' . str_replace($blog_path, '', $str);
            } else {
                $str = '/' . $path . $str;
            }
        }
    } else {
        $str = str_replace($websiteUrl, $websiteUrl . $path . '/', $str);
    }
    return $str;
}
コード例 #2
0
function smarty_modifier_nofollowfy($str, $arg = 1)
{
    # manipulate hyperlinks in $str...
    if (!isset($str)) {
        return $str;
    }
    if (!$arg) {
        return $str;
    }
    $mt = MT::get_instance();
    $ctx =& $mt->context();
    $blog = $ctx->stash('blog');
    $curr_tag = $ctx->_tag_stack[count($ctx->_tag_stack) - 1];
    $enable = false;
    if (isset($curr_tag[1]['nofollowfy'])) {
        $enable = $curr_tag[1]['nofollowfy'] ? true : false;
    }
    if (!$enable && !$blog->blog_nofollow_urls) {
        return $str;
    }
    $arg = strtolower($arg);
    if ($arg == 'mtcommentbody' || $arg == 'mtcommentauthorlink' || $arg == 'mtcommenturl') {
        $comment = $ctx->stash('comment');
        if ($comment->comment_commenter_id) {
            // is an authenticated comment
            $auth = $comment->commenter();
            if ($auth && $blog->blog_follow_auth_links) {
                return $str;
            }
        }
    }
    return preg_replace_callback('#<a\\s([^>]*\\s*href\\s*=[^>]*)>#i', 'nofollowfy_cb', $str);
}
コード例 #3
0
ファイル: mt.php プロジェクト: benvanstaveren/movabletype
 public static function get_instance($blog_id = null, $cfg_file = null)
 {
     if (is_null(MT::$_instance)) {
         MT::$_instance = new MT($blog_id, $cfg_file);
     }
     return MT::$_instance;
 }
コード例 #4
0
function smarty_function_mtcommenteruserpic($args, &$ctx)
{
    $comment = $ctx->stash('comment');
    if (!$comment) {
        return $ctx->error("No comments available");
    }
    $cmntr = $ctx->stash('commenter');
    if (!$cmntr) {
        return '';
    }
    $asset_id = isset($cmntr->author_userpic_asset_id) ? $cmntr->author_userpic_asset_id : 0;
    $asset = $ctx->mt->db()->fetch_assets(array('id' => $asset_id));
    if (!$asset) {
        return '';
    }
    $blog =& $ctx->stash('blog');
    require_once "MTUtil.php";
    $userpic_url = userpic_url($asset[0], $blog, $cmntr);
    if (empty($userpic_url)) {
        return '';
    }
    $mt = MT::get_instance();
    $dimensions = sprintf('width="%s" height="%s"', $mt->config('UserpicThumbnailSize'), $mt->config('UserpicThumbnailSize'));
    $link = sprintf('<img src="%s?%d" %s alt="%s" />', encode_html($userpic_url), $asset_id, $dimensions, encode_html($asset->label));
    return $link;
}
コード例 #5
0
ファイル: Admin_Contact.php プロジェクト: oaki/demoshop
 function showForm()
 {
     $l = dibi::fetch("SELECT * FROM " . self::TABLE . " WHERE id_node=%i", $_GET['id_modul']);
     MT::addTemplate(dirname(__FILE__) . '/default.phtml', self::TABLE);
     MT::addVar(self::TABLE, 'l', $l);
     MT::addVar(self::TABLE, 'table', self::TABLE);
 }
コード例 #6
0
ファイル: cms.php プロジェクト: oaki/demoshop
 function __construct()
 {
     //-----vytvorenie objektu menu
     $menu = new MenuItem();
     $menu->menuAction();
     //-----vytvorenie objektu node
     $node = new node();
     $node->nodeAction();
     MT::addContent($menu->render(), 'leftHolder');
     try {
         if (isset($_GET['id_menu_item']) or isset($_GET['addMenuItem']) or isset($_GET['changeMenuItem'])) {
             MT::addTemplate(APP_DIR . '/templates/admin/modulHolder.phtml', 'modulHolder');
             MT::addVar('modulHolder', 'type_modul', dibi::fetchAll("SELECT * FROM [type_modul] WHERE visible_for_user='******'"));
         }
         //zobrazenie zmeny polozky pre menu
         if (isset($_GET['changeMenuItem'])) {
             $menu->showChangeMenuItem($_GET['id_menu_item']);
         }
         if (isset($_GET['id_menu_item']) and !isset($_GET['changeMenuItem'])) {
             $node->showModul();
         }
         //pridanie polozky do menu
         if (isset($_GET['addMenuItem'])) {
             $menu->showAddMenuItem();
         }
         //zachytenie vynimie
     } catch (NodeException $e) {
         echo '<div style="border: 2px solid red; padding: 5px;">' . $e->getMessage() . '</div>';
         exit;
     }
 }
コード例 #7
0
ファイル: newsletter_class.php プロジェクト: oaki/demoshop
 public static function show()
 {
     if (isset($_GET['ajax_action_section']) and $_GET['ajax_action_section'] == 'save_description') {
         dibi::query("\n  \t\t\tUPDATE [newsletter_emails] \n  \t\t\tSET description = %s", $_POST['description'], "WHERE id_newsletter_emails = %i", $_POST['id_newsletter_emails']);
         exit;
     }
     MT::addTemplate(APP_DIR . '/require_modules/newsletter/default.phtml', 'newsletter');
     $ds = NewsletterModel::getDatasource();
     if (isset($_GET['id_newsletter_delete'])) {
         NewsletterModel::delete($_GET['id_newsletter_delete']);
         header('location: admin.php?section=newsletter');
         exit;
     }
     if (isset($_GET['export'])) {
         $dse = clone $ds;
         MT::addVar('newsletter', 'export', $dse->where('active = 1 AND id_newsletter_emails IN %l', $_GET['id'])->fetchAll());
     }
     if (@$_GET['order_by'] == 'email') {
         $ds->orderBy('email');
     } else {
         $ds->orderBy('adddate');
     }
     //$vp = new MyPaginator($ds, 10);
     MT::addVar('newsletter', 'emails', $ds->fetchAll());
     //  	MT::addVar('newsletter', 'vp', $vp);
 }
コード例 #8
0
 public function testIssetWithOverloading()
 {
     include_once "php/mt.php";
     include_once "php/lib/MTUtil.php";
     $cfg_file = realpath("t/mysql-test.cfg");
     $mt = MT::get_instance(1, $cfg_file);
     $ctx =& $mt->context();
     // Test some objects inheriting ObjectBase class.
     require_once "php/lib/class.mt_config.php";
     $config = new Config();
     $config->Load();
     $this->assertTrue(isset($config->id));
     require_once "php/lib/class.mt_author.php";
     $author = new Author();
     $author->Load();
     $this->assertTrue(isset($author->id));
     // protected variable call (bugid:113105)
     require_once "php/lib/class.mt_entry.php";
     $entry = new Entry();
     $entry->id = 1;
     $this->assertTrue(isset($entry->id));
     $this->assertNull($entry->_prefix);
     $this->assertFalse(isset($entry->_prefix));
     // fixed Dynamic publishing error occurred with memcached environment. bugid: 113546
     $mt->config('MemcachedServers', '127.0.0.1:11211');
     $obj_names = array('asset' => 'Asset', 'author' => 'Author', 'blog' => 'Blog', 'category' => 'Category', 'comment' => 'Comment', 'entry' => 'Entry', 'folder' => 'Folder', 'page' => 'Page', 'tbping' => 'TBPing', 'template' => 'Template', 'website' => 'Website');
     foreach ($obj_names as $table => $name) {
         require_once "php/lib/class.mt_{$table}.php";
         $obj = new $name();
         $obj->Load();
         $this->cache("{$table}:" . $obj->id, $obj);
         $obj_cache = $this->load_cache("{$table}:" . $obj->id);
         $this->assertInstanceOf("{$name}", $obj_cache);
     }
 }
コード例 #9
0
function smarty_modifier_ts_format($text, $arg)
{
    $mt = MT::get_instance();
    $ctx =& $mt->context();
    $text = $mt->db()->db2ts($text);
    $args = array('ts' => $text, 'format' => $arg);
    return $ctx->_hdlr_date($args, $ctx);
}
コード例 #10
0
ファイル: Admin_Home.php プロジェクト: oaki/demoshop
 function showForm()
 {
     $l = dibi::fetch("SELECT * FROM " . self::TABLE . " WHERE id_node=%i", $_GET['id_modul']);
     MT::addTemplate(dirname(__FILE__) . '/default.phtml', 'Home');
     MT::addVar('Home', 'l', $l);
     $f = new Promo(self::MODULE_NAME, $_GET['id_modul']);
     MT::addVar('Home', 'showPromo', $f->render());
 }
コード例 #11
0
ファイル: MT.php プロジェクト: oaki/demoshop
 public static function getInstance()
 {
     if (self::$instance === NULL) {
         return self::$instance = new MT();
     } else {
         return self::$instance;
     }
 }
コード例 #12
0
function smarty_function_mtassettype($args, &$ctx)
{
    $asset = $ctx->stash('asset');
    if (!$asset) {
        return '';
    }
    $mt = MT::get_instance();
    return $mt->translate($asset->asset_class);
}
コード例 #13
0
function smarty_modifier_filters($text, $filters)
{
    // status: complete
    $mt = MT::get_instance();
    $ctx =& $mt->context();
    require_once 'MTUtil.php';
    $text = apply_text_filter($ctx, $text, $filters);
    return $text;
}
コード例 #14
0
function smarty_function_mttagsearchlink($args, &$ctx)
{
    $mt = MT::get_instance();
    $blog = $ctx->stash('blog');
    $tag = $ctx->stash('Tag');
    if (!$tag) {
        return '';
    }
    if (is_object($tag)) {
        $name = $tag->tag_name;
    } else {
        $name = $tag;
    }
    $param = '';
    $include_blogs = $args['include_blogs'] ? $args['include_blogs'] : $ctx->stash('include_blogs');
    $include_blogs or $include_blogs = $args['blog_ids'] ? $args['blog_ids'] : $ctx->stash('blog_ids');
    if ($include_blogs) {
        if ($include_blogs != 'all') {
            $incl = $mt->db()->parse_blog_ids($include_blogs, $include_with_website);
            if (!$blog->is_blog) {
                array_unshift($incl, $blog->id);
            }
            $param = 'IncludeBlogs=' . implode(',', $incl);
        }
    } else {
        $blog_id = $ctx->stash('blog_id');
        $param = 'IncludeBlogs=' . $blog_id;
    }
    if ($exclude_blogs = $args['exclude_blogs'] ? $args['exclude_blogs'] : $ctx->stash('exclude_blogs')) {
        $excl = $mt->db()->parse_blog_ids($exclude_blogs);
        $param = 'ExcludeBlogs=' . implode(',', $excl);
    }
    $tmpl_blog_id = null;
    if (isset($args['tmpl_blog_id'])) {
        $tmpl_blog_id = $args['tmpl_blog_id'];
        if ('parent' == strtolower($tmpl_blog_id)) {
            if ($blog->is_blog) {
                $blog = $blog->website();
            }
            $tmpl_blog_id = $blog->id;
        } else {
            if (!preg_match('/^\\d+$/', $tmpl_blog_id) || $tmpl_blog_id < 1) {
                $mt = MT::get_instance();
                $ctx->error($mt->translate('Invalid [_1] parameter.', 'tmpl_blog_id'));
            }
        }
    }
    require_once "function.mtcgipath.php";
    $search = smarty_function_mtcgipath($args, $ctx);
    $search .= $ctx->mt->config('SearchScript');
    $link = $search . '?' . $param . ($param ? '&amp;' : '') . 'tag=' . urlencode($name);
    $link .= '&amp;limit=' . $ctx->mt->config('MaxResults');
    if ($tmpl_blog_id) {
        $link .= '&amp;blog_id=' . $tmpl_blog_id;
    }
    return $link;
}
コード例 #15
0
function smarty_function_mtcommentauthorlink($args, &$ctx)
{
    $mt = MT::get_instance();
    $comment = $ctx->stash('comment');
    $name = $comment->comment_author;
    if (!$name && isset($args['default_name'])) {
        $name = $args['default_name'];
    }
    $name or $name = $mt->translate("Anonymous");
    require_once "MTUtil.php";
    $name = encode_html($name);
    $email = $comment->comment_email;
    $url = $comment->comment_url;
    if (isset($args['show_email'])) {
        $show_email = $args['show_email'];
    } else {
        $show_email = 0;
    }
    if (isset($args['show_url'])) {
        $show_url = $args['show_url'];
    } else {
        $show_url = 1;
    }
    $target = isset($args['new_window']) && $args['new_window'] ? ' target="_blank"' : '';
    _comment_follow($args, $ctx);
    $cmntr = $ctx->stash('commenter');
    if (!isset($cmntr) && isset($comment->comment_commenter_id)) {
        $cmntr = $comment->commenter();
    }
    if ($cmntr) {
        $name = isset($cmntr->author_nickname) ? encode_html($cmntr->author_nickname) : $name;
        if ($cmntr->author_url) {
            return sprintf('<a title="%s" href="%s"%s>%s</a>', encode_html($cmntr->author_url), encode_html($cmntr->author_url), $target, $name);
        }
        return $name;
    } elseif ($show_url && $url) {
        require_once "function.mtcgipath.php";
        $cgi_path = smarty_function_mtcgipath($args, $ctx);
        $comment_script = $ctx->mt->config('CommentScript');
        $name = strip_tags($name);
        $url = encode_html(strip_tags($url));
        if ($comment->comment_id && (!isset($args['no_redirect']) || isset($args['no_redirect']) && !$args['no_redirect']) && (!isset($args['nofollowfy']) || isset($args['nofollowfy']) && !$args['nofollowfy'])) {
            return sprintf('<a title="%s" href="%s%s?__mode=red;id=%d"%s>%s</a>', $url, $cgi_path, $comment_script, $comment->comment_id, $target, $name);
        } else {
            return sprintf('<a title="%s" href="%s"%s>%s</a>', $url, $url, $target, $name);
        }
    } elseif ($show_email && $email && is_valid_email($email)) {
        $email = encode_html(strip_tags($email));
        $str = 'mailto:' . $email;
        if ($args['spam_protect']) {
            $str = spam_protect($str);
        }
        return sprintf('<a href="%s">%s</a>', $str, $name);
    }
    return $name;
}
コード例 #16
0
 public function Save()
 {
     $val = $this->data;
     $this->data = null;
     $ret = parent::Save();
     if ($ret) {
         $mt = MT::get_instance();
         $mt->db()->db()->UpdateBlob('mt_session', 'session_data', $val, "session_id='" . $this->id . "'", 'BLOB');
     }
 }
コード例 #17
0
ファイル: article.php プロジェクト: oaki/demoshop
 function showForm()
 {
     $l = dibi::fetch("SELECT * FROM article WHERE id_node=%i", $_GET['id_modul']);
     MT::addTemplate(dirname(__FILE__) . '/adminArticle.phtml', 'article');
     MT::addVar('article', 'l', $l);
     $f = new FilesNode(self::MODULE_NAME, $_GET['id_modul']);
     $f->type = 'all';
     MT::addVar('article', 'showMultiupload', $f->render());
     //    Admin_Comment::action(false);
     //    MT::addVar('article', 'comments', Admin_Comment::getCommentListForArticle($_GET['id_modul']));
 }
コード例 #18
0
function smarty_modifier_setvar($text, $name)
{
    $mt = MT::get_instance();
    $ctx =& $mt->context();
    if (array_key_exists('__inside_set_hashvar', $ctx->__stash)) {
        $vars =& $ctx->__stash['__inside_set_hashvar'];
    } else {
        $vars =& $ctx->__stash['vars'];
    }
    $vars[$name] = $text;
    return '';
}
コード例 #19
0
function smarty_function_mtcategorycommentcount($args, &$ctx)
{
    $mt = MT::get_instance();
    $db = $mt->db();
    $category = $ctx->stash('category');
    $cat_id = (int) $category->category_id;
    $count = 0;
    if ($cat_id) {
        $count = $db->category_comment_count(array('category_id' => $cat_id, 'top' => $args['top']));
    }
    return $ctx->count_format($count, $args);
}
コード例 #20
0
function smarty_block_mtentrynext($args, $content, &$ctx, &$repeat)
{
    static $_next_cache = array();
    if (!isset($content)) {
        # save all values, to be restored when we're done...
        $ctx->localize(array('entry', 'conditional', 'else_content'));
        $entry = $ctx->stash('entry');
        if ($entry) {
            $label = $entry->entry_id;
            if (isset($args['by_author'])) {
                $label .= ':author=' . $entry->entry_author_id;
            }
            if (isset($args['by_category']) || isset($args['by_folder'])) {
                $cat = $entry->category();
                $cat_id = $cat ? $cat->category_id : 0;
                $label .= ':category=' . $cat_id;
            }
            if (isset($_next_cache[$label])) {
                $next_entry = $_next_cache[$label];
            } else {
                $mt = MT::get_instance();
                $blog_id = $entry->entry_blog_id;
                if (isset($args['class'])) {
                    $class = $args['class'];
                } else {
                    $class = 'entry';
                }
                $ts = $mt->db()->db2ts($class == 'entry' ? $entry->entry_authored_on : $entry->entry_modified_on);
                $eargs = array('not_entry_id' => $entry->entry_id, 'blog_id' => $blog_id, 'lastn' => 1, 'base_sort_order' => 'ascend', 'current_timestamp' => $ts, 'class' => $class);
                if (isset($args['by_author'])) {
                    $eargs['author_id'] = $entry->entry_author_id;
                }
                if (isset($args['by_category']) || isset($args['by_folder'])) {
                    $eargs['category_id'] = $cat_id;
                }
                list($next_entry) = $ctx->mt->db()->fetch_entries($eargs);
                if ($next_entry) {
                    $_next_cache[$label] = $next_entry;
                }
            }
            $ctx->stash('entry', $next_entry);
        }
        $ctx->stash('conditional', isset($next_entry));
        $ctx->stash('else_content', null);
    } else {
        if (!$ctx->stash('conditional')) {
            $content = $ctx->stash('else_content');
        }
        $ctx->restore(array('entry', 'conditional', 'else_content'));
    }
    return $content;
}
コード例 #21
0
ファイル: Admin_Product.php プロジェクト: oaki/demoshop
 function showForm()
 {
     $l = dibi::fetch("SELECT * FROM [module_product] WHERE id_node=%i", $_GET['id_modul']);
     MT::addTemplate(dirname(__FILE__) . '/adminProduct.phtml', 'product');
     MT::addVar('product', 'l', $l);
     $f = new FilesNode(self::MODULE_NAME, $_GET['id_modul']);
     $f->type = 'all';
     $f->allowedExtensions = array('jpg', 'pdf', 'png');
     MT::addVar('product', 'showMultiupload', $f->render());
     //    $g = new Admin_GalleryMultiuploadControl();
     //    $g->action();
     //    $g->showForm($withOptions = false);
 }
コード例 #22
0
function smarty_block_mtifcommentertrusted($args, $content, &$ctx, &$repeat)
{
    if (!isset($content)) {
        $is_trust = NULL;
        $a = $ctx->stash('commenter');
        if (empty($a)) {
            $is_trust = 0;
        } else {
            $perm = $a->permissions(0);
            $perm = is_array($perm) ? array_shift($perm) : $perm;
            if (!empty($perm)) {
                if (preg_match("/'administer'/", $perm->permission_permissions)) {
                    $is_trust = 1;
                }
            }
            if (is_null($is_trust)) {
                $mt = MT::get_instance();
                $blog_id = 0;
                if (!$mt->config('SingleCommunity')) {
                    $blog = $ctx->stash('blog');
                    if (!empty($blog)) {
                        $blog_id = $blog->id;
                    }
                }
                $perm = $a->permissions($blog_id);
                $perm = is_array($perm) ? array_shift($perm) : $perm;
                if (!empty($perm)) {
                    if (preg_match("/'comment'/", $perm->permission_restrictions)) {
                        $is_trust = 0;
                    } elseif (preg_match("/'(comment|administer_blog|manage_feedback)'/", $perm->permission_permissions)) {
                        $is_trust = 1;
                    }
                } else {
                    if (!$mt->config('SingleCommunity')) {
                        $is_trust = 0;
                    }
                }
                if (is_null($is_trust)) {
                    if ($mt->config('SingleCommunity') && $a->type == 1 && $a->status == 1) {
                        $is_trust = 1;
                    } else {
                        $is_trust = 0;
                    }
                }
            }
        }
        return $ctx->_hdlr_if($args, $content, $ctx, $repeat, $is_trust);
    } else {
        return $ctx->_hdlr_if($args, $content, $ctx, $repeat);
    }
}
コード例 #23
0
ファイル: captcha_lib.php プロジェクト: OCMO/movabletype
 public function form_fields($blog_id)
 {
     $mt = MT::get_instance();
     $token = '';
     $token = sha1(rand(0, 65535));
     if (strlen($token) == 0) {
         return '';
     }
     $cgipath = $mt->config('CGIPath');
     $commentscript = $mt->config('CommentScript');
     $caption = $mt->translate('Captcha');
     $description = $mt->translate('Type the characters shown in the picture above.');
     $form = "\n<div class=\"label\"><label for=\"captcha_code\">{$caption}:</label></div>\n<div class=\"field\">\n<input type=\"hidden\" name=\"token\" value=\"{$token}\" />\n<img src=\"{$cgipath}{$commentscript}/captcha/{$blog_id}/{$token}\" width=\"150\" height=\"35\" /><br />\n<input type=\"text\" name=\"captcha_code\" id=\"captcha-code\" class=\"text\" value=\"\" autocomplete=\"off\" />\n<p>{$description}</p>\n</div>";
     return $form;
 }
コード例 #24
0
 public function data($name = null)
 {
     if (empty($this->_data)) {
         $mt = MT::get_instance();
         $this->_data = $mt->db()->unserialize($this->data);
     }
     if (!empty($name)) {
         if (isset($this->_data[$name])) {
             return $this->_data[$name];
         } else {
             return null;
         }
     } else {
         return $this->_data;
     }
 }
コード例 #25
0
function smarty_function_mtarchivelabel($args, &$ctx)
{
    $at = $ctx->stash('current_archive_type');
    if (isset($args['type'])) {
        $at = $args['type'];
    } elseif (isset($args['archive_type'])) {
        $at = $args['archive_type'];
    }
    $ar = ArchiverFactory::get_archiver($at);
    if (isset($ar)) {
        return $ar->get_label($args);
    } else {
        $mt = MT::get_instance();
        return $mt->translate($at);
    }
}
コード例 #26
0
function smarty_modifier_sanitize($text, $spec = '1')
{
    if (!$spec) {
        return $text;
    } else {
        if ($spec == '1') {
            $mt = MT::get_instance();
            $ctx =& $mt->context();
            $blog = $ctx->stash('blog');
            $spec = $blog->blog_sanitize_spec;
            $spec or $spec = $mt->config('GlobalSanitizeSpec');
        }
    }
    require_once "sanitize_lib.php";
    return sanitize($text, $spec);
}
コード例 #27
0
ファイル: modifier.mteval.php プロジェクト: OCMO/movabletype
function smarty_modifier_mteval($text, $arg)
{
    if (!$arg) {
        return $text;
    }
    $mt = MT::get_instance();
    $ctx =& $mt->context();
    $_var_compiled = '';
    if (!$ctx->_compile_source('evaluated template', $text, $_var_compiled)) {
        return $ctx->error("Error compiling text '{$text}'");
    }
    ob_start();
    $ctx->_eval('?>' . $_var_compiled);
    $_contents = ob_get_contents();
    ob_end_clean();
    return $_contents;
}
コード例 #28
0
ファイル: log_class.php プロジェクト: oaki/demoshop
 function showLog()
 {
     $session = NEnvironment::getSession('Log');
     if (isset($_GET['order_by'])) {
         if ($_GET['order_by'] != "date" and $_GET['order_by'] != "id_user" and $_GET['order_by'] != "description" and $_GET['order_by'] != "value" and $_GET['order_by'] != "value" and $_GET['order_by'] != "id_type_modul" and $_GET['order_by'] != "ip") {
             $session['log_order_by'] = "date";
         } else {
             $session['log_order_by'] = $_GET['order_by'];
         }
     }
     if (!isset($session['log_order_by'])) {
         $session['log_order_by'] = "date";
     }
     $source = dibi::dataSource("\n\t\t\tSELECT log.*, user.login  \n\t\t\tFROM log LEFT JOIN user USING(id_user) \n\t\t\tWHERE\n\t\t\t\t%if", @$_GET['input_id_user'] != '', "login LIKE %s", '%' . @$_GET['input_id_user'] . '%', " AND %end\n\t\t      \t%if", @$_GET['input_date'] != '', "[date] > %s", @$_GET['input_date'], " AND %end\n\t\t\t    %if", @$_GET['input_description'] != '', "description LIKE %s", '%' . @$_GET['input_description'] . '%', " AND %end\n\t\t\t    %if", @$_GET['input_value'] != '', "value LIKE %s", '%' . @$_GET['input_value'] . '%', " AND %end\n\t\t\t    %if", @$_GET['input_id_type_modul'] != '', "name_modul LIKE %s", '%' . @$_GET['input_id_type_modul'] . '%', " AND %end\n\t\t\t    ip LIKE %s", '%' . @$_GET['input_ip'] . '%', " \n\t\t    \n\t\t    ORDER BY " . $session['log_order_by'] . " DESC");
     $p = new MyPaginator($source);
     MT::addTemplate(dirname(__FILE__) . '/log.phtml', 'log');
     MT::addVar('log', 'paginator', $p);
     MT::addVar('log', 'list', $p->getDataSourceItem()->fetchAll());
 }
コード例 #29
0
 public static function _find_current_plugindata($blog)
 {
     $keys = array('configuration:blog:' . $blog->id);
     if ($blog->parent_id) {
         array_push($keys, 'configuration:blog:' . $blog->parent_id);
     }
     array_push($keys, 'configuration');
     require_once 'class.mt_plugindata.php';
     $class = new PluginData();
     $where = "plugindata_plugin = 'GoogleAnalytics' AND " . "plugindata_key IN ('" . join("','", $keys) . "')";
     $tmp_objs = $class->Find($where);
     if (empty($tmp_objs)) {
         return null;
     }
     $objs = array();
     foreach ($keys as $k) {
         foreach ($tmp_objs as $o) {
             if ($o->key == $k) {
                 array_push($objs, $o);
             }
         }
     }
     $mt = MT::get_instance();
     $db = $mt->db();
     for ($i = 0; $i < sizeof($objs); $i++) {
         $o = $objs[$i];
         $data = $o->data();
         if ($data && $data['profile_id']) {
             if ($data['client_id'] && $data['client_secret']) {
                 return $o;
             } else {
                 if ($data['parent_client_id']) {
                     for ($j = 0; $j < sizeof($objs); $j++) {
                         $parent_data = $objs[$j]->data();
                         if ($parent_data && $parent_data['client_id'] && $parent_data['client_id'] == $data['parent_client_id'] && $parent_data['client_secret']) {
                             return $o;
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #30
0
 public function __construct($ttl = 0)
 {
     parent::__construct($ttl);
     if (empty(self::$_server)) {
         $mt = MT::get_instance();
         $servers = $mt->config('MemcachedServers');
         if (!empty($servers)) {
             if (extension_loaded('memcache')) {
                 self::$_server = new Memcache();
                 $this->connect($servers);
             } else {
                 require_once 'class.exception.php';
                 throw new MTException("Cannot load memcached extension.");
             }
         } else {
             require_once 'class.exception.php';
             throw new MTException("Cannot load memcached extension.");
         }
     }
 }