Exemple #1
0
/**
 * Go through all routes and look for next step
 * @param $routes
 * @return array
 */
function routing($routes){
        //Current URI
        $url = $_SERVER['REQUEST_URI'];
        
        //Prevent problems
        $url = str_replace(APP_ROOT, '', $url);
        $url = substr_replace($url,'', 0, 1);
        $params = parseParams();
        
        //Remove ?elements
        $url = str_replace('?'.$_SERVER['QUERY_STRING'], '', $url);
        $foundRoute = false;
        
        foreach($routes as $urls => $route){
                if(preg_match($route['url'], $url, $matches)){
                        $params = array_merge($params, $matches);
                        $foundRoute = true;
                        break;  
                }
        }
        
        //If there is no route founded
        if(!$foundRoute){
                //This should be reported!!!
                header("Location: ".BASE_PATH);
                exit;
        }
        
        return array('route' => $route, 'params' => $params);
}
Exemple #2
0
function main($params)
{
    $params = parseParams($argv);
    $html = doCDnetworksApiCall($params);
    print "response from CDN:\n";
    print $html . "\n";
}
 function parseDescNew($description)
 {
     $regex = '#\\[desc ([^\\]]*)\\]([^\\[]*)\\[/desc\\]#m';
     preg_match_all($regex, $description, $matches, PREG_SET_ORDER);
     $descriptionArray = array();
     foreach ($matches as $match) {
         $params = parseParams($match[1]);
         if (is_array($params)) {
             $img = isset($params['img']) ? trim($params['img']) : '';
             if (!$img) {
                 continue;
             }
             $url = isset($params['url']) ? trim($params['url']) : '';
             $descriptionArray[$img] = array('url' => $url, 'caption' => str_replace("\n", "<br />", trim($match[2])));
         }
     }
     return $descriptionArray;
 }
function myDeserialize($object)
{
    global $session;
    $class = $object["c"];
    $action = $object["a"];
    $cname = $class["name"];
    $cparams = array();
    if (isset($class["params"])) {
        $cparams = $class["params"];
    }
    $my_obj = new $cname($cparams);
    $aname = $action["name"];
    $aparams = array();
    if (isset($action["params"])) {
        $aparams = parseParams($action["params"]);
    }
    call_user_func_array(array($my_obj, $aname), $aparams);
}
Exemple #5
0
function main($params)
{
    $params = parseParams($argv);
    if ($params['file']) {
        $locations = file($params['file']);
        # Per chris.chih from CDNetworks <*****@*****.**>
        # in March, 2014 email to Reuben, we can do 60 cache clear requests
        # with up to 1,000 urls per request
        $MAX_URLS = 1000;
        if (!is_array($locations) || count($locations) > $MAX_URLS) {
            print "error: specified file '{$params['file']}' must contain a list of urls, one per line, at most {$MAX_URLS}\n";
            exit;
        }
        $locations = array_map(parseLocation, $locations);
    } else {
        $locations = array(parseLocation($params['url']));
    }
    $html = CDNetworksSupport::doCDnetworksApiCall($params, $locations);
    print "response from CDNetworks:\n";
    print $html . "\n";
}
Exemple #6
0
/**
 * Go through all routes and look for next step
 * @param $routes
 * @return array
 */
function routing($routes){
        //Current URI
        $url = $_SERVER['REQUEST_URI'];
        
        //Prevent problems
        $url = str_replace(ROOT, '', $url);
        $url = substr_replace($url,'', 0, 1);
        $params = parseParams();
        
        //Remove ?elements
        $url = str_replace('?'.$_SERVER['QUERY_STRING'], '', $url);
        $foundRoute = false;
        
        //Check if it has langage
        if(!preg_match('/^[(?P<lang>('.LANG.'))|404|cms][a-zA-Z0-9\/#&@\-+_]*\/?$/', $url)){
            header("Location: ".BASE_PATH.DEFAULT_LANG);
            exit;
        }
        
        //Check routing
        foreach($routes as $urls => $route){
                if(preg_match($route['url'], $url, $matches)){
                        $params = array_merge($params, $matches);
                        $foundRoute = true;
                        break;  
                }
        }
        
        //If there is no route founded
        if(!$foundRoute){
                //This should be reported!!!
                header("Location: ".BASE_PATH.'404');
                exit;
        }
        
        return array('route' => $route, 'params' => $params);
}
Exemple #7
0
function parseRequest($request)
{
    /* Reads the request (as no framework being in use) */
    $result[0] = $request["REQUEST_METHOD"];
    $result[1] = parseParams($request["REQUEST_URI"]);
    return $result;
}
Exemple #8
0
#!/usr/bin/php
<?php 
/**
 * build script for last.mu
 */
if (strtolower(php_sapi_name()) != 'cli') {
    die("The build script has to be invoked from cli.\n");
}
echo "Welcome to build script for last.mu\n";
$options = parseParams($argv);
if ($options['version'] === '') {
    if (file_exists('builds/.lastversion')) {
        $options['version'] = file_get_contents('builds/.lastversion');
    } else {
        $options['version'] = 'Unknown';
    }
}
if ($argc === 1) {
    echo "Which version do you want to build (Last was " . $options['version'] . ")?\n";
    echo "Version number strings should follow the 'PHP-standarized' version \nnumber string guidline.\n";
    echo "Enter version string and press enter:\n";
    echo "> ";
    $options['version'] = trim(fread(STDIN, 1024));
    echo "I will use " . $options['version'] . " as version number\n";
    do {
        echo "Do you want to include all available modules? (Y/N)\n";
        echo "> ";
        $input = strtoupper(trim(fread(STDIN, 1024)));
        if ($input === 'Y') {
            $options['modules']['AddOn'] = array_map(function ($item) {
                return basename($item, '.js');
Exemple #9
0
<?php

include_once dirname(__FILE__) . '/tools.php';
if (is_null($params = parseParams($argc, $argv))) {
    usage(basename(__FILE__));
}
if ($params['help']) {
    help();
    exit;
}
$config = isset($params['c']) ? $params['c'] : 'test.xml';
include_once dirname(__FILE__) . '/../setup.php';
if (isset($params['t'])) {
    switch ($params['t']) {
        case 'period':
            $qty = count(periods());
            break;
        case 'report':
            $qty = count(groups());
            break;
        case 'basis':
            $qty = count(basis());
            break;
        default:
            usage(basename(__FILE__));
    }
    print $qty;
    exit;
}
if (!isset($params['f'])) {
    print "No input file given\n";
Exemple #10
0
         if ($action == "updatestudent") {
             $ps = parseParams($params);
             $documento = $ps["documento"];
             if ($results = mysqlCmd("select * from Estudiantes where documento='{$documento}'")) {
                 $nombre = $results["nombre"];
                 $email = $results["email"];
                 $html .= "{\"nombre\":\"{$nombre}\",\"email\":\"{$email}\"}";
             } else {
                 $html .= "0";
             }
         } else {
             //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
             //FILL PROFESOR
             //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
             if ($action == "fillProfesor") {
                 $ps = parseParams($params);
                 $documento = $ps["documento"];
                 $db = mysqli_connect("localhost", "comisiones", "123", "Comisiones");
                 if ($results = mysqlCmdDB($db, "select * from Profesores where cedula='{$documento}'")) {
                     $nombre = $results["nombre"];
                     $email = $results["email"];
                     $html .= "{\"nombre\":\"{$nombre}\",\"email\":\"{$email}\"}";
                 } else {
                     $html .= "0";
                 }
             } else {
                 $html .= "Option not recognized";
             }
         }
     }
 }
require_once "../status.inc";
require_once "batch_lib.inc";
require_once "bootstrap.inc";
////////////////////////////////////////////////////////////////////////////////
//
// Start a new run
//
////////////////////////////////////////////////////////////////////////////////
$gNumUrls = 0;
$gUrlsFile = null;
$gbUrlsFileSpecified = 0;
$gSublabel = "";
$gbImportUrls = $gbDev ? 1 : 0;
$gLocation = "";
$startedDateTime = time();
parseParams();
// do NOT start a new crawl if the current crawl is still running.
$latestCrawl = latestCrawl(null, null, false);
if ($latestCrawl && !$latestCrawl['finishedDateTime']) {
    lprint("Can not start a new crawl because the latest crawl (\"{$latestCrawl['label']}\") has not finished.");
    cprint("Can not start a new crawl because the latest crawl (\"{$latestCrawl['label']}\") has not finished.");
    exit;
}
createTables();
// Create all the tables if they are not there.
// Update the list of URLs from Alexa:
if ($gbImportUrls) {
    // TODO - Should we do this for $gbMobile too?????
    require_once "importurls.php";
    if (!$gbMobile && $gPagesTableDesktop != $gPagesTableDev) {
        lprint("Copy 'urls' rows to production");
Exemple #12
0
        $uri = 'http://' . $uri;
    }
    $results = MiCrawler::crawl($uri, $params);
    if ($results && $processorFile && is_file(dirname(__FILE__) . '/' . $processorFile)) {
        require_once dirname(__FILE__) . '/' . $processorFile;
        $processor = ucwords($processor) . 'Processor';
        $results = call_user_func_array(array($processor, 'process'), array($results, $uri));
        echo "\n";
        foreach ((array) $results as $key => $values) {
            echo $key . ' ' . count($values) . " found\n";
        }
        return;
    }
    echo count($results) . " found\n";
}
list($function, $params) = parseParams($argv);
if ($function === 'crawl.php') {
    if (empty($params[0]) && empty($params['uri'])) {
        return crawlHelp();
    }
    $processor = $processorFile = null;
    $uri = $params[0];
    if (!strpos($uri, '://')) {
        $uri = 'http://' . $uri;
    }
    extract($params);
    if (!$processor) {
        $parts = parse_url($uri);
        $processor = strtolower(str_replace(array('www.', '.com'), '', $parts['host']));
        $processorFile = $processor . '_processor.php';
        if (!file_exists(dirname(__FILE__) . '/' . $processor . '_processor.php')) {
 require_once JPATH_SITE . DS . 'modules' . DS . 'mod_universal_ajaxlivesearch' . DS . 'params/library/parameter.php';
 if (isset($_GET['savesuggest']) && $_GET['savesuggest'] != '') {
     SearchHelper::logSearch($_GET['search_exp']);
     exit;
 }
 $areas = "";
 $db = JFactory::getDBO();
 $pluginlist = array();
 $searchresult = array();
 settype($_GET['module_id'], 'integer');
 $q = sprintf("SELECT params, id FROM #__modules WHERE id = %d ", $_GET['module_id']);
 $showPrice = "";
 $db->setQuery($q);
 $res = $db->loadResult();
 $params = new SearchOfflajnJParameter("");
 parseParams($params, $res);
 $params->def('theme', 'elegant');
 $theme = $params->get('theme', 'elegant');
 if (is_object($theme)) {
     //For 1.6, 1.7, 2.5
     $params->merge(new JRegistry($params->get('theme')));
     $params->set('theme', $theme->theme);
     $theme = $params->get('theme');
     $showPrice = $params->get('showprice', '1');
 }
 $plugins = (array) $params->get('plugins', '');
 $imageresizemode = true;
 switch ($params->get('theme')) {
     case "minimal":
         $imageresizemode = false;
         break;
Exemple #14
0
        parse_str(file_get_contents('php://input'), $params);
        $GLOBALS["_{$method}"] = $params;
        // Add these request vars into _REQUEST, mimicing default behavior, PUT/DELETE will override existing COOKIE/GET vars
        $_REQUEST = $params + $_REQUEST;
    } else {
        if ($method == "GET") {
            $params = $_GET;
        } else {
            if ($method == "POST") {
                $params = $_POST;
            }
        }
    }
    return $params;
}
$params = parseParams();
if ($method == 'PUT') {
    // Si el usuario no existe lo creamos
    $sql = mysql_query("SELECT * FROM nasa_usuarios WHERE nusu_phoneid='" . $params["id"] . "' AND nusu_id > 0");
    if (mysql_num_rows($sql) == 0) {
        if (!empty($params["location"])) {
            $sql = mysql_query("INSERT INTO nasa_usuarios (nusu_phoneid) values ('" . $params["id"] . "')");
        } else {
            $result[] = array("status" => "KO", "error" => array("code" => "0004", "text" => "Identificador de usuario no valido"));
            echo json_encode($result[0]);
            return;
        }
    }
    $sql = mysql_query("UPDATE nasa_usuarios SET nusu_location=" . $params["location"] . " WHERE nusu_phoneid='" . $params["id"] . "' ");
    if ($sql) {
        $result[] = array("status" => "OK");