| Revision History |
| Rev | Date | Note |
'.NL;
if ($revision==1) {
// show all major revisions and the last item before the major revision.
hRowColor();
echo ''.$version.'.'.$revision.' | '.$ts.' | '.$note.' | '.NL;
$showNext = true;
} elseif ($showNext) {
hRowColor();
echo ''.$version.'.'.$revision.' | '.$ts.' | '.$note.' | '.NL;
if ($cnt > 12) $showNext = false;
}
}
}
if ($cnt > 0) echo '';
}
function listReferences($article_id, $showQueue) {
global $gDomainID, $prUser, $showMenu, $adminOpt;
list($title, $article_dt, $image_id, $desc, $html_type, $html, $hitCnt, $author_id, $collection_id, $file_nm, $pn, $structured_yn)
= sqlRow('SELECT a.title_nm, a.article_dt, a.image_id, a.article_desc, a.html_type, a.html, a.hit_cnt, a.author_id, collection_id, a.file_nm, a.prev_next, a.structured_yn
FROM Article a
WHERE article_id = '.$article_id);
if ($file_nm == '') $file_nm = '/page.html?a='.$article_id;
list($cDomain, $comments_yn, $collection_nm, $directory_nm, $copyright, $collectionStart, $incRef, $domainURL) =
sqlRow('SELECT c.domain_id, c.comments_yn, c.collection_nm, c.directory_nm, c.copyright, c.intro_url, c.inc_ref_yn, d.url
FROM Article_Collection c, Domain d
WHERE collection_id='.$collection_id.'
and c.domain_id = d.domain_id');
if ($collection_id==5) $gAd=14;
// When references are included in the article, forward to article!
if ($showQueue) {
// show page even if this is a ref article.
} elseif ($incRef == 'Y') {
echo('Location: '.$domainURL.$file_nm);
die();
}
if ($cDomain != '' and $cDomain != $gDomainID) {
header('Location: '.$domainURL.$file_nm);
die();
}
setTitle('Referring Pages for '.$title);
$showMenu=false;
displayHead();
msgHTML();
if ($file_nm == '') $file_nm = 'page.html?a='.$article_id;
echo 'What Links Here
This pages shows resouces and registered references that link to the article
"'.$title.'".
';
$sql = 'SELECT r.article_id, d.url, a.file_nm, a.title_nm, c.collection_nm
FROM Article_Resource r, Article a, Article_Collection c, Domain d
WHERE r.reference_id = '.$article_id.'
and r.type_id = 1
and r.article_id = a.article_id
and a.collection_id = c.collection_id
and c.domain_id = d.domain_id
and a.published_yn = \'Y\'
GROUP BY a.article_id
ORDER BY a.collection_id, a.article_id DESC';
$cnt = 0;
echo 'Internal References
This first set shows internal references:
';
if ($r = mysql_query($sql)) {
while (list($iArticle_id, $url, $file_nm, $title_nm, $collection_nm) = mysql_fetch_row($r)) {
//$struck = ($structure_id > 0)? '#s'.$structure_id : '';
$fName = ($file_nm == '')? 'http://'.$url.'/page.html?a='.$iArticle_id : 'http://'.$url.$file_nm;
echo '- '.$collection_nm.': '.$title_nm.'
';
}
}
if ($cnt == 0) {
echo '- There are currently no internal references to this file.
';
}
$sql = 'SELECT ref_id, weight_no, display_cd, article_dt, host_nm, path_nm, display_nm, author_nm, note_txt
FROM External_Ref
WHERE article_id = '.$article_id.'
and display_cd != \'R\'
ORDER BY weight_no, article_dt DESC';
if ($prUser > 0) $showQueue = true;
$cnt = 0;
$queueStr = ($showQueue)? ' The Following List includes Queued items. These items do not show up in the primary view until approved.' : '';
echo '
External References
This second table lists external references. '.$queueStr.'
';
if ($r = mysql_query($sql)) {
while (list($ref_id, $weight_no, $display_cd, $dt, $host_nm, $path_nm, $display_nm, $author_nm, $note_txt) = mysql_fetch_row($r)) {
$relStr = ($display_cd == 'a')? ' rel="nofollow"' : '';
$qStr = ($display_cd == 'Q')? 'QUEUED ' : '';
$aStr = ($prUser > 0)? '[admin options]' : '';
if ($display_cd=='A' or $display_cd == 'a' or $showQueue) {
$authorStr = ($author_nm != '')? ' by '.$author_nm : '';
echo '- '.$qStr.''.$display_nm.' (added '.$dt.$authorStr.') '.$note_txt.$aStr.'
'.NL;
$cnt++;
}
}
}
if ($cnt == 0) '- No External References
'.NL;
echo '
Add Reference
To encourage readers to blog about this topic, this site invites people to leave a link back to their site. If you have a page
relevant to the topic, you can
request link. If approved, the link will appear above. NOTE, we are highly selective.
';
revHist($article_id);
if ($prUser > 0) {
$adminOpt =($structured_yn=='Y')? ' ~ ~ edit' : ' ~ ~ edit';
} else {
$adminOpt = '';
}
}
function listQueued() {
displayHead('List Queued');
$sql = 'SELECT ref_id, weight_no, display_cd, article_dt, host_nm, path_nm, display_nm, author_nm, note_txt
FROM External_Ref
WHERE display_cd = \'Q\'
ORDER BY ref_id DESC';
echo 'Rows to Review
';
if ($r = mysql_query($sql)) {
while (list($ref_id, $weight_no, $display_cd, $article_dt, $host_nm, $path_nm, $display_nm, $author_nm, $note_txt) = mysql_fetch_row($r)) {
echo '- '.$display_nm.': ('.$article_dt.' by '.$author_nm.') '.$note_txt.'. OPTIONS: ';
echo 'Approve, ';
echo 'approve NF, ';
echo 'Reject, ';
echo 'Edit
';
}
}
echo '
';
}
function listRecent() {
$limitStr = (isset($_GET['start']))? strval(intval( $_GET['start'])).', 50' : '50';
displayHead('List Recent');
$sql = 'SELECT ref_id, weight_no, display_cd, article_dt, host_nm, path_nm, display_nm, author_nm, note_txt
FROM External_Ref
WHERE display_cd !="R"
ORDER BY ref_id DESC
LIMIT '.$limitStr;
echo 'Recent References
';
if ($r = mysql_query($sql)) {
while (list($ref_id, $weight_no, $display_cd, $article_dt, $host_nm, $path_nm, $display_nm, $author_nm, $note_txt) = mysql_fetch_row($r)) {
echo '- '.$display_nm.': ('.$article_dt.' by '.$author_nm.') '.$note_txt.'. OPTIONS: ';
echo 'Approve, ';
echo 'approve NF, ';
echo 'Reject, ';
echo 'Edit
';
}
}
echo '
';
}
function hostSum() {
displayHead('Host Summary');
sqlTable('Host Summary','','SELECT host_nm Host, count(*) Count, max(ts) Last FROM External_Ref WHERE display_cd like "A" GROUP BY host_nm');
}
function changeStatus($newStatus) {
global $prUser;
$ref_id = (isset($_GET['r']))? (int) $_GET['r'] : 0;
$test = mysql_real_escape_string($newStatus);
if ($prUser > 0 and $ref_id > 0) {
execSQL('UPDATE External_Ref SET display_cd = "'.$test.'" WHERE ref_id='.$ref_id,'Set Status to '.$test,'setting status of '.$ref_id.' to '.$test);
}
}
function mostReferenced() {
global $gDomainID;
setTitle('Articles by Internal References');
displayHead();
msgHTML();
//echo 'Internal References
';
//echo '';
$sql = 'SELECT c.collection_nm, a.article_id, a.title_nm, a.file_nm, count(*) cnt, c.inc_ref_yn
FROM Article_Collection c, Article a, Article_Resource r
WHERE c.domain_id = '.$gDomainID.'
and c.collection_id = a.collection_id
and a.article_id = r.reference_id
and r.type_id = 1
GROUP BY a.article_id
ORDER BY cnt DESC
LIMIT 40';
echo '';
hTable('Most Internal References',3);
echo '';
echo '| Collection | Article | References |
';
if ($r = mysql_query($sql)) {
while (list($collection_nm, $article_id, $title_nm, $file_nm, $cnt, $incRef) = mysql_fetch_row($r)) {
hRowColor();
if ($file_nm == '') $file_nm = '/page.html?a='.$article_id;
$refLnk = ($incRef == 'Y')? $cnt :''.$cnt.'';
echo ''.$collection_nm.' | '.$title_nm.' | '.$refLnk.' | ';
}
}
echo '';
$sql='SELECT c.collection_nm, a.article_id, a.title_nm, a.file_nm, count(*) cnt, c.inc_ref_yn
FROM Article_Collection c, Article a, External_Ref r
WHERE c.domain_id = '.$gDomainID.'
and c.collection_id = a.collection_id
and a.article_id = r.article_id
GROUP BY a.article_id
ORDER BY cnt DESC
LIMIT 40';
echo '
This second table counts external links.
';
hTable('Most External References',3);
echo '';
echo '| Collection | Article | References |
';
if ($r = mysql_query($sql)) {
while (list($collection_nm, $article_id, $title_nm, $file_nm, $cnt, $incRef) = mysql_fetch_row($r)) {
hRowColor();
if ($file_nm == '') $file_nm = '/page.html?a='.$article_id;
$refLnk = ($incRef == 'Y')? $cnt :''.$cnt.'';
echo ''.$collection_nm.' | '.$title_nm.' | '.$refLnk.' | ';
}
}
echo '';
}
function extLinkForm($ref_id, $article_id) {
global $prUser, $prUserName, $gDomainID;
//$aid = getVar('aid','Article ID','post int required');
$titleStr ='Add';
if ($article_id > 0) {
$display_nm = getVar('display_nm','','post opt');
$url = getVar('url','','post opt');
$article_dt = getVar('article_dt','','post dec');
$author_nm = getVar('author_nm','','post dec');
$note_txt = getVar('note_txt','','post opt');
list($title, $file_nm, $desc, $cid, $collection_nm, $did, $dURL) = sqlRow('SELECT a.title_nm, a.file_nm, a.article_desc, a.collection_id, c.collection_nm, c.domain_id, d.url
FROM Article a, Article_Collection c, Domain d
WHERE a.article_id = '.$article_id.'
and a.collection_id = c.collection_id
and c.domain_id = d.domain_id');
$actionBtn = ADD_REF_BTN;
if ($file_nm == '') $file_nm = '/page.html?a='.$article_id;
} elseif ($ref_id > 0) {
// load data from the database and set button to Edit Mode.
$titleStr = 'Update';
$actionBtn = EDIT_REF_BTN;
list($aid, $display_nm, $url,
$article_dt, $author_nm, $note_txt, $title, $file_nm, $desc, $cid, $collection_nm, $did, $dURL)
= sqlRow('SELECT r.article_id, r.display_nm, concat(r.host_nm,r.path_nm),
r.article_dt, r.author_nm, r.note_txt, a.title_nm, a.file_nm, a.article_desc, a.collection_id, c.collection_nm, c.domain_id, d.url
FROM External_Ref r, Article a, Article_Collection c, Domain d
WHERE r.ref_id = '.$ref_id.'
and r.article_id = a.article_id
and a.collection_id = c.collection_id
and c.domain_id = d.domain_id');
$article_id = $aid;
if ($prUser < 1) {
msgNoteError('Sorry Only the admin can edit links at this time.');
$article_id = -1;
}
} else {
$article_id = -1;
}
if ($article_id > 0) {
setTitle('Add an external link for '.$title);
displayHead();
msgHTML();
echo '
To actively encourage people to discuss the topics on this web site, I\'ve included a "What Links Here" feature. If you have a blog
post or online article that is relevant to the topic, request listing on this page. Think of the page as a manually edited track back program.
Use the form below to request a listing. If approved it will be listed on the page: Article Resource page.
To prevent spam, I manually approve listings and am extremely selective in approving links.
';
hForm('ref.html');
hTable($titleStr.' External Link');
if ($ref_id > 0) echo inpHidden('ref_id',$ref_id);
$rURL = ''.$title.'';
hPC('Article Name',SQLselect('aid',$article_id,'SELECT article_id, title_nm FROM Article WHERE collection_id='.$cid.' ORDER BY article_id'));
echo 'Enter the name and url of your page
as you wish it displayed on the reference page.
You can also write a short comment. |
';
hPC('Link Name',inpTxt('display_nm',$display_nm,40,50));
if ($prUser > 0) hPC('User Name',$prUserName);
hPC('URL','http://'.inpTxt('url',$url,30,100));
//if ($prUser > 0 and $author_nm == '') $author_nm = $prUserFullName;
hPC('Author Name',inpTxt('author_nm',$author_nm,40,40));
$article_dt = date('Y-m-d');
hPC('Article Date','yyyy-mm-dd '.inpTxt('article_dt',$article_dt,16,16));
hPC('Comment
255 characters max',inpTextarea('note_txt',$note_txt,51,5));
hPC('',inpBtn($actionBtn));
hPC('Return Link','Below is a sample link to this article:
'.NL.inpTextarea('rURL',$rURL,51,5));
echo '';
} else {
setTitle('Invalid Article');
displayHead('Invalid article');
echo 'invalid article.
';
}
}
function addExtLink() {
global $prUser, $refCookie;
$rv = 0;
$aid=getVar('aid','Article ID','int required');
$display_nm = getVar('display_nm','Link Name','post slash required');
$author_nm = getVar('author_nm','Author Name','post slash opt');
$article_dt = getVar('article_dt','Article Date','post dec');
$note_txt = getVar('note_txt','','post maxlen=254 slash');
if (isset($_POST['url'])) {
// $url = getVar('url','Reference URL','post strip');
$url = (substr(strtolower($_POST['url']),0,4) == 'http')? $_POST['url'] : 'http://'.$_POST['url'];
$arr = parse_url($url);
$host_nm = mysql_real_escape_string($arr['host']);
if ($host_nm == '') msgNoteError('Could not parse url: '.$_POST['url']);
if (isset($arr['query'])) {
$path_nm = mysql_real_escape_string($arr['path'].'?'.$arr['query']);
} else {
$path_nm = mysql_real_escape_string($arr['path']);
}
} else {
msgNoteError($_POST['url'].' URL is a required field');
}
//$cookie_id = getVar('cookie_id','','post int');
$display_cd = 'N';
if ($prUser > 0) {
$user_id = $prUser;
$display_cd = 'A';
msgNoteSuccess('User ID is '.$prUser);
} else {
$user_id = 0;
$display_cd = 'Q';
}
if (!hasErrors()) {
$sql = "INSERT INTO External_Ref (article_id, display_cd, user_id, ip_no, ts, host_nm, path_nm, display_nm, author_nm, article_dt, note_txt)
VALUES ($aid,'$display_cd',$user_id,inet_aton('".$_SERVER['REMOTE_ADDR']."'), now(),'$host_nm','$path_nm','$display_nm', '$author_nm','$article_dt', '$note_txt')";
$rv = execSQL($sql,'Added External Link','adding external link. '.$display_cd,'Y');
}
return $rv;
}
function updateExtLink() {
global $prUser, $refCookie;
$ref_id = getVar('ref_id','Reference ID','post int required');
$article_id=getVar('aid','Article ID','int required');
$display_nm = getVar('display_nm','Link Name','post slash required');
$author_nm = getVar('author_nm','Author Name','post slash opt');
$article_dt = getVar('article_dt','Article Date','post dec');
$note_txt = getVar('note_txt','','post maxlen=254 slash');
if (isset($_POST['url'])) {
// $url = getVar('url','Reference URL','post strip');
$url = (substr(strtolower($_POST['url']),0,4) == 'http')? $_POST['url'] : 'http://'.$_POST['url'];
$arr = parse_url($url);
$host_nm = mysql_real_escape_string($arr['host']);
if ($host_nm == '') msgNoteError('Could not parse url: '.$_POST['url']);
if (isset($arr['query'])) {
$path_nm = mysql_real_escape_string($arr['path'].'?'.$arr['query']);
} else {
$path_nm = mysql_real_escape_string($arr['path']);
}
} else {
msgNoteError($_POST['url'].' URL is a required field');
}
//$cookie_id = getVar('cookie_id','','post int');
if (!hasErrors()) {
$sql = "UPDATE External_Ref SET host_nm='$host_nm',
path_nm='$path_nm',
display_nm='$display_nm',
author_nm='$author_nm',
article_id = $article_id,
article_dt='$article_dt',
note_txt='$note_txt'
WHERE ref_id = ".$ref_id;
execSQL($sql,'Upated Row','updating row');
msgNoteSuccess(''.$sql.'
');
}
return $ref_id;
}
// start with public options.
if ($btn=='rl') {
extLinkForm(0,$article_id);
} elseif ($btn==ADD_REF_BTN) {
if (addExtLink() > 0) {
listReferences($_POST['aid'], true);
} else {
extLinkForm(0,$article_id);
}
} elseif ($btn=='hs') {
hostSum();
} elseif ($article_id > 0) {
listReferences($article_id, false);
} elseif (!($gDomainID > 0)) {
displayHead('Error');
echo 'Invalid Domain';
} elseif (!($prUser > 0)) {
mostReferenced();
// now show options for people logged into the system.
} elseif ($btn=='edl') {
$ref_id = (isset($_GET['r']))? (int) $_GET['r'] : 0;
extLinkForm($ref_id,0);
} elseif ($btn==EDIT_REF_BTN) {
$ref_id = updateExtLink();
extLinkForm($ref_id,0);
} elseif (substr($btn,0,3) == 'app') {
changeStatus(substr($btn,3,1));
if (isset($_GET['goto'])) {
listRecent();
} else {
listQueued();
}
} elseif ($btn=='lq') {
listQueued();
} elseif ($btn=='lr') {
listRecent();
} else {
if ($gDomainID > 0) {
} else {
displayHead('Error');
echo 'Invalid Domain';
}
}
if ($prUser > 0) echo 'List Queued
- List Recent
- Host Summary'.$adminOpt.'
';
displayFoot();
?>