Hello all, I installed linkworth code for my blog <? include('http://blog.eches.net/lw_rads.php?location=3&format=6'); ?> Code (markup): but I got the following error Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/eches/public_html/blog/wp-content/themes/langit/rsidebar.php on line 42 Warning: include(http://blog.eches.net/store/lw_rads.php?location=3&format=6) [function.include]: failed to open stream: no suitable wrapper could be found in /home/eches/public_html/blog/wp-content/themes/langit/rsidebar.php on line 42 Warning: include() [function.include]: Failed opening 'http://blog.eches.net/store/lw_rads.php?location=3&format=6' for inclusion (include_path='.:/usr/local/php52/pear') in /home/eches/public_html/blog/wp-content/themes/langit/rsidebar.php on line 42 I want to know the root cause of the problem. Is it from the code mentioned above or the the codes inside the lw_rads.php and how to fix the problem. lw_rads.php code <? $file_name = "lw_rads.txt"; $location = $_GET['location']; $format = $_GET['format']; $nofollow = $_GET['nofollow']; if($nofollow == 1) { $nofollow_attribute = 'rel=nofollow'; } else { $nofollow_attribute = ''; } $index = 0; $handle = @fopen($file_name, "r"); if($handle) { $contents = @fread($handle, filesize($file_name)); if($contents) { fclose($handle); $arr_lines = explode(chr(10), $contents); for($i=0;$i<count($arr_lines);$i++) { $arr_deal = explode('|', $arr_lines[$i]); if($arr_deal[1] == $location) { if($arr_deal[2] == 1) { $arr_anchors = explode('?,?', $arr_deal[3]); $random_index = rand(0, count($arr_anchors) - 1); $arr_data[$index]['anchor'] = $arr_anchors[$random_index]; $arr_data[$index]['url'] = $arr_deal[4]; $arr_data[$index]['desc'] = $arr_deal[5]; } else { $arr_murl_infos = explode('?,?', $arr_deal[3]); $random_index = rand(0, count($arr_murl_infos) - 1); $str_murl_info = $arr_murl_infos[$random_index]; $arr_murl_info = explode('%,%', $str_murl_info); $arr_data[$index]['anchor'] = $arr_murl_info[0]; $arr_data[$index]['url'] = $arr_murl_info[1]; $arr_data[$index]['desc'] = $arr_murl_info[2]; } $index++; } } if($arr_data) { $display_rads = true; } } } if($display_rads) { $num_rads = count($arr_data); if($format == 1) { echo '<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">' . "\n"; echo ' <tr>' . "\n"; echo ' <td>' . "\n"; for($i=0;$i<$num_rads;$i++) { echo '<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { echo ' - ' . $arr_data[$i]['desc']; } if($i < ($num_rads - 1)) { echo '<br/>' . "\n"; } } echo "\n" . ' </td>'; echo "\n" . ' </tr>' . "\n"; echo '</table>'; } elseif($format == 2) { echo '<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">' . "\n"; echo ' <tr>' . "\n"; echo ' <td>' . "\n"; for($i=0;$i<$num_rads;$i++) { echo '<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { echo ' - ' . $arr_data[$i]['desc']; } if($i < ($num_rads - 1)) { echo ' ||| ' . "\n"; } } echo "\n" . ' </td>'; echo "\n" . ' </tr>' . "\n"; echo '</table>'; } elseif($format == 3) { echo '<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">' . "\n"; for($i=0;$i<$num_rads;$i++) { echo ' <tr>' . "\n"; echo ' <td>' . "\n"; echo '<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { echo ' - ' . $arr_data[$i]['desc']; } echo "\n" . ' </td>'; echo "\n" . ' </tr>' . "\n"; } echo '</table>'; } elseif($format == 4) { for($i=0;$i<$num_rads;$i++) { echo '<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">'; echo ' <tr>' . "\n"; echo ' <td>' . "\n"; echo '<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { echo ' - ' . $arr_data[$i]['desc']; } echo "\n" . ' </td>'; echo "\n" . ' </tr>' . "\n"; echo '</table>'; } } elseif($format == 5) { echo '<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">'; echo ' <tr>' . "\n"; for($i=0;$i<$num_rads;$i++) { echo ' <td>' . "\n"; echo '<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { echo ' - ' . $arr_data[$i]['desc']; } echo "\n" . ' </td>'; } echo "\n" . ' </tr>' . "\n"; echo '</table>'; } elseif($format) { for($i=0;$i<$num_rads;$i++) { echo '<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { echo ' - ' . $arr_data[$i]['desc']; } echo $format . "\n"; } } else { echo '<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">'; for($i=0;$i<$num_rads;$i++) { echo ' <tr>' . "\n"; echo ' <td>' . "\n"; echo '<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { echo ' - ' . $arr_data[$i]['desc']; } echo "\n" . ' </td>'; echo "\n" . ' </tr>' . "\n"; } echo '</table>'; } } ?> Code (markup): Thanks in advance!
Normally the option to include files using a URL is disabled by default - you're essentially hotlinking to that file, with the same sort server resource problems you get when you hotlink to an image. Like ilovelinux said, you'll need to ask the server admin if they would activate this for you. If they don't, you'll have to find some other way to do the include, perhaps altering the code so that after you've included the file you pass the location and format variables to it
I just learnt that new PHP version doesn't allow users to add URL, so I changed to the following but the problem persists <?php include('/home/eches/public_html/blog/lw_rads.php?location=3&format=6'); ?> Code (markup): Any reference I should to take a look to solve the problem?
Hi eches83, first of all, I'm not sure if you could add a query string when using the include function, have you done that before? I ussually use the include function without a query string. If I am not mistaken, the include function requires a path to the file/filename and not a URL, that means adding a query string is impossible. if i am not correct, you should try checking the path, keep in mind that it is relative to the path of the file that uses the include function and not the root directory.. hope this helps..
Hey eches83, AFAIK you can't add query strings to an include like that, as include() was never designed to handle GET and POST data. Why not place the code in the lw_rads.php into a function in that file, then do something like: <?php include('path/to/lw_rads.php'); $lw_rads = lw_rads_function(3, 6, 1); // 3,6,1 being examples for $location, $format, $nofollow echo $lw_rads; ?> PHP: The lw_rads.php file would have the following changes: <?php function lw_rads_function($location_var, $format_var, $nofollow_var) { $file_name = "lw_rads.txt"; $location = $location_var; $format = $format_var; $nofollow = $nofollow_var; [rest of the code in the file stays the same] } // closing bracket for function ?> PHP:
Whoops, my bad, that function probably won't return any data. Let me fix that quick. Ok, fixed. Replace the entire if($display_rads) statement with the following: if($display_rads) { $num_rads = count($arr_data); if($format == 1) { $html .='<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">' . "\n"; $html .=' <tr>' . "\n"; $html .=' <td>' . "\n"; for($i=0;$i<$num_rads;$i++) { $html .='<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { $html .=' - ' . $arr_data[$i]['desc']; } if($i < ($num_rads - 1)) { $html .='<br/>' . "\n"; } } $html .="\n" . ' </td>'; $html .="\n" . ' </tr>' . "\n"; $html .='</table>'; } elseif($format == 2) { $html .='<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">' . "\n"; $html .=' <tr>' . "\n"; $html .=' <td>' . "\n"; for($i=0;$i<$num_rads;$i++) { $html .='<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { $html .=' - ' . $arr_data[$i]['desc']; } if($i < ($num_rads - 1)) { $html .=' ||| ' . "\n"; } } $html .="\n" . ' </td>'; $html .="\n" . ' </tr>' . "\n"; $html .='</table>'; } elseif($format == 3) { $html .='<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">' . "\n"; for($i=0;$i<$num_rads;$i++) { $html .=' <tr>' . "\n"; $html .=' <td>' . "\n"; $html .='<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { $html .=' - ' . $arr_data[$i]['desc']; } $html .="\n" . ' </td>'; $html .="\n" . ' </tr>' . "\n"; } $html .='</table>'; } elseif($format == 4) { for($i=0;$i<$num_rads;$i++) { $html .='<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">'; $html .=' <tr>' . "\n"; $html .=' <td>' . "\n"; $html .='<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { $html .=' - ' . $arr_data[$i]['desc']; } $html .="\n" . ' </td>'; $html .="\n" . ' </tr>' . "\n"; $html .='</table>'; } } elseif($format == 5) { $html .='<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">'; $html .=' <tr>' . "\n"; for($i=0;$i<$num_rads;$i++) { $html .=' <td>' . "\n"; $html .='<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { $html .=' - ' . $arr_data[$i]['desc']; } $html .="\n" . ' </td>'; } $html .="\n" . ' </tr>' . "\n"; $html .='</table>'; } elseif($format) { for($i=0;$i<$num_rads;$i++) { $html .='<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { $html .=' - ' . $arr_data[$i]['desc']; } $html .=$format . "\n"; } } else { $html .='<table cellspacing="0" cellpadding="0" width="95%" border="0" class="lw">'; for($i=0;$i<$num_rads;$i++) { $html .=' <tr>' . "\n"; $html .=' <td>' . "\n"; $html .='<a class="lw" href="http://' . $arr_data[$i]['url'] . '" ' . $nofollow_attribute . ' target="_blank">' . $arr_data[$i]['anchor'] . '</a>'; if($arr_data[$i]['desc']) { $html .=' - ' . $arr_data[$i]['desc']; } $html .="\n" . ' </td>'; $html .="\n" . ' </tr>' . "\n"; } $html .='</table>'; } return $html; }else{ return ''; } PHP: