$a = article(array('fr'));
$t->is(resolver($a, 'foo')->hasTranslation($a, 'en'), false, '->hasTranslation() checks if record has not given translation');
$t->is(resolver($a, 'foo')->hasTranslation($a, 'fr'), true, '->hasTranslation() checks if record has not given translation');
// ->computeUris()
$t->diag('->computeUris()');
$t->is(resolver(article(array('en')), 'foo?slug=%slug%')->computeUris(), array('foo?slug=en-slug'), '->computeUris() computes i18n cache uri including field value in default language');
$t->is(resolver(article(array('fr')), 'foo?slug=%slug%')->computeUris(), array('foo?slug=fr-slug'), '->computeUris() computes i18n cache uri including field value in another language');
$t->is(resolver(article(array('en')), 'foo?slug=%slug%&author=%Author.name%')->computeUris(), array('foo?slug=en-slug&author=henry'), '->computeUris() computes cache uri including several fields from relations');
$t->is(resolver(article(array('en', 'fr')), 'foo?slug=%slug%')->computeUris(), array('foo?slug=en-slug', 'foo?slug=fr-slug'), '->computeUris() computes i18n cache uris including field value with multiple language');
$t->is(resolver(article(array('en', 'fr')), 'foo?sf_culture=en&slug=%slug%')->computeUris(), array('foo?sf_culture=en&slug=en-slug'), '->computeUris() computes i18n cache uris when sf_culture is set to default language');
$t->is(resolver(article(array('en', 'fr')), 'foo?sf_culture=fr&slug=%slug%')->computeUris(), array('foo?sf_culture=fr&slug=fr-slug'), '->computeUris() computes i18n cache uris when sf_culture is set to another language');
$t->is(resolver(article(array('en', 'fr')), 'foo?sf_culture=*&slug=%slug%')->computeUris(), array(0 => 'foo?sf_culture=*&slug=en-slug', 1 => 'foo?sf_culture=*&slug=fr-slug'), '->computeUris() computes i18n cache uris when sf_culture is set to any language');
$t->is(resolver(article(array('en', 'fr')), 'foo?slug=%slug%&author=%Author.name%')->computeUris(), array(0 => 'foo?slug=en-slug&author=henry', 1 => 'foo?slug=fr-slug&author=henry'), '->computeUris() computes cache uri including several fields from relations');
$t->is(resolver(comment(array('en')), 'foo?slug=%Article.slug%')->computeUris(), array('foo?slug=en-slug'), '->computeUris() computes i18n cache uri with a foreign relation value in default language');
$t->is(resolver(comment(array('fr')), 'foo?slug=%Article.slug%')->computeUris(), array('foo?slug=fr-slug'), '->computeUris() computes i18n cache uri with a foreign relation value in another language');
$t->is(resolver(comment(array('en', 'fr')), 'foo?slug=%Article.slug%')->computeUris(), array('foo?slug=en-slug', 'foo?slug=fr-slug'), '->computeUris() computes i18n cache uri with a foreign relation value in multiple language');
// Test Helpers
function article(array $langs = array())
{
    $article = new Article();
    $article->setAuthor(author('henry'));
    foreach ($langs as $lang) {
        $article->Translation[$lang]->fromArray(array('title' => 'Title in ' . $lang, 'slug' => $lang . '-slug'));
    }
    return $article;
}
function comment(array $articleLangs = array())
{
    $comment = new Comment();
    $comment->setAuthor(author('niko'));
    $comment->content = 'Booh.';
Beispiel #2
0
<?php

/**
 * Legal Stuff
 *
 * @copyright  2015 FFY00 (Filipe Laíns)
 * @license https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
 * @author Filipe Laíns <*****@*****.**>
 */
/**
 * Live Link: https://ffy00.cf/cfresolver/api.php
 */
header("Content-Type: text/plain");
require "resolver.php";
$error = array("success" => false, "error" => "No domain");
if (isset($_REQUEST["d"])) {
    $r = resolver($_REQUEST["d"]);
    $r["success"] = true;
    echo json_encode($r);
} else {
    echo json_encode($error);
}
Beispiel #3
0
 /**
  * @coroutine
  *
  * Uses the global resolver to resolve the IP address of a domain name.
  *
  * @see \Icicle\Dns\Resolver\ResolverInterface::resolve()
  *
  * @param string $domain
  * @param array $options
  *
  * @return \Generator
  *
  * @resolve array Array of IP addresses.
  */
 function resolve(string $domain, array $options = []) : \Generator
 {
     return resolver()->resolve($domain, $options);
 }
                        <a href="#">About</a>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>

    <!-- Page Content -->
    <div class="container">
        <div class="row">
            <div class="col-md-6 col-sm-12">
                <h1>Cuanto falta para el 4</h1>
                <p><?php 
resolver();
?>
</p>
            </div>
        </div>
        <!-- /.row -->
    </div>
    <!-- /.container -->

    <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

</body>
Beispiel #5
0
function pixie()
{
    global $s, $m, $x, $p, $rel_path, $staticpage, $style, $site_url, $page_display_name, $page_type, $page_id, $syle, $clean_urls, $default_page;
    $request = $_SERVER['REQUEST_URI'];
    if ($style) {
        $request = str_replace("?style={$style}", "", $request);
    }
    $site_url_last = $site_url[strlen($site_url) - 1];
    if ($site_url_last != '/') {
        $site_url = $site_url . '/';
    }
    if ($clean_urls == 'yes') {
        // if the request contains a ? then this person is accessing with a dirty URL and is handled accordingly
        if (strpos($request, '?s=') !== FALSE) {
            $rel_path = './';
        } else {
            //this is directory level of your installation. check autofind works!?!?
            $url = explode('/', $request);
            $count = count($url);
            $site_url_x = str_replace('http://', "", $site_url);
            $temp = explode('/', $site_url_x);
            $install = count($temp);
            $dir_level = $install - 2;
            if ($dir_level < 0) {
                $dir_level = 0;
            }
            if (isset($url[$dir_level + 1])) {
                $s = strtolower($url[$dir_level + 1]);
            } else {
                $s = NULL;
            }
            if (isset($url[$dir_level + 2])) {
                $m = strtolower($url[$dir_level + 2]);
            } else {
                $m = NULL;
            }
            if (isset($url[$dir_level + 3])) {
                $x = strtolower($url[$dir_level + 3]);
            } else {
                $x = NULL;
            }
            if (isset($url[$dir_level + 4])) {
                $p = strtolower($url[$dir_level + 4]);
            } else {
                $p = NULL;
            }
            switch ($count) {
                case $dir_level + 3:
                    $rel_path = '../';
                    break;
                case $dir_level + 4:
                    $rel_path = '../../';
                    break;
                case $dir_level + 5:
                    $rel_path = '../../../';
                    break;
                case $dir_level + 6:
                    $rel_path = '../../../../';
                    break;
                default:
                    $rel_path = './';
                    break;
            }
        }
    } else {
        $rel_path = './';
    }
    if (!isset($s) or !$s) {
        $last = $default_page[strlen($default_page) - 1];
        $default = explode('/', $default_page);
        if (isset($default['0'])) {
            $s = sterilise_txt($default['0']);
        } else {
            $s = NULL;
        }
        if (isset($default['1'])) {
            $m = sterilise_txt($default['1']);
        } else {
            $m = NULL;
        }
        if (isset($default['2'])) {
            $x = sterilise_txt($default['2']);
        } else {
            $x = NULL;
        }
        if (isset($default['3'])) {
            $p = sterilise_txt($default['3']);
        } else {
            $p = NULL;
        }
    }
    $s = public_check_404($s);
    if (isset($s) && $s == '404') {
        $m = "";
        $x = "";
        $p = "";
    }
    if ($m == 'rss') {
        if (isset($s)) {
            $rss = public_check_rss($s);
        }
        if (!$rss) {
            $s = '404';
            $m = "";
            $x = "";
            $p = "";
        }
    }
    if (isset($s)) {
        $page_type = check_type($s);
    }
    if ($page_type == 'dynamic') {
        $style = $page_type;
    } else {
        if ($page_type == 'static') {
            $style = $s;
            $m = "";
            $x = "";
            $p = "";
        } else {
            if ($s == '404') {
                $style = '404';
            } else {
                $style = $s;
            }
        }
    }
    function resolver($string)
    {
        $string = str_replace('-', 'BREAK', $string);
        $string = preg_replace('/[^a-zA-Z0-9]/', "", $string);
        $string = str_replace('BREAK', '-', $string);
        return $string;
    }
    $s = resolver($s);
    $m = resolver($m);
    $x = resolver($x);
    $p = resolver($p);
    $page_id = get_page_id($s);
    $page_hits = safe_field('page_views', 'pixie_core', "page_name='{$s}'");
    $page_display_name = safe_field('page_display_name', 'pixie_core', "page_name='{$s}'");
    safe_update('pixie_core', "page_views  = {$page_hits} + 1", "page_name = '{$s}'");
}
Beispiel #6
0
 /**
  * Partial View
  *
  * @param string $path
  * @param array  $data
  * @param bool   $buffer
  * @return string
  */
 function partial($path, $data = [], $buffer = false)
 {
     $view = di('view');
     $path = resolver()->run('view:partial', function ($path) {
         return $path;
     }, [$path]);
     if ($buffer) {
         ob_start();
     }
     $view->partial($path, $data);
     if ($buffer) {
         return ob_get_clean();
     }
 }
Beispiel #7
0
/**
 * Query specific DNS records.
 *
 * @param string $name Unlike resolve(), query() allows for requesting _any_ name (as DNS RFC allows for arbitrary strings)
 * @param int|int[] $type Use constants of Amp\Dns\Record
 * @param array $options @see resolve documentation
 * @return \Amp\Promise
 */
function query($name, $type, array $options = [])
{
    return resolver()->query($name, $type, $options);
}
Beispiel #8
0
<?php

/**
 * Legal Stuff
 *
 * @copyright  2015 FFY00 (Filipe Laíns)
 * @license https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
 * @author Filipe Laíns <*****@*****.**>
 */
/**
 * Live Link: https://ffy00.cf/cfresolver/info.php
 */
echo '<link rel="stylesheet" type="text/css" href="http://ffy00.cf/bs/bootstrap.min.css"/><center>';
echo "<h1><b>Cloudflare Resolver</b></h1>";
if (isset($_GET["d"])) {
    $json = resolver($_GET["d"]);
    if (isset($json["A"])) {
        echo "<h3><b>A</b></h3>";
        foreach ($json["A"] as $d => $ip) {
            if (is_array($ip)) {
                $ip_total = "";
                foreach ($ip as $ip2) {
                    $geo = json_decode(file_get_contents("http://ip-api.com/json/{$ip2}"), true);
                    if (array_search($ip2, $ip) == 0) {
                        $ip_total = $ip2 . " (" . $geo["isp"] . ")";
                    } else {
                        $ip_total .= ", " . $ip2 . " (" . $geo["isp"] . ")";
                    }
                }
                echo "Domain: {$d}<br>IP: {$ip_total}<br><br>";
            } else {