WordPress

Witaj Gościu ( Zaloguj | Rejestruj )

Każdy temat założony w ewidentnie złym dziale będzie usuwany! Proszę czytać opisy działów i regulamin!

 
Reply to this topicStart new topic
> Zmienne w WordPress
itproject1
post 09.9.2007 - 22:02
Post #1


aktywność:
*

Grupa: Bloger
Postów: 5

Nr: 1 596



Witajcie.

Mam taki problem, chciałbym dokleić kawałek kodu php w plikach typu: header, footer, sidebar.

Wklejając kod otrzymuję coś takiego:

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /wp-content/themes/default/sidebar.php on line 78

Moja linia 78 wygląda następująco:

<form METHOD="get" METHOD="get" ACTION="http://thirdnipple.co.uk/wp-admin/'%20.%20$_SERVER['PHP_SELF']%20.%20'" METHOD="get" METHOD="get">

Domyślam się że chodzi tu o kawałek kody $_SERVER.

Co mam zrobić aby wordpress akceptował mój kod, spotkaliście się z czymś takim ?, będę wdzięczny za pomoc.

Z pozdrowieniami, Tomek.
Go to the top of the page
 
+Quote Post
west28
post 09.9.2007 - 22:38
Post #2


aktywność:
*******

Grupa: Redakcja
Postów: 902

Nr: 309



W wp można wstawiać kod php bez ograniczeń w zasadzie oprócz postów - potrzebna jest wtedy wtyczka. A tak z tego co widzę to masz błąd w składni lub odwołujesz się do niezdefiniowanej zmiennej lub też rozbijasz pętlę. Podaj jakiś przykład obejrzymy smile.gif


--------------------
Go to the top of the page
 
+Quote Post
b4it
post 10.9.2007 - 12:45
Post #3


aktywność:
*****

Grupa: Redakcja
Postów: 335

Nr: 60



Domyślam się, że kawałek co podałeś to zwykły XHTML więc by wstawić PHP musisz rozpocząć od <?php i zakończyć na ?>. Tak więc:
KOD
<form METHOD="get" METHOD="get" ACTION="http://thirdnipple.co.uk/wp-admin/'%20.%20<?php $_SERVER['PHP_SELF']; ?>%20.%20'" METHOD="get" METHOD="get">


--------------------
b4it's log | iPhone Blog

4Avatars v0.2
Nie jestem darmowym, prywatnym pomocnikiem!
Go to the top of the page
 
+Quote Post
itproject1
post 11.9.2007 - 07:15
Post #4


aktywność:
*

Grupa: Bloger
Postów: 5

Nr: 1 596



Witajcie ponownie dzięki za posty, mój kod od początku do końca wygląda tak:


CODE

<?php


if($_GET['youtube']) {


$download = youtube_t($_GET['youtube']);

header("Location: $download");

} else {



echo '

<form METHOD="get" METHOD="get" ACTION="http://thirdnipple.co.uk/wp-admin/'%20.%20$_SERVER['PHP_SELF']%20.%20'" > // TU WYWALA BłąD

Youtube address:

<input NAME="youtube" TYPE="text" /> eg. <em>http://youtube.com/watch?v=O_6wBubwXBM</em>

<input VALUE="Grab and Download!" TYPE="submit" /> ';

}// Functions

// YouTube_T, this will grab the page (with g_page) and find the matches in the result

function youtube_t ($url) {

$page = g_page($url);

if ($page === false)

{

die("Youtube down?");

}

preg_match('/watch_fullscreen\?video_id=(.*?)&l=(.*?)+&t=(.*?)&/', $page, $match);

$match1 = "http://www.youtube.com/get_video?video_id=";

if(!$match[1]){

die("Error no matches - wrong youtube page?");

}

$match1 .= $match[1];

$match1 .= "&t=";

$match1 .= $match[3];

return $match1;

}// G_Page, this grabs the page for YouTube_T

function g_page ($url)

{

$curl = curl_init($url);

curl_setopt($curl, CURLOPT_HEADER, false);

curl_setopt($curl, CURLOPT_VERBOSE, false);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);


$output = curl_exec($curl);

// check for errors

if (curl_errno($curl))

{

trigger_error('CURL error: "' . curl_error($curl) . '"', E_USER_WARNING);

$output = false;

}

curl_close($curl);

return $output;

}

?>


Walczę z tym już drugi dzień i nic.

Z góry dzięki za pomoc, pozdrawiam.
Powód edycji: Dodanie codebox
Go to the top of the page
 
+Quote Post
b4it
post 11.9.2007 - 12:49
Post #5


aktywność:
*****

Grupa: Redakcja
Postów: 335

Nr: 60



Sprawdź to:
CODE
<?php
if($_GET['youtube']) {
$download = youtube_t($_GET['youtube']);
header("Location: $download");
} else {
echo '<form METHOD="get" METHOD="get" ACTION="http://thirdnipple.co.uk/wp-admin/' . $_SERVER['PHP_SELF'] . '">';
echo 'Youtube address:<br />';
echo '<input NAME="youtube" TYPE="text" /> eg. <em>http://youtube.com/watch?v=O_6wBubwXBM</em><br />';
echo '<input VALUE="Grab and Download!" TYPE="submit" />';
echo '</form>';
} // Functions
// YouTube_T, this will grab the page (with g_page) and find the matches in the result

function youtube_t ($url) {
$page = g_page($url);
if ($page === false) {
die("Youtube down?");
}
preg_match('/watch_fullscreen\?video_id=(.*?)&l=(.*?)+&t=(.*?)&/', $page, $match);
$match1 = "http://www.youtube.com/get_video?video_id=";
if (!$match[1]) {
die("Error no matches - wrong youtube page?");
}
$match1 .= $match[1];
$match1 .= "&t=";
$match1 .= $match[3];

return $match1;
}// G_Page, this grabs the page for YouTube_T

function g_page ($url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_VERBOSE, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($curl);
// check for errors
if (curl_errno($curl)) {
trigger_error('CURL error: "' . curl_error($curl) . '"', E_USER_WARNING);
$output = false;
}
curl_close($curl);

return $output;
}
?>


--------------------
b4it's log | iPhone Blog

4Avatars v0.2
Nie jestem darmowym, prywatnym pomocnikiem!
Go to the top of the page
 
+Quote Post
itproject1
post 15.9.2007 - 13:42
Post #6


aktywność:
*

Grupa: Bloger
Postów: 5

Nr: 1 596



Dziękuję, jest lepiej ale tym razem po uruchmieniu kodu za pomocą buttona dostaję coś takiego:


Warning: Cannot modify header information - headers already sent by (output started at /wp-content/themes/default/header.php:2) in /wp-content/themes/default/sidebar.php on line 89

Zresztą zobaczcie sami,

Jest stronka http://www.motiv.net.pl - i tam jest po prwej umieszczone okienko do pbierania filmików z youtube


Po wklejniu jakiegoś adresu z YouTube oraz wciśnieciu garb and download - dosteję nadminiony błąd.

Chodzi o zmienną $download.

Czy potrzebna mi jakaś wtyczka ??

funkcja ob_start(); nie pomaga

Może to jakaś przypadłość wordpressa ?

Będę wdzięczny za posty i szukam gdzieś na forum tematu w którym mógłbym pomóc.

PS - Bardzo FAJNA GALERIA pod WP to nextgenGalerry do pobrania tutaj:

http://wordpress.org/extend/plugins/nextgen-gallery/

Gdyby ktoś miał z nią problem proszę pisać - rozgryzłem ją już.

Pozdrawiam, Tomek.
Go to the top of the page
 
+Quote Post
b4it
post 15.9.2007 - 14:32
Post #7


aktywność:
*****

Grupa: Redakcja
Postów: 335

Nr: 60



Jakiś beznadziejny albo, że wklejony kod znalazłeś. dry.gif
Jedynym wyjściem jest zmiana kodu na taki:
CODE
<?php
echo '<form METHOD="get" METHOD="get" ACTION="http://thirdnipple.co.uk/wp-admin/' . $_SERVER['PHP_SELF'] . '">';
echo 'Youtube address:<br />';
echo '<input NAME="youtube" TYPE="text" /> eg. <em>http://youtube.com/watch?v=O_6wBubwXBM</em><br />';
echo '<input VALUE="Grab and Download!" TYPE="submit" />';
echo '</form>';
// YouTube_T, this will grab the page (with g_page) and find the matches in the result

function youtube_t ($url) {
$page = g_page($url);
if ($page === false) {
die("Youtube down?");
}
preg_match('/watch_fullscreen\?video_id=(.*?)&l=(.*?)+&t=(.*?)&/', $page, $match);
$match1 = "http://www.youtube.com/get_video?video_id=";
if (!$match[1]) {
die("Error no matches - wrong youtube page?");
}
$match1 .= $match[1];
$match1 .= "&t=";
$match1 .= $match[3];

return $match1;
}// G_Page, this grabs the page for YouTube_T

function g_page ($url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_VERBOSE, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($curl);
// check for errors
if (curl_errno($curl)) {
trigger_error('CURL error: "' . curl_error($curl) . '"', E_USER_WARNING);
$output = false;
}
curl_close($curl);

return $output;
}
?>


--------------------
b4it's log | iPhone Blog

4Avatars v0.2
Nie jestem darmowym, prywatnym pomocnikiem!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



Wersja Lo-Fi Aktualny czas: 7 01 09 - 23:01
WebFan | Forum Komputerowe | Spotkania blogerów