Example #1
0
 function shareToPublished()
 {
     $title = $this->dbh->escape_string(strip_tags($_REQUEST["title"]));
     $url = $this->dbh->escape_string(strip_tags($_REQUEST["url"]));
     $content = $this->dbh->escape_string(strip_tags($_REQUEST["content"]));
     if (Article::create_published_article($title, $url, $content, "", $_SESSION["uid"])) {
         $this->wrap(self::STATUS_OK, array("status" => 'OK'));
     } else {
         $this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed'));
     }
 }
    function sharepopup()
    {
        if (SINGLE_USER_MODE) {
            login_sequence();
        }
        header('Content-Type: text/html; charset=utf-8');
        print "<html><head><title>Tiny Tiny RSS</title>";
        stylesheet_tag("css/utility.css");
        javascript_tag("lib/prototype.js");
        javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls");
        print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n\t\t\t</head><body id='sharepopup'>";
        $action = $_REQUEST["action"];
        if ($_SESSION["uid"]) {
            if ($action == 'share') {
                $title = $this->dbh->escape_string(strip_tags($_REQUEST["title"]));
                $url = $this->dbh->escape_string(strip_tags($_REQUEST["url"]));
                $content = $this->dbh->escape_string(strip_tags($_REQUEST["content"]));
                $labels = $this->dbh->escape_string(strip_tags($_REQUEST["labels"]));
                Article::create_published_article($title, $url, $content, $labels, $_SESSION["uid"]);
                print "<script type='text/javascript'>";
                print "window.close();";
                print "</script>";
            } else {
                $title = htmlspecialchars($_REQUEST["title"]);
                $url = htmlspecialchars($_REQUEST["url"]);
                ?>

				<table height='100%' width='100%'><tr><td colspan='2'>
				<h1><?php 
                echo __("Share with Tiny Tiny RSS");
                ?>
</h1>
				</td></tr>

				<form id='share_form' name='share_form'>

				<input type="hidden" name="op" value="sharepopup">
				<input type="hidden" name="action" value="share">

				<tr><td align='right'><?php 
                echo __("Title:");
                ?>
</td>
				<td width='80%'><input name='title' value="<?php 
                echo $title;
                ?>
"></td></tr>
				<tr><td align='right'><?php 
                echo __("URL:");
                ?>
</td>
				<td><input name='url' value="<?php 
                echo $url;
                ?>
"></td></tr>
				<tr><td align='right'><?php 
                echo __("Content:");
                ?>
</td>
				<td><input name='content' value=""></td></tr>
				<tr><td align='right'><?php 
                echo __("Labels:");
                ?>
</td>
				<td><input name='labels' id="labels_value"
					placeholder='Alpha, Beta, Gamma' value="">
				</td></tr>

				<tr><td>
					<div class="autocomplete" id="labels_choices"
						style="display : block"></div></td></tr>

				<script type='text/javascript'>document.forms[0].title.focus();</script>

				<script type='text/javascript'>
					new Ajax.Autocompleter('labels_value', 'labels_choices',
				   "backend.php?op=rpc&method=completeLabels",
				   { tokens: ',', paramName: "search" });
				</script>

				<tr><td colspan='2'>
					<div style='float : right' class='insensitive-small'>
					<?php 
                echo __("Shared article will appear in the Published feed.");
                ?>
					</div>
					<button type="submit"><?php 
                echo __('Share');
                ?>
</button>
					<button onclick="return window.close()"><?php 
                echo __('Cancel');
                ?>
</button>
					</div>

				</form>
				</td></tr></table>
				</body></html>
				<?php 
            }
        } else {
            $return = urlencode($_SERVER["REQUEST_URI"]);
            ?>

			<form action="public.php?return=<?php 
            echo $return;
            ?>
"
				method="POST" id="loginForm" name="loginForm">

			<input type="hidden" name="op" value="login">

			<table height='100%' width='100%'><tr><td colspan='2'>
			<h1><?php 
            echo __("Not logged in");
            ?>
</h1></td></tr>

			<tr><td align="right"><?php 
            echo __("Login:"******"right"><input name="login"
				value="<?php 
            echo $_SESSION["fake_login"];
            ?>
"></td></tr>
				<tr><td align="right"><?php 
            echo __("Password:"******"right"><input type="password" name="password"
				value="<?php 
            echo $_SESSION["fake_password"];
            ?>
"></td></tr>
			<tr><td colspan='2'>
				<button type="submit">
					<?php 
            echo __('Log in');
            ?>
</button>

				<button onclick="return window.close()">
					<?php 
            echo __('Cancel');
            ?>
</button>
			</td></tr>
			</table>

			</form>
			<?php 
        }
    }