Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/link/components/add.php
Строк: 104
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_link_add
{
    public function 
__construct()
    {
    }
    
    public function 
render()
    {
        if (!
VUri::match('link/add/')) {
            
VModule::load('404'TRUE);
        }
    
        
VLanguage::load('frontend.link');
    
        
$lcfg        VF::cfg('module.link');
        
$errors        = array();
        
$messages    = array();
        
$link       = array(
            
'title' => '''description' => '''url' => '',
            
'name' => '''email' => '''linkback' => ''
        
);
        
        if (
$lcfg['add_page'] == '0') {
            
$errors[]    = 'Link exchange not enabled!';
        }
        
        if (isset(
$_POST['submit-link']) && !$errors) {
            
$filter            VF::factory('filter');
            
$title            $filter->get('title');
            
$description    $filter->get('description');
            
$url            $filter->get('url');
            
$name            $filter->get('name');
            
$email            $filter->get('email');
            
$linkback        $filter->get('linkback');
            
            if (
$title == '') {
                
$errors[] = __('title-empty');
            } else {
                
$link['title']    = $title;
            }
            
            if (
$description != '') {
                
$link['description'] = $description;
            }
            
            if (
$url == '') {
                
$errors[] = __('url-empty');
            } elseif (!
VValid::url($url)) {
                
$errors[] = __('url-invalid');
            } else {
                
$link['url'] = $url;
            }
            
            if (
$name == '') {
                
$errors[]    = __('name-empty');
            } else {
                
$link['name']    = $name;
            }
            
            if (
$email == '') {
                
$errors[]    = __('email-empty');
            } elseif (!
VValid::email($email)) {
                
$errors[]    = __('email-invalid');
            } else {
                
$link['email'] = $email;
            }
            
            if (
$linkback == '') {
                
$errors[]     = __('linkback-empty');
            } elseif (!
VValid::url($linkback)) {
                
$errors[]    = __('linkback-invalid');
            } else {
                
$link['linkback'] = $linkback;
            }
            
            
$code $filter->get('code');
            if (
strtoupper($code) != $_SESSION['captcha_code']) {
                  
$errors[] = __('captcha-invalid');
            }
            
            
$pagerank    VPagerank::get($linkback);
            if (
$lcfg['pagerank_min'] !== 0) {
                  if ((int) 
$pagerank $lcfg['pagerank_min']) {
                      
$errors[] = __('pagerank-invalid', array($lcfg['pagerank']));
                  }
            }
            
            if (
$lcfg['backlink_check'] === && $linkback && 
                !
$this->check_backlink($linkback)) {
                
$errors[] = __('linkback-missing');
            }
            
            if (!
$errors) {
                
$linkback     str_replace(array('http://''www.'), ''$linkback);
            
                
$db VF::factory('database');
                
$db->query("INSERT INTO #__link
                            SET title = '"
.$db->escape($title)."',
                                description = '"
.$db->escape($description)."',
                                url = '"
.$db->escape($url)."',
                                name = '"
.$db->escape($name)."',
                                email = '"
.$db->escape($email)."',
                                linkback = '"
.$db->escape($linkback)."',
                                pagerank = "
.$pagerank.",
                                widget = 'footer',
                                status = '0'"
);
                if (
$db->affected_rows()) {
                    
$messages[] = __('link-success');
                } else {
                    throw new 
VException('Application Error! Aborting...');
                }
            }
        }
        
        
$tpl VF::factory('template');
        
$tpl->menu            'home';
        
$tpl->meta_title    __('link-meta-title');
        
$tpl->submenu        '';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->lcfg            $lcfg;
        
$tpl->link            $link;
        
$tpl->load(array('header''link_add''footer'));
        
$tpl->display();
    }
    
    private function 
check_backlink($url)
    {
        
VF::load('simple_html_dom.simple_html_dom');
        
$html    VCurl::string($url);
        
$html    str_get_html($html);
        foreach (
$html->find('a') as $element) {
            if (
$element->href BASE_URL) {
                return 
TRUE;
            }
        }
        
        return 
FALSE;
    }
}
Онлайн: 0
Реклама