public function deleteCategory($blogid, $username, $password, $id)
 {
     $this->auth($username, $password, 'editor');
     $id = (int) $id;
     $categories = tcategories::i();
     if (!$categories->itemexists($id)) {
         return xerror(404, "Sorry, no such page.");
     }
     $categories->delete($id);
     return true;
 }
Пример #2
0
function getDevices($user, $type = null)
{
    global $mysql;
    // this is what i would want to do, but doesn't work
    $sql = "SELECT * FROM `authcodes` WHERE `userid` = '" . $mysql->real_escape_string($user) . "' ORDER BY `created` DESC";
    //echo $sql;
    $result = $mysql->query($sql);
    if ($result->num_rows < 1) {
        // this probably actually shouldn't be an error
        if ($type == "json") {
            return "[]";
        } else {
            if ($type == "xml") {
                return '<?xml version="1.0"?>' . "\n" . '<synccit><devices></devices></synccit>';
            } else {
                xerror("no links found");
                return false;
            }
        }
    }
    $output = "";
    if (is_null($type)) {
        while ($link = $result->fetch_assoc()) {
            $output .= $link['linkid'] . ":" . $link['lastvisit'] . ";" . $link['lastcommentcount'] . ":" . $link['lastcommenttime'] . ",\n";
        }
    } else {
        if ($type == "json") {
            $json = array();
            $i = 0;
            while ($link = $result->fetch_assoc()) {
                $json[$i++] = array("auth" => $link['authhash'], "device" => $link['description'], "created" => $link['created'], "createdby" => $link['createdby'] == null ? "synccit.com" : $link['createdby']);
            }
            $output = json_encode($json);
        } else {
            if ($type = "xml") {
                $xml = new SimpleXMLElement('<?xml version="1.0"?><synccit></synccit>');
                $links = $xml->addChild("links");
                while ($link = $result->fetch_assoc()) {
                    $l = $links->addChild("link");
                    $l->addChild("id", $link['linkid']);
                    $l->addChild("lastvisit", $link["lastvisit"]);
                    $l->addChild("comments", $link["lastcommentcount"]);
                    $l->addChild("commentvisit", $link["lastcommenttime"]);
                }
                $output = $xml->asXML();
            }
        }
    }
    return $output;
}
Пример #3
0
/**
 * @param $links offset count
 * @param $user userid
 * @param null $type json, xml
 * @param $time time since last call
 * @return bool|string output
 *
 *
 */
function historyLinks($user, $type = null, $links = 0, $time = 0)
{
    global $mysql;
    $sql = "\n        SELECT * FROM `links`\n         WHERE ";
    if ($time > 0) {
        $time = (int) $time;
        $sql .= " (`lastvisit` >= '{$time}' OR `lastcommenttime` >= '{$time}') AND ";
    }
    $links = (int) $links;
    $sql .= "\n        `userid` = '" . $mysql->real_escape_string($user) . "'\n\n        LIMIT {$links}, 100\n    ";
    //echo $sql;
    $result = $mysql->query($sql);
    if ($result->num_rows < 1) {
        // this probably actually shouldn't be an error
        if ($type == "json") {
            return "[]";
        } else {
            if ($type == "xml") {
                return '<?xml version="1.0"?>' . "\n" . '<synccit><links></links></synccit>';
            } else {
                xerror("no links found");
                return false;
            }
        }
    }
    $output = "";
    if (is_null($type)) {
        while ($link = $result->fetch_assoc()) {
            $output .= $link['linkid'] . ":" . $link['lastvisit'] . ";" . $link['lastcommentcount'] . ":" . $link['lastcommenttime'] . ",\n";
        }
    } else {
        if ($type == "json") {
            $json = array();
            $i = 0;
            while ($link = $result->fetch_assoc()) {
                $json[$i++] = array("id" => $link['linkid'], "lastvisit" => $link['lastvisit'], "comments" => $link['lastcommentcount'], "commentvisit" => $link['lastcommenttime']);
            }
            $output = json_encode($json);
        } else {
            if ($type = "xml") {
                $xml = new SimpleXMLElement('<?xml version="1.0"?><synccit></synccit>');
                $links = $xml->addChild("links");
                while ($link = $result->fetch_assoc()) {
                    $l = $links->addChild("link");
                    $l->addChild("id", $link['linkid']);
                    $l->addChild("lastvisit", $link["lastvisit"]);
                    $l->addChild("comments", $link["lastcommentcount"]);
                    $l->addChild("commentvisit", $link["lastcommenttime"]);
                }
                $output = $xml->asXML();
            }
        }
    }
    return $output;
}