i have this function here that i have in a class
function enable_ssl() {
if ($_SERVER[HTTPS]!="on") {
$domain = "https://".$_SERVER['HTTP_HOST']."/".$_SERVER['SCRIPT_NAME'];
header("Location: {$domain}");
}
}
but the problem is when the server doesnt have ssl installed and i have this function initiating the page redirects to a 404 page. i was wondering how i can have this function work only when ssl is installed and working
is it possible?
thanks.
ps: did some google research and couldnt find much of anything.
So a simple one that I just never could find a straight answer on.
What is better (performance or otherwise):
$var = false;
If ($a == $b) {
$var = true;
}
or
If ($a == $b) {
$var = true;
} else {
$var = false;
}
I've heard arguments for both ways. I find the first cleaner to ensure I have it set, and a little less code too. The pro being that you may only need to set it once without conditional. But the con being that if the argument is true, it gets set twice.
I am assuming the second way is probably best practice
I am trying to understand the difference between this:
if (isset($_POST['Submit'])) {
//do something
}
and
if ($_POST['Submit']) {
//do something
}
It seems to me that if the $_POST['Submit'] variable is true, then it is set. Why would I need the isset() function in this case?
I have texts in UTF-8 with diacritic characters also, and would like to check if first letter of this text is upper case or lower case. How to do this?
I am going to be implementing a small custom CMS for a website. I was wondering if there are any more popular methods for implementing pagination using OOP. Thanks!
I need to setup LookAndFeel Files in JDK 1.6.
I have two files:
napkinlaf-swingset2.jar
napkinlaf.jar
How can I set this up and use it?
I would like a GTK look and feel OR Qt look and feel, Are they available?
Is there a catchall function somewhere that works well for sanitizing user input for sql injection and XSS attacks, while still allowing certain types of html tags?
I am working on a old code base, where programmers assumed that register_globals will always be on. Hence variables are used without $_GET or $_POST prefix, pretty much in every page (the code base is huge, hundreds of scripts). I tried turning it off, but the very first script (login script) goes on an infinite loop.
I understand that going through one script at a time, and one line at a time and fixing the variables is probably the only option (adding the prefix $_GET or $_POST as the case may be). Has anyone does this before? How did you go about doing it? Any advice?
Hi,
I have searched but havent been able to find my answer.
It follows like:
I would like to replace all URL in a string to links except the URLs within img src tag.
I have a regular expression for replacing all the URLs to links, but would like it to NOT replace the URLs within img src="" attribute.
How can i do this?
Here is the code for replacing all URLs:
/*** make sure there is an http:// on all URLs ***/
$str = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2",$str);
/*** make all URLs links ***/
$str = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$str);
/Regards
I'm getting a problem here when i try to logout, the session is destroy but i still can go inside to that page and view details without login first by using browser mozilla Back button or history cache! How can i solve that? Anybody help me please...
code for logout is
Is there a way to look inside an array and pull out the keys that have keys with matching values? Questions like this have been asked, but I'm not finding anything conclusive.
So if my array looks like this
Array
(
[0] => Array
(
[title] => Title 1
[type] =>
[message] =>
)
[1] => Array
(
[title] => Title 2
[type] =>
[message] =>
)
[2] => Array
(
[title] => Title 3
[type] =>
[message] =>
)
[3] => Array
(
[title] => Title 2
[type] => Limited
[message] => 39
)
[4] => Array
(
[title] => Title 4
[type] => Offline
[message] => 41
)
[5] => Array
(
[title] => Title 5
[type] =>
[message] =>
)
And I want to get this
Array
(
[1] => Array
(
[title] => Title 2
[type] =>
[message] =>
)
[3] => Array
(
[title] => Title 2
[type] => Limited
[message] => 39
)
)
Hi,
I have an object $rows
If I use echo $rows the content is displayed in my html page, however I would like to select only some parts of the content but I cannot see inside the variable how it is structured...
thanks
Hi, I have user defined string (html formated string to be saved and used in web) and need to find a way to replace each white space which is right after a single letter by .
For example "this is a string" should become "this is a string",
"bla bla b l abla b la blabla" should become "bla bla b l abla b la blabla" ...etc...
Are there speed differences, performance issues, and what reasons do businesses have when they choose one or the other... and is there a learning curve steeper for one over the other? Also... are you likely to be paid more using one over the other?
I don't want anything incredibly complicated. I am working on a client outside the US, and I just want a basic check to see if someone is accessing his page from the US or not. After that, I am going to default the language in either English or Spanish, after determining where the visitor is from.
Thanks.
What do you think, what events/changes/news were the most significant in C++ world
Like
templates in the arena, including STL, boost
new standards - C++0x, TR1
The Qt library
MS managed C++
MPI, openmp, PPL
may be new IDE :) : eclipse,
netbeans, codeblocks, codelite
Hi all,
I am using md5 to encrypt the passwords in my project.
When user clicks on forgot password and submits his email,I have to send His password to him.
But the password is encrypted using md5.Generating new password should not do. The initial password is very important. SO how can i decrypt the password or any other way to send him original password?
Thanks in advance...