| 104 | | } else if( $op == "makeNewFolderAndSubmit" ) { |
|---|
| 105 | | if( $debug ) |
|---|
| 106 | | echo "DEBUG: ADDING <b>$linkName</b> ($url)TO NEW FOLDER $newFolderName<br />\n"; |
|---|
| 107 | | if( $url && $linkName ) { |
|---|
| 108 | | if( $newFolderName ) { |
|---|
| 109 | | echo "adding <b>$linkName</b> to <b>$newFolderName</b>...<br />\n"; |
|---|
| 110 | | $url = prepURLforSubmit( $url ); |
|---|
| 111 | | $name = urlencode( $linkName ); |
|---|
| 112 | | $submitter = urlencode( $u ); |
|---|
| 113 | | $isPrivate = $isPrivate ? 1 : "NULL"; |
|---|
| 114 | | |
|---|
| 115 | | # first we create the new category |
|---|
| 116 | | $folderId = addFolder( $newFolderName, $u ); |
|---|
| 117 | | |
|---|
| 118 | | # make sure the category is public, because we want new categories created public by default: |
|---|
| 119 | | if( $folderId ) { |
|---|
| 120 | | echo "created <b>$newFolderName</b>.<br />\n"; |
|---|
| 121 | | } |
|---|
| 122 | | |
|---|
| 123 | | # then we add the link: |
|---|
| 124 | | $q = addLink( $url, $name, $submitter, $folderId, $isPrivate, $options ); |
|---|
| 125 | | if( $q ) { |
|---|
| 126 | | echo "link added!<br />\n"; |
|---|
| 127 | | |
|---|
| 128 | | if( $loggedIn == "wasnt" || $newFolderName ) { |
|---|
| 129 | | %> |
|---|
| 130 | | <script type="text/javascript"> history.go( -3 ); </script> |
|---|
| 131 | | <% |
|---|
| 132 | | } else { |
|---|
| 133 | | %> |
|---|
| 134 | | <script type="text/javascript"> history.go( -2 ); </script> |
|---|
| 135 | | <% |
|---|
| 136 | | } |
|---|
| 137 | | } else { # link add failed |
|---|
| 138 | | echo "sorry, something bad happened and your new link wasn't added."; |
|---|
| 139 | | echo "please click your back button and try again, or email " . get_maintainer_email() . ".<br />\n"; |
|---|
| 140 | | } |
|---|
| 141 | | |
|---|
| 142 | | } else { |
|---|
| 143 | | echo "no new folder to create, try again."; |
|---|
| 144 | | } |
|---|
| 145 | | |
|---|
| 146 | | } else { |
|---|
| 147 | | echo "no url to add, try again."; |
|---|
| 148 | | } |
|---|
| 149 | | |
|---|
| 150 | | } else if( $op == "submit" ) { |
|---|
| 151 | | if( $url && $name ) { |
|---|
| 152 | | echo "submitting link..."; |
|---|
| 153 | | $url = prepURLforSubmit( $url ); |
|---|
| 154 | | $name = urlencode( $name ); |
|---|
| 155 | | if( !$groupid || $from == "toolbar" ) { |
|---|
| 156 | | $groupid = "NULL"; |
|---|
| 157 | | } else { |
|---|
| 158 | | $groupid = $groupid; |
|---|
| 159 | | } |
|---|
| 160 | | $submitter = urlencode( $u ); |
|---|
| 161 | | $isPrivate = $isPrivate ? 1 : "NULL"; |
|---|
| 162 | | $options = ""; # not yet implemented |
|---|
| 163 | | |
|---|
| 164 | | %> |
|---|
| 165 | | <!-- |
|---|
| 166 | | calling: _dLink( <%= $url %>, <%= $name %>, <%= $submitter %>, <%= $groupid %>, <%= $isPrivate %> ); |
|---|
| 167 | | --> |
|---|
| 168 | | <% |
|---|
| 169 | | $q = addLink( $url, $name, $submitter, $groupid, $isPrivate, $options ); |
|---|
| 170 | | if( $q ) { |
|---|
| 171 | | echo "link added!<br />\n"; |
|---|
| 172 | | |
|---|
| 173 | | if( $from == "toolbar" || $from == "funnel" ) { |
|---|
| 174 | | $showLinks = 0; |
|---|
| 175 | | |
|---|
| 176 | | if( $loggedIn == "wasnt" ) { |
|---|
| 177 | | if( preg_match( "/MSIE.*Mac/", $HTTP_USER_AGENT )) { |
|---|
| 178 | | echo "ahh, THE DREADED MAC IE."; |
|---|
| 179 | | %> |
|---|
| 180 | | <script type="text/javascript"> history.go( -5 ); </script> |
|---|
| 181 | | <% |
|---|
| 182 | | } else { |
|---|
| 183 | | %> |
|---|
| 184 | | <script type="text/javascript"> history.go( -3 ); </script> |
|---|
| 185 | | <% |
|---|
| 186 | | } |
|---|
| 187 | | |
|---|
| 188 | | } else { |
|---|
| 189 | | %> |
|---|
| 190 | | <script type="text/javascript"> history.go( -2 ); </script> |
|---|
| 191 | | <% |
|---|
| 192 | | } |
|---|
| 193 | | |
|---|
| 194 | | } else { |
|---|
| 195 | | $showLinks = 0; |
|---|
| 196 | | echo bounceWithDelay( urldecode( "/index" ), 1 ); |
|---|
| 197 | | } |
|---|
| 198 | | } else { |
|---|
| 199 | | echo "failed!"; |
|---|
| 200 | | } |
|---|
| 201 | | } else { |
|---|
| 202 | | echo "no url to add, try again."; |
|---|
| 203 | | } |
|---|
| 204 | | |
|---|
| 205 | | ############################################################## |
|---|
| 206 | | |
|---|
| 207 | | } else if( $op == "edit" ) { |
|---|
| 208 | | $hotRow = $id; |
|---|
| 209 | | %> |
|---|
| 210 | | <form> |
|---|
| 211 | | <input type="hidden" name="folder" value="<%= $folder %>" /> |
|---|
| 212 | | <div class="attention"> |
|---|
| 213 | | editing link '<%= $name %>':<br /> |
|---|
| 214 | | <input class="light" name="op" value="commitEdit" type="hidden" /> |
|---|
| 215 | | <% include( "$modules/addLinkForm.inc.php" ); %> |
|---|
| 216 | | </div> |
|---|
| 217 | | </form> |
|---|
| 218 | | <% |
|---|
| 219 | | |
|---|
| 220 | | ############################################################## |
|---|
| 221 | | |
|---|
| 222 | | } else if( $op == "commitEdit" ) { |
|---|
| 223 | | if( strlen( $name ) > $MAX_NAME_LENGTH ) |
|---|
| 224 | | $displayName = substr( $name, 0, $MAX_NAME_LENGTH ) . "..."; |
|---|
| 225 | | else |
|---|
| 226 | | $displayName = $name; |
|---|
| 227 | | %> |
|---|
| 228 | | <div class="small attention"> |
|---|
| 229 | | saving <b><%= $name %></b>... |
|---|
| 230 | | <% |
|---|
| 231 | | $url = urlencode( $url ); |
|---|
| 232 | | $name = urlencode( $name ); |
|---|
| 233 | | $groupid = ($groupid && $groupid != "unfiled") ? $groupid : "NULL"; |
|---|
| 234 | | $createDate = urlencode( $createDate ); |
|---|
| 235 | | $submitter = urlencode( $u ); |
|---|
| 236 | | $isPrivate = $isPrivate ? 1 : "NULL"; |
|---|
| 237 | | |
|---|
| 238 | | $qs = "REPLACE INTO links VALUES($id, '$url', '$name', '$createDate', NULL, '$submitter', $groupid, $isPrivate);"; |
|---|
| 239 | | $q = mysql_query( $qs ); |
|---|
| 240 | | if( $q ) { |
|---|
| 241 | | $showLinks = 0; |
|---|
| 242 | | %> |
|---|
| 243 | | <b>saved</b>. (window will close in 2 seconds) |
|---|
| 244 | | </div> |
|---|
| 245 | | <% |
|---|
| 246 | | if( $from == "popup" ) { |
|---|
| 247 | | %> |
|---|
| 248 | | |
|---|
| 249 | | <script type="text/javascript"> |
|---|
| 250 | | var timer = setTimeout( "window.close()", 2 * 1000 ); |
|---|
| 251 | | window.resizeTo(437,146); |
|---|
| 252 | | </script> |
|---|
| 253 | | |
|---|
| 254 | | <% |
|---|
| 255 | | } |
|---|
| 256 | | } else { |
|---|
| 257 | | %> |
|---|
| 258 | | <div class="attention"> |
|---|
| 259 | | <%= $qs %> |
|---|
| 260 | | oh no! couldn't commit edit! |
|---|
| 261 | | </div> |
|---|
| 262 | | <% |
|---|
| 263 | | } |
|---|
| 264 | | |
|---|
| 265 | | ############################################################## |
|---|
| 266 | | |
|---|
| 267 | | } else if( $op == "confirmDelete" ) { |
|---|
| 268 | | $hotRow = $id; |
|---|
| 269 | | %> |
|---|
| 270 | | <div class="attention"> |
|---|
| 271 | | <b>delete link:</b> |
|---|
| 272 | | <br /> |
|---|
| 273 | | <img src="/img/dk-gray.gif" height="1" width="250" /> |
|---|
| 274 | | <br /> |
|---|
| 275 | | <br /> |
|---|
| 276 | | are you sure you want to delete the link '<%= $name %>'? |
|---|
| 277 | | <p style="text-align:right;"> |
|---|
| 278 | | <a href="<%= $page %>?op=delete&id=<%= $id %>&folder=<%= urlencode( $folder ) %>">yes</a> / <a href="<%= $page %>">no</a> |
|---|
| 279 | | </p> |
|---|
| 280 | | </div> |
|---|
| 281 | | <br /> |
|---|
| 282 | | <% |
|---|
| 283 | | |
|---|
| 284 | | ############################################################## |
|---|
| 285 | | |
|---|
| 286 | | } else if( $op = "delete" ) { |
|---|
| 287 | | $q = deleteLink( $id, $u ); |
|---|
| 288 | | if( $q ) { |
|---|
| 289 | | $showLinks = 0; |
|---|
| 290 | | %> |
|---|
| 291 | | |
|---|
| 292 | | <div class="small attention"> |
|---|
| 293 | | <b>link deleted</b>. (window will close in 2 seconds) |
|---|
| 294 | | </div> |
|---|
| 295 | | <script type="text/javascript"> |
|---|
| 296 | | var timer = setTimeout( "window.close()", 2 * 1000 ); |
|---|
| 297 | | window.resizeTo(437,146); |
|---|
| 298 | | </script> |
|---|
| 299 | | |
|---|
| 300 | | <% |
|---|
| 301 | | } else { |
|---|
| 302 | | $_x = 1; |
|---|
| 303 | | } |
|---|
| 304 | | } # end if delete |
|---|
| 305 | | if( $showLinks ) { |
|---|
| 306 | | %> |
|---|
| 307 | | |
|---|
| 308 | | <% if( $debug != "nosubmit" ) { %> |
|---|
| 309 | | |
|---|
| 310 | | <!-- start left --> |
|---|
| 311 | | <div id="leftColumn"> |
|---|
| 312 | | |
|---|
| 313 | | <?php |
|---|
| 314 | | $num_links = get_simple_rs( getQuery( "links_per_user", $u )); |
|---|
| 315 | | if( $num_links < 1 ) { |
|---|
| 316 | | include( "modules/new-user-no-links.inc.php" ); |
|---|
| 317 | | } |
|---|
| 318 | | ?> |
|---|
| 319 | | |
|---|
| 320 | | <div class="box"> |
|---|
| 321 | | <div class="subhead"> |
|---|
| 322 | | <?php |
|---|
| 323 | | $qs = getQuery( "sorted_tags_per_user", $u ); |
|---|
| 324 | | $q = mysql_query( $qs ); |
|---|
| 325 | | if( $q ) |
|---|
| 326 | | $num_tags = $numRows = mysql_num_rows($q); |
|---|
| 327 | | else { |
|---|
| 328 | | ?> <!-- ERROR: running <%= $qs %> --> <?php |
|---|
| 329 | | } |
|---|
| 330 | | |
|---|
| 331 | | $tagbox_title = ($num_tags < 4) |
|---|
| 332 | | ? "Tags are like labels for your links." : |
|---|
| 333 | | ( |
|---|
| 334 | | get_ownoun() |
|---|
| 335 | | . " " |
|---|
| 336 | | . getCatsName() |
|---|
| 337 | | . " (Sort by: " |
|---|
| 338 | | . (( $taglist_sort_order == "alphabetic" ) ? "<a href='" . $page . "?taglist_sort_order=popularity'>Popularity</a>" : "Popularity" ) |
|---|
| 339 | | . " |" |
|---|
| 340 | | . (( $taglist_sort_order == "alphabetic" ) ? "A-Z" : "<a href='" . $page . "?taglist_sort_order=alphabetic'>A-Z</a>") |
|---|
| 341 | | ); |
|---|
| 342 | | |
|---|
| 343 | | echo $tagbox_title; |
|---|
| 344 | | ?> |
|---|
| 345 | | |
|---|
| 346 | | </div> |
|---|
| 347 | | |
|---|
| 348 | | <?php |
|---|
| 349 | | |
|---|
| 350 | | |
|---|
| 351 | | if( $num_tags > 4 ) { |
|---|
| 352 | | $qs2 = getQuery( "links_per_user", $u ); |
|---|
| 353 | | $q2 = mysql_query( $qs2 ); |
|---|
| 354 | | if( $q2 ) { |
|---|
| 355 | | $numLinks = mysql_result($q2,0); |
|---|
| 356 | | ?> |
|---|
| 357 | | <div class=""> |
|---|
| 358 | | <%= printLinkCount( $numLinks ) %> total links, |
|---|
| 359 | | <% |
|---|
| 360 | | $qs3 = getQuery( "num_unfiled" ) . "AND links.submitter = '$u' ORDER BY $sortOrder $direction"; |
|---|
| 361 | | |
|---|
| 362 | | if( $debug ) { |
|---|
| 363 | | e( "<br>" ); |
|---|
| 364 | | e( $qs ); |
|---|
| 365 | | } |
|---|
| 366 | | |
|---|
| 367 | | $q3 = mysql_query( $qs3 ); |
|---|
| 368 | | $numLinks = ( $q3 && mysql_num_rows( $q3 )) ? mysql_result($q3,0) : 0; |
|---|
| 369 | | $bg = "class='r0'"; |
|---|
| 370 | | %> |
|---|
| 371 | | <%= printLinkCount( $numLinks ) %> |
|---|
| 372 | | <a href="/f/unfiled"><b><em><%= getUnCattedName() %></em></b></a>. |
|---|
| 373 | | </div> |
|---|
| 374 | | |
|---|
| 375 | | <% include( "$modules/folder-list.inc.php" ); %> |
|---|
| 376 | | |
|---|
| 377 | | <% |
|---|
| 378 | | } |
|---|
| 379 | | } else { |
|---|
| 380 | | include( "modules/new-user-no-tags.inc.php" ); |
|---|
| 381 | | } |
|---|
| 382 | | %> |
|---|
| 383 | | |
|---|
| 384 | | <p> |
|---|
| 385 | | <form action="edit-folder"> |
|---|
| 386 | | Add <%= getCatName() %>: |
|---|
| 387 | | <input class="text" name="name" value="<%= $folderToEdit ? $folderToEdit : "Type the tag name..." %>" |
|---|
| 388 | | onFocus="if( this.value == 'Type the tag name...')this.value='';" |
|---|
| 389 | | onBlur="if( this.value == '')this.value='Type the tag name...';" |
|---|
| 390 | | type="text" |
|---|
| 391 | | size="18" |
|---|
| 392 | | maxlength="36" |
|---|
| 393 | | /> |
|---|
| 394 | | <input type="hidden" name="op" value="createGroup" /> |
|---|
| 395 | | <input type="submit" class="button" value="Add tag" style="padding: 3px;" /> |
|---|
| 396 | | </form> |
|---|
| 397 | | </p> |
|---|
| 398 | | |
|---|
| 399 | | <?php |
|---|
| 400 | | if( $num_tags > 3 ) { |
|---|
| 401 | | |
|---|
| 402 | | ?> |
|---|
| 403 | | <p> |
|---|
| 404 | | You can also <big><a href="/delete-unused-tags">Delete any unused tags</a></big>. |
|---|
| 405 | | </p> |
|---|
| 406 | | <?php |
|---|
| 407 | | } |
|---|
| 408 | | ?> |
|---|
| 409 | | </div> |
|---|
| 410 | | </div> |
|---|
| 411 | | |
|---|
| 412 | | <div id="rightColumn"> |
|---|
| 413 | | <div id="news" class="box"> |
|---|
| 414 | | <% include( "$modules/news-divs.inc.php" ); %> |
|---|
| 415 | | </div> |
|---|
| 416 | | |
|---|
| 417 | | <% include( "$modules/recent.inc.php" ); %> |
|---|
| 418 | | |
|---|
| 419 | | <% include( "$modules/my-recent.inc.php" ); %> |
|---|
| 420 | | |
|---|
| 421 | | <% include( "$modules/random-links.inc.php" ); %> |
|---|
| 422 | | </div> |
|---|
| 423 | | |
|---|
| 424 | | <% |
|---|
| 425 | | } |
|---|
| 426 | | } |
|---|
| 427 | | %> |
|---|
| 428 | | <% include( "$modules/footer.inc.php" ); %> |
|---|
| 429 | | |
|---|
| 430 | | <% |
|---|