示例#1
0
                         $updates[$id]["link"] = 1;
                     }
                 } else {
                     $updates[$id]["link"] = 1;
                 }
             }
             insertLinks($updates, $developer, $authinfo["userid"], $authinfo["device"]);
             xsuccess(count($updates) . " links updated", "xml");
         } else {
             $links = array();
             $i = 0;
             foreach ($xml->links->link as $link) {
                 $links[$i++] = "" . $link->id;
                 // convert simplexml to string. not that important here though
             }
             $result = readLinks($links, $authinfo["userid"], "xml");
             echo $result;
             die;
         }
     } catch (Exception $e) {
         xerror("xml error", "xml");
     }
     xerror("xml error");
 } else {
     //we're just going to assume json if data variable is set with no type
     // still sent on post var data
     $json = json_decode($_POST['data'], true);
     if ($json == false || $json == null) {
         xerror("json error " . json_last_error(), "json");
     }
     $username = $json["username"];
示例#2
0
            $developer = isset($_POST['dev']) ? $_POST['dev'] : "unknown";
            insertLinks($updates, $developer, $authinfo["userid"], $authinfo["device"]);
            xsuccess(count($updates) . " links updated");
        } else {
            $username = $_POST['username'];
            $auth = $_POST['auth'];
            // try to update last used time of auth. if fails, auth doesnt exist
            $authinfo = checkAuth($username, $auth);
            if (strpos($_POST['links'], ",") === FALSE) {
                $links = array($_POST['links']);
            } else {
                $links = explode(",", $_POST['links']);
            }
            // no comments for reading
            // comment count is returned by default
            $result = readLinks($links, $authinfo["userid"], null);
            echo $result;
        }
    } else {
        xerror("no post data");
    }
}
function checkAuth($username, $auth, $mode = false)
{
    global $mysql;
    // seems running this and seeing if affected_rows was > 0 doesn't work.
    // this does help me get the user id I use later
    // but just using username probably wouldn't be a bad idea
    /*$sql = "UPDATE `authcodes`
      SET `lastused` = '".time()."'
      WHERE