function Variant($testname, $vars = [], $goal = null) { global $g_mv_tests, $g_mv_goals, $g_log_id; $reread = false; foreach ($vars as $v => $content) { if (count(array_filter($g_mv_tests, function ($c) use($testname, $v) { return $c["test"] == $testname && $c["variation"] == $v; })) != count($g_mv_goals)) { foreach ($g_mv_goals as $cgoal) { dbupinsert("sys_variations", ["test" => $testname, "variation" => $v, "goal" => $cgoal, "url" => $_SERVER["REQUEST_URI"], "content" => $content, "start_log_id" => $g_log_id], ["url", "content"]); $reread = true; } } } if ($reread) { variants_start(); } $this->test = $testname; $this->goal = $goal == null ? $g_mv_goals[0] : $goal; }
<?php // cog core modules include_once "./engine/_config.php"; include_once "./engine/cog_common.php"; include_once "./engine/cog_errorhandler.php"; include_once "./engine/cog_database.php"; include_once "./engine/cog_logger.php"; include_once "./engine/cog_scriptor.php"; include_once "./engine/cog_variants.php"; include_once "./engine/cog_webhandler.php"; include_once "./engine/cog_session.php"; initsql(); // initalize database session_start(); // start session log_start(); // log request variants_start(); // initalizes variants // create a new webhandler for all requests $w = new WebHandler(["/" => "site_guestbook/guestbook.php", "/purchase" => "site_guestbook/purchase.php", "/thanks" => "site_guestbook/thanks.html", "/admin" => "site_admin/multivariants.php", "/user_api" => "site_admin/user_api.php", "(.*)" => "site_guestbook/notfound.php"], ["title" => "Cog - guestbook example", "frame" => "site_guestbook/frame.html"]); // print_r($w); exit; echo $w->result();