Esempio n. 1
0
function json_encode_cn($arr)
{
    return urldecode(json_encode(urlencode_array($arr)));
}
Esempio n. 2
0
/** 
 * Función para pasar por url un array
 */
function urlencode_array($var, $varName, $separator = '&')
{
    $toImplode = array();
    foreach ($var as $key => $value) {
        if (is_array($value)) {
            $toImplode[] = urlencode_array($value, "{$varName}[{$key}]", $separator);
        } else {
            $toImplode[] = "{$varName}[{$key}]=" . urlencode($value);
        }
    }
    return implode($separator, $toImplode);
}
Esempio n. 3
0
 public function openid()
 {
     $openid = new LightOpenID($_SERVER['SERVER_NAME']);
     if (!$openid->mode) {
         if (isset($_POST['google'])) {
             $openid->identity = 'https://www.google.com/accounts/o8/id';
             $openid->required = array('namePerson/friendly', 'contact/email');
             $openid->optional = array('namePerson', 'birthDate', 'person/gender', 'contact/postalCode/home', 'contact/country/home', 'pref/language', 'pref/timezone');
             header('Location: ' . $openid->authUrl());
         }
     } else {
         if ($openid->mode === 'cancel') {
             echo 'User has canceled authentication!';
         } else {
             if ($openid->validate()) {
                 $data = $openid->getAttributes();
                 /* check for first login, if no record exists create one and force user to input remaining data. 
                  * If a login does exist create the session and redirect the user to their dashboard. */
                 $identity = $this->model->check_openid($openid->identity);
                 if (!$identity) {
                     redirect('auth/register/' . urlencode_array($data) . '&identity=' . urlencode($openid->identity));
                 } else {
                     if (!$this->model->login_user($identity['identity'])) {
                         die("could not login user");
                     } else {
                         redirect('dashboard');
                     }
                 }
             } else {
                 echo "Login with '{$openid->identity}' failed";
             }
         }
     }
 }
/**/
/**
* Testing get_billing_methods 
*****************************/
open_div('Testing get_billing_methods', 'billing_methods');
$billing_methods = $r->get_billing_methods();
print_pre($billing_methods);
close_div();
/**/
/**
* Testing get_orders 
********************/
open_div('Testing get_orders', 'list_nodes');
$filters = array('include_inactive' => 'N');
//
$orders = $r->get_orders(urlencode_array($filters));
print_pre($orders);
close_div();
/**/
/**
* Testing find_order 
********************/
open_div('Testing find_order', 'find_node');
$vps = $r->find_order('example.com', false);
print_pre($vps);
close_div();
/**/
/**
* Testing vps->get_info 
***********************/
open_div('Testing vps->get_info', 'node_info');
function AMP_url_build_query($attr = array())
{
    if (empty($attr)) {
        return array();
    }
    $complete = array();
    foreach ($attr as $key => $value) {
        if (is_array($value)) {
            $complete[$key] = urlencode_array($value, $key);
            continue;
        } elseif (strip_tags($value) != $value) {
            continue;
        }
        $complete[$key] = AMP_url_print($value, $key);
    }
    return $complete;
}
Esempio n. 6
0
 function navegador($datos, $offset, $numrows, $cfilas, $maxpag)
 {
     $id = $this->id;
     //****************************************** CARGA DEL NAVERGADOR *********************************************************************
     // variables del get que no se van a volver a pasar
     $ex_pasaget = array("offset" . $id, "borrar", "publicar", "despublicar");
     if ($datos) {
         foreach ($datos as $param => $valor) {
             if (!in_array($param, $ex_pasaget)) {
                 // AGREGADO
                 if (!is_array($valor)) {
                     $valor = urlencode($valor);
                     $auxarr_nav[] = "{$param}=" . $valor;
                 } else {
                     $auxarr_nav[] = urlencode_array($valor, $param);
                 }
             }
         }
     }
     if (count($auxarr_nav) > 0) {
         $pasa_get = "&" . join("&", $auxarr_nav);
     } else {
         $pasa_get = "";
     }
     //---Calculos de paguinado---
     $paginaactual = $offset / $cfilas + 1;
     $intermaxpag = intval(($paginaactual - 1) / $maxpag);
     $pages = intval($numrows / $cfilas);
     if ($numrows % $cfilas) {
         $pages++;
     }
     $total_pages = $pages;
     //total de paginas
     //Logica de maximo de paginas en el navegador
     if ($pages > $intermaxpag * $maxpag) {
         //si el numero total de pagias es mayor a el numero de inervalos por el maximo de paginas a                 // mostrar..
         if ($pages > $intermaxpag * $maxpag + $maxpag) {
             //lo mismo que el anterior pero este sirbe para el ultimo intervlo.
             $pages = $intermaxpag * $maxpag + $maxpag;
             //modifica el valor de las paginas a mostrar segun el limite de paginas
         }
         $init = $intermaxpag * $maxpag + 1;
         //modifica el valor de donde va a empesar a mostrar los paginas
     }
     $str_nav = "<div class=\"paginado\">";
     // pfagalde: Para que en el caso de que la consulta traiga mas resultados
     //			pero solo querramos mostrar una pagina
     if ($total_pages > 1 && $maxpag > 1) {
         //link anterior
         if ($offset > 0 && $offset <= $numrows) {
             // previene que no aparezca el link de pagina anterior
             $prevoffset = $offset - $cfilas;
             $str_nav = $str_nav . "<a  class=\"prevnext\" href=\"{$PHP_SELF}?offset{$id}=0{$pasa_get}\">« Primera</a> &nbsp; \n";
             if ($intermaxpag >= 1) {
                 $str_nav = $str_nav . "<a  class=\"prevnext\" href=\"{$PHP_SELF}?offset{$id}=" . ($maxpag * $cfilas * $intermaxpag - $maxpag * $cfilas) . "{$pasa_get}\"><img src='" . $this->path_image . "boton_retro.gif' alt='Retroceder {$maxpag} p&aacute;ginas' style='border:0px; text-align:center;'></a> &nbsp;\n";
             }
             $str_nav = $str_nav . "<a class=\"prevnext\" href=\"{$PHP_SELF}?offset{$id}={$prevoffset}{$pasa_get}\">« Anterior</a> &nbsp; \n";
         }
         //arma del navegador
         for ($i = $init; $i <= $pages; $i++) {
             if ($offset / $cfilas + 1 == $i) {
             }
             $newoffset = $cfilas * ($i - 1);
             $str_nav = $str_nav . "<a class='paginado' href=\"{$PHP_SELF}?offset{$id}={$newoffset}{$pasa_get}\">" . ($offset / $cfilas + 1 == $i ? "<strong class='actual'>{$i}</strong>" : "{$i}") . "</a> &nbsp; \n";
         }
         // link siguiente
         if (!($offset / $cfilas == $pages)) {
             //para que la ultima pagina no tenga siguiente
             $newoffset = $offset + $cfilas;
             if ($numrows - $offset > $cfilas && $offset < $numrows) {
                 $str_nav = $str_nav . "<a class=\"prevnext\" href=\"{$PHP_SELF}?offset{$id}={$newoffset}{$pasa_get}\">Siguiente »</a> &nbsp;\n";
                 if (($intermaxpag + 1) * $maxpag * $cfilas == $pages * $cfilas && $total_pages != $pages) {
                     $str_nav = $str_nav . "<a class=\"prevnext\" href=\"{$PHP_SELF}?offset{$id}=" . ($intermaxpag + 1) * $maxpag * $cfilas . "{$pasa_get}\"><img src='" . $this->path_image . "boton_avance.gif' alt='Adelantar {$maxpag} P&aacute;ginas' style='border:0px; text-align:center;'></a> &nbsp;\n";
                 }
                 $str_nav = $str_nav . "<a class=\"prevnext \" href=\"{$PHP_SELF}?offset{$id}=" . ($total_pages * $cfilas - $cfilas) . "{$pasa_get}\">Ultima »</a>\n";
             }
         }
         $str_nav = $str_nav . "</div>";
         return $str_nav;
     }
 }
 /**
  * Gets a list of orders belonging to the user. The list can be filtered
  * @param string|array filters
  * 	 dc-location: dclondon; dcdallas; dcbrisbane
  *   sever-type: VPS; PHYSICAL
  * 	 include_inactive: Y | N
  * @return array empty array if nothing found or array of RimuHostingNode objects
  */
 public function get_orders($filters = '')
 {
     if (is_array($filters)) {
         $filters = urlencode_array($filters);
     }
     $url = $this->_base_url . '/r/orders;' . $filters;
     $orders = array();
     $response = $this->run_query($url);
     $this->response = $response->get_orders_response;
     if ($response->get_orders_response->response_type == 'OK') {
         foreach ($response->get_orders_response->about_orders as $order) {
             $orders[$order->order_oid] = new RimuHostingNode($this, $order, $order->domain_name);
         }
     }
     return $orders;
 }