<commit_before><?php
/**
 * @author         <NAME> <<EMAIL>>
 * @copyright      (c) 2015-2017, <NAME>. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Core / Class
 */
namespace PH7;

use
PH7\Framework\Url\Header,
PH7\Framework\Mvc\Router\Uri,
PH7\Framework\Date\Various as VDate;

class ValidateSiteCore
{
    const SESS_IS_VISITED = 'validatesitebox_visited';

    /**
     * Check if the JS validationbox has to be added and redirect if the site hasn't been validated yet for a while.
     *
     * @param object \PH7\Framework\Session\Session $oSess
     * @return boolean
     */
    public static function needInject(Framework\Session\Session $oSess)
    {
        $oVSModel = new ValidateSiteCoreModel;
        $iSinceSiteCreated = VDate::getTime(StatisticCoreModel::getDateOfCreation());

        // After over 2 months, the site is still not validated, maybe the validation box doesn't really work, so we redirected to the page form
        if (!$oVSModel->is() && VDate::setTime('-2 months') > $iSinceSiteCreated && !$oSess->exists(self::SESS_IS_VISITED)) {
            Header::redirect(Uri::get('validate-site', 'main', 'validationbox'));
        }

        if (!$oVSModel->is() && VDate::setTime('-2 days') > $iSinceSiteCreated) {
            // OK for adding the validation colorbox
            return true;
        }
        return false;
    }

}<commit_msg>Show validationbox for 2 days/2 months and not more<commit_after><?php
/**
 * @author         <NAME> <<EMAIL>>
 * @copyright      (c) 2015-2017, <NAME>. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Core / Class
 */
namespace PH7;

use
PH7\Framework\Url\Header,
PH7\Framework\Mvc\Router\Uri,
PH7\Framework\Date\Various as VDate;

class ValidateSiteCore
{
    const SESS_IS_VISITED = 'validatesitebox_visited';

    /**
     * Check if the JS validationbox has to be added and redirect if the site hasn't been validated yet for a while.
     *
     * @param object \PH7\Framework\Session\Session $oSess
     * @return boolean
     */
    public static function needInject(Framework\Session\Session $oSess)
    {
        $oVSModel = new ValidateSiteCoreModel;
        $iSinceSiteCreated = VDate::getTime(StatisticCoreModel::getDateOfCreation());

        // After over 2 months, the site is still not validated, maybe the validation box doesn't really work, so we redirected to the page form
        if (!$oVSModel->is() && VDate::setTime('-2 months') >= $iSinceSiteCreated && !$oSess->exists(self::SESS_IS_VISITED)) {
            Header::redirect(Uri::get('validate-site', 'main', 'validationbox'));
        }

        if (!$oVSModel->is() && VDate::setTime('-2 days') >= $iSinceSiteCreated) {
            // OK for adding the validation colorbox
            return true;
        }
        return false;
    }
}
{'fraction_non_alphanumeric': 0.12026359143327842, 'fraction_numerical': 0.013179571663920923, 'mean_word_length': 2.8773946360153255, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3398003', 'n_tokens_mistral': 930, 'n_tokens_neox': 897, 'n_words': 264}