Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/05/2010, 07:42
Avatar de EmaD
EmaD
 
Fecha de Ingreso: marzo-2008
Mensajes: 93
Antigüedad: 16 años, 2 meses
Puntos: 2
Ayuda con if , switch o case

HOla que tal , tengo el siguiente codigo que te da backlinks para colocar los enlaces en la web, el problema es que quiero hacerlo dinamico asi no tengo que agregar todo los codigos todas las paginas. Backlinks por cada pagina te asigna un BLkey unico por pagina , y el resto del codigo es igual , lo que estoy haciendo en este momento y espero encontrarle otra solucion ya que es muy largo el codigo y creo qeu hay mejores soluciones es esto.

Código PHP:
if($_GET['p']=='videos') {
    

// (1 = Yes, 0 = No)
$OpenInNewWindow "1";


$BLKey "HE56-B9JQ-XQ4L";

if(
strlen($_SERVER['SCRIPT_URI'])){
    
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_URI'].((strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}

if(!
strlen($_SERVER['REQUEST_URI'])){
    
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].((strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}

$QueryString  "LinkUrl=".urlencode((($_SERVER['HTTPS']=='on')?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$QueryString .= "&Key=" .urlencode($BLKey);
$QueryString .= "&OpenInNewWindow=" .urlencode($OpenInNewWindow);


if(
intval(get_cfg_var('allow_url_fopen')) && function_exists('readfile')) {
    @
readfile("http://www.backlinks.com/engine.php?".$QueryString); 
}
elseif(
intval(get_cfg_var('allow_url_fopen')) && function_exists('file')) {
    if(
$content = @file("http://www.backlinks.com/engine.php?".$QueryString)) 
        print @
join(''$content);
}
elseif(
function_exists('curl_init')) {
    
$ch curl_init ("http://www.backlinks.com/engine.php?".$QueryString);
    
curl_setopt ($chCURLOPT_HEADER0);
    
curl_exec ($ch);

    if(
curl_error($ch))
        print 
"Error processing request";

    
curl_close ($ch);
}
else {
    print 
"It appears that your web host has disabled all functions for handling remote pages and as a result the BackLinks software will not function on your web page. Please contact your web host for more information.";
}
}                
                
                if(
$_GET['p']=='survey') {
    

// (1 = Yes, 0 = No)
$OpenInNewWindow "1";


$BLKey "1DNH-49UO-I0G2";

if(
strlen($_SERVER['SCRIPT_URI'])){
    
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_URI'].((strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}

if(!
strlen($_SERVER['REQUEST_URI'])){
    
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].((strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}

$QueryString  "LinkUrl=".urlencode((($_SERVER['HTTPS']=='on')?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$QueryString .= "&Key=" .urlencode($BLKey);
$QueryString .= "&OpenInNewWindow=" .urlencode($OpenInNewWindow);


if(
intval(get_cfg_var('allow_url_fopen')) && function_exists('readfile')) {
    @
readfile("http://www.backlinks.com/engine.php?".$QueryString); 
}
elseif(
intval(get_cfg_var('allow_url_fopen')) && function_exists('file')) {
    if(
$content = @file("http://www.backlinks.com/engine.php?".$QueryString)) 
        print @
join(''$content);
}
elseif(
function_exists('curl_init')) {
    
$ch curl_init ("http://www.backlinks.com/engine.php?".$QueryString);
    
curl_setopt ($chCURLOPT_HEADER0);
    
curl_exec ($ch);

    if(
curl_error($ch))
        print 
"Error processing request";

    
curl_close ($ch);
}
else {
    print 
"It appears that your web host has disabled all functions for handling remote pages and as a result the BackLinks software will not function on your web page. Please contact your web host for more information.";
}
}                
                if(
$_GET['p']=='staff') {
    

// (1 = Yes, 0 = No)
$OpenInNewWindow "1";


$BLKey "GK65-V6V2-LJQ9";

if(
strlen($_SERVER['SCRIPT_URI'])){
    
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_URI'].((strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}

if(!
strlen($_SERVER['REQUEST_URI'])){
    
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].((strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}

$QueryString  "LinkUrl=".urlencode((($_SERVER['HTTPS']=='on')?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$QueryString .= "&Key=" .urlencode($BLKey);
$QueryString .= "&OpenInNewWindow=" .urlencode($OpenInNewWindow);


if(
intval(get_cfg_var('allow_url_fopen')) && function_exists('readfile')) {
    @
readfile("http://www.backlinks.com/engine.php?".$QueryString); 
}
elseif(
intval(get_cfg_var('allow_url_fopen')) && function_exists('file')) {
    if(
$content = @file("http://www.backlinks.com/engine.php?".$QueryString)) 
        print @
join(''$content);
}
elseif(
function_exists('curl_init')) {
    
$ch curl_init ("http://www.backlinks.com/engine.php?".$QueryString);
    
curl_setopt ($chCURLOPT_HEADER0);
    
curl_exec ($ch);

    if(
curl_error($ch))
        print 
"Error processing request";

    
curl_close ($ch);
}
else {
    print 
"It appears that your web host has disabled all functions for handling remote pages and as a result the BackLinks software will not function on your web page. Please contact your web host for more information.";
}
}
        
        
        if(
$_GET['p']=='reviews' && 'id'!='0') {
    

// (1 = Yes, 0 = No)
$OpenInNewWindow "1";


$BLKey "TZLJ-59NL-24ID";

if(
strlen($_SERVER['SCRIPT_URI'])){
    
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_URI'].((strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}

if(!
strlen($_SERVER['REQUEST_URI'])){
    
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].((strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}

$QueryString  "LinkUrl=".urlencode((($_SERVER['HTTPS']=='on')?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$QueryString .= "&Key=" .urlencode($BLKey);
$QueryString .= "&OpenInNewWindow=" .urlencode($OpenInNewWindow);


if(
intval(get_cfg_var('allow_url_fopen')) && function_exists('readfile')) {
    @
readfile("http://www.backlinks.com/engine.php?".$QueryString); 
}
elseif(
intval(get_cfg_var('allow_url_fopen')) && function_exists('file')) {
    if(
$content = @file("http://www.backlinks.com/engine.php?".$QueryString)) 
        print @
join(''$content);
}
elseif(
function_exists('curl_init')) {
    
$ch curl_init ("http://www.backlinks.com/engine.php?".$QueryString);
    
curl_setopt ($chCURLOPT_HEADER0);
    
curl_exec ($ch);

    if(
curl_error($ch))
        print 
"Error processing request";

    
curl_close ($ch);
}
else {
    print 
"It appears that your web host has disabled all functions for handling remote pages and as a result the BackLinks software will not function on your web page. Please contact your web host for more information.";
}

Como veran lo que hago es ver que pagina es con

Código PHP:
if($_GET['p']=='videos') { 
Y que muestre el codigo baklink de sa pagina.

El BLkey de la pagina videos es

$BLKey = "HE56-B9JQ-XQ4L";

Y asi tiene cada una de las paginas uno distinto , hay alguna forma de definir cada key para cada pagina y despues agregar un codigo solo de baklinks que tome ese key depediendo de la pagina en que entremos?

Con algun case? switch ? array?

Intete pero mi conocimiento en esos metodos no son muy buenos , espero que me puedan ayudar.

Saludos y buen fi nde semana para todos.
__________________
http://www.RadioMetal.com.ar
Portal/Radio Argentino De Rock & Heavy Metal
Villa Constitucion - Santa Fe - Argentina