[Moodle] Dynamically changing wwwroot

Laurie Savage sav at pvgc.vic.edu.au
Mon Nov 24 10:41:17 EST 2008


Thanks Michael, 

I didn't realise the 10 would be stored as a string. As for the "==", well I
should have known better!

Laurie 

-----Original Message-----
From: moodle-bounces at edulists.com.au [mailto:moodle-bounces at edulists.com.au]
On Behalf Of Michael Greenhill
Sent: Monday, 24 November 2008 10:10 AM
To: 'The Moodle Users' in Schools Mailing List'
Subject: RE: [Moodle] Dynamically changing wwwroot

Try changing it to this - note the extra equals sign in the third line.

$PVGCip = $_SERVER['REMOTE_ADDR'];
$PVGCparts = explode('.',$PVGCip);

if ($PVGCparts[0] == '10') {
  $CFG->wwwroot = "http://10.x.y.z";
} else {
  $CFG->wwwroot = "http://moodle.pvgc.vic.edu.au"; }

Also note that I've put the quotes in the third line. This is because you're
comparing a string ($PVGCparts[0], explode splits one string into an array
of strings), so the value you're comparing it against should be a string
too. 

Michael Greenhill
IT Technician
Wheelers Hill Secondary College
+61 03 9561 5811

-----Original Message-----
From: moodle-bounces at edulists.com.au [mailto:moodle-bounces at edulists.com.au]
On Behalf Of laurie Savage
Sent: Sunday, 23 November 2008 6:37 PM
To: The Moodle Users' in Schools Mailing List
Subject: [Moodle] Dynamically changing wwwroot

Hi Moodlers and PHP coders,

I have a problem which I thought I'd solved but, alas, only made worse.
I'd be grateful for your suggestions.

Here goes:

Our college's moodle is located on a box 10.x.y.z within our intranet which
is visible to the Internet as  http://moodle.pvgc.vic.edu.au. Its wwwroot in
config.php is "http://moodle.pvgc.vic.edu.au" and users use this address
whether they are at school (intranet access) or at home. All machines on our
local network are prefixed with "10." and our border IP identifies as
210.a.b.c.

When users access the site using the intranet and the moodle.pvgc.vic.edu.au
URL they get a lot of 403 errors and my logs report a lot of header
problems. A bit of research suggested DNS issues.

I thought I would fix this by having my intRAnet users use an alias
"http://moodle/" which points to 10.x.y.z and modifying config.php to test
whether the user's IP starts with 10. The result was access through the
intRAnet was greatly improved but the site was unusable over the intERnet
- the document root is identified as 10.x.y.z instead of
moodle.pvgc.vic.edu.au. Here is the modification:

$PVGCip = $_SERVER['REMOTE_ADDR'];
$PVGCparts = explode('.',$PVGCip);

if ($PVGCparts[0] = 10)
  {$CFG->wwwroot = "http://10.x.y.z";}
else
  {$CFG->wwwroot = "http://moodle.pvgc.vic.edu.au";}

(The logic in my script's first two lines works - try it in a little script
to display and reformat the contents of $parts[n])

Laurie
--
Laurie Savage
=
Student Assessment/Reporting & Tracking
Pascoe Vale Girls College
Pascoe Vale, Victoria, AU  9306 2544
_______________________________________________
http://www.edulists.com.au - FAQ, resources, subscribe, unsubscribe Moodle
Mailing List kindly supported by http://www.vcaa.vic.edu.au - Victorian
Curriculum and Assessment Authority and http://www.vitta.org.au  - VITTA
Victorian Information Technology Teachers Association Inc

--
Important Notice:
This email is for the named recipient only. Its contents are confidential.
If you are not the authorised recipient you must not use, disclose or copy
any of these contents. If you receive this email in error please contact us
immediately and delete the email from your system. Representations or
opinions expressed are those of the sender & not necessarily those of
Wheelers Hill SC.
_______________________________________________
http://www.edulists.com.au - FAQ, resources, subscribe, unsubscribe Moodle
Mailing List kindly supported by http://www.vcaa.vic.edu.au - Victorian
Curriculum and Assessment Authority and http://www.vitta.org.au  - VITTA
Victorian Information Technology Teachers Association Inc




More information about the moodle mailing list