Ticket #124: better_404_errors.patch
| File better_404_errors.patch, 4.3 KB (added by sidtheduck, 4 months ago) |
|---|
-
plog-includes/plog-functions.php
679 679 return $thumburl; 680 680 } 681 681 682 function check_picture_id($id) { 683 $sql = "SELECT `parent_album` FROM ".TABLE_PREFIX."pictures WHERE `id` = ".intval($id); 684 $result = run_query($sql); 685 if (mysql_num_rows($result) > 0) { 686 return true; 687 } else { 688 $GLOBALS['plogger_level'] = "404"; 689 return false; 690 } 691 } 692 682 693 function get_picture_by_id($id, $album_id = null) { 683 694 global $config; 684 695 … … 761 772 return $pictures; 762 773 } 763 774 775 function check_album_id($id) { 776 $sql = "SELECT `thumbnail_id` FROM ".TABLE_PREFIX."albums WHERE `id` = ".intval($id); 777 $result = run_query($sql); 778 if (mysql_num_rows($result) > 0) { 779 return true; 780 } else { 781 $GLOBALS['plogger_level'] = "404"; 782 return false; 783 } 784 } 785 764 786 function get_album_by_id($id) { 765 787 global $config; 766 788 … … 817 839 return $album; 818 840 } 819 841 842 function check_collection_id($id) { 843 $sql = "SELECT `thumbnail_id` FROM ".TABLE_PREFIX."collections WHERE `id` = ".intval($id); 844 $result = run_query($sql); 845 if (mysql_num_rows($result) > 0) { 846 return true; 847 } else { 848 $GLOBALS['plogger_level'] = "404"; 849 return false; 850 } 851 } 852 820 853 function get_collection_by_id($id) { 821 854 global $config; 822 855 … … 1456 1489 'from' => $from, 1457 1490 'limit' => $lim)); 1458 1491 } else if ($GLOBALS["plogger_level"] == "album") { 1459 plogger_init_pictures(array( 1460 'type' => 'album', 1461 'value' => $id, 1462 'from' => $from, 1463 'limit' => $lim, 1464 'sortby' => isset($_SESSION['plogger_sortby']) ? $_SESSION['plogger_sortby'] : '', 1465 'sortdir' => isset($_SESSION['plogger_sortdir']) ? $_SESSION['plogger_sortdir'] : '')); 1492 if (check_album_id($id)) { 1493 plogger_init_pictures(array( 1494 'type' => 'album', 1495 'value' => $id, 1496 'from' => $from, 1497 'limit' => $lim, 1498 'sortby' => isset($_SESSION['plogger_sortby']) ? $_SESSION['plogger_sortby'] : '', 1499 'sortdir' => isset($_SESSION['plogger_sortdir']) ? $_SESSION['plogger_sortdir'] : '')); 1500 } 1466 1501 } else if ($GLOBALS["plogger_level"] == "collection") { 1467 plogger_init_albums(array( 1468 'from' => $from, 1469 'limit' => $lim, 1470 'collection_id' => $id, 1471 'sortby' => !empty($config['album_sortby']) ? $config['album_sortby'] : 'id', 1472 'sortdir' => !empty($config['album_sortdir']) ? $config['album_sortdir'] : 'DESC')); 1502 if (check_collection_id($id)) { 1503 plogger_init_albums(array( 1504 'from' => $from, 1505 'limit' => $lim, 1506 'collection_id' => $id, 1507 'sortby' => !empty($config['album_sortby']) ? $config['album_sortby'] : 'id', 1508 'sortdir' => !empty($config['album_sortdir']) ? $config['album_sortdir'] : 'DESC')); 1509 } 1473 1510 } else if ($GLOBALS["plogger_level"] == "picture") { 1474 // first lets load the thumbnail of the picture at the correct size 1475 plogger_init_picture(array('id' => $id)); 1511 if (check_picture_id($id)) { 1512 // first lets load the thumbnail of the picture at the correct size 1513 plogger_init_picture(array('id' => $id)); 1514 } 1476 1515 } else { 1477 1516 // Show all of the collections 1478 1517 plogger_init_collections(array( … … 1491 1530 $row = mysql_fetch_assoc($result); 1492 1531 1493 1532 if (!$row) { 1494 $GLOBALS['plogger_level'] = "404";1495 1533 return false; 1496 1534 } 1497 1535 … … 1680 1718 $result = run_query("SELECT p.*, 1681 1719 UNIX_TIMESTAMP(`date_submitted`) AS `unix_date_submitted`, 1682 1720 UNIX_TIMESTAMP(`EXIF_date_taken`) AS `unix_exif_date_taken` " . $sql); 1683 if (!mysql_num_rows($result)){ 1684 $GLOBALS['plogger_level'] = "404"; 1685 return false; 1686 } 1721 1687 1722 $GLOBALS["available_pictures"] = mysql_num_rows($result); 1688 1723 $GLOBALS["picture_counter"] = 0; 1689 1724 $GLOBALS["picture_dbh"] = $result; … … 1829 1864 $sql = "SELECT * FROM `".TABLE_PREFIX."collections` 1830 1865 $cond $ordering LIMIT $from,$lim"; 1831 1866 $result = run_query($sql); 1832 if (!mysql_num_rows($result)){ 1833 $GLOBALS['plogger_level'] = "404"; 1834 return false; 1835 } 1867 1836 1868 $GLOBALS["available_collections"] = mysql_num_rows($result); 1837 1869 $GLOBALS["collection_counter"] = 0; 1838 1870 $GLOBALS["collection_dbh"] = $result; … … 1878 1910 WHERE `parent_id` = '$collection_id' $cond $order LIMIT $from,$lim"; 1879 1911 1880 1912 $result = run_query($sql); 1881 if (!mysql_num_rows($result)){ 1882 $GLOBALS['plogger_level'] = "404"; 1883 return false; 1884 } 1913 1885 1914 $GLOBALS["available_albums"] = mysql_num_rows($result); 1886 1915 $GLOBALS["album_counter"] = 0; 1887 1916 $GLOBALS["album_dbh"] = $result;
