<?php
/**
 * Filename: _helpers.php
 * Created by: BlogProfitNetwork.Com <marcus@blogprofitnetwork.com> (https://BlogProfitNetwork.Com)
 * Copyright:2018 All Rights Reserved - BlogProfitNetwork.Com <marcus@blogprofitnetwork.com> (https://BlogProfitNetwork.Com)
 *
 * Skype: blogprofitnetwork
 * Email: marcus@blogprofitnetwork.com
 */
defined('_IN_MAIN_MODULE') or die ('ACCESS DENIED');

class clickVoodooV4Helpers {
	function loadCustomJQuery() {
		?>

		<script type="text/javascript">
			if (!window.jQuery) {
				document.write('<script type="text/javascript" src="<?php echo CLICKVOODOOV4_URL .'tmpl/js/jquery-3.3.1.min.js'; ?>"><\/script>');
			}
		</script>

		<?php
	}

	function printTerminalMsg($msg) {
		return error_log($msg, 0);
	}

	function printBrowserMsg($msg) {
		echo '<pre>';
			print_r ($msg);
		echo '</pre>';
	}

	function generateRandomChars() {
	    global $clickVoodooV4Database;

	    $isUnique       = false;
	    $generatedChars = substr(md5(microtime()), rand(0, 26));

	    while (!$isUnique) {
	        $check = $clickVoodooV4Database->checkUrlValue($generatedChars);
	        if (0 == $check) {
	            $isUnique = true;
            }
	        else {
                $generatedChars = substr(md5(microtime()), rand(0, 26));
            }
        }

        echo $generatedChars;
    }
}
