static function lookup($url, $custom_hash = '', $pref = '') { global $serendipity; $custom_hash = trim($custom_hash); $url = trim($url); if (!preg_match('@https?://@i', $url)) { $url = 'http://' . $url; } $res = serendipity_db_query("SELECT hash FROM {$serendipity['dbPrefix']}linktrimmer WHERE url = '" . serendipity_db_escape_string($url) . "' LIMIT 1", true, 'assoc'); if (!is_array($res) || empty($res['hash'])) { if (!empty($custom_hash)) { $res = serendipity_db_query("SELECT hash FROM {$serendipity['dbPrefix']}linktrimmer WHERE hash = '" . serendipity_db_escape_string($custom_hash) . "' LIMIT 1", true, 'assoc'); if (is_array($res) && !empty($res['hash'])) { return false; } } $hash = serendipity_event_linktrimmer::create($url, $custom_hash); if (empty($hash)) { return false; } else { return $pref . $hash; } } return $pref . $res['hash']; }