Example #1
0
function writeDebug()
{
    if (isDev() && isInternal()) {
        echo "<div id='debug'>\n\t<h5>Debug Output</h5>\n";
        foreach ($GLOBALS['aDebug'] as $d) {
            echo "\t\t<p>{$d}</p>\n";
        }
        echo "\t<h5>SESSION</h5>\n";
        foreach ($_SESSION as $k => $v) {
            echo "\t\t<p>{$k}: {$v}</p>\n";
        }
        echo "\t<h5>POST: Cleaned</h5>\n";
        foreach ($GLOBALS['aPost'] as $k => $v) {
            echo "\t\t<p>{$k}: {$v}</p>\n";
        }
        echo "\t<h5>POST: Raw</h5>\n";
        foreach ($_POST as $k => $v) {
            echo "\t\t<p>{$k}: {$v}</p>\n";
        }
        echo "\t<h5>GET (Query String)</h5>\n";
        foreach ($_GET as $k => $v) {
            echo "\t\t<p>{$k}: {$v}</p>\n";
        }
        echo "\t<h5>FILES</h5>\n";
        print_r($_FILES);
        echo "\t<h5>DEBUG</h5>\n";
        foreach ($_SERVER as $k => $v) {
            echo "\t\t<p>{$k}: {$v}</p>\n";
        }
        echo "</div>\n";
    }
}
Example #2
0
/**
 * Resolves an IP address to a country code
 * 
 * @param string $ipaddr IP address to resolve (defaults to <get_ip_address>)
 * @return array Country code or empty string if not found
 */
function get_countrycode_by_ip($ipaddr = false)
{
    if ($ipaddr === false) {
        $ipaddr = $GLOBALS['current_ip_addr'];
    }
    if (isset($_SESSION['geoip_countrycode_by_ip_' . $ipaddr]) && $_SESSION['geoip_countrycode_by_ip_' . $ipaddr] != "") {
        return $_SESSION['geoip_countrycode_by_ip_' . $ipaddr];
    }
    if (function_exists('geoip_open')) {
        $gi = geoip_open($GLOBALS['CONFIG']['geoip']['city_dat_file'], GEOIP_STANDARD);
        $country_code = geoip_country_code_by_addr($gi, $ipaddr);
        geoip_close($gi);
    } else {
        $country_code = geoip_country_code_by_name($ipaddr);
    }
    if ($country_code == "") {
        if (isDev() && starts_with($ipaddr, '192.168.')) {
            $country_code = 'DE';
        } else {
            $location = get_geo_location_by_ip($ipaddr);
            if ($location && isset($location->country_code)) {
                $country_code = $location->country_code;
            }
        }
    }
    $_SESSION['geoip_countrycode_by_ip_' . $ipaddr] = $country_code . "";
    return $country_code;
}
Example #3
0
/**
 * Prepares an email.
 * 
 * @param string $recipient The mail recipient
 * @param string $subject The subject
 * @param string $message The message (may be HTML formatted)
 * @param string $plainmessage Optional plain message (may differ from $message)
 * @param array $attachments Array of filenames to attach
 * @return PHPMailer A PHPMailer object ready to be sent.
 */
function mail_prepare($recipient, $subject, $message, $plainmessage = "", $attachments = array())
{
    global $CONFIG;
    require_once __DIR__ . "/mail/class.smtp.php";
    require_once __DIR__ . "/mail/class.phpmailer.php";
    if (isDev() && isset($CONFIG['mail']['dev_whitelist'])) {
        $isvalidrecipient = false;
        // on dev server, only domains/recipients in the whitelist are allowed
        foreach ($CONFIG['mail']['dev_whitelist'] as $needle) {
            if (!isset($CONFIG['mail']['dev_recipient'])) {
                $CONFIG['mail']['dev_recipient'] = $needle;
            }
            if (stripos($recipient, $needle) !== false) {
                $isvalidrecipient = true;
                break;
            }
        }
        if (!$isvalidrecipient && isset($CONFIG['mail']['dev_recipient'])) {
            // if not found in whitelist, send to predefined recipient
            $recipient = $CONFIG['mail']['dev_recipient'];
            log_debug("email recipient changed to: " . var_export($recipient, true));
        }
    }
    $mail = new PHPMailer(true);
    $mail->SetLanguage("en", __DIR__ . "/mail/language/");
    $mail->CharSet = "utf-8";
    $mail->IsSMTP();
    $mail->Host = $CONFIG['mail']['smtp_server'];
    if (isset($CONFIG['mail']['smtp_auth']) && $CONFIG['mail']['smtp_auth']) {
        $mail->SMTPAuth = true;
        $mail->Username = $CONFIG['mail']['smtp_user'];
        $mail->Password = $CONFIG['mail']['smtp_pass'];
    }
    if (isset($CONFIG['mail']['smtp_tls']) && $CONFIG['mail']['smtp_tls'] == true) {
        $mail->SMTPSecure = 'tls';
    }
    $mail->From = $CONFIG['mail']['from'];
    $mail->FromName = $CONFIG['mail']['from_name'];
    try {
        if (is_array($recipient)) {
            foreach ($recipient as $r) {
                $mail->AddAddress($r);
            }
        } else {
            $mail->AddAddress($recipient);
        }
    } catch (Exception $ex) {
        WdfException::Log($ex);
        $res = false;
    }
    $mail->AddReplyTo($CONFIG['mail']['from']);
    $mail->WordWrap = 80;
    if (starts_with($subject, "[nomark]")) {
        $subject = trim(str_replace("[nomark]", "", $subject));
    } else {
        $env = getEnvironment();
        if (isDev() && !starts_with($subject, "[{$env}]")) {
            $subject = "[{$env}] {$subject}";
        }
    }
    $mail->Subject = $subject;
    $mail->ContentType = "text/html";
    $message = str_ireplace("<br>", "<br/>", $message);
    $message = str_ireplace("<br >", "<br/>", $message);
    $message = str_ireplace("<br />", "<br/>", $message);
    $message = str_ireplace("{crlf}", "<br/>", $message);
    $message = str_ireplace("\\r", "\r", $message);
    $message = str_ireplace("\\'", "'", $message);
    $message = str_ireplace("\\\"", "\"", $message);
    $message = str_ireplace("\r\n", "<br/>", $message);
    $message = str_ireplace("\n", "<br/>", $message);
    $message = str_ireplace("<br/>", "<br/>\n", $message);
    $mail->Body = $message;
    $mail->AltBody = strip_tags($plainmessage == "" ? $message : str_ireplace("<br/>", "\n", $plainmessage));
    $mail->AltBody = str_ireplace("\n--\n", "\n--\n", $mail->AltBody);
    if (!is_array($attachments)) {
        $attachments = array($attachments);
    }
    foreach ($attachments as $a) {
        if (file_exists($a)) {
            $mail->AddAttachment($a);
        } else {
            log_debug("email attachment not found: {$a}");
        }
    }
    return $mail;
}
Example #4
0
    ?>
	wdf.ready.add(function()
	{
	<?php 
    echo implode(isDev() ? "\n" : "", $docready);
    ?>
	});
<?php 
}
?>
	<?php 
echo $wdf_init;
?>
});
	<?php 
echo implode(isDev() ? "\n" : "", $plaindocready);
?>
</script>
</head>
<body<?php 
echo isset($isrtl) ? "{$isrtl}" : "";
echo isset($bodyClass) ? " class='{$bodyClass}'" : "";
?>
>
<?php 
if ($render_noscript_block) {
    ?>
<noscript>
	<style type="text/css">
		body>*:not(noscript) { display:none !important; }
	</style>
Example #5
0
/**
 * Builds a request.
 * 
 * This is quite basic and used very often. It will return an URL to the given controller.
 * It checks if the routing features are enabled and ensures the the URLs are working!
 * @param mixed $controller The page to be loaded (can be <Renderable> or string)
 * @param string $event The event to be executed
 * @param array|string $data Optional data to be passed
 * @param string $url_root Optional root, will use system-wide detected/set one if not given
 * @return string A complete Request (for use as HREF)
 */
function buildQuery($controller, $event = "", $data = "", $url_root = false)
{
    global $CONFIG;
    if ($controller instanceof Renderable) {
        $controller = $controller->_storage_id;
    }
    if (substr($controller, 0, 4) == "http") {
        return $controller;
    }
    // allow buildQuery('controller/method')
    if (is_string($controller) && $event == "" && $data == "" && !$url_root) {
        if (preg_match('|^([a-z0-9]+)/([a-z0-9]+)$|i', $controller)) {
            list($controller, $event) = explode("/", $controller);
        }
    }
    if ($controller != "") {
        $route = "{$controller}/";
    } else {
        $route = "";
    }
    if ($event != "") {
        $route .= $event;
        if ('#' != substr($event, 0, 1)) {
            $route .= '/';
        }
    }
    /**
     * data can contain a # to jump to named anchors i.e. on redirect
     */
    $hash = false;
    if (is_array($data)) {
        if (isset($data['#'])) {
            $hash = $data['#'];
            unset($data['#']);
        }
        $data = http_build_query($data);
    }
    if (!can_rewrite()) {
        $data = http_build_query(array('wdf_route' => $route)) . ($data ? "&{$data}" : "");
        $route = "";
    }
    if (isDev() && isset($_REQUEST["XDEBUG_PROFILE"])) {
        $data .= ($data ? "&" : "") . "XDEBUG_PROFILE";
    }
    if (!$url_root) {
        $url_root = $CONFIG['system']['url_root'];
    }
    return $url_root . $route . ($data ? "?{$data}" : "") . ($hash ? '#' . $hash : '');
}
Example #6
0
/**
 * Builds a request.
 * 
 * This is quite basic and used very often. It will return an URL to the given controller.
 * It checks if the routing features are enabled and ensures the the URLs are working!
 * @param mixed $controller The page to be loaded (can be <Renderable> or string)
 * @param string $event The event to be executed
 * @param array|string $data Optional data to be passed
 * @param string $url_root Optional root, will use system-wide detected/set one if not given
 * @return string A complete Request (for use as HREF)
 */
function buildQuery($controller, $event = "", $data = "", $url_root = false)
{
    global $CONFIG;
    if ($controller instanceof Renderable) {
        $controller = $controller->_storage_id;
    }
    if (substr($controller, 0, 4) == "http") {
        return $controller;
    }
    if ($controller != "") {
        $route = "{$controller}/";
    } else {
        $route = "";
    }
    if ($event != "") {
        $route .= $event;
        if ('#' != substr($event, 0, 1)) {
            $route .= '/';
        }
    }
    if (is_array($data)) {
        $data = http_build_query($data);
    }
    if (!can_rewrite()) {
        $data = http_build_query(array('wdf_route' => $route)) . ($data ? "&{$data}" : "");
        $route = "";
    }
    if (isDev() && isset($_REQUEST["XDEBUG_PROFILE"])) {
        $data .= ($data ? "&" : "") . "XDEBUG_PROFILE";
    }
    if (!$url_root) {
        $url_root = $CONFIG['system']['url_root'];
    }
    //log_debug($url_root,$route,($data?"?$data":""));
    return $url_root . $route . ($data ? "?{$data}" : "");
}
<?php

$folderString = createFolderString($folderLevel);
if (isDev()) {
    $url = 'http://www.zooqie.com/development/';
} else {
    $url = 'http://www.zooqie.com/';
}
//NOTE: AJAX SEARCH SUGGESTION CURRENTLY DISABLED
echo '
                <div id="fb-root"></div>
                <script>(function(d, s, id) {
                var js, fjs = d.getElementsByTagName(s)[0];
                  if (d.getElementById(id)) return;
                  js = d.createElement(s); js.id = id;
                  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
                  fjs.parentNode.insertBefore(js, fjs);
                }(document, "script", "facebook-jssdk"));</script>

                <div class="header-background">
                    <div class="header-content">
                        <a href="' . $folderString . 'index.php">
                            <img class="header-logo" src="' . $folderString . 'images/zooqie_white.png" onmouseover="this.src=\'' . $folderString . 'images/zooqie_red.png\';" onmouseout="this.src=\'' . $folderString . 'images/zooqie_white.png\';"  alt="Home">
                        </a>

                        <script type="text/javascript">
                            $(function(){
                                $("#searchid DISABLE").keyup(function()
                                {
                                    var searchid = $(this).val();
                                    var dataString = "search="+ searchid;
Example #8
0
/**
 * Resolves an IP address to a country code
 * 
 * @param string $ipaddr IP address to resolve (defaults to <get_ip_address>)
 * @return array Country code or empty string if not found
 */
function get_countrycode_by_ip($ipaddr = false)
{
    if ($ipaddr === false) {
        $ipaddr = $GLOBALS['current_ip_addr'];
    }
    if (isset($_SESSION['geoip_countrycode_by_ip_' . $ipaddr]) && $_SESSION['geoip_countrycode_by_ip_' . $ipaddr] != "") {
        return $_SESSION['geoip_countrycode_by_ip_' . $ipaddr];
    }
    //	// maxmind installed as server module?
    //	if(isset($_SERVER["GEOIP_COUNTRY_CODE"]))
    //		return $_SERVER["GEOIP_COUNTRY_CODE"];
    if (function_exists('geoip_open')) {
        $gi = geoip_open($GLOBALS['CONFIG']['geoip']['city_dat_file'], GEOIP_STANDARD);
        $country_code = geoip_country_code_by_addr($gi, $ipaddr);
        //		log_debug("country: ".$country_code);
        geoip_close($gi);
    } else {
        $country_code = geoip_country_code_by_name($ipaddr);
    }
    if ($country_code == "") {
        if (isDev() && starts_with($ipaddr, '192.168.1.')) {
            $country_code = 'DE';
        } else {
            $location = get_geo_location_by_ip($ipaddr);
            if ($location && isset($location->country_code)) {
                $country_code = $location->country_code;
            }
        }
    }
    $_SESSION['geoip_countrycode_by_ip_' . $ipaddr] = $country_code . "";
    return $country_code;
}