authorizenet) { require 'includes/authnetsdk.php'; } if ($scriptinfo['scriptname'] != 'wsnlinks' && !$action) $action = 'detail'; if (!$id && $linktitle) $id = $db->selectitem('id', 'linkstable', "title='".encodeit(unrewritetitle($linktitle))."' AND deleted=0"); if ($id > 0) { $thislink = new onelink('id', $id); // get for frequent later use if (!$action && $thislink->url == '' && $action != 'sponsor') $action = 'detail'; // if no url, don't try to go to it if ($todo == 'clearbookmarkedattachments') { $thislink->bookmarkattachments = ''; $thislink->update('bookmarkattachments'); header("Location: ".str_replace("&todo=clearbookmarkedattachments", "", currenturl())); } // redirect to avoid having a refresh re-clear it if ($thislink->catid > 0) { if (!$thislink->cat->canview()) { if (tweakisset('hidebadrequest')) endwithbadrequest(); else { $template = new template("noaccess.tpl"); require 'end.php'; die(); } } } } if (!$id && !$orderid && !$catid && !$action) redirect($language->nosuchlink, 'index.php'); if ($switches['linkcalendars']) { require 'includes/eventfunctions.php'; if (isset($_REQUEST['monthID']) && $id) { // check if we have quantities to update reset($_REQUEST); while(list($key, $value) = each($_REQUEST)) { if (strstr($key, '-') && !strstr($key, 'price')) { // db date format: Jun 20, 2011. quantity field names: 2012-10-05 $timestamp = strtotime($key); $formated = strftime("%b %d, %Y", $timestamp); if ($db->hascount('calendartable', "date='$formated' AND objectid='{$id}'")) $db->update('calendartable', 'quantity', $value, "date='$formated' AND objectid='{$id}'"); else if ($value != $thislink->defaulteventquantity) { // make new event $e = new event('new', 'new'); $e->quantity = $value; $e->date = $formated; $e->objectid = $id; $e->validated = 1; $e->starttime = strtotime("$formated 12:00 AM"); $e->endtime = strtotime("$formated 11:59 PM"); $e->add(); } } if (strstr($key, '-') && strstr($key, 'price')) { // db date format: Jun 20, 2011. price field names: price2012-10-05 $datestuff = str_replace('price', '', $key); $timestamp = strtotime($datestuff); $formated = strftime("%b %d, %Y", $timestamp); if ($db->hascount('calendartable', "date='$formated' AND objectid='{$id}'")) $db->update('calendartable', 'price', $value, "date='$formated' AND objectid='{$id}'"); else if ($value != $thislink->price) { // make new event $e = new event('new', 'new'); $e->price = $value; if ($_POST[$datestuff]) $e->quantity = $_POST[$datestuff]; else $e->quantity = $thislink->defaulteventquantity; $e->date = $formated; $e->objectid = $id; $e->validated = 1; $e->starttime = strtotime("$formated 12:00 AM"); $e->endtime = strtotime("$formated 11:59 PM"); $e->add(); } } } } } if ($filled) { if ($action == 'addtags') { if ($thismember->isregistered()) $usedtags = $db->selectcount('tagstable', 'ownerid='.$thismember->id.' AND deleted=0 AND link='.$thislink->id); else $usedtags = $db->selectcount('tagstable', "ownerip='".realip()."' AND deleted=0 AND link=".$thislink->id); $newtags = explode(',', str_replace(', ', ',', $newtags)); $n = count($newtags); for ($x=0; $x<$n; $x++) { if (!$thismember->grouplimittags || $usedtags < $thismember->grouplimittags) { $t = new tag($newtags[$x], $thislink, $thismember->id); if ($name != '' && !$db->hascount('tagstable', "name='". encodeit($newtags[$x]) ."' AND link=". $thislink->id)) { $t->add(); $usedtags++; } // only add unique tags } } redirect("", $returnurl, true); } elseif ($action == 'deletetag') { $tag = urldecode($_GET['tag']); $t = new tag($tag, $thislink, $thismember->id); if ($t->candelete()) $t->deletethis(); $returnurl = urldecode($_GET['returnurl']); redirect("", $returnurl, true); } elseif ($action == 'sponsor') { // process unpaid sponsorship which can be renewed at will by clicking $thislink->sponsorend = time() + (86400 * $settings->sponsortime); $thislink->type = $sponsordata->linktypesarr[0]; // only one level allowed for unpaid sponsorship $thislink->update('type,sponsorend'); $message = $language->sponsor_done; $destination = $thislink->detailsurl(); redirect($message, $destination); } } else { if ($action == 'preview') { // link.php?action=preview $previewing = true; // flag that doattachments checks if ($switches['detailcomments']) { if (!$template) $template = new template('detailcomments.tpl'); } else { if (!$template) $template = new template('details.tpl'); } $thislink = new onelink('blank', 'blank'); $previewid = 'temp/preview_'.str_replace('.', '', realip()).'.wsn'; $tempdata = explode('[|||]', fileread($previewid)); foreach($tempdata as $td) { $parts = explode('[=]', $td); $key = $parts[0]; $value = $parts[1]; $thislink->$key = $value; } if (!$thislink->ownerid) $thislink->ownerid = 0; // so toplist of latest listings by member gets a 0 in it properly $thislink->objectfieldarray = explode(',', $thislink->objectfields); expandspecialfields($thislink); $thislink->codesandsmilies(); $thislink->makecat(); $thislink->parentnames = $thislink->cat->parentnames; $thislink->parentids = $thislink->cat->parentids; if ($thislink->id > 0) $cond = "type='link' AND objectid={$thislink->id}"; else $cond = "type='link' AND objectid=0 AND ownerip='".realip()."'"; $thislink->numattachments = $db->selectcount('attachmentstable', $cond); if ($thislink->numattachments) $thislink->filefield = 1; else $thislink->filefield = 0; $template->replace('{LINKFILEFIELD}', $thislink->filefield); // no idea why this is necessary here but it is! if (!$thislink->id) $thislink->id = 0; if (!$thislink->latitude && !$thislink->longitude) { // need to do geofromaddr only if no manual specification. but lat/lon could be filled on preview edit for non-manual specification. how does that logic work? i think it worked itself out now actually since the map always resets itself when the address changes? $thislink->latitude = 0; $thislink->longitude = 0; $thislink->numcomments = 0; $thislink->pagerank = 0; if ($switches['map'] && ($thislink->address || ($thislink->zip && tweakisset('geocodezip')))) { $arr = geofromaddr($thislink); $thislink->latitude = $arr[0]; $thislink->longitude = $arr[1]; } if (!$thislink->latitude) $thislink->latitude = 0; if (!$thislink->longitude) $thislink->longitude = 0; } if ($thislink->feedurl == 'http://') $thislink->feedurl = ''; if ($thislink->url == 'http://') $thislink->url = ''; $template->replacements($thislink); $com = new comment('blank', 'blank'); $template->replacements($com); // in case it's the detailcomments template $template->replace($template->extract('', ''), ''); $template->replace('{PAGINATION}', ''); $template->shownav($thislink->navpath(), $thislink->title); $template->replace(' href=', ' disabled='); // disable links $pat = preg_quote(''); // but, allow tab/activetab links while changing action=detail to action=preview $pat = '/'.$pat.'/i'; $template->text = preg_replace($pat, '', $template->text); $template->replace('disabled="'.$thislink->detailsurl().'"', 'href="link.php?action=preview"'); $template->replace('
replace("type='link' AND objectid={LINKEFFECTIVEID}", $cond); // make slideshow work for pre-submission prevew, and for edit preview, both //$template->replace('type="submit"', ''); // disable forms adjustpreviews($template); $pat = '/'.preg_quote('pregreplace($pat, 'replace('dirurl ."/comments.php?id=$id"; if ($edit) $u .= '&edit='. $edit; redirect301($u); } $area = $language->title_detail; if ($orderlinks == '') $orderlinks = $settings->orderlinks; $condition = 'validated = 1 AND hide=0 AND deleted=0'; if ($thislink->catid) $catid = $thislink->catid; if ($catid > 0) $condition .= ' AND catid='. $catid; if ($orderid != '') { $getit = $db->select('all', 'linkstable', $condition, $orderlinks, "LIMIT $orderid,1"); if ($row = $db->row($getit)) { $thislink = new onelink('row', $row); if ($orderid == 0) $previous = $orderid; } else { $orderid = $orderid - 1; $getit = $db->select('all', 'linkstable', $condition, $orderlinks, "LIMIT $orderid,1"); $row = $db->row($getit); $thislink = new onelink('row', $row); if ($orderid == 0) $previous = $orderid; } } if (!isset($thislink) || $thislink->id == 0) { if ($id) $test = $db->selectitem('id', 'linkstable', "id=$id"); if (!$id || $test != $id) endwithbadrequest(); $thislink = new onelink('id', $id); } if (($thislink->deleted || !$thislink->id || !$thislink->validated || ($thislink->effectivetime > 0 && $thislink->effectivetime > time())) && !$previewedit && !$thismember->isadmin() && ($thismember->id != $thislink->ownerid || !$thismember->id)) endwithbadrequest(); // for non-admin/owners if (tweakisset('hidebadrequest') && $thislink->hide && !$previewedit && !$thismember->isadmin() && ($thismember->id != $thislink->ownerid || !$thismember->id)) endwithbadrequest(); // for non-admin/owners when tweak says we want hidden links to not be viewable if (($thislink->deleted || !$thislink->id) && !$previewedit) endwithbadrequest(); // for admin/owners if (!rewrittenuptodate($thislink->rewritepath(), $thislink->rewritetitle(), $thislink->title)) { if ($section == 'download') redirect301($thislink->downloadsoftwareurl()); else if ($section == 'screenshots') redirect301($thislink->screenshotsurl()); else if (!$section) redirect301($thislink->detailsurl()); // check that URL used is valid, not a changed title/category } include 'includes/detailandcomments.php'; } else if ($action == 'sponsor') { if ($settings->authorizenet) $sslize = true; if (!$template) $template = new template("sponsor.tpl"); if (tweakisset('paypalsandbox')) $template->replace('www.paypal.com', 'www.sandbox.paypal.com'); if (tweakisset('authnettesting')) $template->replace("'x_test_request' value='FALSE'", "'x_test_request' value='TRUE'"); $thislink = new onelink('id', $id); if ($sponsordata->getfreetypes() && !in_array($thislink->type, $sponsordata->getfreetypes())) $template->replace('{SPONSORREQUIRED}', 'yes'); // if object already has non-free type set, tell them they have to pay $template->shownav($thislink->navpath('includeme'), $language->title_sponsor); makecookie("sponsorlink", $id, time() + 100000); $ip = realip(); $thislink->ip = $ip; $thislink->update('ip'); $area = $language->title_sponsor; $bit = $template->getsection('LEVELS'); if ($_REQUEST['type']) $data = $sponsordata->getlinklevels($thislink->catid, $_REQUEST['type']); else $data = $sponsordata->getlinklevels($thislink->catid); $count = count($data); $all = ''; for ($x=0; $x<$count; $x++) { $one = $bit; $one = str_replace('{SPONSORLINKTYPE}', $data[$x]['type'], $one); $one = str_replace('{SPONSORLINKTYPELANG}', gettypelang($data[$x]['type']), $one); $one = str_replace('{SPONSORCHARGE}', $data[$x]['charge'], $one); $one = str_replace('{SPONSORITEM}', $data[$x]['item'], $one); if ($settings->authorizenet) $one = str_replace('{SPONSORFINGERPRINT}', authnet_fingerprint($data[$x]['charge']), $one); $one = str_replace('{SPONSORLINKFEEDURATION}', $data[$x]['feeduration'], $one); $one = str_replace('{SPONSORCOUPONEXISTS}', couponexists('listing sponsorship', $data[$x]['id']), $one); $all .= $one; } $template->replace($bit, $all); $template->replacements($thislink); appendcouponjs(); if (!$settings->authorizenet) { $template->replace('{FUNC_AUTHNET_TIMESTAMP}', ''); $template->replace('{FUNC_AUTHNET_SEQUENCE}', ''); } // prevents error message about invalid callback } else { $goingtolink = true; if (($id == '') && ($url != '')) { $q = $db->select('id', 'linkstable', "url='$url'", '', ''); $id = $db->rowitem($q); } $thislink = new onelink('id', $id); if ($TID != 'outgoingtop') $thislink->counthitout(); $thislink->markread(); $url = $thislink->url; $url = str_replace('[NOTVAR]', '', $url); if (isset($frameofffield) && $thislink->$frameofffield == $frameoffvalue) $frameoff = true; else $frameoff = false; if ($switches['frameset'] && !$frameoff) { $usewrapper = 'no'; if (!$template) $template = new template('outgoingframe.tpl'); $template->replacements($thislink); } else { if ($url != '') { redirect301($url); } else { redirect($language->nosuchlink, 'index.php'); } } } } require_once 'end.php'; ?>