datadoit.com
|
Posted: 03/13/2006, 9:11 AM |
|
I develop and test on a local web server (localhost), and then push to
production when ready. For sites with SSL, I've set up the Project Settings
to have an SSL Server URL (ex: https://www.blablabla.com). Then, in the
pages that need only to be view via SSL, I set the Convert URL To SSL. This
all works great on the production server, since the production server has
SSL installed and working.
My problem is that I don't have SSL installed locally on my WAMP development
machine (I really don't want to go through all that if necessary). I'd like
to be able to continue to test locally, without having to go and adjust the
Project Settings and Page Settings for SSL and publish locally with these
'temporary' settings. Is there some magical way to adjust something in the
Common.php file to see if I'm local use these settings, if remote, use these
alternative settings?
Gracias.
|
|
|
feha
Posts: 712
|
Posted: 03/13/2006, 12:28 PM |
|
Yes
define("SITE_URL", strtolower(substr($_SERVER['SERVER_PROTOCOL'],0,strpos($_SERVER['SERVER_PROTOCOL'],'/')) . (isset($_SERVER['HTTPS']) ? ($_SERVER['HTTPS'] == "on" ? 's://' : '://') : '://' ) . $_SERVER['SERVER_NAME'] ) );
This should change whenever is SSL possible ...
or use the function below:
function Secure_Connection()
{
if (isSet($_SERVER['HTTPS']))
return (0 == strcmp(strtolower($_SERVER['HTTPS']), 'on')) ? TRUE : FALSE;
else
return FALSE;
}
Then define the constant depending on connection type ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
datadoit.com
|
Posted: 03/13/2006, 6:42 PM |
|
This looks very much like what I'll need! Now where would I put this or how
would it be used? In my Common.php file, I see a:
define("SecureURL", "https://www.mysite.com/");
Now it looks like I would simply plug in your 'define("SITE_URL")' statement
into the Common.php, and disable all of the other CCS settings for checking
for SSL (which would remove the above statement). Would that be correct?
I'm actually hoping to be able to keep using the CCS settings as they are
intended, with a little workaround to deal with my situation.
Thanks.
|
|
|
feha
Posts: 712
|
Posted: 03/14/2006, 4:35 AM |
|
OK
when you open project settings there you write the ssl url
you just enter a constant ".SSL_URL."
at the top you include the function ...
you call the function:
if(Secure_Connection() )
{
define("SSL_URL", "https://www.mysite.com/");
}
else
{
define("SSL_URL", "http://www.mysite.com/");
}
}
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
datadoit.com
|
Posted: 03/14/2006, 11:11 AM |
|
I'm still a little confused as to exactly what goes where, so here's what
the very top of my Common.php file looks like with the samples you provided:
//Include Files @0-6CA7C540
include(RelativePath . "/Classes.php");
include(RelativePath . "/db_mysql.php");
define("SITE_URL",strtolower(substr($_SERVER['SERVER_PROTOCOL'],0,strpos($_SERVER['SERVER_PROTOCOL'],'/'))(isset($_SERVER['HTTPS'])
? ($_SERVER['HTTPS'] == "on" ? 's://' : '://') : '://' ) .
$_SERVER['SERVER_NAME'] ) );
function Secure_Connection()
{
if (isSet($_SERVER['HTTPS']))
return (0 == strcmp(strtolower($_SERVER['HTTPS']), 'on')) ? TRUE :
FALSE;
else
return FALSE;
}
if(Secure_Connection() )
{
define("SSL_URL", "https://www.mysite.com/");
}
else
{
define("SSL_URL", "http://www.mysite.com/");
}
//End Include Files
//Initialize Common Variables @0-9B7888D3
session_start();
header('Pragma: ');
header('Cache-control: ');
header('Expires: ');
define("TemplatePath", "./");
define("ServerURL", "http://localhost/mysite.com/");
define("SecureURL", ".SSL_URL.");
Running anything on the site produces a blank page, so it doesn't like
something above. Am I following your instructions correctly?
Thanks again.
|
|
|
feha
Posts: 712
|
Posted: 03/14/2006, 12:59 PM |
|
remove
define("SITE_URL",strtolower(substr($_SERVER['SERVER_PROTOCOL'],0,strpos($_SERVER['SERVER_PROTOCOL'],'/'))(isset($_SERVER['HTTPS'])
? ($_SERVER['HTTPS'] == "on" ? 's://' : '://') : '://' ) .
$_SERVER['SERVER_NAME'] ) );
do not use both
these are two options
the second is better ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
datadoit.com
|
Posted: 03/14/2006, 1:58 PM |
|
Okay, so my Common.php now looks like:
<?php
function Secure_Connection()
{
if (isSet($_SERVER['HTTPS']))
return (0 == strcmp(strtolower($_SERVER['HTTPS']), 'on')) ? TRUE :
FALSE;
else
return FALSE;
}
if(Secure_Connection() )
{
define("SSL_URL", "https://www.mysite.com/");
}
else
{
define("SSL_URL", "http://www.mysite.com/");
}
define("SecureURL", ".SSL_URL.");
....
In the Project Settings for Secure Server URL, I have .SSL_URL. . When
attempting to view a page that should be SSL'ified, I get:
The requested URL /mysite.com/.SSL_URL.subdir/index.php was not found on
this server.
It's taking that .SSL_URL. too literally. (?)
Thanks.
|
|
|
feha
Posts: 712
|
Posted: 03/15/2006, 12:05 AM |
|
try puting complete ".SSL_URL." including " ...
or just SSL_URL
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
feha
Posts: 712
|
Posted: 03/15/2006, 12:22 AM |
|
define("SecureURL", ".SSL_URL.");
must be define("SecureURL", SSL_URL);
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
datadoit.com
|
Posted: 03/15/2006, 7:15 AM |
|
K, think we've got something working now, but not exactly as presented.
However, the key to all this was the ability to dynamically assign the value
of SecureURL (thanks Feha!!) via:
define("SecureURL", SSL_URL);
NOTE: In the Project Settings, if you set a value for Secure Server URL, in
the Common.php file it will put:
define("SecureURL", "YourValue/");
Notice it will put it in quotes, plus add the "/" onto the end of it. You
must go into the Common.php file and remove the quotes and trailing "/". As
Feha states: defining the constant.
The problem with the sample provided was that it was checking to see if the
page currently being viewed was accessed via HTTPS - if you can't view HTTPS
in the first place, the test always resulted in false. This also won't work
if you're attempting to go to (link to) an HTTPS page from an HTTP page.
There may be a way to check the server to see if the HTTPS port can accept
connections (?). Perhaps something like:
if (Server can take connections on port 443) {
define("SSL_URL", "https://" . $_SERVER['HTTP_HOST'] . "/");
}
else {
define("SSL_URL", "http://" . $_SERVER['HTTP_HOST'] . "/");
}
For my situation where I am developing on a local machine, I just simply
used:
if ($_SERVER['HTTP_HOST'] == "127.0.0.1") {
define("SSL_URL", "http://" . $_SERVER['HTTP_HOST'] . "/mysite.com/");
}
else {
define("SSL_URL", "https://" . $_SERVER['HTTP_HOST'] . "/");
}
and this solved my problem. However, this really isn't the best permanent
solution if your development machine changes location/IP, or if you do get a
local SSL and want to test. Open to suggestions on how to test whether the
server can take an SSL connection using PHP.
Thanks.
|
|
|
|