Pull Request 

I think passing a variable $pagenum is not needed here anymore po since you're getting the value of pn, you could just initialize the value of $pagenum like this:
$pagenum = 1; 

if (isset($_GET['pn'])) {
    $pagenum = preg_replace('#[^0-9]#', '', $_GET['pn']);   
}