]> git.wh0rd.org - tt-rss.git/blobdiff - classes/rpc.php
add mail and share plugins
[tt-rss.git] / classes / rpc.php
index 8f03381f8a311a9281768b8a74db3a99f43315a4..55ea05da9f166304c344559059a47d2bdcae15f2 100644 (file)
@@ -1,9 +1,9 @@
 <?php
-class RPC extends Handler {
+class RPC extends Protected_Handler {
 
        function setprofile() {
                $id = db_escape_string($_REQUEST["id"]);
-               
+
                $_SESSION["profile"] = $id;
                $_SESSION["prefs_cache"] = array();
        }
@@ -215,7 +215,7 @@ class RPC extends Handler {
 
                 if ($last_article_id != getLastArticleId($this->link)) {
                                $omode = $_REQUEST["omode"];
-       
+
                        if ($omode != "T")
                                $reply['counters'] = getAllCounters($this->link, $omode);
                        else
@@ -401,13 +401,13 @@ class RPC extends Handler {
        }
 
        function assigntolabel() {
-               return labelops(true);
+               return $this->labelops(true);
        }
-       
+
        function removefromlabel() {
-               return labelops(false);
+               return $this->labelops(false);
        }
-       
+
        function labelops($assign) {
                $reply = array();
 
@@ -507,7 +507,7 @@ class RPC extends Handler {
                        FROM ttrss_entries, ttrss_user_entries
                        WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
 
-               $content = sanitize_rss($this->link, db_fetch_result($result, 0, "content"));
+               $content = sanitize($this->link, db_fetch_result($result, 0, "content"));
                $title = strip_tags(db_fetch_result($result, 0, "title"));
                $article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
                $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
@@ -563,78 +563,6 @@ class RPC extends Handler {
                print json_encode(array("message" => "UPDATE_COUNTERS"));
        }
 
-       function sendEmail() {
-               $secretkey = $_REQUEST['secretkey'];
-
-               require_once 'lib/phpmailer/class.phpmailer.php';
-
-               $reply = array();
-
-               if (DIGEST_ENABLE && $_SESSION['email_secretkey'] &&
-               $secretkey == $_SESSION['email_secretkey']) {
-
-                       $_SESSION['email_secretkey'] = '';
-
-                       $destination = $_REQUEST['destination'];
-                       $subject = $_REQUEST['subject'];
-                       $content = $_REQUEST['content'];
-
-                       $replyto = strip_tags($_SESSION['email_replyto']);
-                       $fromname = strip_tags($_SESSION['email_fromname']);
-
-                       $mail = new PHPMailer();
-
-                       $mail->PluginDir = "lib/phpmailer/";
-                       $mail->SetLanguage("en", "lib/phpmailer/language/");
-
-                       $mail->CharSet = "UTF-8";
-
-                       $mail->From = $replyto;
-                       $mail->FromName = $fromname;
-                       $mail->AddAddress($destination);
-
-                       if (DIGEST_SMTP_HOST) {
-                               $mail->Host = DIGEST_SMTP_HOST;
-                               $mail->Mailer = "smtp";
-                               $mail->SMTPAuth = DIGEST_SMTP_LOGIN != '';
-                               $mail->Username = DIGEST_SMTP_LOGIN;
-                               $mail->Password = DIGEST_SMTP_PASSWORD;
-                       }
-
-                       $mail->IsHTML(false);
-                       $mail->Subject = $subject;
-                       $mail->Body = $content;
-
-                       $rc = $mail->Send();
-
-                       if (!$rc) {
-                               $reply['error'] =  $mail->ErrorInfo;
-                       } else {
-                               save_email_address($this->link, db_escape_string($destination));
-                               $reply['message'] = "UPDATE_COUNTERS";
-                       }
-
-               } else {
-                       $reply['error'] = "Not authorized.";
-               }
-
-               print json_encode($reply);
-       }
-
-       function completeEmails() {
-               $search = db_escape_string($_REQUEST["search"]);
-
-               print "<ul>";
-
-               foreach ($_SESSION['stored_emails'] as $email) {
-                       if (strpos($email, $search) !== false) {
-                               print "<li>$email</li>";
-                       }
-               }
-
-               print "</ul>";
-       }
-
        function quickAddCat() {
                $cat = db_escape_string($_REQUEST["cat"]);
 
@@ -706,7 +634,7 @@ class RPC extends Handler {
                        if (db_num_rows($result) != 0) {
                                $line = db_fetch_assoc($result);
 
-                               $article_content = sanitize_rss($this->link, $line["content"],
+                               $article_content = sanitize($this->link, $line["content"],
                                        false, false, $line['site_url']);
 
                                array_push($rv,
@@ -753,21 +681,16 @@ class RPC extends Handler {
                return;
        }
 
-       function getTweetInfo() {
-               $id = db_escape_string($_REQUEST['id']);
-
-               $result = db_query($this->link, "SELECT title, link
-                               FROM ttrss_entries, ttrss_user_entries
-                               WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
+       function buttonPlugin() {
+               $pclass = basename($_REQUEST['plugin']) . "_button";
+               $method = $_REQUEST['plugin_method'];
 
-               if (db_num_rows($result) != 0) {
-                       $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')),
-                               100, '...');
-                       $article_link = db_fetch_result($result, 0, 'link');
+               if (class_exists($pclass)) {
+                       $plugin = new $pclass($this->link);
+                       if (method_exists($plugin, $method)) {
+                               return $plugin->$method();
+                       }
                }
-
-               print json_encode(array("title" => $title, "link" => $article_link,
-                               "id" => $id));
        }
 
        function setNote() {