Beispiel #1
0
function sort_bookmark($id, $sort, $recursive = 0, $bookmark_json)
{
    $bookmark = parse_bookmark_json($bookmark_json);
    $id_s = $id;
    $levels = explode('_', substr($id, 1));
    $id = array_pop($levels);
    $data = update_bookmark_recursive($bookmark[0], $levels, 0, 'sort_bookmark_callback', array($id, $sort));
    $bookmark[0] = $data[0];
    file_put_contents($bookmark_json, json_encode($bookmark), LOCK_EX);
    if ($recursive == 1) {
        if ($id == 0) {
            $entries = $data[1];
            $id_s = '';
        } else {
            $entries = $data[1]['entries'];
        }
        foreach ($entries as $entry) {
            if ($entry['type'] == 'folder') {
                $data[1]['entries']['_' . $entry['id']] = sort_bookmark($id_s . '_' . $entry['id'], $sort, 1, $bookmark_json);
            }
        }
    }
    return $data[1];
}
Beispiel #2
0
                     $entry = delete_bookmark($_GET['id'], 1, $bookmark_json);
                     move_bookmark($entry, $_POST['l'] . '_0', $bookmark_json);
                 }
                 $anchor = $_POST['l'] . '_' . $entry['id'];
             }
             break;
         case 'move':
             if (isset($_GET['id']) && $_GET['id']) {
                 $entry = delete_bookmark($_GET['id'], 1, $bookmark_json);
                 move_bookmark($entry, $_GET['position'], $bookmark_json);
                 $anchor = substr($_GET['position'], 0, strrpos($_GET['position'], '_')) . '_' . $entry['id'];
             }
             break;
         case 'sort':
             if (isset($_GET['id']) && $_GET['id']) {
                 $entry = sort_bookmark($_GET['id'], $_GET['sort'], isset($_GET['recursive']) ? $_GET['recursive'] : 0, $bookmark_json);
                 $anchor = $_GET['id'] == '_0' ? '' : $_GET['id'];
             }
             break;
         case 'export':
             header('Content-Type: text/plain');
             readfile($bookmark_json);
             exit;
     }
     header('Location: index.php' . (isset($anchor) && $anchor ? '#entry-' . $anchor : ''));
     exit;
 } elseif (isset($_GET['u'])) {
     $url = addhttp(urldecode(substr($_SERVER['QUERY_STRING'], 2)));
     $entry = add_bookmark($url, '_0', 'url', $sync_json, null, 1);
     echo '<html><body><script>if (window.confirm("URL synced to ' . htmlentities($site_name) . '. Redirect to ' . htmlentities($site_name) . '?")) {window.location="' . $site_url . '";} else {window.location="' . $url . '";}</script></body></html>';
     //header('Location: '.$url);