">records with similar URL</a></span> <?php } else { ?> <span style="width: 150px;"><b>records with similar URL</b></span> <span style="width: 150px;"><a href="<?php echo htmlspecialchars($base_url . '&site_hierarchy'); ?> ">all URLs from this site</a></span> <?php } ?> </div> </div> <?php if (!$use_site_hierarchy) { $bib_ids = similar_urls($_REQUEST['bkmk_url']); if (!$bib_ids) { /* no similar URLs */ $noproto_url = preg_replace('!^http://(?:www[.])?([^/]*).*!', '\\1', $_REQUEST['bkmk_url']); // URL minus the protocol + possibly www. ?> <div><b>No similar URLs have been bookmarked, but there are other URLs on <span> <?php echo htmlspecialchars($noproto_url); ?> </span>.</b></div> <div>You may look at <a href="<?php echo htmlspecialchars($base_url . '&site_hierarchy'); ?> ">all known URLs from the same site</a>,<br> or <a href="addRecord.php?db=<?php
function records_check($url, $title, $notes, $user_rec_id) { /* * Look for a Records record corresponding to the given record; * user_rec_id is the user's preference if there isn't an exact match. * Insert one if it doesn't already exist; * return the rec_ID, or 0 on failure. * If there are a number of similar URLs, return a list of their rec_ids. */ // saw FIXME this should be $res = mysql_query('select rec_ID from Records where rec_URL = "' . mysql_real_escape_string($url) . '" and (rec_OwnerUGrpID=0 or not rec_NonOwnerVisibility="hidden")'); if (mysql_num_rows($res) > 0) { $bib = mysql_fetch_assoc($res); return $bib['rec_ID']; } if ($user_rec_id > 0) { $res = mysql_query('select rec_ID from Records where rec_ID = "' . mysql_real_escape_string($user_rec_id) . '" and (rec_OwnerUGrpID=0 or not rec_NonOwnerVisibility="hidden")'); if (mysql_num_rows($res) > 0) { $bib = mysql_fetch_assoc($res); return $bib['rec_ID']; } } else { if (!$user_rec_id) { $rec_ids = similar_urls($url); if ($rec_ids) { return $rec_ids; } /* $par_url = preg_replace('/[?].*'.'/', '', $url); if (substr($par_url, strlen($par_url)-1) == '/') // ends in a slash; remove it $par_url = substr($par_url, 0, strlen($par_url)-1); $res = mysql_query('select rec_ID from Records where rec_URL like "'.mysql_real_escape_string($par_url).'%" and (rec_OwnerUGrpID=0 or not rec_NonOwnerVisibility="hidden")'); if (mysql_num_rows($res) > 0) { $rec_ids = array(); while ($row = mysql_fetch_row($res)) array_push($rec_ids, $row[0]); return $rec_ids; } */ } } // no similar URLs, no exactly matching URL, or user has explicitly selected "add new URL" //insert the main record if (mysql__insert('Records', array('rec_RecTypeID' => RT_INTERNET_BOOKMARK, 'rec_URL' => $url, 'rec_Added' => date('Y-m-d H:i:s'), 'rec_Modified' => date('Y-m-d H:i:s'), 'rec_Title' => $title, 'rec_ScratchPad' => $notes, 'rec_AddedByUGrpID' => get_user_id()))) { $rec_id = mysql_insert_id(); //add title input-cell mysql__insert('recDetails', array('dtl_RecID' => $rec_id, 'dtl_DetailTypeID' => DT_NAME, 'dtl_Value' => $title)); //add notes input-cell if ($notes) { mysql__insert('recDetails', array('dtl_RecID' => $rec_id, 'dtl_DetailTypeID' => DT_EXTENDED_DESCRIPTION, 'dtl_Value' => $notes)); } return $rec_id; } return 0; }