<?php
    // error_reporting(E_ALL);
    // ini_set('display_errors', 'On');

    if (!empty($_GET['project'])) {
        define('URL_TO_CRAWL', $_GET['project']);
    }

    define('MY_IP', '167.114.96.216');

    if(!empty($_GET['p_id'])) {
        define('P_ID', (int)$_GET['p_id']);
    }

    define('BASE_DIR', __DIR__.'/');
    define('DUP_DIR', BASE_DIR."../../Duplicates/");

    define('PRIORITY_USERS', '12137,5454,11392,11781,4697,13154,9979,11548,9317,13290,12309');

    require_once BASE_DIR.'../classes/Database.php';
    require_once BASE_DIR.'../classes/Config.php';

    $desc_arr = array(
        'mal' => array('Missing Image Alt', 'have missing ALT in images', 'eimg.mal'),
        'mkw' => array('Missing Meta Keyword', 'have meta keywords missing', 'emet.mkw'),
        'lkw' => array('Long Meta Keyword', 'have too long meta keyword', 'emet.lkw'),
        'skw' => array('Short Meta Keyword', 'have too short meta keyword', 'emet.skw'),
        'mds' => array('Missing Meta Description', 'have meta description missing', 'emet.mds'),
        'lds' => array('Long Meta Description', 'have too long meta description', 'emet.lds'),
        'sds' => array('Short Meta Description', 'have too short meta keyword', 'emet.sds'),
        'thn' => array('Thin Content', 'have thin content', 'epage.thn'),
        'low' => array('Text to Html Ratio', 'have low text to html ratio', 'etth.low'),
        'dti' => array('Duplicate Title', 'have duplicate title in them', 'etit.dti'),
        'dkw' => array('Duplicate Meta Keywords', 'have duplicate meta keywords in them', 'emet.dkw'),
        'dde' => array('Duplicate Meta Description', 'have duplicate meta description in them', 'emet.dde'),
        'tu' => array('Duplicate Content', 'have duplicate content in them', 'tu'),
        'lt' => array('Long Title', 'have too long title', 'etit.lt'),
        'sti' => array('Short Title', 'have too short title', 'etit.sti'),
        'eti' => array('Empty/Missing Title', 'have empty title', 'etit.eti'),
        'mrf' => array('Meta Refresh', 'have meta refresh', 'emet.mrf'),
        'mre' => array('Meta Redirect', 'have meta redirect', 'emet.mre'),
        'mnf' => array('Meta Nofollow', 'have meta nofollow', 'emet.mnf'),
        'mlg' => array('Missing Language Declaration', 'have language declaration missing', 'mlg'),
        'mst' => array('Too Many Stylesheets', 'have too many stylesheets included', 'esht.mst'),
        'mh1' => array('Missing H1 Tag', 'have missing h1 tag', 'eh1s.mh1'),
        'eh1' => array('Too Many H1 Tags', 'have too many h1 tags', 'eh1s.eh1'),
        'mh2' => array('Missing H2 Tag', 'have missing h2 tag', 'eh2s.mh2'),
        'eh2' => array('Too Many H2 Tags', 'have too many h2 tags', 'eh2s.eh2'),
        'lu' => array('Long URL', 'have too long URL', 'eurl.lu'),
        'spu' => array('Special Characters in URL', 'have special characters in URL', 'eurl.spu'),
        'unu' => array('Underscore Characters in URL', 'have underscores in URL', 'eurl.unu'),
        'upu' => array('UpperCase Characters in URL', 'have uppercase characters in URL', 'eurl.upu'),
        'frm' => array('Using Iframes', 'have iframes in content', 'efrm.frm'),
        'fls' => array('Using Flash', 'have flash in content', 'efls.fls'),
        'ent' => array('Too Many Internal Links', 'have too many internal links', 'eln.ent'),
        'eex' => array('Too Many External Links', 'have too many external links', 'eln.eex'),
        'nfc' => array('Internal NoFollow Links', 'have internal nofollow links', 'eln.nfc'),
        'eim' => array('Too many images', 'have too many images', 'eimg.eim'),
        // 'esp' => array('Too many spelling mistakes', 'have too many spelling mistakes', 'espl.esp'),
        't' => array('Slow Page Speed', 'have slow response time', 't'),
        'big' => array('Page Size too Big', 'have big page size', 'epage.big'),
        'cms' => array('Missing Characterset Declaration', 'have characterset declaration missing', 'emet.cms'),
        'dms' => array('Missing Doctype Declaration', 'have doctype declaration missing', 'edoc.dms')
    );

    foreach ($desc_arr as $eckey => $ecvalue) {
        $err_col_arr[$ecvalue[2]] = 1;
    }


    $processed_arr = array(
    );

    $final_arr = array_merge($desc_arr, $processed_arr);


    // thresholds for page content
    define('T_TITLE_HIGH', 100);
    define('T_TITLE_LOW', 10);
    define('T_META_HIGH', 250);
    define('T_META_LOW', 100);
    define('T_DESC_HIGH', 200);
    define('T_DESC_LOW', 50);
    define('T_PAGE_SIZE_HIGH', 100000);
    define('T_URL_HIGH', 115);
    define('T_TEXT_HTML_RATIO', 15);
    define('T_CONTENT_THIN', 200);
    define('T_STYLE_NO', 4);
    define('T_PAGE_LOAD', 0.5);
    define('T_IMG_NO', 1); // remove
    define('T_H1_NO', 2);
    define('T_H2_NO', 4);
    define('T_H3_NO', 1); // remove
    define('T_H4_NO', 1); // remove
    define('T_LINK_INT_HIGH', 100); // remove
    define('T_LINK_EXT_HIGH', 100); // remove
    define('T_SPEED_SLOW', 30); // remove
    define('T_SPELL_COUNT', 10); // remove



    $ERR_VALUES = array(
        'emet.kws' => 1,
        'emet.desc' => 1,
        'etit.tit' => 1,
        'etth.ratio' => 1,
        'dp' => 1,
        'tu' => 1,
        't' => 1,
        'epage.wrd' => 1,
        'url' => 1,
        'eln.int' => 1,
        'eln.ext' => 1,
        'eln.nfc' => 1,
        'eln.fc' => 1,
        'eln.t' => 1,
        'eimg.c' => 1,
        'esht.sts' => 1,
        'espl.c' => 1,
        'eh1s.h1t' => 1,
        'eh2s.h2t' => 1,
        'epage.hsi' => 1,
    );

    define('T_ERR_MAJOR', ",
        dde,
        eti,
        dti,
        dkw,
        tu,
        mrf,
    ");
    define('T_ERR_MEDIUM', ",
        frm,
        fls,
        sti,
        lt,
        mds,
        lu,
        upu,
        unu,
        spu,
        eex,
        ent,
        nfc,
        thn,
        low,
        big,
        t,
        mnf,
        mh1,
        eh1,
        mh2,
        eh2,
        mal,
        eim,
    ");
    // esp,

    define('T_ERR_MINOR', ",
        cms,
        dms,
        mlg,
        mkw,
        lkw,
        skw,
        lds,
        sds,
        mst,
    ");

