/** * Copy URL to TAGS */ function CopyUrlToTags($f_iUrlId, $f_szTags = "") { if (empty($f_szTags)) { exit('No tags, no copy!'); } global $db; $arrTags = unaliasTags(explode(" ", str_replace('/', ' ', str_replace('+', ' ', valid_tags($f_szTags))))); $iUrlId = (int) $f_iUrlId; $iAdded = 0; foreach ($arrTags as $szTag) { // Add tag $iTagId = AddTag($szTag); // Insert relation $arrInsert = array('url_id' => $iUrlId, 'tag_id' => $iTagId, 'utc_added' => time()); try { $iAdded += (int) $db->insert('l_links', $arrInsert); } catch (db_exception $ex) { } } exit('OK' . $iAdded); }
/** * Add a LINK between TAGS and a URL */ function _AddLink($f_szUrl, $f_szTitle, $f_szTags) { global $db; $szUrl = trim($f_szUrl); $arrTags = unaliasTags(explode(' ', str_replace('/', ' ', valid_tags($f_szTags)))); $szTitle = trim($f_szTitle); if (!$arrTags || !$szUrl) { return 'ERROR:' . __LINE__; } // Add url $iUrlId = AddUrl($szUrl, $szTitle); foreach ($arrTags as $szTag) { // Add tag $iTagId = AddTag($szTag); // Insert relation try { $db->insert('l_links', array('url_id' => $iUrlId, 'tag_id' => $iTagId, 'utc_added' => time())); } catch (db_exception $ex) { } } return 'OK'; }