Advertisement

05.12.2008 at 12:42AM PDT, ID: 23393860
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.7

include APPROOT doesn't work in xampp

Asked by jimgordon in PHP Scripting Language, Apache Web Server

Tags:

Hi,
I have a script that randomly display some ads. Since I need it in the entire website, I put the related files in a single dir, then I used an include function to make the script read the related txt file containing the ads from any website level (folder). This works perfectly on MAMP (on a mac) and in my live server. I start working with windows vista some days ago, and decided to use XAMPP as my local testing server. It doesn't work anymore.

In my config file, I defined:
define('APPROOT', dirname(__FILE__));

In the script file, I have this (need to get the ads and display them randomly):
<?php $Page=$_SERVER['PHP_SELF']; $Filename="$base/xml_txt/annunci.txt"; $RunType=1; $Number=3; include(APPROOT ."/script/php/rotator.php"); ?>

The included file, rotator.php is in the code snippet.

I have this error:
Warning: file_get_contents(http://localhost/siti/mywebsite/xml_txt/annunci.txt) [function.file-get-contents]: failed to open stream: Impossibile stabilire la connessione. Risposta non corretta della parte connessa dopo l'intervallo di tempo oppure mancata risposta dall'host collegato. in C:\xampp\htdocs\siti\mywebsite\script\php\rotator.php on line 30

Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\siti\mywebsite\script\php\rotator.php on line 30
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
<?php
//Had to add for PHP versions older than 4.3.11
srand();
 
if(!isset($Filename))
{
  echo "Non sono al momento presenti offerte in vendita.";
  exit();
}
 
if(!isset($Number))
{
  $Number = 1000000;
}
 
if($RunType == 1 && isset($Snippet_Array))
{
  $Item_Array = $Snippet_Array;
}
else if($RunType == 2 && isset($SnippetTag_Array))
{
  $Item_Array = $SnippetTag_Array;
}
else if($RunType == 3 && isset($SitemapTag_Array))
{
  $Item_Array = $SitemapTag_Array;
}
else
{
  $File_Contents = file_get_contents($Filename);
  $Item_Array = explode("#BREAK#", $File_Contents);
  array_pop($Item_Array);
}
 
 
for($ctr = 0; $ctr < count($Item_Array); $ctr++)
{
  if(strpos($Item_Array[$ctr], $Page))
    unset($Item_Array[$ctr]);
}
 
$Item_Array = array_values($Item_Array);
 
 
if($Number > count($Item_Array))
{
  $Number = count($Item_Array);
}
 
if($Number == 0)
{
  exit();
}
 
$Output_Keys = array_rand($Item_Array, $Number);
if(!is_array($Output_Keys))
  $Output_Keys = array($Output_Keys);
 
$LeftOver_Array = $Item_Array;
 
for($ctr=0; $ctr < count($Output_Keys); $ctr++)
{
  unset($LeftOver_Array[$Output_Keys[$ctr]]);
}
 
$LeftOver_Array = array_values($LeftOver_Array);
 
unset($File_Contents);
 
$Page = substr($Page, strrpos($Page, "/")+1);
 
$File_Contents = file_get_contents($Page);
 
$ctr=0;
while($ctr < count($Output_Keys))
{
  if(strpos($File_Contents, $Item_Array[$Output_Keys[$ctr]]))
  {
    unset($Output_Keys[$ctr]);
    $Output_Keys = array_values($Output_Keys);
    if(count($LeftOver_Array) > 0)
    {
      $Item = array_rand($LeftOver_Array, 1);
      array_push($Output_Keys, $Item[0]);
      unset($LeftOver_Array[$Item[0]]);
      $LeftOver_Array = array_values($LeftOver_Array);
    } 
  }
  else
  {
    $ctr++;
  }
}
 
$ctr = 0;
while(count($Output_Keys) != 0)
{
  echo $Item_Array[array_shift($Output_Keys)];
}
 
 
if($RunType == 1)
{
  $Snippet_Array = $LeftOver_Array;
}
else if($RunType == 2)
{
  $SnippetTag_Array = $LeftOver_Array;
}
else
{
  $SitemapTag_Array = $LeftOver_Array;
}
 
unset($RunType);
unset($Number);
unset($Page);
unset($Filename);
 
?>
[+][-]05.12.2008 at 12:56AM PDT, ID: 21545213

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 01:00AM PDT, ID: 21545227

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 01:04AM PDT, ID: 21545239

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 01:14AM PDT, ID: 21545272

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 01:32AM PDT, ID: 21545314

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 01:36AM PDT, ID: 21545328

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 01:38AM PDT, ID: 21545335

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 01:38AM PDT, ID: 21545336

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 01:45AM PDT, ID: 21545361

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 02:02AM PDT, ID: 21545417

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 02:47AM PDT, ID: 21545555

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 02:50AM PDT, ID: 21545567

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Apache Web Server
Tags: PHP (XAMPP environment)
Sign Up Now!
Solution Provided By: logudotcom
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628