Example #1
0
 /**
  * Hands the user a yummy cookie.
  * The cookie holds the md5 hash of the user password
  */
 function setUserCookie($user, $hash)
 {
     $rs = rss_query('select value_ from ' . getTable('config') . "where key_ = 'rss.config.autologout'", false, true);
     if (rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR) && rss_num_rows($rs) > 0) {
         list($als) = rss_fetch_row($rs);
         $al = $als == 'true';
     } else {
         $al = false;
     }
     $t = $al ? 0 : time() + COOKIE_LIFESPAN;
     setcookie(RSS_USER_COOKIE, $user . '|' . $hash, $t, getPath());
 }
Example #2
0
function _init_properties()
{
    $table = getTable('properties');
    rss_query_wrapper('DROP TABLE IF EXISTS ' . $table, true, true);
    $sql_create = str_replace('__table__', $table, <<<_SQL_
\t\tCREATE TABLE __table__ (
\t\t  fk_ref_object_id text NOT NULL,
\t\t  proptype enum('item','feed','folder','category','plugin','tag','theme','misc') NOT NULL default 'item',
\t\t  property varchar(128) NOT NULL default '',
\t\t  value text NOT NULL
\t\t) ENGINE=MyISAM
\t\t
_SQL_
);
    rss_query_wrapper($sql_create, false, true);
    if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) {
        rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR);
        return 0;
    } else {
        $idSql = "alter table {$table} add UNIQUE KEY uniq (fk_ref_object_id(180),property,proptype)";
        rss_query_wrapper($idSql, false, true);
        return rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR);
    }
}
Example #3
0
function __exp__rateItem($iid, $rt)
{
    $iid = sanitize($iid, RSS_SANITIZER_NUMERIC);
    $rt = sanitize($rt, RSS_SANITIZER_NUMERIC);
    list($rrt) = rss_fetch_row(rss_query("select rating from " . getTable('rating') . " where iid = {$iid}"));
    rss_query('delete from ' . getTable('rating') . ' where iid = ' . $iid);
    if ($rt == $rrt) {
        return "{$iid}|0";
    }
    rss_query('insert into ' . getTable('rating') . "(iid,rating) values ({$iid},{$rt})");
    if (rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) {
        return "{$iid}|{$rt}";
    }
}
Example #4
0
function cacheFavicon($icon)
{
    // Make sure only real favicons get fetched into the DB
    if (!preg_match('#^https?://.+$#', $icon)) {
        return false;
    }
    $icon_ = rss_real_escape_string($icon);
    $binIcon = getUrl($icon);
    if ($binIcon) {
        $sql = "delete from " . getTable('cache') . " where cachetype='icon' and cachekey='{$icon_}'";
        rss_query($sql);
        $sql = "insert into " . getTable('cache') . "(cachekey,timestamp,cachetype,data) values " . "('{$icon_}',now(),'icon','" . rss_real_escape_string($binIcon) . "')";
        rss_query($sql);
        return rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR);
    }
    return false;
}