uawdijnntqw1x1x1
IP : 216.73.216.54
Hostname : neogeopocket.gameplayer.club
Kernel : Linux neogeopocket.gameplayer.club 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
var
/
www
/
html
/
1c732
/
..
/
components
/
com_jvld
/
models
/
addlink.php
/
/
<?php /** * @version $Id$ * @package JV-LinkDirectory * @subpackage com_jvld * @copyright Copyright 2008-2013 JV-Extensions. All rights reserved * @license GNU General Public License version 3 or later * @author JV-Extensions * @link http://www.jv-extensions.com */ // No direct access defined('_JEXEC') or die('Restricted access'); class JvldModelAddlink extends JvldFendModel { public $sess_val = array(); public $sess_var = array( 'oway_plan', 'owpaid_id', 'partner_url', 'partner_email', 'link_category', 'reciprocal_link_url', 'language', 'metadesc', 'title', 'tp_desc', 'bp_file', 'icon_image', 'localthumb_img', 'metakeys', 'pscats_new', 'sef_string', 'ef_sql_p', 'ef_sql_v', 'photos', 'videos', 'files', 'coupons', 'lecs_accept_invites', 'lecs_xglink_url', 'notify_email_rated', 'notify_email_reviewed', 'notify_email_bookmarked', 'notify_email_fdownloaded', 'notify_sms_rated', 'notify_sms_reviewed', 'notify_sms_bookmarked', 'notify_sms_fdownloaded', 'receive_mstats_email', 'mobile', 'contact_me', 'selfprofile_id', ); public function getForm($data = array(), $loadData = false) { $cfg = JvldCfg::getInstance(); $step = $this->input->getInt('step', 0); $form_name = 'addlink_'.$step; $form = $this->loadForm('com_jvld.'.$form_name, $form_name, array('control' => 'jform', 'load_data' => $loadData), true); if (empty($form)) return false; if ($step == 1) { $csmode = ($cfg->get('catselection_mode')) ? 'h' : 'l'; if ($csmode == 'h') { // advanced $xml_element = '<field name="link_category" type="hidden" label="COM_JVLD_CATEGORY" description="" />'; } else { // normal $xml_element = '<field name="link_category" type="jvldcategory" published="true" accept_links="true" class="inputbox" required="true" label="COM_JVLD_CATEGORY" description="" > <option value="0" selected="selected">COM_JVLD_SELECT</option> </field>'; } $element = new SimpleXMLElement($xml_element); $form->setField($element); } return $form; } public function commit(&$result_msg) { try { JvldLog::log("FE Add Link: Commit processing started"); $datetime_now = JvldDate::getDateTimeInUTCInMySqlFormat(); $datetime_null = JvldDate::getMySQLNullDateTime(); // load values from session $this->loadAllDataFromSession(); $oway_plan = $this->sess_val['oway_plan']; $linkplan = new JvldLinkPlan(); $linkplan->setPlanCode($oway_plan); // Get submitter IP $ip = JvldFrameworkHelper::getIpAddress(); // Check meta keys if ($this->sess_val['metakeys'] == '{value}') $this->sess_val['metakeys'] = ''; // Get Spam score $spam = new JvldAntispam($this->sess_val['partner_email'], $this->sess_val['title']." ".strip_tags($this->sess_val['tp_desc'])." ".$this->sess_val['metakeys'], $this->sess_val['partner_url'], $ip, 'website information'); $spamscore = $spam->getSpamScore(); $spam = ($spamscore > $this->cfg->get('spam_min_score')) ? 1 : 0; if ($spam && (!$this->cfg->get('as_proc'))) throw new Exception(JText::_("COM_JVLD_ADDLINK_SPAM_LIKE")); JvldLog::log("FE Add Link: Anti spam check complete and passed. Spam score: ".(int)$spamscore); // Get Ordering $ordering = JvldDb::getValue("select max(ordering) as max from #__jvld_links"); $ordering++; JvldLog::log("FE Add Link: Ordering for new link identified: ".(int)$ordering); // ATR $atr = 0; $atr_update = $datetime_null; if (($this->sess_val['partner_url'] != '') && ($this->cfg->get('atr_en'))) { $u_atr = 0; $atr = JvldUtil::setAlexaTR($this->sess_val['partner_url'], 0, $datetime_null, $u_atr); $atr_update = $datetime_now; JvldLog::log('FE Add Link: Alexa TR has been fetched for the new link.'); } // rel=nofollow $add_relnofollow = ($linkplan->allowSEFollow()) ? 0 : 1; // Set scheduled SRC $en_src = ($linkplan->isBacklinkRequired()) ? 1 : 0; // check approval mode if (!$this->cfg->get('link_apprmode')) { // auto approve link JvldLog::log("FE Add Link:: Auto approval mode set. Hence setting status to established"); $status = _JVLD_LINKSTATUS_ESTABLISHED; $pub_on = $datetime_now; $lsub_on = $datetime_null; $lrej_on = $datetime_null; } else { // approve manually or by email JvldLog::log("FE Add Link: Auto approval mode NOT set. Hence setting status to pending"); $status = _JVLD_LINKSTATUS_WPENDING; $pub_on = $datetime_null; $lsub_on = $datetime_now; $lrej_on = $datetime_null; } if ($spam) { // spam overrides auto approval function JvldLog::log("FE Add Link: Link is identified as spam. Hence overriding status to pending"); $status = _JVLD_LINKSTATUS_WPENDING; $pub_on = $datetime_null; $lsub_on = $datetime_now; $lrej_on = $datetime_null; } // Trigger before save plugins $tresults = (array)JvldInit::triggerPlugins('OnLinkBeforeSave', array(&$this, 1)); if (count($tresults) && ($tresults[0] == false)) { JvldLog::log('onLinkBeforeSave failed'); throw new Exception('onLinkBeforeSave failed'); } //Trigger the finder before save event JvldInit::triggerPlugins('onFinderBeforeSave', array('com_jvld.link', $this, 1)); $add_on = $datetime_now; // Store link in db and get link id JvldLog::log(__FUNCTION__.":: Database Operations Started"); $id = JvldDb::update("insert into `#__jvld_links` (partner_url, partner_title, partner_email, reciprocal_link_url, selfprofile_id, link_status, link_added_on, link_published_on, link_updated_on, enable_scheduler, uid, sef_string, antispam_flag, metakeys, add_relnofollow, submitter_ip, spam_score, notify_email_rated, notify_email_reviewed, notify_email_bookmarked, notify_email_fdownloaded, notify_sms_rated, notify_sms_reviewed, notify_sms_bookmarked, notify_sms_fdownloaded, receive_mstats_email, metadesc, contact_me, icon_image, localthumb_img, oway_plan, atr, atr_update, lecs_accept_invites, lecs_xglink_url, access, `language`, `num_submits`, `last_submitted_on`, `last_rejected_on`, `mobile`, ordering".$this->sess_val['ef_sql_p'].") values('".JvldSecure::defendSQL($this->sess_val['partner_url'])."','".JvldSecure::defendSQL(\Joomla\String\StringHelper::trim($this->sess_val['title']))."','".JvldSecure::defendSQL(\Joomla\String\StringHelper::trim($this->sess_val['partner_email']))."','".JvldSecure::defendSQL($this->sess_val['reciprocal_link_url'])."','".(int)$this->sess_val['selfprofile_id']."','".(int)$status."','".JvldSecure::defendSQL($add_on)."','".$pub_on."','".JvldSecure::defendSQL($add_on)."','".(int)$en_src."','".(int)$this->user->get('id')."', '".JvldSecure::defendSQL($this->sess_val['sef_string'])."','".(int)$spam."','".JvldSecure::defendSQL($this->sess_val['metakeys'])."','".(int)$add_relnofollow."', '".JvldSecure::defendSQL($ip)."','".(int)$spamscore."','".JvldSecure::defendSQL($this->sess_val['notify_email_rated'])."','".JvldSecure::defendSQL($this->sess_val['notify_email_reviewed'])."','".JvldSecure::defendSQL($this->sess_val['notify_email_bookmarked'])."','".JvldSecure::defendSQL($this->sess_val['notify_email_fdownloaded'])."','".JvldSecure::defendSQL($this->sess_val['notify_sms_rated'])."','".JvldSecure::defendSQL($this->sess_val['notify_sms_reviewed'])."','".JvldSecure::defendSQL($this->sess_val['notify_sms_bookmarked'])."','".JvldSecure::defendSQL($this->sess_val['notify_sms_fdownloaded'])."','".JvldSecure::defendSQL($this->sess_val['receive_mstats_email'])."','".JvldSecure::defendSQL(\Joomla\String\StringHelper::trim($this->sess_val['metadesc']))."','".(int)$this->sess_val['contact_me']."', '".JvldSecure::defendSQL($this->sess_val['icon_image'])."', '".JvldSecure::defendSQL($this->sess_val['localthumb_img'])."', '".JvldSecure::defendSQL($oway_plan)."', '".(int)$atr."', '".JvldSecure::defendSQL($atr_update)."', '".(int)$this->sess_val['lecs_accept_invites']."', '".JvldSecure::defendSQL($this->sess_val['lecs_xglink_url'])."', '".JvldSecure::defendSQL($this->cfg->get('link_fe_access'))."', '".JvldSecure::defendSQL($this->sess_val['language'])."', '1', '".$lsub_on."', '".$lrej_on."', '".JvldSecure::defendSQL($this->sess_val['mobile'])."', '".(int)$ordering."'".$this->sess_val['ef_sql_v'].")"); JvldLog::log("1::FE Add Link: Row for new link insertion into links table completed. ID of link added: ".$id); // Update primary category JvldDb::update("insert into #__jvld_catlinks (lid, cid, isprimary) values('".(int)$id."', '".(int)$this->sess_val['link_category']."', '1')"); JvldLog::log("3::FE Add Link: Primary category updated"); // Update Secondary categories if (count($this->sess_val['pscats_new'])) { JvldUtil::updateSecondaryCategoriesForLink($id, $this->sess_val['pscats_new']); } JvldLog::log("4::FE Add Link: Secondary Categories update completed"); // Add Profile JvldDb::update("insert into `#__jvld_linkprof` (lid, title, description, banner) values('".(int)$id."','".JvldSecure::defendSQL($this->sess_val['title'])."','".JvldSecure::defendSQL($this->sess_val['tp_desc'])."','".JvldSecure::defendSQL($this->sess_val['bp_file'])."')"); JvldLog::log("5::FE Add Link: Profiles DB update completed"); // Add Tags JvldPostinit::updateTagsAndLinksAssociations($this->sess_val['metakeys'], $id); JvldLog::log("6::FE Add Link: updateTagsAndLinksAssociations completed"); // Add Photos for ($i=0;$i<count($this->sess_val['photos']);$i++) { JvldDb::update("insert into #__jvld_photos (lid, title, image, thumb, carousel, ordering) values('".(int)$id."', '".JvldSecure::defendSQL($this->sess_val['photos'][$i]['title'])."', '".JvldSecure::defendSQL($this->sess_val['photos'][$i]['image'])."', '".JvldSecure::defendSQL($this->sess_val['photos'][$i]['thumb'])."', '".JvldSecure::defendSQL($this->sess_val['photos'][$i]['carousel'])."', '".(int)$i."')"); } JvldLog::log("7::FE Add Link: Photos DB update completed"); // Add Videos for ($i=0;$i<count($this->sess_val['videos']);$i++) { JvldDb::update("insert into #__jvld_videos (lid, title, vid, ordering) values('".(int)$id."', '".JvldSecure::defendSQL($this->sess_val['videos'][$i]['title'])."', '".JvldSecure::defendSQL($this->sess_val['videos'][$i]['vid'])."', '".(int)$i."')"); } JvldLog::log("8::FE Add Link: Video DB update completed"); // Add Files for ($i=0;$i<count($this->sess_val['files']);$i++) { JvldDb::update("insert into #__jvld_files (lid, title, description, upname, obname, version, fsize, num_downloads, uploaded_on, checksum, published, access) values('".(int)$id."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['title'])."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['description'])."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['upname'])."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['obname'])."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['version'])."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['fsize'])."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['num_downloads'])."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['uploaded_on'])."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['checksum'])."', '".JvldSecure::defendSQL($this->sess_val['files'][$i]['published'])."', '".JvldSecure::defendSQL($this->cfg->get('files_fe_access'))."' )"); } JvldLog::log("9::FE Add Link: Files DB update completed"); // Add Coupons $liscoupon_created_on = JvldDate::getDateTimeInUTCInMySqlFormat(); for ($i=0;$i<count($this->sess_val['coupons']);$i++) { JvldDb::update("insert into #__jvld_liscoupons (lid, title, description, code, discount, discount_unit, expires_on, onclick_url, ordering, created_on, updated_on) values('".(int)$id."', '".JvldSecure::defendSQL($this->sess_val['coupons'][$i]['title'])."', '".JvldSecure::defendSQL($this->sess_val['coupons'][$i]['desc'])."', '".JvldSecure::defendSQL($this->sess_val['coupons'][$i]['code'])."', '".JvldSecure::defendSQL($this->sess_val['coupons'][$i]['disc'])."', '".JvldSecure::defendSQL($this->sess_val['coupons'][$i]['discu'])."', '".JvldSecure::defendSQL($this->sess_val['coupons'][$i]['expon'])."', '".JvldSecure::defendSQL($this->sess_val['coupons'][$i]['clurl'])."', '".(int)(1+$i)."', '".JvldSecure::defendSQL($liscoupon_created_on)."', '".JvldSecure::defendSQL($liscoupon_created_on)."')"); } JvldLog::log("10::FE Add Link: Coupons DB update completed"); JvldLog::log("11::FE Add Link: All critical database operations complete"); // Done - now post processing to start $linkobj = new JvldLinkinfo($id); // maps $linkobj->resetCoordinates(); JvldLog::log("12:FE Add Link: Map coordinates DB update completed"); // Send email notifications JvldSiteUtil::sendEmailNotifications($linkobj, $this->sess_val['owpaid_id']); JvldLog::log("13: FE Add Link: Send Email Notification completed"); // Send SMS if (($linkobj->getInfo('link_status') == _JVLD_LINKSTATUS_ESTABLISHED) && $this->cfg->get('admin_sms_notify_link_published')) { JvldPostinit::sendSMStoAdmin(JText::sprintf("COM_JVLD_ADDLINK_SMS_1", JvldPostinit::getLinkUrlorTitleForDisplay($linkobj->getInfo('partner_url'), $linkobj->getInfo('partner_title')), $this->cfg->get('site_url'))); } else if ($this->cfg->get('admin_sms_notify_link_added')) { JvldPostinit::sendSMStoAdmin(JText::sprintf("COM_JVLD_ADDLINK_SMS_2", JvldPostinit::getLinkUrlorTitleForDisplay($linkobj->getInfo('partner_url'), $linkobj->getInfo('partner_title')), $this->cfg->get('site_url'))); } JvldLog::log("14: FE Add Link: Send Admin SMS Notification completed"); // Event handlers if ($status == _JVLD_LINKSTATUS_ESTABLISHED) { JvldInit::triggerPlugins('OnLinkPublish', array($linkobj->getInfo('id'))); JvldLog::log("FE Add Link: OnLinkPublish Plugins triggered ok"); /* Trigger LECS announcement */ if (($this->sess_val['partner_url'] != '') && $this->cfg->get('lecs_en')) { if ($this->sess_val['lecs_accept_invites']) { JvldInit::triggerPlugins('OnLecsAcceptInvite', array($linkobj->getInfo('id'))); JvldLog::log("FE Add Link: OnLecsAcceptInvite Plugins triggered ok"); } } } // Set expiry date for link and also the link id in revenue table for paid links if ($linkplan->isPaid() && ($this->sess_val['owpaid_id'] != '')) { // paid $row = JvldDb::getRow("select custom from #__jvld_revenue where id = '".JvldSecure::defendSQL($this->sess_val['owpaid_id'])."'"); if ($row) { JvldDb::update("update #__jvld_revenue set uid = '".(int)$this->user->get('id')."', lid = '".(int)$id."' where id = '".JvldSecure::defendSQL($this->sess_val['owpaid_id'])."'"); JvldLog::log(__FUNCTION__.":: Revenue record updated with link ID and user ID for associated purchase"); } } // set end date for listing $months = ($linkplan->getDuration() == -1) ? 240 : $linkplan->getDuration(); $end_date = JvldDate::addToDate($months, "month"); JvldDb::update("update #__jvld_links set owpaid_till = '".JvldSecure::defendSQL($end_date)."' where id = '".(int)$id."'"); JvldLog::log(__FUNCTION__.":: Links table updated with end date for this link: [".$end_date."]"); // Set output message; if ($status == _JVLD_LINKSTATUS_ESTABLISHED) { $detail_url = JvldPostinit::getRoute('detailpageurl', $id); $result_msg = ($linkplan->isBacklinkRequired()) ? JText::_("COM_JVLD_ADDLINK_DONE_2WAY") : JText::_("COM_JVLD_ADDLINK_DONE_1WAY"); $result_msg = str_replace("{HERE}", "<a target='_blank' href='".$detail_url."'><strong>".JText::_('COM_JVLD_ADDLINK_HERE')."</strong></a>", $result_msg); } else { $result_msg = ($linkplan->isBacklinkRequired()) ? JText::_("COM_JVLD_ADDLINK_PENDING_2") : JText::_("COM_JVLD_ADDLINK_PENDING_1"); } JvldLog::log(__FUNCTION__.":: Result message formatted and ready"); JvldInit::triggerPlugins('OnLinkAfterSave', array($linkobj->getInfo('id'))); //Trigger the finder after save event JvldInit::triggerPlugins('onFinderAfterSave', array('com_jvld.link', $this, 1)); JvldSession::clear(array('efields_values'), 'com_jvld.addlink'); $this->clearSessionData(); $this->clearSessionData('com_jvld.addlink.step.module'); // Remove session variables coming from module JvldLog::log(__FUNCTION__.":: Cool! All ok and complete"); return $id; } catch (Exception $ex) { JvldLog::log(__FUNCTION__.":: Error: ".$ex->getMessage()); $result_msg = $ex->getMessage(); return 0; } } public function process(&$result_msg, $step) { $result_msg = ''; try { $fn = "processStep".$step; return $this->$fn(); } catch (Exception $ex) { $result_msg = $ex->getMessage(); return 0; } } public function loadAllDataFromSession() { for ($i=0;$i<count($this->sess_var);$i++) { $defval = (in_array($this->sess_var[$i], array('pscats_new', 'photos', 'videos', 'files', 'coupons'))) ? array() : ''; $this->sess_val[$this->sess_var[$i]] = JvldSession::get($this->sess_var[$i], $defval, 'com_jvld.addlink.step'); } } public function clearSessionData($ns = 'com_jvld.addlink.step') { JvldSession::clear($this->sess_var, $ns); } public function getSessionData($var, $def='', $ns = 'com_jvld.addlink.step') { return JvldSession::get($var, $def, $ns); } public function setSessionData($var, $val, $ns = 'com_jvld.addlink.step') { JvldSession::set($var, $val, $ns); } private function processStep0() { // clear all session data $this->clearSessionData(); // store data in session $this->setSessionData('oway_plan', $this->input->getString('oway_plan', '')); $this->setSessionData('owpaid_id', $this->input->getString('owpaid_id', '')); // passed from module $this->setSessionData('partner_url', ($this->getSessionData('partner_url', '', 'com_jvld.addlink.step.module') != '') ? $this->getSessionData('partner_url', '', 'com_jvld.addlink.step.module') : $this->input->getString('mod_url', '')); $this->setSessionData('partner_email', ($this->getSessionData('partner_email', '', 'com_jvld.addlink.step.module') != '') ? $this->getSessionData('partner_email', '', 'com_jvld.addlink.step.module') : $this->input->getString('mod_email', '')); $this->setSessionData('partner_title', ($this->getSessionData('partner_title', '', 'com_jvld.addlink.step.module') != '') ? $this->getSessionData('partner_title', '', 'com_jvld.addlink.step.module') : $this->input->getString('mod_title', '')); // passed from a specific cat page addlink menu $cid = ($this->input->getInt('catid', 0) == 0) ? JvldSession::get('pcat', 0, 'addlink') : $this->input->getInt('catid', 0); $this->setSessionData('link_category', $cid); return 1; } private function processStep1() { // General information - partner_email, partner_url, link_category, selfprofiles, reciprocal link, language JvldLog::log("FE Add Link: Step-1 Basic processing started"); // initialize $this->reciprocal_link_url = ''; // load values from form $s_addn_params = array(); parent::preProcess(true, $s_addn_params); $this->loadAllDataFromSession(); // start now if (!isset($this->language)) $this->language = '*'; JvldLog::log("FE Add Link: Language check passed. Language detected: ".$this->language); if (!$this->link_category) throw new Exception(JText::_('COM_JVLD_ADDLINK_SELECT_PCAT')); JvldLog::log("FE Add Link: Check Primary Category passed"); if ($this->partner_email == '') throw new Exception(JText::_("COM_JVLD_ERR_INSUFFINFO")); JvldLog::log("FE Add Link: Partner Email check passed"); // get the link plan object $linkplan = new JvldLinkPlan(); $linkplan->setPlanCode($this->sess_val['oway_plan']); switch ($linkplan->isUrlRequired()) { case _JVLD_OWAY_URL_MANDATORY: { if ($this->partner_url == '') throw new Exception(JText::_("COM_JVLD_ERR_INSUFFINFO")); break; } case _JVLD_OWAY_URL_OPTIONAL: { break; } case _JVLD_OWAY_URL_NOURL: { $this->partner_url = ''; break; } } $this->partner_url = \Joomla\String\StringHelper::trim($this->partner_url); JvldLog::log("FE Add Link: Url: [".$this->partner_url."]"); if ($this->partner_url != '') { if ((\Joomla\String\StringHelper::substr($this->partner_url, 0, 7) != 'http://') && (\Joomla\String\StringHelper::substr($this->partner_url, 0, 8) != 'https://')) throw new Exception(JText::_("COM_JVLD_INVALID_URL")); JvldLog::log('FE Add Link: Partner url http/https validation passed'); // New link validation if (!JvldUtil::isLinkNew($this->partner_url, $this->language)) throw new Exception(JText::_("COM_JVLD_ADDLINK_DUPLICATE")); JvldLog::log("Add FE Link: Partner new link validation passed"); } // Primary category $ctmp = new JvldCategoryinfo($this->link_category); if (($ctmp->getInfo('maxlinks')) && ((1 + $ctmp->getInfo('numlinks')) > $ctmp->getInfo('maxlinks'))) throw new Exception(JText::sprintf("COM_JVLD_ADDLINK_MAXLINKS_CAT_REACHED", htmlspecialchars($ctmp->getInfo('title')))); JvldLog::log("Add FE Link: Primary category maxlinks validation passed"); if (!$ctmp->getInfo('accept_links')) throw new Exception(JText::sprintf("COM_JVLD_ADDLINK_CAT_NOT_ACCEPT_LINKS", htmlspecialchars($ctmp->getInfo("title")))); JvldLog::log("Add FE Link: Primary category accept links validation passed"); // Check if the plan allows top level category addition if (!JvldUtil::doesAllowAddToTopLevelCategory($linkplan, $this->link_category)) throw new Exception(JText::_('COM_JVLD_ADDLINK_TOPCATADD_ERR')); JvldLog::log("FE Add Link: Check to allow top level category addition passed"); if ($linkplan->isBacklinkRequired()) { JvldLog::log("FE Add Link: Link Exchange detected"); if ($this->reciprocal_link_url == '') throw new Exception(JText::_("COM_JVLD_ERR_INSUFFINFO")); JvldLog::log("FE Add Link: Reciprocal link validation passed"); if (JvldUtil::isUrlHacked($this->partner_url, $this->reciprocal_link_url)) throw new Exception(JText::_("COM_JVLD_LINK_RURL_URL_SAME_DOMAIN")); JvldLog::log("FE Add Link: Hacking attempt validation passed"); if (JvldUtil::isLoopback($this->reciprocal_link_url)) throw new Exception(JText::_("COM_JVLD_LINK_RURL_OUR_DOMAIN")); JvldLog::log("FE Add Link: Loopback validation passed"); if (JvldUtil::isRedirectionHack($this->reciprocal_link_url)) throw new Exception(JText::_("COM_JVLD_LINK_RURL_URL_SAME_DOMAIN")); JvldLog::log("FE Add Link: Redirection hack validation passed"); $selfprofile_id = JvldUtil::getJFormVariableValue('selfprofid', 0, 'int'); if (!$selfprofile_id) throw new Exception(JText::_("COM_JVLD_LINK_RURL_URL_NOSELFPROF")); $error = ''; $ret = JvldUtil::checkReciprocalLink($selfprofile_id, $this->reciprocal_link_url, $linkplan->allowRelnofollowInBacklink(), $error); if ($ret) throw new Exception($error.' - '.JText::_("COM_JVLD_LINK_RURL_CHECK_FAILED")); JvldLog::log("Add FE Link: Reciprocal link check validation passed"); } // store data in session $this->setSessionData('partner_url', $this->partner_url); $this->setSessionData('partner_email', $this->partner_email); $this->setSessionData('link_category', $this->link_category); $this->setSessionData('reciprocal_link_url', $this->reciprocal_link_url); $this->setSessionData('selfprofile_id', (isset($selfprofile_id)) ? $selfprofile_id : 0); $this->setSessionData('language', $this->language); return 1; } private function processStep2() { // Entry info - title, description, banner, logo, additional categories, localthumb, metakeys JvldLog::log("FE Add Link: Step-2 Details processing started"); // initialize $pscats_new = array(); $this->localthumb_img = $this->icon_image = $this->metakeys = $this->sef_string = $this->bp_file = ''; // load values from form $s_addn_params = array(); parent::preProcess(true, $s_addn_params); $this->loadAllDataFromSession(); // start $oway_plan = $this->sess_val['oway_plan']; $link_category = $this->sess_val['link_category']; $linkplan = new JvldLinkPlan(); $linkplan->setPlanCode($oway_plan); JvldLog::log("FE Add Link: Profile detected"); $this->title = \Joomla\String\StringHelper::trim($this->title); if ($this->title == '') throw new Exception(JText::_("COM_JVLD_LINKS_ADD_TP_TITLE_MISSING")); if (\Joomla\String\StringHelper::strlen($this->title) > $this->cfg->get('prof_title_maxchar')) throw new Exception(JText::sprintf("COM_JVLD_LINKS_ADD_TP_TITLELEN_EXCEEDS", $this->cfg->get('prof_title_maxchar'))); if (in_array($this->cfg->get('prof_desc_require'), array(_JVLD_LISTING_PROF_REQUIRED, _JVLD_LISTING_PROF_OPTIONAL))) { if (($this->cfg->get('prof_desc_require') == _JVLD_LISTING_PROF_REQUIRED) && ($this->tp_desc == '')) throw new Exception(JText::_("COM_JVLD_LINKS_ADD_TP_DESC_MISSING")); } else { $this->tp_desc = ''; } $this->bp_file = ''; if (in_array($this->cfg->get('prof_banner_require'), array(_JVLD_LISTING_PROF_REQUIRED, _JVLD_LISTING_PROF_OPTIONAL))) { $up_bp_file = JvldFileManager::upload("bp_file", _JVLD_PROFBANNERS_ABSPATH, array('allowed_extns' => $this->cfg->get('prof_banner_allowextns'), 'width' => $this->cfg->get('prof_banner_maxwpix'), 'height' => $this->cfg->get('prof_banner_maxhpix'), 'maxsize' => $this->cfg->get('prof_banner_maxsize'), 'genprefix' => 1, 'err_on_nofileupload' => 0)); if ($up_bp_file != '') { $this->bp_file = $up_bp_file; } if (($this->cfg->get('prof_banner_require') == _JVLD_LISTING_PROF_REQUIRED) && ($this->bp_file == '')) throw new Exception(JText::_("COM_JVLD_LINKS_ADD_BP_GIVEFULLINFO")); } $metadesc = ($this->tp_desc != '') ? \Joomla\String\StringHelper::substr(strip_tags($this->tp_desc), 0, 160) : $this->title; // Secondary Categories $num_max_seccats = $linkplan->getMaxSecondaryCategories(); if (($num_max_seccats) && (isset($this->link_sec_cats))) { for ($i=0;$i<count($this->link_sec_cats);$i++) { if ($this->link_sec_cats[$i] == $link_category) continue; array_push($pscats_new, $this->link_sec_cats[$i]); } if (count($pscats_new) > $num_max_seccats) throw new Exception(JText::sprintf("COM_JVLD_ADDLINK_MAX_CAT_EXCEED", $num_max_seccats)); for ($i=0;$i<count($pscats_new);$i++) { $ctmp = new JvldCategoryinfo($pscats_new[$i]); if (($ctmp->getInfo('maxlinks')) && ((1 + $ctmp->getInfo('numlinks')) > $ctmp->getInfo('maxlinks'))) throw new Exception(JText::sprintf("COM_JVLD_ADDLINK_MAXLINKS_CAT_REACHED", $ctmp->getInfo('title'))); if (!$ctmp->getInfo('accept_links')) throw new Exception(JText::sprintf('COM_JVLD_ADDLINK_CAT_NOT_ACCEPT_LINKS', $ctmp->getInfo("title"))); if (!JvldUtil::doesAllowAddToTopLevelCategory($linkplan, $pscats_new[$i])) throw new Exception(JText::_('COM_JVLD_ADDLINK_TOPCATADD_ERR')); } } JvldLog::log("FE Add Link: Secondary categories processing passed"); // Icon image if ($linkplan->allowLogo()) { $up_icon_image = JvldFileManager::upload("icon_image", _J_ABSPATH_TMP, array('allowed_extns'=>_JVLD_ICONIMAGES_EXTNS, 'maxsize'=>$this->cfg->get('icon_image_x'), 'err_on_nofileupload'=>0)); if ($up_icon_image != '') { $imgHandlerIcim = new JvldImageProcessor(_J_ABSPATH_TMP, $up_icon_image); $imgHandlerIcim->setImage(_JVLD_ICONIMAGES_ABSPATH); $imgHandlerIcim->setDimensions($this->cfg->get('icon_image_w'), $this->cfg->get('icon_image_h')); $imgHandlerIcim->usePrefix(); $this->icon_image = $imgHandlerIcim->resizeImage(); JFile::copy(_J_ABSPATH_TMP.DIRECTORY_SEPARATOR.$up_icon_image, _JVLD_ICONIMAGES_ABSPATH.DIRECTORY_SEPARATOR.'org_'.$this->icon_image); } JvldLog::log("FE Add Link: Logo processing passed"); } else { JvldLog::log("FE Add Link: Logo is not allowed"); } // localthumbs if ($this->cfg->get('tb_provider') == 'localthumbs') { $up_localthumb_img = JvldPreviewsCache::uploadLocalThumbsImage("localthumb_img", $this->partner_url); if ($up_localthumb_img != '') { $this->localthumb_img = $up_localthumb_img; } JvldLog::log("FE Add Link: Custom Local Thumb processing passed"); } // Check meta keys if ($this->metakeys != '') { $metakeys = ''; $m = explode(",", $this->metakeys); for ($p=0;$p<count($m);$p++) { $metakeys .= \Joomla\String\StringHelper::trim($m[$p]).", "; if ($p+1 == $this->cfg->get("max_keywords")) break; } $this->metakeys = \Joomla\String\StringHelper::trim($metakeys, ", "); JvldLog::log("FE Add Link: Meta keys processing passed"); } else { JvldLog::log("FE Add Link: No meta keywords provided"); } // SEF String $this->sef_string = JvldPostinit::getSefUrlStringForLink($this->title, $this->sef_string); if ($this->sef_string == '') throw new Exception(JText::_("COM_JVLD_LINKS_ADD_DUPLICATE_SEF_STRING")); JvldLog::log("FE Add Link: Sef string/Alias processing passed"); // store data in session $this->setSessionData('metadesc', $metadesc); $this->setSessionData('title', $this->title); $this->setSessionData('tp_desc', $this->tp_desc); $this->setSessionData('bp_file', $this->bp_file); $this->setSessionData('icon_image', $this->icon_image); $this->setSessionData('localthumb_img', $this->localthumb_img); $this->setSessionData('metakeys', $this->metakeys); $this->setSessionData('pscats_new', $pscats_new); $this->setSessionData('sef_string', $this->sef_string); return 1; } private function processStep3() { // Extra fields info JvldLog::log("FE Add Link: Step-3 Addninfo processing started"); // load values from form $s_addn_params = array(); parent::preProcess(true, $s_addn_params); $this->loadAllDataFromSession(); // start $ef_sql_p = $ef_sql_v = ''; $efields = JvldUtil::getExtraFields($this->sess_val['link_category'], $this->sess_val['oway_plan']); if (count($efields)) { $ef_err = 0; $ef_errmsg = ''; $efields_values = array(); foreach ($efields as $myfield) { $field = new JvldField($myfield->id); $field_type_obj = JvldXFieldtype::getInstance($field->getFieldType()); $field_value = $field_type_obj->getInputFieldValue($field); $efields_values["field".$field->getID()] = $field_value; try { if ($field_value == '') { if ($field->isRequired()) throw new Exception(JText::sprintf("COM_JVLD_ERR_INSUFFINFO", htmlspecialchars($field->getName()))); else $field_value = $field->getDefaultValue(); } if ($field_value != '') $field_type_obj->validateData($field_value, _JVLD_FIELD_ACTION_SOURCE_LINK_EDIT, $field); $ef_sql_p .= ", field".$field->getID(); $ef_sql_v .= ", '".JvldSecure::defendSQL($field_value)."'"; } catch (Exception $ex1) { $ef_err = 1; $ef_errmsg .= $ex1->getMessage().'<br />'; } } JvldSession::set('efields_values', json_encode($efields_values), 'com_jvld.addlink'); if ($ef_err) throw new Exception($ef_errmsg); JvldLog::log("FE Add Link: Extra fields processing passed"); } // store data in session $this->setSessionData('ef_sql_p', $ef_sql_p); $this->setSessionData('ef_sql_v', $ef_sql_v); return 1; } private function processStep4() { // Photos JvldLog::log("FE Add Link: Step-4 Photos processing started"); // load values from form $s_addn_params = array(); parent::preProcess(true, $s_addn_params); $this->loadAllDataFromSession(); // start $photos = array(); $oway_plan = $this->sess_val['oway_plan']; $linkplan = new JvldLinkPlan(); $linkplan->setPlanCode($oway_plan); // Photos $mpcnt = $linkplan->getMaxPhotos(); if ($this->cfg->get('pgallery_en') && $mpcnt) { $mcnt = ($mpcnt > _JVLD_NUM_PHOTOS_ADD_LINK) ? _JVLD_NUM_PHOTOS_ADD_LINK : $mpcnt; for ($i=1;$i<=$mcnt;$i++) { $t = 'photo_title_'.$i; $m = 'photo_image_'.$i; $image = JvldFileManager::upload($m, _JVLD_PHOTOS_ABSPATH, array('allowed_extns'=>$this->cfg->get('pgallery_allowextns'), 'width'=>$this->cfg->get('pgallery_maxwpix'), 'height'=>$this->cfg->get('pgallery_maxhpix'), 'maxsize'=>$this->cfg->get('pgallery_maxsize'), 'genprefix'=>1, 'err_on_nofileupload'=>0)); if ($image == '') { JvldLog::log("No photo was uploaded for ".$m); continue; } $imgHandler = new JvldImageProcessor(_JVLD_PHOTOS_ABSPATH, $image); $imgHandler->setImage(_JVLD_PHOTOS_ABSPATH, 'tb_'.$image); $imgHandler->setDimensions($this->cfg->get('pgallery_thumbw'), $this->cfg->get('pgallery_thumbh')); $thumb = $imgHandler->resizeImage(); if ($thumb == '') { JvldLog::log("Thumb generation failed for image [".$image."]"); continue; } $imgHandlerC = new JvldImageProcessor(_JVLD_PHOTOS_ABSPATH, $image); $imgHandlerC->setImage(_JVLD_PHOTOS_ABSPATH, 'ca_'.$image); $imgHandlerC->setDimensions($this->cfg->get('pgallery_carouselw'), $this->cfg->get('pgallery_carouselh')); $imgHandlerC->useImageCropping(); $carousel = $imgHandlerC->resizeImage(); if ($carousel == '') { JvldLog::log("Carousel generation failed for image [".$image."]"); continue; } if ($this->$t == '') $this->$t = $thumb; $photo = array('image' => $image, 'title' => $this->$t, 'thumb' => $thumb, 'carousel' => $carousel); array_push($photos, $photo); } JvldLog::log("FE Add Link: Photo Gallery processing passed: <pre>".print_r($photos, true)."</pre>"); } // store data in session $this->setSessionData('photos', $photos); return 1; } private function processStep5() { // Videos JvldLog::log("FE Add Link: Step-5 Videos processing started"); // load values from form $s_addn_params = array(); parent::preProcess(true, $s_addn_params); $this->loadAllDataFromSession(); // start $oway_plan = $this->sess_val['oway_plan']; $videos = array(); $linkplan = new JvldLinkPlan(); $linkplan->setPlanCode($oway_plan); $mvcnt = $linkplan->getMaxVideos(); if ($this->cfg->get('vgallery_en') && $mvcnt) { $mcnt = ($mvcnt > _JVLD_NUM_VIDEOS_ADD_LINK) ? _JVLD_NUM_VIDEOS_ADD_LINK : $mvcnt; for ($i=1;$i<=$mcnt;$i++) { $t = 'video_title_'.$i; $m = 'video_id_'.$i; if ((isset($this->{$t})) && (isset($this->{$m})) && ($this->{$t} != '') && ($this->{$m} != '')) { $title = $this->{$t}; $vid = $this->{$m}; $vid = JvldUtil::getVideoIDFromUrl($vid); if ($vid == "") throw new Exception(JText::_('COM_JVLD_ERR_INVALID_REQ')); for ($j=0;$j<count($videos);$j++) { if (($videos[$j]['title'] == $title) || ($videos[$j]['vid'] == $vid)) throw new Exception(JText::_('COM_JVLD_VIDEO_DUPLICATE')); } $video = array('vid' => $vid, 'title' => $title); array_push($videos, $video); } } JvldLog::log("FE Add Link: Video Gallery processing passed: <pre>".print_r($videos, true)."</pre>"); } // store data in session $this->setSessionData('videos', $videos); return 1; } private function processStep6() { // Files JvldLog::log("FE Add Link: Step-6 Files processing started"); // load values from form $s_addn_params = array(); parent::preProcess(true, $s_addn_params); $this->loadAllDataFromSession(); // start $oway_plan = $this->sess_val['oway_plan']; $files = array(); $linkplan = new JvldLinkPlan(); $linkplan->setPlanCode($oway_plan); $mfiles = $linkplan->getMaxFiles(); if ($this->cfg->get('files_en') && $mfiles) { $mcnt = ($mfiles > _JVLD_NUM_FILES_ADD_LINK) ? _JVLD_NUM_FILES_ADD_LINK : $mfiles; for ($i=1;$i<=$mcnt;$i++) { $f_t = 'file_title_'.$i; $f_d = 'file_desc_'.$i; $f_v = 'file_ver_'.$i; $f_n = 'file_nm_'.$i; $myfile = array(); $up_file = JvldFileManager::upload($f_n, $this->cfg->get('files_location'), array('allowed_extns'=>$this->cfg->get('files_extens'), 'maxsize'=>$this->cfg->get('files_maxsize'), 'genprefix'=>1, 'err_on_nofileupload'=>0), $myfile); if ($up_file == '') // file not uploaded { JvldLog::log("No file was uploaded for ".$f_n); continue; } else // file was uploaded, either new or existing { JvldLog::log("Uploaded file: <pre>".print_r($myfile, true)."</pre>"); if ($this->$f_t == '') $this->$f_t = $myfile['name']; $ul_file = array('title' => $this->$f_t, 'description' => $this->$f_d, 'version' => $this->$f_v, 'upname' => $myfile['name'], 'obname' => $up_file, 'fsize' => round($myfile['size']/1024, 2), 'uploaded_on' => JvldDate::getDateTimeInUTCInMySqlFormat(), 'checksum' => md5_file($this->cfg->get('files_location').DIRECTORY_SEPARATOR.$up_file), 'published' => '1', 'num_downloads' => '0'); array_push($files, $ul_file); } } JvldLog::log("FE Add Link: Files processing passed: <pre>".print_r($files, true)."</pre>"); } // store data in session $this->setSessionData('files', $files); return 1; } private function processStep7() { // Coupons JvldLog::log("FE Add Link: Step-7 Coupons processing started"); // load values from form $s_addn_params = array(); parent::preProcess(true, $s_addn_params); $this->loadAllDataFromSession(); // start $oway_plan = $this->sess_val['oway_plan']; $coupons = array(); $linkplan = new JvldLinkPlan(); $linkplan->setPlanCode($oway_plan); $maxcoupons = $linkplan->getMaxCoupons(); if ($this->cfg->get('coupons_en') && $maxcoupons) { $mcnt = ($maxcoupons > _JVLD_NUM_COUPONS_ADD_LINK) ? _JVLD_NUM_COUPONS_ADD_LINK : $maxcoupons; for ($i=1;$i<=$mcnt;$i++) { $ttitle = 'coupon_title_'.$i; $tdesc = 'coupon_desc_'.$i; $tcode = 'coupon_code_'.$i; $tdisc = 'coupon_disc_'.$i; $tdiscu = 'coupon_discu_'.$i; $texpon = 'coupon_expon_'.$i; $tclurl = 'coupon_clurl_'.$i; if (isset($this->{$ttitle}) && isset($this->{$tdesc}) && isset($this->{$tcode}) && isset($this->{$tdisc}) && isset($this->{$texpon}) && isset($this->{$tclurl}) && ($this->{$ttitle} != '') && ($this->{$tcode} != '') && ($this->{$tdisc} != '') && ($this->{$tdiscu} != '') && ($this->{$texpon} != '')) { $c_title = $this->{$ttitle}; $c_desc = $this->{$tdesc}; $c_code = $this->{$tcode}; $c_disc = $this->{$tdisc}; $c_discu = $this->{$tdiscu}; $c_expon = $this->{$texpon}; $c_clurl = $this->{$tclurl}; for ($j=0;$j<count($coupons);$j++) { if (($coupons[$j]['title'] == $c_title) || ($coupons[$j]['code'] == $c_code)) throw new Exception(JText::_('COM_JVLD_COUPON_DUPLICATE')); } $coupon = array('title' => $c_title, 'desc' => $c_desc, 'code' => $c_code, 'disc' => $c_disc, 'discu' => $c_discu, 'expon' => $c_expon, 'clurl' => $c_clurl); array_push($coupons, $coupon); } } JvldLog::log("FE Add Link: Coupons processing passed: <pre>".print_r($coupons, true)."</pre>"); } // store data in session $this->setSessionData('coupons', $coupons); return 1; } private function processStep8() { // LECS JvldLog::log("FE Add Link: Step-8 LECS processing started"); // initialize $this->lecs_xglink_url = ''; $this->lecs_accept_invites = 0; // load values from form $s_addn_params = array(); parent::preProcess(true, $s_addn_params); $this->loadAllDataFromSession(); // start $oway_plan = $this->sess_val['oway_plan']; $partner_url = $this->sess_val['partner_url']; $linkplan = new JvldLinkPlan(); $linkplan->setPlanCode($oway_plan); if (($partner_url != '') && ($this->cfg->get('lecs_en'))) { if (($this->lecs_accept_invites) && ($this->lecs_xglink_url == '')) $this->lecs_xglink_url = $partner_url; JvldLog::log("FE Add Link: LECS processing passed"); } // store data in session $this->setSessionData('lecs_accept_invites', $this->lecs_accept_invites); $this->setSessionData('lecs_xglink_url', $this->lecs_xglink_url); return 1; } private function processStep9() { // Notifications, contact me, t&c JvldLog::log("FE Add Link: Step-9 Alerts processing started"); // initialize $this->notify_email_rated = 0; $this->notify_email_reviewed = 0; $this->notify_email_bookmarked = 0; $this->notify_email_fdownloaded = 0; $this->notify_sms_rated = 0; $this->notify_sms_reviewed = 0; $this->notify_sms_bookmarked = 0; $this->notify_sms_fdownloaded = 0; $this->receive_mstats_email = 0; $this->mobile = ''; $this->contact_me = 0; // load values from form $s_addn_params = array(); parent::preProcess(true, $s_addn_params); $this->loadAllDataFromSession(); $oway_plan = $this->sess_val['oway_plan']; $partner_url = $this->sess_val['partner_url']; $linkplan = new JvldLinkPlan(); $linkplan->setPlanCode($oway_plan); $this->contact_me = ($linkplan->allowContactOwner()) ? $this->contact_me : 0; $checkagreement = ($this->cfg->get('link_tandc') != '') ? 1 : 0; if (($checkagreement) && ($this->agreement != 1)) throw new Exception(JText::_("COM_JVLD_ADDLINK_TANDC_AGREE")); JvldLog::log("FE Add Link: Check agreement passed"); $mobvalid = $this->input->getInt('mobvalid', 0); if ($this->notify_sms_rated || $this->notify_sms_reviewed || $this->notify_sms_bookmarked || $this->notify_sms_fdownloaded) { // sms notification is required if ($this->mobile != '') { // mobile number provided if (!$mobvalid) throw new Exception(JText::_("COM_JVLD_ADDLINK_SMS_NOTIFY_MOBILE_INVALID")); } else { // mobile number is not provided throw new Exception(JText::_("COM_JVLD_ADDLINK_SMS_NOTIFY_MOBILE_EMPTY")); } } JvldLog::log("FE Add Link: Notification preferences processing passed"); // store data in session $this->setSessionData('notify_email_rated', $this->notify_email_rated); $this->setSessionData('notify_email_reviewed', $this->notify_email_reviewed); $this->setSessionData('notify_email_bookmarked', $this->notify_email_bookmarked); $this->setSessionData('notify_email_fdownloaded', $this->notify_email_fdownloaded); $this->setSessionData('notify_sms_rated', $this->notify_sms_rated); $this->setSessionData('notify_sms_reviewed', $this->notify_sms_reviewed); $this->setSessionData('notify_sms_bookmarked', $this->notify_sms_bookmarked); $this->setSessionData('notify_sms_fdownloaded', $this->notify_sms_fdownloaded); $this->setSessionData('receive_mstats_email', $this->receive_mstats_email); $this->setSessionData('contact_me', $this->contact_me); $this->setSessionData('mobile', $this->mobile); return 1; } }
/var/www/html/1c732/../components/com_jvld/models/addlink.php