| 1344 | | function get_uni_pattern() { |
|---|
| 1345 | | return "/%u([A-Fa-f0-9]{4}|[A-Fa-f0-9]{2})/"; |
|---|
| 1346 | | } |
|---|
| 1347 | | |
|---|
| 1348 | | function toggle_link_privacy( $arg_user, $arg_link_id ) { |
|---|
| 1349 | | if( $arg_user && $arg_link_id ) { |
|---|
| 1350 | | $qs = "SELECT isPrivate FROM links WHERE ID = $arg_link_id AND userid = '$arg_user'"; |
|---|
| 1351 | | $con_toggle_link_privacy = mysql_connect(); |
|---|
| 1352 | | mysql_selectdb( getDBName() ); |
|---|
| 1353 | | $q = mysql_query( $qs ); |
|---|
| 1354 | | if( $q ) { |
|---|
| 1355 | | $old = mysql_result($q, 0, "isPrivate" ); |
|---|
| 1356 | | $old = $old ? $old : "NULL"; |
|---|
| 1357 | | $new = $old == 1 ? "NULL" : 1; |
|---|
| 1358 | | $new_label = $new == 1 ? "private" : "public"; |
|---|
| 1359 | | if( $new == "NULL" ) |
|---|
| 1360 | | run_heuristics( "publicize_link", $arg_user, array( "link" => $arg_link_id )); |
|---|
| 1361 | | |
|---|
| 1362 | | $qs = "UPDATE links SET isPrivate = $new WHERE id = $arg_link_id AND userid = '$arg_user';"; |
|---|
| 1363 | | $q = mysql_query( $qs ); |
|---|
| 1364 | | if( $q ) { |
|---|
| 1365 | | conClose( $con_toggle_link_privacy ); |
|---|
| 1366 | | return "Made link $arg_link_id $new_label."; |
|---|
| 1367 | | } |
|---|
| 1368 | | } |
|---|
| 1369 | | conClose( $con_toggle_link_privacy ); |
|---|
| 1370 | | } else |
|---|
| 1371 | | return "error!"; |
|---|
| 1372 | | } |
|---|
| 1373 | | |
|---|
| 1374 | | |
|---|
| 1375 | | function get_linkpocket( $argUser ) { |
|---|
| 1376 | | if( $argUser ) { |
|---|
| 1377 | | $con_getLinkpocket = mysql_connect(); |
|---|
| 1378 | | mysql_selectdb( getDBName() ); |
|---|
| 1379 | | $qs = |
|---|
| 1380 | | "SELECT ID FROM tags |
|---|
| 1381 | | WHERE |
|---|
| 1382 | | name = 'linkpocket' |
|---|
| 1383 | | AND userid = '$argUser';"; |
|---|
| 1384 | | $q = mysql_query( $qs ); |
|---|
| 1385 | | if( $q ) |
|---|
| 1386 | | $id = mysql_result($q, 0, "ID" ); |
|---|
| 1387 | | $qs = "SELECT COUNT(*) AS count FROM links_tags_xref WHERE tagID = $id"; |
|---|
| 1388 | | $q = mysql_query( $qs ); |
|---|
| 1389 | | if( $q ) |
|---|
| 1390 | | $count = mysql_result($q, 0, "count" ); |
|---|
| 1391 | | |
|---|
| 1392 | | conClose( $con_getLinkpocket ); |
|---|
| 1393 | | return array( "id" => $id, "count" => $count ); |
|---|
| 1394 | | } |
|---|
| 1395 | | } |
|---|
| 1396 | | |
|---|
| 1397 | | function get_entities() { |
|---|
| 1398 | | return array( |
|---|
| 1399 | | 128 => '€', |
|---|
| 1400 | | 130 => '‚', |
|---|
| 1401 | | 131 => 'ƒ', |
|---|
| 1402 | | 132 => '„', |
|---|
| 1403 | | 133 => '…', |
|---|
| 1404 | | 134 => '†', |
|---|
| 1405 | | 135 => '‡', |
|---|
| 1406 | | 136 => 'ˆ', |
|---|
| 1407 | | 137 => '‰', |
|---|
| 1408 | | 138 => 'Š', |
|---|
| 1409 | | 139 => '‹', |
|---|
| 1410 | | 140 => 'Œ', |
|---|
| 1411 | | 142 => 'Ž', |
|---|
| 1412 | | 145 => '‘', |
|---|
| 1413 | | 146 => '’', |
|---|
| 1414 | | 147 => '“', |
|---|
| 1415 | | 148 => '”', |
|---|
| 1416 | | 149 => '•', |
|---|
| 1417 | | 150 => '–', |
|---|
| 1418 | | 151 => '—', |
|---|
| 1419 | | 152 => '˜', |
|---|
| 1420 | | 153 => '™', |
|---|
| 1421 | | 154 => 'š', |
|---|
| 1422 | | 155 => '›', |
|---|
| 1423 | | 156 => 'œ', |
|---|
| 1424 | | 158 => 'ž', |
|---|
| 1425 | | 159 => 'Ÿ'); |
|---|
| | 1353 | function get_uni_pattern() { |
|---|
| | 1354 | return "/%u([A-Fa-f0-9]{4}|[A-Fa-f0-9]{2})/"; |
|---|
| | 1355 | } |
|---|
| | 1356 | |
|---|
| | 1357 | function toggle_link_privacy( $arg_user, $arg_link_id ) { |
|---|
| | 1358 | if( $arg_user && $arg_link_id ) { |
|---|
| | 1359 | $qs = "SELECT isPrivate FROM links WHERE ID = $arg_link_id AND userid = '$arg_user'"; |
|---|
| | 1360 | $con_toggle_link_privacy = mysql_connect(); |
|---|
| | 1361 | mysql_selectdb( getDBName() ); |
|---|
| | 1362 | $q = mysql_query( $qs ); |
|---|
| | 1363 | if( $q ) { |
|---|
| | 1364 | $old = mysql_result($q, 0, "isPrivate" ); |
|---|
| | 1365 | $old = $old ? $old : "NULL"; |
|---|
| | 1366 | $new = $old == 1 ? "NULL" : 1; |
|---|
| | 1367 | $new_label = $new == 1 ? "private" : "public"; |
|---|
| | 1368 | if( $new == "NULL" ) |
|---|
| | 1369 | run_heuristics( "publicize_link", $arg_user, array( "link" => $arg_link_id )); |
|---|
| | 1370 | else |
|---|
| | 1371 | apply_tag_by_ID( $arg_link_id, get_private_tag_ID( get_user())); |
|---|
| | 1372 | |
|---|
| | 1373 | $qs = "UPDATE links SET isPrivate = $new WHERE id = $arg_link_id AND userid = '$arg_user';"; |
|---|
| | 1374 | $q = mysql_query( $qs ); |
|---|
| | 1375 | if( $q ) { |
|---|
| | 1376 | conClose( $con_toggle_link_privacy ); |
|---|
| | 1377 | return "Made link $arg_link_id $new_label."; |
|---|
| | 1378 | } |
|---|
| | 1379 | } |
|---|
| | 1380 | conClose( $con_toggle_link_privacy ); |
|---|
| | 1381 | } else |
|---|
| | 1382 | return "error!"; |
|---|
| | 1383 | } |
|---|
| | 1384 | |
|---|
| | 1385 | function get_private_tag_ID( $user ) { |
|---|
| | 1386 | $tag_id = get_simple_rs( getQuery( "find_private_tag", $user )); |
|---|
| | 1387 | log_mesg_to( "get_private_tag_ID: $user : $tag_id", "global" ); |
|---|
| | 1388 | return $tag_id; |
|---|
| | 1389 | } |
|---|
| | 1390 | |
|---|
| | 1391 | function get_linkpocket( $argUser ) { |
|---|
| | 1392 | if( $argUser ) { |
|---|
| | 1393 | $con_getLinkpocket = mysql_connect(); |
|---|
| | 1394 | mysql_selectdb( getDBName() ); |
|---|
| | 1395 | $qs = |
|---|
| | 1396 | "SELECT ID FROM tags |
|---|
| | 1397 | WHERE |
|---|
| | 1398 | name = 'linkpocket' |
|---|
| | 1399 | AND userid = '$argUser';"; |
|---|
| | 1400 | $q = mysql_query( $qs ); |
|---|
| | 1401 | if( $q ) |
|---|
| | 1402 | $id = mysql_result($q, 0, "ID" ); |
|---|
| | 1403 | $qs = "SELECT COUNT(*) AS count FROM links_tags_xref WHERE tagID = $id"; |
|---|
| | 1404 | $q = mysql_query( $qs ); |
|---|
| | 1405 | if( $q ) |
|---|
| | 1406 | $count = mysql_result($q, 0, "count" ); |
|---|
| | 1407 | |
|---|
| | 1408 | conClose( $con_getLinkpocket ); |
|---|
| | 1409 | return array( "id" => $id, "count" => $count ); |
|---|
| 1427 | | |
|---|
| 1428 | | # strips slashes, and converts special characters to HTML equivalents for string defined in $var |
|---|
| 1429 | | function o( $s ){ |
|---|
| 1430 | | $chars = get_entities(); |
|---|
| 1431 | | return hateration( unicode_fix( str_replace(array_map('chr', array_keys($chars)), $chars, htmlentities(stripslashes($s))))); |
|---|
| 1432 | | } |
|---|
| 1433 | | |
|---|
| 1434 | | function hateration( $s ) { |
|---|
| 1435 | | return unEscapeQuotes( preg_replace( "/&#x/", "&#x", $s )); |
|---|
| 1436 | | } |
|---|
| 1437 | | |
|---|
| 1438 | | # replace things which look like ghastly php entities with cute lil hex escapes |
|---|
| 1439 | | function unicode_fix( $s ) { |
|---|
| 1440 | | return preg_replace( get_uni_pattern(), "&#x$1;", $s ); |
|---|
| 1441 | | } |
|---|
| | 1411 | } |
|---|
| | 1412 | |
|---|
| | 1413 | function get_entities() { |
|---|
| | 1414 | return array( |
|---|
| | 1415 | 128 => '€', |
|---|
| | 1416 | 130 => '‚', |
|---|
| | 1417 | 131 => 'ƒ', |
|---|
| | 1418 | 132 => '„', |
|---|
| | 1419 | 133 => '…', |
|---|
| | 1420 | 134 => '†', |
|---|
| | 1421 | 135 => '‡', |
|---|
| | 1422 | 136 => 'ˆ', |
|---|
| | 1423 | 137 => '‰', |
|---|
| | 1424 | 138 => 'Š', |
|---|
| | 1425 | 139 => '‹', |
|---|
| | 1426 | 140 => 'Œ', |
|---|
| | 1427 | 142 => 'Ž', |
|---|
| | 1428 | 145 => '‘', |
|---|
| | 1429 | 146 => '’', |
|---|
| | 1430 | 147 => '“', |
|---|
| | 1431 | 148 => '”', |
|---|
| | 1432 | 149 => '•', |
|---|
| | 1433 | 150 => '–', |
|---|
| | 1434 | 151 => '—', |
|---|
| | 1435 | 152 => '˜', |
|---|
| | 1436 | 153 => '™', |
|---|
| | 1437 | 154 => 'š', |
|---|
| | 1438 | 155 => '›', |
|---|
| | 1439 | 156 => 'œ', |
|---|
| | 1440 | 158 => 'ž', |
|---|
| | 1441 | 159 => 'Ÿ'); |
|---|
| | 1442 | } |
|---|
| | 1443 | |
|---|
| | 1444 | # strips slashes, and converts special characters to HTML equivalents for string defined in $var |
|---|
| | 1445 | function o( $s ){ |
|---|
| | 1446 | $chars = get_entities(); |
|---|
| | 1447 | return hateration( unicode_fix( str_replace(array_map('chr', array_keys($chars)), $chars, htmlentities(stripslashes($s))))); |
|---|
| | 1448 | } |
|---|
| | 1449 | |
|---|
| | 1450 | function hateration( $s ) { |
|---|
| | 1451 | return unEscapeQuotes( preg_replace( "/&#x/", "&#x", $s )); |
|---|
| | 1452 | } |
|---|
| | 1453 | |
|---|
| | 1454 | # replace things which look like ghastly php entities with cute lil hex escapes |
|---|
| | 1455 | function unicode_fix( $s ) { |
|---|
| | 1456 | return preg_replace( get_uni_pattern(), "&#x$1;", $s ); |
|---|
| | 1457 | } |
|---|