Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 04:57:25 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155555 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Code section problem  (Read 444 times)
lexscripta

Offline Offline

Posts: 62


« on: February 17, 2008, 02:36:12 PM »

Hi WB gurus!

I am having a little problem with getting the code snippet below to work. I am using a "CODE" section. (WB 2.6.7).  Its function is to grab info from another server and display it on a WB page. Can anyone tell me if the code is correct - I mean are there any glaring problems, as I cannot get it to do its bizness... (the url - xyberlinks.net  - is not the actual url, for privacy issues, however everything else is exactly the same)


Code:
if(!isset($_GET["article"])){
  $_GET["article"] = "";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate");
curl_setopt($ch, CURLOPT_URL, "http://xyberlinks.net/links.php?id=13424&incode=1&article=$_GET[article]&g=" . urlencode(serialize($_GET)));
$html = curl_exec($ch);
curl_close($ch);

echo $html;


Any help is greatly appreciated..

LexScripta
« Last Edit: February 17, 2008, 02:42:15 PM by lexscripta » Logged
thorn

Offline Offline

Posts: 980


WWW
« Reply #1 on: February 17, 2008, 03:03:38 PM »

Hello,

just two comments:
1. http://en.wikipedia.org/wiki/Cross-site_scripting - ok, you know that, i bet
2. inside double-quotes use {$_GET['article']} instead of $_GET['article']

thorn.
Logged

lexscripta

Offline Offline

Posts: 62


« Reply #2 on: February 17, 2008, 03:55:00 PM »

WB didn't like your suggestion. It changed it to:

if(!isset()){
  $_GET["article"] = "";
}

Seems the {} aren't appreciated within the standard braces ()

LexScripta
« Last Edit: February 17, 2008, 03:56:32 PM by lexscripta » Logged
thorn

Offline Offline

Posts: 980


WWW
« Reply #3 on: February 17, 2008, 04:06:11 PM »

WB didn't like your suggestion. It changed it to:
if(!isset()){
  $_GET["article"] = "";
}
No,no. Inside doublequotes " you have to use {$x['i']} instead of $x['i'].

But see http://projects.websitebaker.org/websitebaker2/ticket/553
So, inside code-section, you have to use {$x['i'] }

Code:
curl_setopt($ch, CURLOPT_URL, "http://xyberlinks.net/links.php?id=13424&incode=1&article={$_GET['article'] }&g=" . urlencode(serialize($_GET)));
should do the trick - supposed your PHP has curl-support compiled in.

Edit: or use
Code:
curl_setopt($ch, CURLOPT_URL, "http://xyberlinks.net/links.php?id=13424&incode=1&article=".$_GET['article']."&g=" . urlencode(serialize($_GET)));

thorn.
Logged

Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!