HEX
Server: Apache
System: Linux www3.pit.tblive.com 5.14.0-687.38.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 12 17:19:12 EDT 2026 x86_64
User: awaldron (1020)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //home/awaldron/_domains/phlibrary.alanwaldron.com/get_new_books.php
<?php
require_once("wp-load.php");
date_default_timezone_set('America/New_York');

function array_trim($arr) {
    for ($i=0; $i < count($arr); $i++) {
        $arr[$i] = trim($arr[$i]);
    }
    return $arr;
}
function make_url($arr) {
    for ($i=0; $i < count($arr); $i++) {
        $arr[$i] = urldecode('https://librarycatalog.einetwork.net'.trim($arr[$i]));
    }
    return $arr;
}
error_reporting(E_ALL);
$handle = curl_init();

$url = 'https://librarycatalog.einetwork.net/Search/Results?sort=year&type=Keyword&filter%5B%5D=%7Ebuilding%3A%22Penn+Hills+Library%22&filter%5B%5D=%7Ebuilding%3A%22Penn+Hills+Library+-+Lincoln+Park%22&filter%5B%5D=%7Etime_since_added%3A%22Month%22&filter%5B%5D=%7Etime_since_added%3A%222+Months%22&filter%5B%5D=%7Eformat%3A%22Print+Book%22';
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($handle);
curl_close($handle);

preg_match_all('/class="itemTitle"><a href="\/Record\/([^"]+)">([^<]+)/',$html,$matches);
$ids = $matches[1];
$titles = array_trim($matches[2]);

preg_match_all('/<img alt="Cover Image" class="recordcover" src="([^"]+)"/',$html,$image_matches);
$images = make_url($image_matches[1]);

$numbers = range(0, count($images)-1 );
shuffle($numbers);

$data = array();
for ($i=0; $i < 6; $i++) {
    $n = $numbers[$i];
    $data[] = array( $images[$n], 'https://librarycatalog.einetwork.net/Record/'.$ids[$n] );
}

update_option('new_and_noteworthy', serialize($data));

echo 'ok'; exit;