示例#1
0
    //
    //else /* key fails */ { exit ("key incorrect "); }
} else {
    if (isset($_GET['step']) && $_GET['step'] == "collections") {
        $api_user_id = zp_get_api_user_id();
        //if (get_option('ZOTPRESS_PASSCODE') && isset($_GET['key']) && get_option('ZOTPRESS_PASSCODE') == $_GET['key'])
        //{
        // GET LOCAL COLLECTIONS
        //$_SESSION['zp_session'][$api_user_id]['collections']['zp_local_collections'] = zp_get_local_collections ($wpdb, $api_user_id);
        //
        //// Set up session item query vars
        //$_SESSION['zp_session'][$api_user_id]['collections']['zp_collections_to_update'] = array();
        //$_SESSION['zp_session'][$api_user_id]['collections']['zp_collections_to_add'] = array();
        //$_SESSION['zp_session'][$api_user_id]['collections']['query_total_collections_to_add'] = 0;
        // Set delete list
        update_option('ZOTPRESS_DELETE_' . $api_user_id, zp_get_local_collections($wpdb, $api_user_id));
        // SYNC COLLECTIONS
        ?>
<script type="text/javascript">
            
            jQuery(document).ready(function()
            {
                function zp_get_collections (zp_plugin_url, api_user_id, zp_start)
                {
                    var zpXMLurl = zp_plugin_url + "lib/actions/actions.sync.php?api_user_id=" + api_user_id + "&step=collections&start=" + zp_start;
                    //alert(zpXMLurl); // DEBUG
                    
                    jQuery.get( zpXMLurl, {}, function(xml)
                    {
                        var $result = jQuery("result", xml);
                        
        echo "'" . ZOTPRESS_PLUGIN_URL . "', '" . $api_user_id . "', '" . $_SESSION['zp_session'][$api_user_id]['key'];
        ?>
', 0);
                
            });
            
            </script><?php 
    } else {
        exit("key incorrect: " . $_GET['key'] . " vs " . $_SESSION['zp_session'][$api_user_id]['key']);
    }
} else {
    if (isset($_GET['step']) && $_GET['step'] == "collections") {
        $api_user_id = zp_get_api_user_id();
        if (isset($_SESSION['zp_session'][$api_user_id]['key']) && isset($_GET['key']) && $_SESSION['zp_session'][$api_user_id]['key'] == $_GET['key']) {
            // GET LOCAL COLLECTIONS
            $_SESSION['zp_session'][$api_user_id]['collections']['zp_local_collections'] = zp_get_local_collections($wpdb, $api_user_id);
            // Set up session item query vars
            $_SESSION['zp_session'][$api_user_id]['collections']['zp_collections_to_update'] = array();
            $_SESSION['zp_session'][$api_user_id]['collections']['zp_collections_to_add'] = array();
            $_SESSION['zp_session'][$api_user_id]['collections']['query_total_collections_to_add'] = 0;
            // SYNC COLLECTIONS
            ?>
<script type="text/javascript">
            
            jQuery(document).ready(function()
            {
                function zp_get_collections (zp_plugin_url, api_user_id, zp_key, zp_start)
                {
                    var zpXMLurl = zp_plugin_url + "lib/actions/actions.sync.php?api_user_id=" + api_user_id + "&key=" + zp_key + "&step=collections&start=" + zp_start;
                    
                    jQuery.get( zpXMLurl, {}, function(xml)
示例#3
0
         //    $xml = "<result success=\"true\" next=\"" . ($start+50) . "\" />\n";
         //}
     } else {
         if ($zp_continue === false) {
             //global $wpdb;
             zp_save_synced_items($wpdb, $api_user_id);
             $xml = "<result success=\"next\" next=\"collections\" />\n";
         } else {
             $xml = "<result success=\"false\" />\n";
             $xml = "<errors>" . $zp_continue . "</errors>\n";
         }
     }
 } else {
     if (isset($_GET['step']) && $_GET['step'] == "collections") {
         global $wpdb;
         $GLOBALS['zp_session'][$api_user_id]['collections']['zp_local_collections'] = zp_get_local_collections($wpdb, $api_user_id);
         $zp_continue = zp_get_server_collections($wpdb, $api_user_id, $start);
         if ($zp_continue === true) {
             //if ($start % 200 == 0) // Save, then continue
             //{
             zp_save_synced_collections($wpdb, $api_user_id, false);
             $xml = "<result success=\"true\" next=\"" . ($start + 50) . "\" saved=\"true\" />\n";
             //}
             //else // just continue
             //{
             //    $xml = "<result success=\"true\" next=\"" . ($start+50) . "\" />\n";
             //}
         } else {
             //global $wpdb;
             zp_save_synced_collections($wpdb, $api_user_id);
             $xml = "<result success=\"next\" next=\"tags\" />\n";