/application/models/System_model.php

.htaccess
LICENSE
PHPMailer
    .gitignore
    .scrutinizer.yml
    .travis.yml
    LICENSE
    PHPMailerAutoload.php
    README.md
    VERSION
    changelog.md
    class.phpmailer.php
    class.pop3.php
    class.smtp.php
    composer.json
    docs
        Callback_function_notes.txt
        DomainKeys_notes.txt
        Note_for_SMTP_debugging.txt
        extending.html
        faq.html
        generatedocs.sh
        pop3_article.txt
    examples
        code_generator.phps
        contents.html
        contentsutf8.html
        exceptions.phps
        gmail.phps
        images
            phpmailer.png
            phpmailer_mini.png
        index.html
        mail.phps
        mailing_list.phps
        pop_before_smtp.phps
        scripts
            XRegExp.js
            shAutoloader.js
            shBrushPhp.js
            shCore.js
            shLegacy.js
        send_file_upload.phps
        sendmail.phps
        smtp.phps
        smtp_check.phps
        smtp_no_auth.phps
        ssl_options.phps
        styles
            shCore.css
            shCoreDefault.css
            shCoreDjango.css
            shCoreEclipse.css
            shCoreEmacs.css
            shCoreFadeToGrey.css
            shCoreMDUltra.css
            shCoreMidnight.css
            shCoreRDark.css
            shThemeAppleScript.css
            shThemeDefault.css
            shThemeDjango.css
            shThemeEclipse.css
            shThemeEmacs.css
            shThemeFadeToGrey.css
            shThemeMDUltra.css
            shThemeMidnight.css
            shThemeRDark.css
            shThemeVisualStudio.css
            wrapping.png
    extras
        EasyPeasyICS.php
        README.md
        htmlfilter.php
        ntlm_sasl_client.php
    language
        phpmailer.lang-am.php
        phpmailer.lang-ar.php
        phpmailer.lang-az.php
        phpmailer.lang-be.php
        phpmailer.lang-bg.php
        phpmailer.lang-br.php
        phpmailer.lang-ca.php
        phpmailer.lang-ch.php
        phpmailer.lang-cz.php
        phpmailer.lang-de.php
        phpmailer.lang-dk.php
        phpmailer.lang-el.php
        phpmailer.lang-eo.php
        phpmailer.lang-es.php
        phpmailer.lang-et.php
        phpmailer.lang-fa.php
        phpmailer.lang-fi.php
        phpmailer.lang-fo.php
        phpmailer.lang-fr.php
        phpmailer.lang-gl.php
        phpmailer.lang-he.php
        phpmailer.lang-hr.php
        phpmailer.lang-hu.php
        phpmailer.lang-id.php
        phpmailer.lang-it.php
        phpmailer.lang-ja.php
        phpmailer.lang-ka.php
        phpmailer.lang-ko.php
        phpmailer.lang-lt.php
        phpmailer.lang-lv.php
        phpmailer.lang-ms.php
        phpmailer.lang-nl.php
        phpmailer.lang-no.php
        phpmailer.lang-pl.php
        phpmailer.lang-pt.php
        phpmailer.lang-ro.php
        phpmailer.lang-ru.php
        phpmailer.lang-se.php
        phpmailer.lang-sk.php
        phpmailer.lang-sl.php
        phpmailer.lang-sr.php
        phpmailer.lang-tr.php
        phpmailer.lang-uk.php
        phpmailer.lang-vi.php
        phpmailer.lang-zh.php
        phpmailer.lang-zh_cn.php
    test
        bootstrap.php
        fakepopserver.sh
        fakesendmail.sh
        phpmailerLangTest.php
        phpmailerTest.php
        runfakepopserver.sh
        test_callback.php
        testbootstrap-dist.php
    travis.phpunit.xml.dist
application
    .htaccess
    cache
        .htaccess
        index.html
    config
        autoload.php
        config.php
        constants.php
        database.php
        doctypes.php
        foreign_chars.php
        hooks.php
        index.html
        memcached.php
        migration.php
        mimes.php
        profiler.php
        routes.php
        smileys.php
        user_agents.php
    controllers
        Cronid.php
        Systemid.php
        Welcome.php
        index.html
    core
        index.html
    errors
        error_404.php
        error_db.php
        error_general.php
        error_php.php
        index.html
    helpers
        index.html
    hooks
        index.html
    index.html
    language
        english
            index.html
            system_lang.php
        index.html
        polish
            .gitattributes
            README.md
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            system_lang.php
            unit_test_lang.php
            upload_lang.php
    libraries
        index.html
    logs
        index.html
    models
        System_model.php
        index.html
    third_party
        index.html
    views
        components.php
        errors
            cli
                error_404.php
                error_db.php
                error_exception.php
                error_general.php
                error_php.php
                index.html
            html
                error_404.php
                error_db.php
                error_exception.php
                error_general.php
                error_php.php
                index.html
            index.html
        foot.php
        head.php
        index.html
        login.php
        user
            changepassword.php
            editemail.php
            getpassword.php
            postpassword.php
            settings.php
        welcome_message.php
        wykop
            access.php
            accesscheck.php
            accessedit.php
            addcomment.php
            addcomment2.php
            addentry.php
            cronsetup.php
            microblog.php
            microblogplus.php
            searchlink.php
            searchlink2.php
            searchmicroblog.php
            searchmicroblog2.php
            show.php
            tagsfrommicroblog.php
            tagsfrommicroblog2.php
            wykop.php
            wykopplusminus.php
            wykopplusminuscomm.php
arial.ttf
captcha
    sys.txt
css
    bootstrap-theme.css
    bootstrap-theme.css.map
    bootstrap-theme.min.css
    bootstrap-theme.min.css.map
    bootstrap.css
    bootstrap.css.map
    bootstrap.min.css
    bootstrap.min.css.map
favicon.ico
fonts
    glyphicons-halflings-regular.eot
    glyphicons-halflings-regular.svg
    glyphicons-halflings-regular.ttf
    glyphicons-halflings-regular.woff
    glyphicons-halflings-regular.woff2
hrefsystem.png
images
    access.png
    comment.png
    cron.png
    entry.png
    hot.png
    microblog.png
    plus.png
    plusminus.png
    search.png
    tag.png
    top.png
    upcoming.png
index.php
install.php
jquery-latest.min.js
js
    bootstrap.js
    bootstrap.min.js
    npm.js
library
    ajax-loader.gif
    bootstrap.min.js
    crop
        Canvas.php
        Coordinate.php
        Exception.php
        Font
            GDF.php
            PS.php
            TTF.php
        Image.php
        Mapper
            BMP.php
            GD.php
            GD2.php
            GIF.php
            JPEG.php
            PNG.php
            TGA.php
        MapperFactory.php
        Operation
            AddNoise.php
            ApplyConvolution.php
            ApplyFilter.php
            ApplyMask.php
            AsGrayscale.php
            AsNegative.php
            AutoCrop.php
            CopyChannelsPalette.php
            CopyChannelsTrueColor.php
            CorrectGamma.php
            Crop.php
            Flip.php
            GetMask.php
            Merge.php
            Mirror.php
            Resize.php
            ResizeCanvas.php
            Rotate.php
            RoundCorners.php
            Unsharp.php
        OperationFactory.php
        PaletteImage.php
        README
        TrueColorImage.php
        VERSION
        WideImage.php
        gpl.txt
        lgpl.txt
        vendor
            de77
                BMP.php
                TGA.php
    datetime
        css
            bootstrap-datetimepicker.min.css
        js
            bootstrap-datetimepicker.min.js
    index.html
    jquery-autocomplete
        changelog.txt
        demo
            bg.gif
            emails.php
            emails.phps
            images
                Amsterdam Van-Gogh Museum.jpg
                Amsterdam.jpg
                Antwerpen Rubenshaus.jpg
                Antwerpen.jpg
                Appenzell.jpg
                Arnhem Historisches Museum.jpg
                Bled.jpg
                Bled_Die Burg von Bled.jpg
                Bogojina_Die Pfarrkirche.jpg
                BolognaBasilicadiSanPetronio.jpg
                BolognaFontanadelNettuno.jpg
                BolognaPiazzaMaggiore.jpg
                Bolsward Martinikerk.jpg
                Bolsward Stadhuis.jpg
                Bolsward.jpg
                BordeauxND.jpg
                BordeauxPlaceB.jpg
                BotanischerGartenZuerich.jpg
                Bouillon.jpg
                Gent Hotel de Ville2.jpg
                Gent.jpg
                GenuaStrand.jpg
                GenuabeiNacht.jpg
                Giessbachfaelle Brienz.jpg
                Giethoorn.jpg
                Gnesen.jpg
                Gornij Grad_KATHEDRALE.jpg
                Gossensass.jpg
                Grad_Burg Grad2.jpg
                GrandDixence.jpg
                GrenoblePanorama.jpg
                Groningen.jpg
                GrottenvonReclere.jpg
                Guebwiller.jpg
                Kamnik_Die Franziskaner Bibliothek.jpg
                Karlsbad Muehlbrunnkolonnade.jpg
                Kazimierz.jpg
                KirchbergAltesRathaus1.jpg
                KlagenfurtDom.jpg
                KleineMeerjungfreu.jpg
                LazienkiparkWarschau.jpg
                LeHavreHafen.jpg
                LeMans.jpg
                Lednice.jpg
                Leeuwarden Fries Museum.jpg
                Leeuwarden.jpg
                Lelystad.jpg
                Lemmer.jpg
                Leper Halles aux draps.jpg
                Leuven Museum fuer Kirchenkunst.jpg
                Leuven.jpg
                Luxemburg.jpg
                LuzernAltstadt.jpg
                LuzernPicassoMuseum.jpg
                Lyon.jpg
                Maastricht Onze Lieve Vrou...jpg
                Maastricht St Servaasbasiliek.jpg
                Maastricht Walmuur.jpg
                Maastricht.jpg
                MagiatalMaggia.jpg
                Mailand3.jpg
                Metlika_Bela Krajina Museum.jpg
                MilanoCastelloSforzesco.jpg
                MilanoDom.jpg
                MilazzoBurg.jpg
                Novo Mesto_Das Museum.jpg
                ObervellachBurgFalkenstein.jpg
                OdenseeAndersen.jpg
                Olimje_Kirche und Apotheke in Olimje.jpg
                Olomouc.jpg
                OlympischesMuseumLausanne.jpg
                OrleansMaisonJeannedArc.jpg
                OrleansParcFloraldelaSource.jpg
                OstiaAntica.jpg
                Ostrow Tumski.jpg
                PoertschachSchlossLeonstain.jpg
                Portoroz.jpg
                Posen.jpg
                Postojna.jpg
                Prag Altstaedter Ring.jpg
                Prag Waldsteinpalais.jpg
                RouenNotreDame.jpg
                Salzbergwerk Bex.jpg
                SalzbergwerkWieliczka.jpg
                SalzburgFestungHohensalzburg.jpg
                SalzburgResidenz.jpg
                WienMuseumsQuartier.jpg
                WienMusikverein.jpg
                WienRiesenrad.jpg
                WienRingstrasse.jpg
            images.php
            index.html
            indicator.gif
            json.html
            localdata.js
            main.css
            search.php
            search.phps
        jquery.autocomplete.css
        jquery.autocomplete.js
        jquery.autocomplete.min.js
        jquery.autocomplete.pack.js
        lib
            jquery.ajaxQueue.js
            jquery.bgiframe.min.js
            jquery.js
            thickbox-compressed.js
            thickbox.css
        todo
    jquery-ui-sliderAccess.js
    jquery-ui-timepicker-addon.css
    jquery-ui-timepicker-addon.js
    jquery-ui.css
    jquery-ui.min.js
    jquery.min.js
    jquery.selection.js
    jscolor
        arrow.gif
        cross.gif
        demo.html
        hs.png
        hv.png
        jscolor.js
    lightbox2
        .editorconfig
        .gitignore
        .jscsrc
        .jshintrc
        CONTRIBUTING.md
        DEPLOY.md
        Gruntfile.js
        LICENSE
        README.md
        ROADMAP.md
        bower.json
        dist
            css
                lightbox.css
                lightbox.min.css
            images
                close.png
                loading.gif
                next.png
                prev.png
            js
                lightbox-plus-jquery.js
                lightbox-plus-jquery.min.js
                lightbox-plus-jquery.min.map
                lightbox.js
                lightbox.min.js
                lightbox.min.map
        examples
            index.html
        package.json
        src
            css
                lightbox.css
            images
                close.png
                loading.gif
                next.png
                prev.png
            js
                lightbox.js
    slimbox
        README.txt
        css
            closelabel.gif
            loading.gif
            nextlabel.gif
            prevlabel.gif
            slimbox2-rtl.css
            slimbox2.css
        example.html
        example.jpg
        extra
            autoactivation.js
            fix-urls.js
            flickr.js
            picasaweb.js
        js
            slimbox2.js
        src
            autoload.js
            slimbox2.js
    style.css
    wykopapi.php
script.js
special.txt
stylesmenu.css
system
    .htaccess
    core
        Benchmark.php
        CodeIgniter.php
        Common.php
        Config.php
        Controller.php
        Exceptions.php
        Hooks.php
        Input.php
        Lang.php
        Loader.php
        Log.php
        Model.php
        Output.php
        Router.php
        Security.php
        URI.php
        Utf8.php
        compat
            hash.php
            index.html
            mbstring.php
            password.php
            standard.php
        index.html
    database
        DB.php
        DB_active_rec.php
        DB_cache.php
        DB_driver.php
        DB_forge.php
        DB_query_builder.php
        DB_result.php
        DB_utility.php
        drivers
            cubrid
                cubrid_driver.php
                cubrid_forge.php
                cubrid_result.php
                cubrid_utility.php
                index.html
            ibase
                ibase_driver.php
                ibase_forge.php
                ibase_result.php
                ibase_utility.php
                index.html
            index.html
            mssql
                index.html
                mssql_driver.php
                mssql_forge.php
                mssql_result.php
                mssql_utility.php
            mysql
                index.html
                mysql_driver.php
                mysql_forge.php
                mysql_result.php
                mysql_utility.php
            mysqli
                index.html
                mysqli_driver.php
                mysqli_forge.php
                mysqli_result.php
                mysqli_utility.php
            oci8
                index.html
                oci8_driver.php
                oci8_forge.php
                oci8_result.php
                oci8_utility.php
            odbc
                index.html
                odbc_driver.php
                odbc_forge.php
                odbc_result.php
                odbc_utility.php
            pdo
                index.html
                pdo_driver.php
                pdo_forge.php
                pdo_result.php
                pdo_utility.php
                subdrivers
                    index.html
                    pdo_4d_driver.php
                    pdo_4d_forge.php
                    pdo_cubrid_driver.php
                    pdo_cubrid_forge.php
                    pdo_dblib_driver.php
                    pdo_dblib_forge.php
                    pdo_firebird_driver.php
                    pdo_firebird_forge.php
                    pdo_ibm_driver.php
                    pdo_ibm_forge.php
                    pdo_informix_driver.php
                    pdo_informix_forge.php
                    pdo_mysql_driver.php
                    pdo_mysql_forge.php
                    pdo_oci_driver.php
                    pdo_oci_forge.php
                    pdo_odbc_driver.php
                    pdo_odbc_forge.php
                    pdo_pgsql_driver.php
                    pdo_pgsql_forge.php
                    pdo_sqlite_driver.php
                    pdo_sqlite_forge.php
                    pdo_sqlsrv_driver.php
                    pdo_sqlsrv_forge.php
            postgre
                index.html
                postgre_driver.php
                postgre_forge.php
                postgre_result.php
                postgre_utility.php
            sqlite
                index.html
                sqlite_driver.php
                sqlite_forge.php
                sqlite_result.php
                sqlite_utility.php
            sqlite3
                index.html
                sqlite3_driver.php
                sqlite3_forge.php
                sqlite3_result.php
                sqlite3_utility.php
            sqlsrv
                index.html
                sqlsrv_driver.php
                sqlsrv_forge.php
                sqlsrv_result.php
                sqlsrv_utility.php
        index.html
    fonts
        index.html
        texb.ttf
    helpers
        array_helper.php
        captcha_helper.php
        cookie_helper.php
        date_helper.php
        directory_helper.php
        download_helper.php
        email_helper.php
        file_helper.php
        form_helper.php
        html_helper.php
        index.html
        inflector_helper.php
        language_helper.php
        number_helper.php
        path_helper.php
        security_helper.php
        smiley_helper.php
        string_helper.php
        text_helper.php
        typography_helper.php
        url_helper.php
        xml_helper.php
    index.html
    language
        english
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        index.html
    libraries
        Cache
            Cache.php
            drivers
                Cache_apc.php
                Cache_dummy.php
                Cache_file.php
                Cache_memcached.php
                Cache_redis.php
                Cache_wincache.php
                index.html
            index.html
        Calendar.php
        Cart.php
        Driver.php
        Email.php
        Encrypt.php
        Encryption.php
        Form_validation.php
        Ftp.php
        Image_lib.php
        Javascript
            Jquery.php
            index.html
        Javascript.php
        Log.php
        Migration.php
        Pagination.php
        Parser.php
        Profiler.php
        Session
            Session.php
            SessionHandlerInterface.php
            Session_driver.php
            drivers
                Session_database_driver.php
                Session_files_driver.php
                Session_memcached_driver.php
                Session_redis_driver.php
                index.html
            index.html
        Session.php
        Sha1.php
        Table.php
        Trackback.php
        Typography.php
        Unit_test.php
        Upload.php
        User_agent.php
        Xmlrpc.php
        Xmlrpcs.php
        Zip.php
        index.html
tmp
    sys.txt
uploads
    sys.txt
wykopapi.png
<?php

/**
 * @author Lukasz Sosna
 * @copyright 2019
 * @e-mail tree@interia.pl
 * @e-mail support@phpbluedragon.eu
 * @www http://phpbluedragon.eu
 */

class System_model extends CI_Model 
{
    public function __construct()
    {
        parent::__construct();
        
        //if($this->CheckLicenseExists() == 'yes')
		//{
			$this->ThisFileLicense = true;
		//}
    }

    private $ThisFileLicense = false;
    
	private function GetMyUrl($Url) 
	{
	    //echo '--------------'.$Url.'----------------';
		$ResultUrl = parse_url($Url);
        /*echo '<pre>';
        print_r($ResultUrl);
        echo '</pre>';*/
		return $ResultUrl['scheme']."://".$ResultUrl['host'];
	}

    public function CheckLicenseExists()
    {
        /*if(file_exists('wykopapi.php'))
        {
            //yes
			
			//$ContentLicenseFile = @file_get_contents('hrefsystem.txt');
			$ContentLicenseFileTemp = file('wykopapi.php');
            
            $ContentLicenseFile = $ContentLicenseFileTemp[2];
            
            //echo $ContentLicenseFile;
            
            if(isset($_SERVER['HTTPS']))
            {
                $HostName = 'https://';
            }
            else
            {
                $HostName = 'http://';
            }
            
			$ReadyUrl = $this->GetMyUrl($HostName.$_SERVER['SERVER_NAME']);
            
			//echo '---'.$ReadyUrl.'---'.$_SERVER['SERVER_NAME'];
            
			if(password_verify($ReadyUrl.'j8c9bpybxceql8m53vd7hayz0nsbp5ed',trim($ContentLicenseFile)))
			{
				$ValToReturn = 'yes';
			}
			else
			{
				$ValToReturn = 'no';
			}
			
        }
        else
        {
            $ValToReturn = 'no';
        }*/
        

        //echo $ValToReturn;
		$ValToReturn = 'yes';
		
        return $ValToReturn;
    }
    
    public function CheckLicenseExistsNoAlert()
    {
        if(file_exists('wykopapilic.php'))
        {
			$ContentLicenseFileTemp = file('wykopapilic.php');
            
            $ContentLicenseFile = $ContentLicenseFileTemp[2];
            
            if(isset($_SERVER['HTTPS']))
            {
                $HostName = 'https://';
            }
            else
            {
                $HostName = 'http://';
            }
            
			$ReadyUrl = $this->GetMyUrl($HostName.$_SERVER['SERVER_NAME']);
                       
			if(password_verify($ReadyUrl.'j8c9bpybxceql8m53vd7hayz0nsbp5ed_lic',trim($ContentLicenseFile)))
			{
				$ValToReturn = 'yes';
			}
			else
			{
				$ValToReturn = 'no';
			}
        }
        else
        {
            $ValToReturn = 'no';
        }
		
        return $ValToReturn;
    }
    
    public function AccessRemoveToken()
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}session
        SET
        session_time = "'.$this->db->escape_str((time()-2*60*60)).'"
        WHERE
        session_time > "'.$this->db->escape_str((time()-1*60*60)).'"
        ');   
    }
    
    public function AccessShowToken()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}session
        WHERE
        session_time > "'.$this->db->escape_str((time()-1*60*60)).'"
        ORDER BY
        session_id DESC
        LIMIT 0,1
		');
        		
		return $QueryResult;
    }
    
    public function AccessAddToken($TokenId,$KeyId,$SecretId)
    {
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}session
        (
        session_ident,
        session_key,
        session_secret,
        session_time
        )
        VALUES
        (
        "'.$this->db->escape_str($TokenId).'",
        "'.$this->db->escape_str($KeyId).'",
        "'.$this->db->escape_str($SecretId).'",
        "'.$this->db->escape_str(time()).'"
        )
        ');
    }
    
    public function CronSelectSetup()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}cron
        WHERE
        cron_id = "1"
		');
        		
		return $QueryResult;
    }
    
    public function CronSetSettings()
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}cron
        SET
        cron_top = "'.$this->db->escape_str($this->input->post('cron_top')).'",
        cron_dig = "'.$this->db->escape_str($this->input->post('cron_dig')).'",
        cron_microblog = "'.$this->db->escape_str($this->input->post('cron_microblog')).'",
        cron_comm_top = "'.$this->db->escape_str($this->input->post('cron_comm_top')).'",
        cron_comm_howmany_top = "'.$this->db->escape_str($this->input->post('cron_comm_howmany_top')).'",
        cron_comm_dig = "'.$this->db->escape_str($this->input->post('cron_comm_dig')).'",
        cron_comm_howmany_dig = "'.$this->db->escape_str($this->input->post('cron_comm_howmany_dig')).'",
        cron_start = "'.$this->db->escape_str($this->input->post('cron_start')).'",
        cron_stop = "'.$this->db->escape_str($this->input->post('cron_stop')).'"
        WHERE
        cron_id = "1"
        ');
    }
    
    public function QueryInCronUpdateDate($RecordId)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}cron_date
        SET
        date_maked = "y"
        WHERE
        date_id = "'.$this->db->escape_str($RecordId).'"
        ');   
    }
    
    public function CronSelectJobsToDo()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}entry_cron
        WHERE
        entry_time < "'.$this->db->escape_str(time()).'"
		');
        		
		return $QueryResult;
    }
    
    public function CronSetJobsAddMaked($CronId)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}entry_cron
        SET
        entry_maked = "y"
        WHERE
        entry_id = "'.$this->db->escape_str($CronId).'"
        ');   
    }
    
    public function CronQueryAboutDate()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}cron_date
        WHERE
        date_when_read LIKE "'.$this->db->escape_str(date('Y-m-d')).'%"
		');
        		
		return $QueryResult;
    }
    
    public function CronQueryAfterDate()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}cron_date
        WHERE
        date_when < "'.$this->db->escape_str(time()).'"
        AND
        date_maked = ""
        LIMIT 0,1
		');
        		
		return $QueryResult;
    }
    
    public function CronInsertDate()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}cron
        WHERE
        cron_id = "1"
		');
        
        foreach($QueryResult->result() as $row)
        {
            $DateStart = $row->cron_start;
            $DateStop = $row->cron_stop;
        }
        
        $MakeDateStart = date('Y-m-d').' '.$DateStart;
        $TimeStart = strtotime($MakeDateStart);
        
        $MakeDateStop = date('Y-m-d').' '.$DateStop;
        $TimeStop = strtotime($MakeDateStop);
        
        $Time_cron_top = rand($TimeStart,$TimeStop);
        $Time_cron_dig = rand($TimeStart,$TimeStop);
        $Time_cron_microblog = rand($TimeStart,$TimeStop);
        $Time_cron_comm_top = rand($TimeStart,$TimeStop);
        $Time_cron_comm_dig = rand($TimeStart,$TimeStop);
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}cron_date
        (date_when,date_when_read,date_what)
        VALUES
        ("'.$this->db->escape_str($Time_cron_top).'","'.$this->db->escape_str(date('Y-m-d H:i:s', $Time_cron_top)).'","cron_top")');
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}cron_date
        (date_when,date_when_read,date_what)
        VALUES
        ("'.$this->db->escape_str($Time_cron_dig).'","'.$this->db->escape_str(date('Y-m-d H:i:s', $Time_cron_dig)).'","cron_dig")');
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}cron_date
        (date_when,date_when_read,date_what)
        VALUES
        ("'.$this->db->escape_str($Time_cron_microblog).'","'.$this->db->escape_str(date('Y-m-d H:i:s', $Time_cron_microblog)).'","cron_microblog")');
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}cron_date
        (date_when,date_when_read,date_what)
        VALUES
        ("'.$this->db->escape_str($Time_cron_comm_top).'","'.$this->db->escape_str(date('Y-m-d H:i:s', $Time_cron_comm_top)).'","cron_comm_top")');
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}cron_date
        (date_when,date_when_read,date_what)
        VALUES
        ("'.$this->db->escape_str($Time_cron_comm_dig).'","'.$this->db->escape_str(date('Y-m-d H:i:s', $Time_cron_comm_dig)).'","cron_comm_dig")');
    }
    
    public function AddNewCronJobAddEntry($Body,$File1='',$File2='')
    {
        if($File2 != '')
        {
            $FileToDB = $File2;
        }
        else
        {
            $FileToDB = $File1;
        }
        
        $StartTime = strtotime($this->input->post('period_date_1'));
        $StopTime = strtotime($this->input->post('period_date_2'));
        $PeriodTime = $this->input->post('period_period');
        
        if(!is_numeric($StartTime)){exit;}
        if(!is_numeric($StopTime)){exit;}
        if(!is_numeric($PeriodTime)){exit;}
        
        $PeriodTime = $PeriodTime * 60;
        
        //echo $StartTime.' - '.$StopTime.' - '.$PeriodTime.' - '.($StopTime - $StartTime);
        
        $HowManyTimes = ($StopTime - $StartTime) / $PeriodTime;
        
        $HowManyTimes = round($HowManyTimes,0);
        
        for($i=0;$i<$HowManyTimes;$i++)
        {
            //echo date('Y-m-d H:i:s', $StartTime + ($PeriodTime * $i) + rand(5,35)).'<br />';
            
            $QueryResult = $this->db->query('INSERT INTO 
            {PREFIXDB}entry_cron
            (
            entry_comment,
            entry_file,
            entry_time
            )
            VALUES
            (
            "'.$this->db->escape_str($Body).'",
            "'.$this->db->escape_str($FileToDB).'",
            "'.$this->db->escape_str($StartTime + ($PeriodTime * $i) + rand(5,35)).'"
            )
            ');
        }
    }
    
    public function AccessShowAll()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}access
        ORDER BY
        access_id ASC
		');
        		
		return $QueryResult;
    }
    
    public function AccessGetById($AccessId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}access
        WHERE
        access_id = "'.$this->db->escape_str($AccessId).'"
		');
        		
		return $QueryResult;
    }
    
    public function AccessDelete($AccessId)
    {
        $QueryResult = $this->db->query('DELETE FROM 
		{PREFIXDB}access
        WHERE
        access_id = "'.$this->db->escape_str($AccessId).'"
		');
    }
    
    public function AccessAddNew()
    {
        $AccessKey = htmlspecialchars($this->input->post('access_key'));
        $AccessSecret = htmlspecialchars($this->input->post('access_secret'));
        $AccessConnection = htmlspecialchars($this->input->post('access_connection'));
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}access
        (
        access_key,
        access_secret,
        access_connection
        )
        VALUES
        (
        "'.$this->db->escape_str($AccessKey).'",
        "'.$this->db->escape_str($AccessSecret).'",
        "'.$this->db->escape_str($AccessConnection).'"
        )
        ');
    }
    
    public function AccessEdit($AccessId)
    {
        $AccessKey = htmlspecialchars($this->input->post('access_key'));
        $AccessSecret = htmlspecialchars($this->input->post('access_secret'));
        $AccessConnection = htmlspecialchars($this->input->post('access_connection'));
        
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}access
        SET
        access_key = "'.$this->db->escape_str($AccessKey).'",
        access_secret = "'.$this->db->escape_str($AccessSecret).'",
        access_connection = "'.$this->db->escape_str($AccessConnection).'"
        WHERE
        access_id = "'.$this->db->escape_str($AccessId).'"
        ');
    }
    
    public function AccessSetDate($AccessId)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}access
        SET
        access_check = "'.$this->db->escape_str(date('Y-m-d H:i:s')).'"
        WHERE
        access_id = "'.$this->db->escape_str($AccessId).'"
        ');
    }
    
    public function AccessSelectAll()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}access
        WHERE
        access_check != "0000-00-00 00:00:00"
        ORDER BY access_id ASC
		');
        		
		return $QueryResult;
    }
    
    /*public function GetProjectList()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project
        ORDER BY
        project_id ASC
		');
        		
		return $QueryResult;
    }
    
    public function GetHowManyProject()
    {
        $QueryResult = $this->db->query('SELECT count(project_id) AS HowMany FROM 
		{PREFIXDB}project
		');
        		
		return $QueryResult;
    }
    
    public function GetProjectListSort($Column='', $Order='')
    {
        
        if($Column == 'project_id'){ $SortColumn = 'project_id'; } 	
        if($Column == 'project_href'){ $SortColumn = 'project_href'; } 	
        if($Column == 'project_name'){ $SortColumn = 'project_name'; } 	
        if($Column == 'project_lastcheck'){ $SortColumn = 'project_lastcheck'; }
        if($Column == 'project_long'){ $SortColumn = 'project_long'; }
        if($SortColumn == ''){$SortColumn = 'project_id';}
        
        if($Order == 'desc')
        {
            $SortOrder = 'DESC';
        }
        else
        {
            $SortOrder = 'ASC';
        }
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project
        ORDER BY
        '.$this->db->escape_str($SortColumn).' '.$this->db->escape_str($SortOrder).'
		');
        		
		return $QueryResult;
    }
    
    public function ProjectAddNew()
    {
        $ProjectName = htmlspecialchars($this->input->post('project_name'));
        $ProjectBrief = htmlspecialchars($this->input->post('project_brief'));
        $ProjectHref = htmlspecialchars($this->input->post('project_href'));
        $ProjectLong = htmlspecialchars($this->input->post('project_long'));
        $ProjectEmail = htmlspecialchars($this->input->post('project_email'));
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}project
        (
        project_name,
        project_brief,
        project_href,
        project_long,
        project_email
        )
        VALUES
        (
        "'.$this->db->escape_str($ProjectName).'",
        "'.$this->db->escape_str($ProjectBrief).'",
        "'.$this->db->escape_str($ProjectHref).'",
        "'.$this->db->escape_str($ProjectLong).'",
        "'.$this->db->escape_str($ProjectEmail).'"
        )
        ');
    }
    
    public function UpdateSort($SortColumn,$SortOrder)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}config
        SET
        config_value = "'.$this->db->escape_str($SortColumn).'"
        WHERE
        config_name = "column"
        ');
        
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}config
        SET
        config_value = "'.$this->db->escape_str($SortOrder).'"
        WHERE
        config_name = "order"
        ');
    }
    
    public function UpdateSort2($SortColumn,$SortOrder)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}config
        SET
        config_value = "'.$this->db->escape_str($SortColumn).'"
        WHERE
        config_name = "column2"
        ');
        
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}config
        SET
        config_value = "'.$this->db->escape_str($SortOrder).'"
        WHERE
        config_name = "order2"
        ');
    }
    
    public function UpdateSort3($SortColumn,$SortOrder)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}config
        SET
        config_value = "'.$this->db->escape_str($SortColumn).'"
        WHERE
        config_name = "column3"
        ');
        
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}config
        SET
        config_value = "'.$this->db->escape_str($SortOrder).'"
        WHERE
        config_name = "order3"
        ');
    }
    
    public function ProjectEditExisting()
    {
        $ProjectName = htmlspecialchars($this->input->post('project_name'));
        $ProjectBrief = htmlspecialchars($this->input->post('project_brief'));
        $ProjectHref = htmlspecialchars($this->input->post('project_href'));
        $ProjectLong = htmlspecialchars($this->input->post('project_long'));
        $ProjectEmail = htmlspecialchars($this->input->post('project_email'));
        
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}project
        SET
        project_name = "'.$this->db->escape_str($ProjectName).'",
        project_brief = "'.$this->db->escape_str($ProjectBrief).'",
        project_href = "'.$this->db->escape_str($ProjectHref).'",
        project_long = "'.$this->db->escape_str($ProjectLong).'",
        project_email = "'.$this->db->escape_str($ProjectEmail).'"
        WHERE
        project_id = "'.$this->db->escape_str($this->input->post('project_id')).'"
        ');
    }
    
    public function ProjectGetById($ProjectId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project
        WHERE
        project_id = "'.$this->db->escape_str($ProjectId).'"
		');
        		
		return $QueryResult;
    }
    
    public function ProjectDelete($ProjectId)
    {
        $QueryResult = $this->db->query('DELETE FROM 
		{PREFIXDB}project
        WHERE
        project_id = "'.$this->db->escape_str($ProjectId).'"
		');
    }
    
    public function GetOneLinkFromProject($ProjectId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project_link
        WHERE
        link_project_id = "'.$this->db->escape_str($ProjectId).'"
        AND
        link_checkhand = ""
        ORDER BY
        link_id ASC
        LIMIT 0,1
		');
        		
		return $QueryResult;
    }
    
    public function UpdateLinkHandStatus($LinkId)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}project_link
        SET
        link_checkhand = "y"
        WHERE
        link_id = "'.$this->db->escape_str($LinkId).'"
        ');
    }
    
    public function UpdateLinkCronStatus($LinkId)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}project_link
        SET
        link_check = "y"
        WHERE
        link_id = "'.$this->db->escape_str($LinkId).'"
        ');
    }
    
    public function GetLinkProjectData($LinkId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project_link
        WHERE
        link_id = "'.$this->db->escape_str($LinkId).'"
		');
        
        return $QueryResult;
    }
    
    public function CheckEmptyLink($ProjectId)
    {
        $QueryResult = $this->db->query('SELECT count(link_id) AS HowMany FROM 
		{PREFIXDB}project_link
        WHERE
        link_project_id = "'.$this->db->escape_str($ProjectId).'"
        AND
        link_check != "y"
		');
        
        return $QueryResult;
    }
    
    public function GetOneLinkFromProjectCron()
    {
        $CronCheck = false;
        $LinkId = false;
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project
        WHERE
        project_lastcheck = "0000-00-00"
        LIMIT 0,1
		');
        
        foreach($QueryResult->result() as $row)
		{	
            $CronCheck = true;
            
            $IsLink = false;
            
            $ProjectId = $row->project_id;
            
            $QueryResult2 = $this->db->query('SELECT * FROM 
    		{PREFIXDB}project_link
            WHERE
            link_project_id = "'.$this->db->escape_str($ProjectId).'"
            AND
            link_check = ""
    		');
            
            foreach($QueryResult2->result() as $row2)
            {
                $IsLink = true;
                
                $LinkId = $row2->link_id;
            }
            
            if($IsLink == false)
            {
                $this->ProjectMakeReport($ProjectId);
                
                // Aktualizacja linków
                
                $QueryResult = $this->db->query('UPDATE 
                {PREFIXDB}project_link
                SET
                link_check = ""
                WHERE
                link_project_id = "'.$this->db->escape_str($ProjectId).'"
                ');
                
                // Aktualizacja projktu
                
                $QueryResult = $this->db->query('UPDATE 
                {PREFIXDB}project
                SET
                project_lastcheck = "'.$this->db->escape_str(date('Y-m-d')).'"
                WHERE
                project_id = "'.$this->db->escape_str($ProjectId).'"
                ');
            }
        }
        
        
        if($CronCheck == false)
        {
            $QueryResult = $this->db->query('SELECT * FROM 
    		{PREFIXDB}project
    		');
            
            foreach($QueryResult->result() as $row)
    		{
    		  $DateStamp = explode('-', $row->project_lastcheck);
              
    		  $DateDB =  mktime(0, 1, 0, $DateStamp[1], $DateStamp[2], $DateStamp[0]);
              $DataAfterDB = $row->project_long * 24 * 60 * 60;
              
              $DateDB = $DateDB + $DataAfterDB;
              
              if($DateDB < time())
              {
                $QueryResult2 = $this->db->query('SELECT * FROM 
        		{PREFIXDB}project_link
                WHERE
                link_project_id = "'.$this->db->escape_str($row->project_id).'"
                AND
                link_check = ""
        		');
                
                $IsLink = false;
                
                foreach($QueryResult2->result() as $row2)
                {
                    $IsLink = true;
                    
                    $LinkId = $row2->link_id;
                    
                    $BreakWhole = true;
                    
                    break;
                }
                
                if($IsLink == false)
                {
                    $this->ProjectMakeReport($row->project_id);
                    
                    // Aktualizacja linków
                    
                    $QueryResult = $this->db->query('UPDATE 
                    {PREFIXDB}project_link
                    SET
                    link_check = ""
                    WHERE
                    link_project_id = "'.$this->db->escape_str($row->project_id).'"
                    ');
                    
                    // Aktualizacja projktu
                    
                    $QueryResult = $this->db->query('UPDATE 
                    {PREFIXDB}project
                    SET
                    project_lastcheck = "'.$this->db->escape_str(date('Y-m-d')).'"
                    WHERE
                    project_id = "'.$this->db->escape_str($row->project_id).'"
                    ');
                }
              }
              
              if($BreakWhole)
              {
                break;
              }
                  
            }
        }

		return $LinkId;
    }
    
    public function GetLinkData($LinkId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project_link
        WHERE
        link_id = "'.$this->db->escape_str($LinkId).'"
		');
        
        return $QueryResult;
    }
    
    public function UpdateLink($LinkId,$CORE_RobotAviable,$CORE_MetaAviable,$CORE_UrlInOnPage,$CORE_UrlHasNoFollow,$CORE_HeaderStatus,$CORE_LinksOut)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}project_link
        SET
        link_robots = "'.$this->db->escape_str($CORE_RobotAviable).'",
        link_meta = "'.$this->db->escape_str($CORE_MetaAviable).'",
        link_exists = "'.$this->db->escape_str($CORE_UrlInOnPage).'",
        link_nofollow = "'.$this->db->escape_str($CORE_UrlHasNoFollow).'",
        link_http = "'.$this->db->escape_str($CORE_HeaderStatus).'",
        link_howmany = "'.$this->db->escape_str($CORE_LinksOut).'"
        WHERE
        link_id = "'.$this->db->escape_str($LinkId).'"
        ');
    }
    
    public function ProjectMakeReport($ProjectId)
    {
        $DateOfArchive = date("Y-m-d");
        
        $this->db->query('INSERT INTO 
        {PREFIXDB}archive
        (
        archive_project_id,
        archive_date
        )
        VALUES
        (
        "'.$this->db->escape_str($ProjectId).'",
        "'.$this->db->escape_str($DateOfArchive).'"
        )
        ');
        
        $InsertedId = $this->db->insert_id();
        
        $QueryResult = $this->db->query('INSERT INTO {PREFIXDB}project_archive 
        (
        link_link_id,
        link_project_id,
        link_url,
        link_text,
        link_exists,
        link_robots,
        link_nofollow,
        link_meta,
        link_http,
        link_howmany,
        link_date,
        link_archive_id
        )
        SELECT link_id,
        link_project_id,
        link_url,
        link_text,
        link_exists,
        link_robots,
        link_nofollow,
        link_meta,
        link_http,
        link_howmany,
        "'.$this->db->escape_str($DateOfArchive).'",
        "'.$this->db->escape_str($InsertedId).'"
        FROM {PREFIXDB}project_link WHERE link_project_id = "'.$this->db->escape_str($ProjectId).'"
        ');
        
        //
        // Aktualizacja projektu
        //
        
        $this->db->query('UPDATE 
		{PREFIXDB}project
        SET
        project_lastcheck = "'.$this->db->escape_str($DateOfArchive).'"
        WHERE
        project_id = "'.$this->db->escape_str($ProjectId).'"
		');
        
        //
        // Wybieranie danych i generowanie raportu
        //
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project
        WHERE
        project_id = "'.$this->db->escape_str($ProjectId).'"
		');
        
        foreach($QueryResult->result() as $row)
		{
            $IsReportOnEmail = $row->project_email;
            $EmailProjectName = $row->project_name;
            $EmailProjectHref = $row->project_href;
        }
        
        $ResultDB = $this->SelectEmailContent('report');
                
        foreach($ResultDB->result() as $row)
		{
			 $ReadyTitle = $row->email_title;
             $ReadyContent = $row->email_content;
        }
        
        if($IsReportOnEmail == 'y')
        {
            
            $ResultDB = $this->GetProjectLinksSort($ProjectId,'link_exists','asc');

            $UserReportTable = '<!DOCTYPE HTML>
            <html>
            <head>
            	<meta http-equiv="content-type" content="text/html" />
            	<title>'.$ReadyTitle.'</title>
            </head>
            <body>
            <br /><br />
            '.$this->lang->line('a1066').' '.$EmailProjectName.'<br />
            '.$this->lang->line('a1067').' '.$EmailProjectHref.'<br />
            '.$this->lang->line('a1068').' '.$DateOfArchive.'<br />
            <br />
            <table style="border-spacing: 0px; border-collapse: collapse; border: 1px solid black;">';
            
            $UserReportTable .= '<tr>
            <td style="background-color: #ffffff; padding: 5px; color: #000000; font-weight: bold; border: solid 1px #000000;">'.$this->lang->line('a1014').'</td>
            <td style="background-color: #ffffff; padding: 5px; color: #000000; font-weight: bold; text-align: center; border: solid 1px #000000;">'.$this->lang->line('a1015').'</td>
            <td style="background-color: #ffffff; padding: 5px; color: #000000; font-weight: bold; text-align: center; border: solid 1px #000000;">'.$this->lang->line('a1016').'</td>
            <td style="background-color: #ffffff; padding: 5px; color: #000000; font-weight: bold; text-align: center; border: solid 1px #000000;">'.$this->lang->line('a1017').'</td>
            <td style="background-color: #ffffff; padding: 5px; color: #000000; font-weight: bold; text-align: center; border: solid 1px #000000;">'.$this->lang->line('a1018').'</td>
            <td style="background-color: #ffffff; padding: 5px; color: #000000; font-weight: bold; text-align: center; border: solid 1px #000000;">'.$this->lang->line('a1019').'</td>
            <td style="background-color: #ffffff; padding: 5px; color: #000000; font-weight: bold; text-align: center; border: solid 1px #000000;">'.$this->lang->line('a1020').'</td>
            </tr>';
                
            foreach($ResultDB->result() as $row)
            {
                if($row->link_exists == 'y'){$Exists = '<span class="btn btn-info btn-xs">'.$this->lang->line('a1022').'</span>';}else{$Exists = '<span class="btn btn-danger btn-xs">'.$this->lang->line('a1023').'</span>';}
                if($row->link_robots == 'y'){$Robots = '<span class="btn btn-info btn-xs">'.$this->lang->line('a1022').'</span>';}else{$Robots = '<span class="btn btn-danger btn-xs">'.$this->lang->line('a1023').'</span>';}
                if($row->link_nofollow == 'y'){$NoFollow = '<span class="btn btn-danger btn-xs">'.$this->lang->line('a1022').'</span>';}else{$NoFollow = '<span class="btn btn-info btn-xs">'.$this->lang->line('a1023').'</span>';}
                if($row->link_meta == 'n'){$Meta = '<span class="btn btn-info btn-xs">'.$this->lang->line('a1024').'</span>';}else{
                    if (strpos($row->link_meta, 'noindex') !== false) {$HasBad = true;}
                    if (strpos($row->link_meta, 'nofollow') !== false) {$HasBad = true;}
                    if($HasBad)
                    {
                        $Meta = '<span class="btn btn-danger btn-xs">'.$row->link_meta.'</span>';
                    }
                    else
                    {
                        $Meta = '<span class="btn btn-info btn-xs">'.$row->link_meta.'</span>';
                    }
                    }
                
                if($row->link_http == 'n')
                {
                    $HttpHeader = '<span class="btn btn-danger btn-xs">'.$this->lang->line('a1025').'</span>';
                }
                else
                {
                    $HttpHeader = $row->link_http;
                }
                
                if($row->link_howmany == 0)
                {
                    $HowMany = '<span class="btn btn-info btn-xs">'.$row->link_howmany.'</span>';
                }
                else
                {
                    $HowMany = '<span class="btn btn-success btn-xs">'.$row->link_howmany.'</span>';
                }
            
                if($Color == 0)
                {
                    $UserReportTable .= '<tr>';
                    $InsertStyle = 'style="background-color: #f9f9f9; padding: 5px; color: #000000; text-align: center; border: solid 1px #000000;"';
                    $InsertStyleMain = 'style="background-color: #f9f9f9; padding: 5px; color: #000000; text-align: left; border: solid 1px #000000;"';
                    $Color = 1;
                }
                else
                {
                    $UserReportTable .= '<tr>';
                    $InsertStyle = 'style="background-color: #ffffff; padding: 5px; color: #000000; text-align: center; border: solid 1px #000000;"';
                    $InsertStyleMain = 'style="background-color: #ffffff; padding: 5px; color: #000000; text-align: left; border: solid 1px #000000;"';
                    $Color = 0;
                }
                
                $UserReportTable .= '
                <td '.$InsertStyleMain.'>'.$row->link_url.'<br /><span style="font-size: 12px; font-style: italic;">'.$row->link_text.'</span></td>
                <td '.$InsertStyle.'>'.$Exists.'</td>
                <td '.$InsertStyle.'>'.$Robots.'</td>
                <td '.$InsertStyle.'>'.$NoFollow.'</td>
                <td '.$InsertStyle.'>'.$Meta.'</td>
                <td '.$InsertStyle.'>'.$HttpHeader.'</td>
                <td '.$InsertStyle.'>'.$HowMany.'</td>
                </tr>';
            }
            
            $UserReportTable .= '</table>
            <br />
            <br />
            </body>
            </html>';

            $ReadyContent = str_replace('[user_content]',$UserReportTable,$ReadyContent);
            
            $QueryResult = $this->db->query('SELECT * FROM 
    		{PREFIXDB}user
            WHERE
            user_id = "1"
    		');
            
            foreach($QueryResult->result() as $row)
    		{
    			 $UserUsername = $row->user_email;
            }

            $ContactAddress = $this->System_model->GetConfig();
                
            require 'PHPMailer/PHPMailerAutoload.php';
            $mail = new PHPMailer;
    
            $mail->SMTPDebug = 0;
            if($this->config->item('send_email_tls'))
            {
                $mail->SMTPSecure = 'tls';
            }
            $mail->Host = $this->config->item('send_email_stmp_host');
            $mail->SMTPAuth = true;
            $mail->Username = $this->config->item('send_email_stmp_username');
            $mail->Password = $this->config->item('send_email_stmp_password');
            $mail->Port = $this->config->item('send_email_stmp_port');
            $mail->CharSet = 'UTF-8';
            
            $mail->FromName = $this->config->item('send_email_user_name');
            $mail->From = $ContactAddress['root_email'];
            $mail->addAddress($UserUsername);
            
            $mail->isHTML(true);
            
            $mail->Subject = $ReadyTitle;
            $mail->Body    = $ReadyContent;
    
            if(!$mail->send())
            {
                $SystemLang['email_send2'] = true;
            } 
            else 
            {
                $SystemLang['email_send'] = true;
            }
        }
    }
    */
    
    public function UpdateConfig()
    {
        $QueryResult = $this->db->query('UPDATE {PREFIXDB}config SET config_value = "'.$this->db->escape_str($this->input->post('title')).'" WHERE config_name = "title"');
        $QueryResult = $this->db->query('UPDATE {PREFIXDB}config SET config_value = "'.$this->db->escape_str($this->input->post('root_email')).'" WHERE config_name = "root_email"');
        $QueryResult = $this->db->query('UPDATE {PREFIXDB}config SET config_value = "'.$this->db->escape_str($this->input->post('cron')).'" WHERE config_name = "cron"');
    }
    
    /*
    public function ProjectSelectArchive($ProjectId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}archive
        WHERE
        archive_project_id = "'.$this->db->escape_str($ProjectId).'"
        ORDER BY
        archive_id DESC
        LIMIT 0,8
		');
        		
		return $QueryResult;
    }
    
    public function ProjectSelectAllArchive($ProjectId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}archive
        WHERE
        archive_project_id = "'.$this->db->escape_str($ProjectId).'"
        ORDER BY
        archive_id DESC
		');
        		
		return $QueryResult;
    }
    
    public function ProjectResetHandCheck($ProjectId)
    {
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}project_link
        SET
        link_checkhand = ""
        WHERE
        link_project_id = "'.$this->db->escape_str($ProjectId).'"
        ');
    }
    
    public function GetProjectLinks($ProjectId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project_link
        WHERE
        link_project_id = "'.$this->db->escape_str($ProjectId).'"
        ORDER BY
        link_id ASC
		');
        		
		return $QueryResult;
    }
    
    public function GetProjectLinksSort($ProjectId,$Column='',$Order='')
    {
        if($Column == 'link_url'){ $SortColumn = 'link_url'; } 	
        if($Column == 'link_text'){ $SortColumn = 'link_text'; } 	
        if($Column == 'link_exists'){ $SortColumn = 'link_exists'; } 	
        if($Column == 'link_robots'){ $SortColumn = 'link_robots'; }
        if($Column == 'link_nofollow'){ $SortColumn = 'link_nofollow'; }
        if($Column == 'link_meta'){ $SortColumn = 'link_meta'; }
        if($Column == 'link_http'){ $SortColumn = 'link_http'; }
        if($Column == 'link_howmany'){ $SortColumn = 'link_howmany'; }
        
        if($SortColumn == ''){$SortColumn = 'link_url';}
        
        if($Order == 'desc')
        {
            $SortOrder = 'DESC';
        }
        else
        {
            $SortOrder = 'ASC';
        }

        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project_link
        WHERE
        link_project_id = "'.$this->db->escape_str($ProjectId).'"
        ORDER BY
        '.$this->db->escape_str($SortColumn).' '.$this->db->escape_str($SortOrder).'
		');
        		
		return $QueryResult;
    }
    
    public function SelectReportSort($ReportId,$Column='',$Order='')
    {
        if($Column == 'link_url'){ $SortColumn = 'link_url'; } 	
        if($Column == 'link_text'){ $SortColumn = 'link_text'; } 	
        if($Column == 'link_exists'){ $SortColumn = 'link_exists'; } 	
        if($Column == 'link_robots'){ $SortColumn = 'link_robots'; }
        if($Column == 'link_nofollow'){ $SortColumn = 'link_nofollow'; }
        if($Column == 'link_meta'){ $SortColumn = 'link_meta'; }
        if($Column == 'link_http'){ $SortColumn = 'link_http'; }
        if($Column == 'link_howmany'){ $SortColumn = 'link_howmany'; }
        
        if($SortColumn == ''){$SortColumn = 'link_url';}
        
        if($Order == 'desc')
        {
            $SortOrder = 'DESC';
        }
        else
        {
            $SortOrder = 'ASC';
        }
        
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}project_archive 
        WHERE
        link_archive_id = "'.$this->db->escape_str($ReportId).'"
        ORDER BY
        '.$this->db->escape_str($SortColumn).' '.$this->db->escape_str($SortOrder).'
        ');
        
        return $QueryResult;
    }
    
    public function SelectReportExport($ArchiveId,$WhatExport)
    {
        if($WhatExport == 'link')
        {
            $QueryResult = $this->db->query('SELECT * FROM 
            {PREFIXDB}project_archive 
            WHERE
            link_archive_id = "'.$this->db->escape_str($ArchiveId).'"
            AND
            link_exists = "y"
            ORDER BY
            link_id ASC
            ');
        }
        elseif($WhatExport == 'nolink')
        {
            $QueryResult = $this->db->query('SELECT * FROM 
            {PREFIXDB}project_archive 
            WHERE
            link_archive_id = "'.$this->db->escape_str($ArchiveId).'"
            AND
            link_exists != "y"
            ORDER BY
            link_id ASC
            ');
        }
        else
        {
            //all   
            $QueryResult = $this->db->query('SELECT * FROM 
            {PREFIXDB}project_archive 
            WHERE
            link_archive_id = "'.$this->db->escape_str($ArchiveId).'"
            ORDER BY
            link_id ASC
            ');
        }
        
        return $QueryResult;
    }
    
    public function ProjectAddNewLnik($ProjectId)
    {
        $LinkUrl = htmlspecialchars($this->input->post('link_url'));
        $Linktext = htmlspecialchars($this->input->post('link_text'));
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}project_link
        (
        link_url,
        link_text,
        link_project_id
        )
        VALUES
        (
        "'.$this->db->escape_str($LinkUrl).'",
        "'.$this->db->escape_str($Linktext).'",
        "'.$this->db->escape_str($ProjectId).'"
        )
        ');
    }
    
    public function ProjectEditExistingLink()
    {
        $LinkUrl = htmlspecialchars($this->input->post('link_url'));
        $Linktext = htmlspecialchars($this->input->post('link_text'));
        
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}project_link
        SET
        link_url = "'.$this->db->escape_str($LinkUrl).'",
        link_text = "'.$this->db->escape_str($Linktext).'"
        WHERE
        link_id = "'.$this->db->escape_str($this->input->post('link_id')).'"
        ');
    }
    
    public function ProjectGetLinkById($LinkId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project_link
        WHERE
        link_id = "'.$this->db->escape_str($LinkId).'"
		');
        		
		return $QueryResult;
    }
    
    public function ProjectDeleteLink($LinkId)
    {
        $QueryResult = $this->db->query('DELETE FROM 
		{PREFIXDB}project_link
        WHERE
        link_id = "'.$this->db->escape_str($LinkId).'"
		');
    }
    
    public function ImportToProject($ProjectId, $Url, $Brief='')
    {
        $LinkUrl = htmlspecialchars($Url);
        $LinkBrief = htmlspecialchars($Brief);
        
        if($LinkBrief == "")
        {
            $LinkBrief = '*';
        }
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}project_link
        (
        link_url,
        link_text,
        link_project_id
        )
        VALUES
        (
        "'.$this->db->escape_str($LinkUrl).'",
        "'.$this->db->escape_str($LinkBrief).'",
        "'.$this->db->escape_str($ProjectId).'"
        )
        ');
    }
    
    public function CheckCountProject()
    {
        $IsSomethingToCheck = false;
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}project
		');
        
        foreach($QueryResult->result() as $row)
        {
            if($row->project_lastcheck == '0000-00-00')
            {
                $IsSomethingToCheck = true;
            }
            else
            {
                $DateSeparated = explode('-', $row->project_lastcheck);
                
                $time1 = mktime(0, 1, 0, $DateSeparated[1], $DateSeparated[2], $DateSeparated[0]);
                $time2 = time() - $row->project_long;

                if($time1 < $time2)
                {
                    $IsSomethingToCheck = true;
                }
            }
        }
        		
		return $IsSomethingToCheck;
    }
    */
    
    public function UserCheckEmail($Email)
    {
        $Email = htmlspecialchars($Email);
        
        $QueryResult = $this->db->query('SELECT count(user_email) AS HowMany FROM 
		{PREFIXDB}user
        WHERE
        user_email = "'.$this->db->escape_str($Email).'"
		');
        		
		return $QueryResult;
    }
    
    public function ChangePasswordAutomat($UserId,$TemporaryPassword)
    {
        /*
        user_password_clear = "'.$this->db->escape_str($TemporaryPassword).'"
        */
        
        $UserId = htmlspecialchars($UserId);
        $TemporaryPassword = htmlspecialchars($TemporaryPassword);
        
        $SaltPassword = password_hash($TemporaryPassword, PASSWORD_DEFAULT);
        
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}user
        SET
        user_password = "'.$this->db->escape_str($SaltPassword).'"
        WHERE
        user_id = "'.$this->db->escape_str($UserId).'"
        ');
        
    }
    
    public function CheckKeyPasswords($UserId,$KeyPassword,$KeyPassword2)
    {
        $UserId = htmlspecialchars($UserId);
        $KeyPassword = htmlspecialchars($KeyPassword);
        $KeyPassword2 = htmlspecialchars($KeyPassword2);
        
        $QueryResult = $this->db->query('SELECT count(password_id) As HowMany FROM 
        {PREFIXDB}password 
        WHERE
        password_user_id = "'.$this->db->escape_str($UserId).'"
        AND
        password_hash1 = "'.$this->db->escape_str($KeyPassword).'"
        AND
        password_hash2 = "'.$this->db->escape_str($KeyPassword2).'"
        AND
        password_time > "'.$this->db->escape_str(date('Y-m-d H:i:s')).'"
        AND
        password_used = ""
        ');
        
        $this->db->query('UPDATE 
        {PREFIXDB}password 
        SET
        password_used = "y"
        WHERE
        password_user_id = "'.$this->db->escape_str($UserId).'"
        AND
        password_hash1 = "'.$this->db->escape_str($KeyPassword).'"
        AND
        password_hash2 = "'.$this->db->escape_str($KeyPassword2).'"
        AND
        password_time > "'.$this->db->escape_str(date('Y-m-d H:i:s')).'"
        ');
        
        return $QueryResult;
    }
    
    public function GenerateNewPassword($UserId,$KeyPassword,$KeyPassword2)
    {
        $UserId = htmlspecialchars($UserId);
        $KeyPassword = htmlspecialchars($KeyPassword);
        $KeyPassword2 = htmlspecialchars($KeyPassword2);
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}password
        (
        password_user_id,
        password_hash1,
        password_hash2,
        password_time,
        password_ip
        )
        VALUES
        (
        "'.$this->db->escape_str($UserId).'",
        "'.$this->db->escape_str($KeyPassword).'",
        "'.$this->db->escape_str($KeyPassword2).'",
        "'.$this->db->escape_str(date("Y-m-d H:i:s",time()+2*60*60)).'",
        "'.$this->db->escape_str($_SERVER['REMOTE_ADDR']).'"
        )
        ');
    }
    
    public function SelectGenerateNewPassword($UserId,$KeyPassword,$KeyPassword2)
    {
        $UserId = htmlspecialchars($UserId);
        $KeyPassword = htmlspecialchars($KeyPassword);
        $KeyPassword2 = htmlspecialchars($KeyPassword2);
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}password
        WHERE
        password_user_id = "'.$this->db->escape_str($UserId).'"
        AND
        password_hash1 = "'.$this->db->escape_str($KeyPassword).'"
        AND
        password_hash2 = "'.$this->db->escape_str($KeyPassword2).'"
		');
        		
		return $QueryResult;
    }
    
    public function UserCheckEmailSelect($Email)
    {
        $Email = htmlspecialchars($Email);
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}user
        WHERE
        user_email = "'.$this->db->escape_str($Email).'"
		');
        		
		return $QueryResult;
    }
    
    public function UserGetData()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}user
        WHERE
        user_id = "'.$this->db->escape_str($_SESSION['user_id']).'"
		');
        		
		return $QueryResult;
    }
    
    public function UpdateUserPswd()
    {
        $SaltPassword = password_hash($this->input->post('user_pswd2'), PASSWORD_DEFAULT);
        $SaltPassword = htmlspecialchars($SaltPassword);
        
        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}user
        SET
        user_password = "'.$this->db->escape_str($SaltPassword).'"
        WHERE
        user_id = "'.$this->db->escape_str($_SESSION['user_id']).'"
        ');
    }
    
    public function CheckUser()
    {
        $Email = htmlspecialchars($this->input->post('user_email'));
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}user
        WHERE
        user_email = "'.$this->db->escape_str($Email).'"
		');
        
        foreach($QueryResult->result() as $row)
		{
            $PasswordToVerify = $row->user_password;
            $UserId = $row->user_id;
        }
        
        if(password_verify($this->input->post('user_password'), $PasswordToVerify) == false)
        {
            $TableUser['IsAuth'] = 'no';
        }
        else
        {
            $TableUser['IsAuth'] = 'yes';
            $TableUser['UserId'] = $UserId;
        }
        
        return $TableUser;
    }
    public function GetUserData($Email)
    {
        $Email = htmlspecialchars($Email);
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}user
        WHERE
        user_email = "'.$this->db->escape_str($Email).'"
		');
        		
		return $QueryResult;
    }
    
    public function GetUserDataById($Id)
    {
        $Id = htmlspecialchars($Id);
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}user
        WHERE
        user_id = "'.$this->db->escape_str($Id).'"
		');
        		
		return $QueryResult;
    }
    
    public function GetUserDataByDate($Id)
    {
        $Id = htmlspecialchars($Id);
        
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}user
        WHERE
        user_id = "'.$this->db->escape_str($Id).'"
        AND
        user_package_date > "'.$this->db->escape_str(date('Y-m-d H:i:s')).'"
		');
        		
		return $QueryResult;
    }    
    public function WriteLog($Message)
    {
        $Message = htmlspecialchars($Message);
        
        $QueryResult = $this->db->query('INSERT INTO 
        {PREFIXDB}log
        (
        log_user_id,
        log_what,
        log_time,
        log_ip
        )
        VALUES
        (
        "'.$this->db->escape_str($_SESSION['user_id']).'",
        "'.$this->db->escape_str($Message).'",
        "'.$this->db->escape_str(date('Y-m-d H:i:s')).'",
        "'.$this->db->escape_str($_SERVER['REMOTE_ADDR']).'"
        )
        ');
    }
    
    public function PageSelect($Id)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}pages 
        WHERE
        page_id = "'.$this->db->escape_str($Id).'"
        ');
        
        return $QueryResult;
    }
    
    public function GetSystemConfig()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}config
        ');
        
        return $QueryResult;
    }
    
    public function UpdateEmails()
    {    
        $EmailTitle1 = htmlspecialchars($this->input->post('email_title1'));
        $EmailContent1 = htmlspecialchars($this->input->post('email_content1'));

        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}email
        SET
        email_title = "'.$this->db->escape_str($EmailTitle1).'",
        email_content = "'.$this->db->escape_str($EmailContent1).'"
        WHERE
        email_what = "recpassword"
        ');
        
        $EmailTitle2 = htmlspecialchars($this->input->post('email_title2'));
        $EmailContent2 = htmlspecialchars($this->input->post('email_content2'));

        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}email
        SET
        email_title = "'.$this->db->escape_str($EmailTitle2).'",
        email_content = "'.$this->db->escape_str($EmailContent2).'"
        WHERE
        email_what = "newpass"
        ');
        
        $EmailTitle3 = htmlspecialchars($this->input->post('email_title3'));
        $EmailContent3 = htmlspecialchars($this->input->post('email_content3'));

        $QueryResult = $this->db->query('UPDATE 
        {PREFIXDB}email
        SET
        email_title = "'.$this->db->escape_str($EmailTitle3).'",
        email_content = "'.$this->db->escape_str($EmailContent3).'"
        WHERE
        email_what = "report"
        ');
    }
    
    /*public function SelectProjectName($ProjectId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}project
        WHERE
        project_id = "'.$this->db->escape_str($ProjectId).'"
        ');
        
        foreach($QueryResult->result() as $row)
    	{
    		$ProjectName = $row->project_name;
    	}
        
        return $ProjectName;
    }
    
    public function SelectProjectIdByLink($LinkId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}project_link
        WHERE
        link_id = "'.$this->db->escape_str($LinkId).'"
        ');
        
        foreach($QueryResult->result() as $row)
    	{
    		$ProjectId = $row->link_project_id;
    	}
        
        return $ProjectId;
    }
    
    public function SelectProjectNameByLink($LinkId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}project_link
        WHERE
        link_id = "'.$this->db->escape_str($LinkId).'"
        ');
        
        foreach($QueryResult->result() as $row)
    	{
    		$ProjectId = $row->link_project_id;
    	}
        
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}project
        WHERE
        project_id = "'.$this->db->escape_str($ProjectId).'"
        ');
        
        foreach($QueryResult->result() as $row)
    	{
    		$ProjectName = $row->project_name;
    	}
        
        return $ProjectName;
    }
    */
    
    public function SelectEmail($Name)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}email 
        WHERE
        email_what = "'.$this->db->escape_str($Name).'"
        ');
        
        return $QueryResult;
    }
    
    public function GetConfig()
    {
        $ResultDB = $this->System_model->GetSystemConfig();
    
    	foreach($ResultDB->result() as $row)
    	{
    		$ConfigTable[$row->config_name] = $row->config_value;
    	}
        
        return $ConfigTable;
    }
    
    public function SelectEmailContent($WhatEmail)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
		{PREFIXDB}email
        WHERE
        email_what = "'.$this->db->escape_str($WhatEmail).'"
		');
        		
		return $QueryResult;
    }
    
    public function GetUserEmail()
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}user 
        WHERE
        user_id = "'.$this->db->escape_str($_SESSION['user_id']).'"
        ');
        
        foreach($QueryResult->result() as $row)
    	{
    	   $UserEmail = $row->user_email;
        }
        
        return $UserEmail;
    }
    
    /*
    public function SelectReport($ReportId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}project_archive 
        WHERE
        link_archive_id = "'.$this->db->escape_str($ReportId).'"
        ORDER BY link_url ASC
        ');
        
        return $QueryResult;
    }
    
    public function SelectProjectNameByArchive($ArchiveId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}project_archive 
        WHERE
        link_archive_id = "'.$this->db->escape_str($ArchiveId).'"
        LIMIT 0,1
        ');
        
        foreach($QueryResult->result() as $row)
    	{
    	   $ProjectId = $row->link_project_id;
        }
        
        return $ProjectId;
    }
    
    public function SelectDateArchive($ArchiveId)
    {
        $QueryResult = $this->db->query('SELECT * FROM 
        {PREFIXDB}project_archive 
        WHERE
        link_archive_id = "'.$this->db->escape_str($ArchiveId).'"
        LIMIT 0,1
        ');
        
        foreach($QueryResult->result() as $row)
    	{
    	   $DateOfArchive = $row->link_date;
        }
        
        return $DateOfArchive;
    }
    */
}

?>




Copyright © 2015-2019 - by Lucas SOS | About the Author | Tags | Blog | Links | Login