Ejemplo n.º 1
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     needRole(RDR_User::ROLE_ADMIN, true);
     $this->user = new RDR_User(db());
     if (get("id")) {
         $tmp = RDR_User::getById(get("id"));
         if ($tmp) {
             $this->user = $tmp;
         }
     }
     $this->form = $this->getForm();
     if (post("save")) {
         if (!$this->form->validateAllFields()) {
             v("message", t("form.validation.error"));
         } elseif (post("password") && post("password") != post("password2")) {
             v("message", t("admin.user.2"));
         } else {
             $this->form->setObjectMembersBySubmittedValues($this->user);
             if (post("password")) {
                 $this->user->setPassword(post("password"));
             }
             $this->user->store();
             v("message", t("saved"));
             $this->form = $this->getForm();
         }
     }
     view("RDR_BasicFrame", array("view" => $this));
 }
Ejemplo n.º 2
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     if (!needRole()) {
         return;
     }
     if (get("type") == "image") {
         $url = urldecode(get("url"));
         if (substr($url, 0, 2) == "//") {
             $url = "http:" . $url;
         }
         $exp = explode(".", preg_replace("~\\?.*~i", "", $url));
         $extension = end($exp);
         if (count($exp) <= 1 || !$extension || strlen($extension) > 4 || preg_match("~[^a-z]~i", $extension)) {
             $extension = "jpg";
         }
         $slug = md5($url);
         $tmpPath = CHOQ_ACTIVE_MODULE_DIRECTORY . "/tmp/filecontents.{$slug}.{$extension}";
         if (!file_exists($tmpPath)) {
             $data = @file_get_contents($url);
             file_put_contents($tmpPath, $data !== false ? $data : "");
         }
         header("content-type: image/{$extension}");
         header("content-length: " . filesize($tmpPath));
         header("Last-Modified: " . date("r", filemtime($tmpPath)));
         header("Expires: " . date("r", filemtime($tmpPath) + self::CACHETIME));
         header("Cache-Control: public, max-age= " . self::CACHETIME);
         readfile($tmpPath);
     }
 }
Ejemplo n.º 3
0
 public function changePassword()
 {
     needRole('admin');
     if (!$this->checkPassword(getRole('admin'), $_REQUEST['oldpasswd'])) {
         $this->_tpl->assign('msg', '原密码不对!');
     } else {
         daocall('admin_user', 'updatePassword', array(getRole('admin'), $_REQUEST['passwd']));
         $this->_tpl->assign('msg', '修改密码成功');
     }
     return $this->_tpl->display('msg.html');
 }
Ejemplo n.º 4
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     needRole(null, true);
     if (post("savepw")) {
         if (post("newpw") && post("newpw") == post("newpw2")) {
             user()->setPassword(post("newpw"));
             user()->store();
             v("message", t("saved"));
         }
     }
     view("RDR_BasicFrame", array("view" => $this));
 }
Ejemplo n.º 5
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     needRole(RDR_User::ROLE_ADMIN, true);
     if (req()->isAjax()) {
         if (post("update")) {
             $feed = RDR_Feed::getById(post("update"));
             if ($feed) {
                 RDR_Import::importFeedEntries($feed);
             }
         }
         return;
     }
     view("RDR_BasicFrame", array("view" => $this));
 }
Ejemplo n.º 6
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     needRole(RDR_User::ROLE_ADMIN, true);
     $this->form = $this->getForm();
     if (post("save")) {
         foreach ($this->form->fields as $field) {
             if ($field->attr->get("data-setting")) {
                 RDR_Setting::set($field->name, $field->getSubmittedValue());
             }
         }
         v("message", t("saved"));
         $this->form = $this->getForm();
     }
     view("RDR_BasicFrame", array("view" => $this));
 }
Ejemplo n.º 7
0
<?php

needRole('user');
class FrameControl extends Control
{
    public function __construct()
    {
        parent::__construct();
    }
    public function __destruct()
    {
        parent::__destruct();
    }
    public function login()
    {
        return $this->display('user/index.html');
    }
    public function index()
    {
        $request = '';
        foreach ($_REQUEST as $k => $v) {
            if ($k == 'a' || $k == 'c' || $k == 'fa' || $k == 'fc') {
                continue;
            }
            $request .= '&' . $k . '=' . urlencode($v);
        }
        $this->assign('request', $request);
        return $this->display('frame/index.html');
    }
    public function top()
    {
Ejemplo n.º 8
0
<?php

needRole('admin');
class NodesControl extends Control
{
    public function __construct()
    {
        parent::__construct();
    }
    public function __destruct()
    {
        parent::__destruct();
    }
    public function listNode()
    {
        $username = $_GET['username'];
        $list = daocall('nodes', "listNodes", null);
        $sum = count($list);
        $this->_tpl->assign('sum', $sum);
        $this->_tpl->assign('username', $username);
        $this->_tpl->assign('list', $list);
        $this->_tpl->display('nodes/listnode.html');
    }
    public function addNode()
    {
        $this->_tpl->assign('action', 'insert');
        $this->_tpl->display('nodes/addnode.html');
    }
    public function ajaxCheckNode()
    {
        $node = $_REQUEST['node'];
Ejemplo n.º 9
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     needRole(null, true);
     view("RDR_BasicFrame", array("view" => $this));
 }
Ejemplo n.º 10
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     needRole(null, true);
     # OPML
     if (get("opml")) {
         $categories = user()->getCategories();
         $opml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><opml></opml>');
         $opml->addAttribute("version", "1.0");
         $head = $opml->addChild("head");
         $head->addChild("title", "Subscriptions from nReeda");
         $body = $opml->addChild("body");
         foreach ($categories as $category) {
             $cat = $body->addChild("outline");
             $cat->addAttribute("title", $category->name);
             $cat->addAttribute("text", $category->name);
             $feeds = $category->feeds;
             if ($feeds) {
                 foreach ($feeds as $feed) {
                     $f = $cat->addChild("outline");
                     $f->addAttribute("type", "rss");
                     $f->addAttribute("text", $feed->getCustomName($category));
                     $f->addAttribute("title", $feed->getCustomName($category));
                     $f->addAttribute("xmlUrl", $feed->url);
                 }
             }
         }
         $data = $opml->asXML();
         CHOQ_OutputManager::cleanAllBuffers();
         header("Content-type: application/octet-stream");
         header("Content-Disposition: filename=\"nreeda.opml\"");
         echo $data;
         die;
     }
     # textfile
     if (get("file")) {
         $categories = user()->getCategories();
         $lines = array();
         foreach ($categories as $category) {
             $feeds = $category->feeds;
             if ($feeds) {
                 foreach ($feeds as $feed) {
                     $lines[] = $feed->url;
                 }
             }
         }
         $data = implode("\n", $lines);
         CHOQ_OutputManager::cleanAllBuffers();
         header("Content-type: application/octet-stream");
         header("Content-Disposition: filename=\"nreeda.txt\"");
         echo $data;
         die;
     }
     # Import
     if (isset($_FILES["file"]["tmp_name"])) {
         $data = file_get_contents($_FILES["file"]["tmp_name"]);
         if (strpos($data, "<?xml") === false || strpos($data, "</opml>") === false) {
             $event = RDR_Import::importFromFile($_FILES["file"]["tmp_name"]);
             if ($event->type == RDR_Event::TYPE_FILE_OK) {
                 RDR_Import::updateAllFeeds();
             }
             v("message", $event->getText());
         } else {
             $event = RDR_Import::importFromOPML($_FILES["file"]["tmp_name"]);
             if ($event->type == RDR_Event::TYPE_OPML_OK) {
                 RDR_Import::updateAllFeeds();
             }
             v("message", $event->getText());
         }
     }
     if (post("new") && trim(post("val"))) {
         RDR_Category::get(post("val"));
         redirect(url()->getUri(), 302);
     }
     if (req()->isAjax()) {
         $categories = user()->getCategories();
         $feeds = user()->getFeeds();
         if (post("action") == "edit" && post("val")) {
             if (isset($categories[post("category")])) {
                 $category = $categories[post("category")];
                 if (post("feed")) {
                     $feed = arrayValue($feeds, post("feed"));
                     if ($feed) {
                         $feed->setCustomName($category, post("val"));
                         $category->store();
                     }
                 } else {
                     $category->name = post("val");
                     $category->store();
                 }
             }
         }
         if (post("action") == "move") {
             if (isset($categories[post("categoryOld")])) {
                 $categoryOld = $categories[post("categoryOld")];
                 $categoryNew = $categories[post("categoryNew")];
                 if (post("feed")) {
                     $feed = arrayValue($feeds, post("feed"));
                     if ($feed) {
                         $name = $feed->getCustomName($categoryOld);
                         $categoryOld->remove("feedsData", $feed->getId() . "-name");
                         $categoryOld->remove("feeds", $feed->getId());
                         $categoryOld->store();
                         $feed->setCustomName($categoryNew, $name);
                         $categoryNew->add("feeds", $feed);
                         $categoryNew->store();
                     }
                 }
             }
         }
         if (post("action") == "delete") {
             if (isset($categories[post("category")])) {
                 $category = $categories[post("category")];
                 if (post("feed")) {
                     $feed = arrayValue($feeds, post("feed"));
                     if ($feed) {
                         $category->remove("feedsData", $feed->getId() . "-name");
                         $category->remove("feeds", $feed);
                         $category->store();
                     }
                 } else {
                     $category->delete();
                 }
             }
         }
         RDR_Cleanup::cleanupFeeds();
         RDR_Cleanup::cleanupFlags();
         user()->updateNewsCache();
         return;
     }
     view("RDR_BasicFrame", array("view" => $this));
 }
Ejemplo n.º 11
0
 public function upgrade()
 {
     needRole('user');
     $user = getRole('user');
     $product = apicall('product', 'newProduct', array($_REQUEST['product_type']));
     if ($product->upgrade($user, $_REQUEST['name'], $_REQUEST['product_id'])) {
         $this->_tpl->assign('msg', '升级成功');
     } else {
         $this->_tpl->assign('msg', '升级失败.' . $GLOBALS["last_error"]);
     }
     return $this->_tpl->fetch('public/msg.html');
 }
Ejemplo n.º 12
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     if (req()->isAjax() && get("code") == self::getValidHash()) {
         $data = null;
         switch (get("action")) {
             case "update-check":
                 # fetching branches from GIT
                 $data = array("error" => t("update.4"));
                 $branches = self::getGitJSON("https://api.github.com/repos/brainfoolong/nreeda/branches");
                 if ($branches) {
                     $newest = null;
                     foreach ($branches as $branch) {
                         if ($branch["name"] == "master") {
                             continue;
                         }
                         if (!$newest || version_compare($branch["name"], $newest, ">")) {
                             $newest = $branch["name"];
                         }
                     }
                     $data = array("version" => $newest, "update" => version_compare($newest, RDR_VERSION, ">"));
                     RDR_Setting::set("latestversion", $newest);
                 }
                 break;
             case "start":
                 if (RDR_Cron::isRunning()) {
                     $data = array("message" => t("update.1"), "event" => "error");
                 } else {
                     RDR_Maintenance::enableMaintenanceMode();
                     $data = array("message" => sprintf(nl2br(t("update.2"), true), url()->getByAlias("root", l("RDR_Maintenance")) . '?disable-maintenance=' . RDR_Maintenance::getValidHash(), 'RDR::$maintenanceMode = true'), "event" => "success", "next" => "check");
                 }
                 break;
             case "check":
                 try {
                     # checking all files and directories for write access
                     $files = CHOQ_FileManager::getFiles(CHOQ_ROOT_DIRECTORY, true, true);
                     $count = 0;
                     $files[] = CHOQ_ROOT_DIRECTORY;
                     foreach ($files as $file) {
                         if (substr($file, 0, 1) == ".") {
                             continue;
                         }
                         if (!is_writable($file)) {
                             $count++;
                         }
                     }
                     if ($count) {
                         error(sprintf(t("update.3"), $count));
                     }
                     $version = RDR_Setting::get("latestversion")->value;
                     $data = array("message" => sprintf(t("update.5"), $version), "event" => "success", "next" => "prepare", "params" => array("version" => $version));
                 } catch (Exception $e) {
                     $data = array("message" => sprintf(t("update.7"), $e->getMessage()), "event" => "error");
                 }
                 break;
             case "prepare":
                 try {
                     # downloading zip file from GIT
                     $url = "https://github.com/brainfoolong/nreeda/archive/" . get("version") . ".zip";
                     $data = RDR_FileContents::get($url);
                     if ($data === false) {
                         return;
                     }
                     $tmpZip = CHOQ_ACTIVE_MODULE_DIRECTORY . "/tmp/update.zip";
                     file_put_contents($tmpZip, $data);
                     $updateDir = CHOQ_ACTIVE_MODULE_DIRECTORY . "/tmp/update";
                     if (!is_dir($updateDir)) {
                         mkdir($updateDir);
                     }
                     # removing all old files
                     $files = CHOQ_FileManager::getFiles($updateDir, true, true);
                     foreach ($files as $file) {
                         if (!is_dir($file)) {
                             unlink($file);
                         }
                     }
                     foreach ($files as $file) {
                         if (is_dir($file)) {
                             rmdir($file);
                         }
                     }
                     # extract zip file to tmp folder
                     $zip = new ZipArchive();
                     $zip->open($tmpZip);
                     $zip->extractTo($updateDir);
                     $zip->close();
                     $folder = $updateDir . "/nreeda-" . get("version");
                     $data = array("message" => t("update.9"), "event" => "success", "next" => "update", "params" => array("updatefolder" => $folder, "rootfolder" => CHOQ_ROOT_DIRECTORY, "updateurl" => url()->getByAlias("base", "modules/RDR/tmp/update/nreeda-" . get("version") . "/update.php")));
                 } catch (Exception $e) {
                     $data = array("message" => sprintf(t("update.7"), $e->getMessage()), "event" => "error");
                 }
                 break;
             case "db":
                 try {
                     RDR_DBUpdate::run();
                     $data = array("message" => t("update.10"), "event" => "success", "next" => "cleanup");
                 } catch (Exception $e) {
                     $data = array("message" => sprintf(t("update.7"), $e->getMessage()), "event" => "error");
                 }
                 break;
             case "cleanup":
                 try {
                     # deleting all update files
                     $updateDir = CHOQ_ACTIVE_MODULE_DIRECTORY . "/tmp/update";
                     if (is_dir($updateDir)) {
                         $files = CHOQ_FileManager::getFiles($updateDir, true, true);
                         foreach ($files as $file) {
                             if (!is_dir($file)) {
                                 unlink($file);
                             }
                         }
                         foreach ($files as $file) {
                             if (is_dir($file)) {
                                 rmdir($file);
                             }
                         }
                     }
                     if (is_dir($updateDir)) {
                         rmdir($updateDir);
                     }
                     $updateFile = CHOQ_ROOT_DIRECTORY . "/update.php";
                     if (file_exists($updateFile)) {
                         unlink($updateFile);
                     }
                     $data = array("message" => t("update.11"), "event" => "success");
                 } catch (Exception $e) {
                     $data = array("message" => sprintf(t("update.7"), $e->getMessage()), "event" => "error");
                 }
                 break;
             case "disable":
                 RDR_Maintenance::disableMaintenanceMode();
                 break;
         }
         echo json_encode($data);
         return;
     }
     needRole(RDR_User::ROLE_ADMIN, true);
     view("RDR_BasicFrame", array("view" => $this));
 }
Ejemplo n.º 13
0
    /**
     * Load the View
     */
    public function onLoad()
    {
        if (!needRole()) {
            return;
        }
        # some ajax actions
        switch (post("action")) {
            case "admin-feed":
                if (needRole(RDR_User::ROLE_ADMIN)) {
                    $entry = RDR_Entry::getById(post("eid"));
                    $feed = RDR_Feed::getById(post("fid"));
                    ?>
                    <b><?php 
                    echo t("feedadmin.raw.1");
                    ?>
</b>
                    <div class="small">
                        <?php 
                    echo t("feedadmin.raw.2");
                    ?>
                    </div>
                    <code class="raw"><?php 
                    echo s('<div>' . $entry->text . '</div>');
                    ?>
</code><br/><br/>
                    <b><?php 
                    echo t("feedadmin.format.1");
                    ?>
</b>
                    <div class="small">
                        <?php 
                    echo t("feedadmin.format.2");
                    ?>
                    </div>
                    <code class="formated"></code><br/><br/>
                    <b><?php 
                    echo sprintf(t("feedadmin.js.1"), s(cut($feed->name, 30)));
                    ?>
</b>
                    <div class="small">
                        <?php 
                    echo nl2br(sprintf(t("feedadmin.js.2"), s('<p>'), 'html = $(html); html.find("p").remove()'));
                    ?>
<br/>
                        <textarea data-field="contentJS" style="width:90%" cols="45" rows="3"><?php 
                    echo s($feed->contentJS);
                    ?>
</textarea>
                    </div>
                    <?php 
                }
                return;
                break;
            case "readed":
                if (post("ids")) {
                    $entries = RDR_Entry::getByIds(post("ids"));
                    if ($entries) {
                        user()->loadReadedFlags(array_keys($entries));
                        $insertIds = $deleteIds = array();
                        foreach ($entries as $entry) {
                            $id = $entry->getId();
                            if ($id < user()->setting("init.entry")) {
                                continue;
                            }
                            if (isset(user()->_cacheReaded[$id])) {
                                $deleteIds[$id] = $id;
                            } else {
                                $insertIds[$id] = $id;
                            }
                        }
                        if ($insertIds) {
                            $query = "INSERT IGNORE INTO RDR_User_readed (o,k,v) VALUES ";
                            foreach ($insertIds as $id) {
                                $query .= " (" . user()->getId() . ", {$id}, 1), ";
                            }
                            $query = substr($query, 0, -2);
                            db()->query($query);
                        }
                        if ($deleteIds) {
                            $query = "DELETE FROM RDR_User_readed WHERE o = " . user()->getId() . " && k IN " . db()->toDb($deleteIds);
                        }
                        user()->updateReadedCount();
                    }
                }
                break;
            case "saved":
                if (post("ids")) {
                    $entry = RDR_Entry::getById(post("ids[0]"));
                    if ($entry) {
                        if (user()->getByKey("saved", $entry->getId())) {
                            user()->remove("saved", $entry->getId());
                        } else {
                            user()->add("saved", 1, $entry->getId());
                        }
                        user()->store();
                    }
                }
                break;
        }
        $jsonData = user()->getAjaxData();
        echo json_encode($jsonData, JSON_FORCE_OBJECT);
    }
Ejemplo n.º 14
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     if (!needRole()) {
         return;
     }
     $jsonData = null;
     switch (post("action")) {
         case "delete-feed-user":
             $feed = RDR_Feed::getById(post("data[fid]"));
             if ($feed) {
                 $cats = user()->getCategories();
                 foreach ($cats as $category) {
                     $feeds = $category->feeds;
                     if ($feeds) {
                         foreach ($feeds as $key => $catFeed) {
                             if (compare($catFeed, $feed)) {
                                 unset($feeds[$key]);
                             }
                         }
                         if (count($feeds) != count($category->feeds)) {
                             $category->feeds = $feeds;
                             $category->store();
                         }
                     }
                 }
             }
             break;
         case "delete-feed-admin":
             if (needRole(RDR_User::ROLE_ADMIN)) {
                 $feed = RDR_Feed::getById(post("data[fid]"));
                 if ($feed) {
                     $feed->delete();
                 }
             }
             break;
         case "add-feed":
             $event = RDR_Import::addFeed(post("data[url]"), RDR_Category::get(post("data[category]")));
             if ($event->feed) {
                 RDR_Import::importFeedEntries($event->feed);
             }
             break;
         case "mark-all-as-readed":
             $cache = session("entry.ids.original");
             if ($cache) {
                 $ids = array_keys($cache);
                 user()->loadReadedFlags(array_keys($ids));
                 $insertIds = array();
                 foreach ($ids as $id) {
                     if (!isset(user()->_cacheReaded[$id])) {
                         $insertIds[$id] = $id;
                     }
                 }
                 if ($insertIds) {
                     $query = "INSERT IGNORE INTO RDR_User_readed (o,k,v) VALUES ";
                     foreach ($insertIds as $id) {
                         $query .= " (" . user()->getId() . ", {$id}, 1), ";
                     }
                     $query = substr($query, 0, -2);
                     db()->query($query);
                     user()->updateReadedCount();
                 }
             }
             break;
         case "update-setting-user":
             user()->setting(post("data[key]"), post("data[value]"));
             user()->store();
             break;
         case "update-newscache":
             user()->updateNewsCache();
             $jsonData = user()->getAjaxData();
             break;
         case "set-entries-readed":
             if (post("data[ids]")) {
                 $entries = RDR_Entry::getByIds(post("data[ids]"));
                 if ($entries) {
                     user()->loadReadedFlags(array_keys($entries));
                     $insertIds = $deleteIds = array();
                     foreach ($entries as $entry) {
                         $id = $entry->getId();
                         if ($id < user()->setting("init.entry")) {
                             continue;
                         }
                         if (isset(user()->_cacheReaded[$id])) {
                             $deleteIds[$id] = $id;
                         } else {
                             $insertIds[$id] = $id;
                         }
                     }
                     if ($insertIds) {
                         $query = "INSERT IGNORE INTO RDR_User_readed (o,k,v) VALUES ";
                         foreach ($insertIds as $id) {
                             $query .= " (" . user()->getId() . ", {$id}, 1), ";
                         }
                         $query = substr($query, 0, -2);
                         db()->query($query);
                     }
                     if ($deleteIds) {
                         $query = "DELETE FROM RDR_User_readed WHERE o = " . user()->getId() . " && k IN " . db()->toDb($deleteIds);
                     }
                     user()->updateReadedCount();
                 }
             }
             break;
         case "set-entries-saved":
             if (post("data[ids]")) {
                 $entry = RDR_Entry::getById(post("data[ids][0]"));
                 if ($entry) {
                     if (user()->getByKey("saved", $entry->getId())) {
                         user()->remove("saved", $entry->getId());
                     } else {
                         user()->add("saved", 1, $entry->getId());
                     }
                     user()->store();
                 }
             }
             break;
         case "set-feed-property":
             if (needRole(RDR_User::ROLE_ADMIN)) {
                 $feed = RDR_Feed::getById(post("data[feed]"));
                 if ($feed) {
                     $feed->{post("data[field]")} = post("data[value]");
                     $feed->store();
                 }
             }
             break;
     }
     echo json_encode($jsonData, JSON_FORCE_OBJECT);
 }
Ejemplo n.º 15
0
    /**
     * Get content
     */
    public function getContent()
    {
        headline(t("dashboard"));
        $settings = array("note.opml.import" => array("url" => l("RDR_Organize")), "note.addfeed" => array("url" => ""), "note.bug" => array("url" => "https://bfldev.com/nreeda"), "note.opml.export" => array("url" => l("RDR_Organize")), "note.search" => array("url" => ""), "note.settings" => array("url" => ""));
        echo sprintf(t("hello"), '<b>' . user()->username . '</b>') . "<br/><br/>";
        foreach ($settings as $key => $data) {
            if (user()->setting($key)) {
                continue;
            }
            echo '<div class="note" data-id="' . $key . '" data-url="' . $data["url"] . '">' . t($key) . '</div>';
        }
        ?>

        <script type="text/javascript">
        $("#content .note").on("click", function(){
            var url = $(this).attr("data-url");
            var e = $(this);
            $.post(Global.vars.ajaxUrl, {action : "changesetting", "key" : $(this).attr("data-id"), "value" : 1}, function(data){
                e.remove();
                if(url){
                    if(url.match(/^http/)){
                        window.open(url);
                    }else{
                        window.location.href = url;
                    }
                }
            })
        });
        </script>

        <div class="spacer"></div>
        <?php 
        if (needRole(RDR_User::ROLE_ADMIN)) {
            headline(t("dashboard.eventlog"));
            $logs = RDR_Event::getByCondition(null, null, "-id", 50);
            ?>
            <div id="eventlog">
                <?php 
            if ($logs) {
                ?>
<input type="button" class="btn" value="<?php 
                echo t("dashboard.clearlog");
                ?>
"/><?php 
            }
            ?>
                <div class="spacer"></div>
                <?php 
            foreach ($logs as $log) {
                ?>
                    <div class="event">
                        <time datetime="<?php 
                echo $log->createTime->getUnixtime();
                ?>
" class="inline-btn"></time>
                        <?php 
                echo $log->getText();
                ?>
                    </div>
                <?php 
            }
            ?>
            </div>
            <div class="spacer"></div>
            <script type="text/javascript">
            $("#eventlog input.btn").on("click", function(){
                $.post(window.location.href, {clearlog : 1});
                $("#eventlog").remove();
            });
            </script>
            <?php 
            $file = CHOQ_ACTIVE_MODULE_DIRECTORY . "/logs/error.log.php";
            if (file_exists($file) && filesize($file)) {
                $data = file_get_contents($file);
                $data = substr($data, strpos($data, "\n\n"));
                headline(t("dashboard.errorlog"));
                ?>
                <div id="errorlog">
                    <input type="button" class="btn" value="<?php 
                echo t("dashboard.clearlog");
                ?>
"/>
                    <pre style="font-size:11px; overflow:auto; max-height:400px;"><code><?php 
                echo s(trim($data));
                ?>
</code></pre>
                </div>
                <script type="text/javascript">
                $("#errorlog input.btn").on("click", function(){
                    $.post(window.location.href, {clearerrorlog : 1});
                    $("#errorlog").remove();
                });
                </script>
                <?php 
            }
        }
    }
Ejemplo n.º 16
0
    /**
     * Display contents for a entry
     *
     * @param RDR_Entry $entry
     */
    private function displayEntry(RDR_Entry $entry)
    {
        $jsonData = $entry->_dbValues;
        $jsonData["id"] = $entry->getId();
        $readed = isset(user()->_cacheReaded[$entry->getId()]) || user()->setting("init.entry") >= $entry->getId();
        $saved = user()->getByKey("saved", $entry->getId());
        $categories = user()->getCategories();
        $feed = $entry->feed;
        $jsonData["contentJS"] = $feed->contentJS;
        $jsonData["feedId"] = $feed->getId();
        $category = user()->getCategoryToFeed($feed);
        $layout = "default";
        $favicon = $entry->feed->getFaviconUrl();
        if (user()->setting("layout")) {
            $layout = user()->setting("layout");
        }
        $smallTag = '<div class="feed-options small">';
        if (!$readed) {
            $smallTag .= '<span><a href="#" class="readed">' . t("mark.read") . '</a> · </span>';
        }
        $smallTag .= '<span><a href="#" class="saved">' . (!$saved ? t("saveit") : t("remove.save")) . '</a> · </span>';
        $smallTag .= '<time datetime="' . $entry->datetime->getUnixtime() . '"></time> · ';
        $smallTag .= t("feed") . ': ';
        if ($favicon) {
            $smallTag .= '<span class="favicon" style="background-image:url(' . $favicon . ')"></span>';
        }
        $smallTag .= sprintf(t("feeds.2"), '<a href="' . $entry->feed->getLink() . '">' . s(cut($entry->feed->name, 30)) . '</a>', '<a href="' . $category->getLink() . '">' . s(cut($category->name, 30)) . '</a>') . " · ";
        $smallTag .= t("url") . ': <a href="' . $entry->link . '" target="_blank">' . s(cut($entry->link, 30)) . '</a>';
        if (needRole(RDR_User::ROLE_ADMIN)) {
            $smallTag .= ' · <a href="#" class="adminview">' . t("adminview") . '</a>';
        }
        $smallTag .= '</div>';
        $titleTag = '<h2><a href="' . $entry->link . '" target="_blank" onclick="return false;" rel="noreferrer">' . s($entry->title) . '</a></h2>';
        $imageTag = '<div class="image"></div>';
        ?>
        <div class="<?php 
        echo user()->setting("hideimages") ? 'no-feed-images' : null;
        ?>
 entry <?php 
        echo $readed && $this->readedLayoutEnabled ? 'readed' : null;
        ?>
 layout-<?php 
        echo s($layout);
        ?>
" id="entry-<?php 
        echo $entry->getId();
        ?>
" data-id="<?php 
        echo $entry->getId();
        ?>
" data-feed="<?php 
        echo $feed->getId();
        ?>
">
            <div class="feed-start"></div>
            <?php 
        switch ($layout) {
            case "big":
                ?>
                    <?php 
                echo $titleTag;
                ?>
                    <div class="clear"></div>
                    <div class="float-one">
                        <div class="inner"><?php 
                echo $imageTag;
                ?>
</div>
                    </div>
                    <div class="float-two">
                        <div class="inner">
                           <?php 
                echo $smallTag;
                ?>
                           <div class="text"></div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <?php 
                break;
            case "headline":
                echo $titleTag;
                echo $smallTag;
                break;
            default:
                ?>
                    <div class="float-one">
                        <div class="inner"><?php 
                echo $imageTag;
                ?>
</div>
                    </div>
                    <div class="float-two">
                        <div class="inner">
                            <?php 
                echo $titleTag;
                ?>
                            <?php 
                echo $smallTag;
                ?>
                            <div class="text"></div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <?php 
                break;
        }
        ?>
            <div class="feed-end"></div>
            <?php 
        if (!user()->setting("noautoread") && !$readed) {
            ?>
                <div class="entry-readed" data-id="<?php 
            echo $entry->getId();
            ?>
"></div>
            <?php 
        }
        ?>
            <?php 
        if (needRole(RDR_User::ROLE_ADMIN)) {
            ?>
                <div class="adminview"></div>
            <?php 
        }
        ?>
        </div>

        <script type="text/javascript">
        (function(){
            var d = <?php 
        echo json_encode($jsonData, JSON_FORCE_OBJECT);
        ?>
;
            Feeds.feedInit(d);
        })();
        </script>
        <?php 
    }
Ejemplo n.º 17
0
 /**
  * Load the View
  */
 public function onLoad()
 {
     needRole(null, true);
     if (get("token")) {
         $token = explode(".", get("token"));
         if (count($token) == 2 && saltedHash("sha256", $token[0]) == $token[1]) {
             session("user.id", $token[0]);
             if (user()) {
                 $max = min(array(200, (int) get("max")));
                 $catmax = get("catmax") ? min(array($max, (int) get("catmax"))) : $max;
                 $feedmax = get("feedmax") ? min(array($max, (int) get("feedmax"))) : $max;
                 $feedIds = explode(",", get("f"));
                 $rss = new SimpleXMLElement('<' . '?xml version="1.0" encoding="utf-8"?><rss></rss>');
                 $rss->addAttribute("version", "2.0");
                 $channel = $rss->addChild("channel");
                 $channel->addChild("title", get("title"));
                 $channel->addChild("description", get("desc"));
                 $channel->addChild("pubDate", dt("now")->format("r"));
                 $feeds = user()->getFeeds();
                 $catCount = $feedCount = array();
                 $count = 0;
                 $allEntries = array();
                 $offset = 0;
                 $limit = 50;
                 while (true) {
                     if (!$feeds) {
                         break;
                     }
                     $entries = RDR_Entry::getByCondition("feed IN {0} && id > {1}", array($feeds, (int) user()->setting("init.entry")), array("-datetime", "-id"), $limit, $offset);
                     $offset += $limit;
                     if (!$entries) {
                         break;
                     }
                     user()->loadReadedFlags(array_keys($entries));
                     foreach ($entries as $entry) {
                         if (isset(user()->_cacheReaded[$entry->getId()])) {
                             continue;
                         }
                         if ($count >= $max) {
                             break 2;
                         }
                         $feed = $entry->feed;
                         $category = user()->getCategoryToFeed($feed);
                         $feedId = $feed->getId();
                         $catId = $category->getId();
                         if (!isset($catCount[$catId])) {
                             $catCount[$catId] = 0;
                         }
                         if (!isset($feedCount[$feedId])) {
                             $feedCount[$feedId] = 0;
                         }
                         if ($feedCount[$feedId] >= $feedmax) {
                             if (isset($feeds[$feedId])) {
                                 unset($feeds[$feedId]);
                             }
                             continue;
                         }
                         if ($catCount[$catId] >= $catmax) {
                             continue;
                         }
                         $entry->category = $category;
                         $entry->time = $entry->datetime->getUnixtime();
                         $allEntries[] = $entry;
                         $feedCount[$feedId]++;
                         $catCount[$catId]++;
                         $count++;
                     }
                 }
                 foreach ($allEntries as $entry) {
                     $feed = $entry->feed;
                     $category = $entry->category;
                     $item = $channel->addChild("item");
                     $this->addCData($item->addChild("title"), $entry->title);
                     $this->addCData($item->addChild("link"), $entry->link);
                     $this->addCData($item->addChild("description"), $entry->text);
                     $this->addCData($item->addChild("category"), $category->name);
                     $item->addChild("guid", $entry->getId());
                     $item->addChild("pubDate", $entry->datetime->format("r"));
                 }
                 $data = $rss->asXML();
                 CHOQ_OutputManager::cleanAllBuffers();
                 header("Content-type: application/rss+xml");
                 echo $data;
                 die;
             }
         }
     }
     view("RDR_BasicFrame", array("view" => $this));
 }
Ejemplo n.º 18
0
 public function register()
 {
     $username = trim($_POST['username']);
     if (!$this->checkRight($username)) {
         exit("用户名不符合标准");
     }
     if (UC_START && UC_START == 'on') {
         @(include_once dirname(__FILE__) . '/../../config.inc.php');
         $uctable = explode('.', UC_DBTABLEPRE);
         $tablepre = substr($uctable[1], 0, -8);
         if (UC_KEY == "" || UC_API == "") {
             return "注册失败,请检查ucenter配置文件.";
         }
         include_once dirname(__FILE__) . '/../../uc_client/client.php';
         $passwd = trim($_REQUEST['passwd']);
         $email = $_REQUEST['email'];
         $uid = uc_user_register($username, $passwd, $email);
         if ($uid <= 0) {
             if ($uid == -6) {
                 $this->_tpl->assign('msg', '注册失败,email已注册');
             } elseif ($uid == -5) {
                 $this->_tpl->assign('msg', '注册失败,Email 不允许注册');
             } elseif ($uid == -4) {
                 $this->_tpl->assign('msg', '注册失败,Email 格式有误');
             } elseif ($uid == -3) {
                 $this->_tpl->assign('msg', '注册失败,用户名已经存在');
             } elseif ($uid == -2) {
                 $this->_tpl->assign('msg', '注册失败,包含不允许注册的词语');
             } elseif ($uid == -1) {
                 $this->_tpl->assign('msg', '注册失败,用户名不合法');
             }
             return $this->fetch('msg.html');
         } else {
             include_once dirname(__FILE__) . '/../../include/db_mysql.class.php';
             $db = new dbstuff();
             $conn = $db->connect(UC_DBHOST, UC_DBUSER, UC_DBPW);
             $password = md5($_REQUEST['passwd']);
             $sql = "INSERT INTO " . UC_DBNAME . "." . $tablepre . "common_member (`uid`,`email`,`username`,`password`)";
             $sql .= " VALUES ('{$uid}','{$email}','{$username}','{$password}')";
             @$db->query($sql);
             //at 管理员还是user
             if ($_REQUEST['at'] == 1) {
                 needRole('admin');
                 return header("Location:  /admin/index.php?c=user&a=pageUsers");
             }
             $this->_tpl->assign('msg', '注册成功');
             return $this->_tpl->fetch('msg.html');
         }
     }
     $money = daocall('setting', 'get', array('reg_user_price'));
     $result = daocall('user', 'newUser', array($username, trim($_REQUEST['passwd']), $_REQUEST['email'], $_REQUEST['name'], $_REQUEST['ids'], 0, $money));
     if ($result) {
         registerRole('user', $username);
         $external = $_REQUEST['external'];
         if ($external == '1') {
             $url = "?fc=user&fa=index";
         } else {
             $url = "?c=user&a=index";
         }
         header("Location: " . $url);
         die;
     } else {
         exit('注册失败');
     }
 }
Ejemplo n.º 19
0
 public function changePasswordForm()
 {
     needRole('user');
     return $this->_tpl->fetch('user/changePassword.html');
 }