Stripslashes and server time zone?

Forum
Last Post
Threads / Messages

GeneticAlpha

Loving Mysidia!
Member
Joined
May 24, 2020
Messages
287
Points
18
Age
31
Location
Tennessee
Mysidian Dollar
13,377
So I have a couple questions. First one is needing help with stripslashes in users bios. I found one post that helped fix some of the other areas with this same issue but I'm still stuck with the bio one.
I keeps running into things with the ' into having slashes. So

I'm

becomes

I/'m.

I found in accountview.php a bio section:

Quote:
$profileForm->add(new Comment("Name: ", FALSE));
$profileForm->add(new TextField("nickname", $profile->getNickname()));
$profileForm->add(new Comment(""));
$profileForm->add(new Comment("Gender: ", FALSE));
$profileForm->add(new TextField("gender", $profile->getGender()));
$profileForm->add(new Comment(""));
$profileForm->add(new Comment("Bio: "));
$profileForm->add(new TextArea("bio", $profile->getBio()));
$profileForm->add(new Comment($lang->bio));
but I'm unsure if this is the area I need to use to fix it, or what code to even use.
________________

My next question is what is the time zone for the server? I'm trying to make a code that changes an image based on thy hour, and for some reason results are turning out weird lol like my time zone didn't match the server was my only guess.

Any help would be really appreciated,

thank you!
 
I believe I fixed this in my own install once upon a time. In classes/class_userprofile.php, replace
PHP:
      $basicinfo = "<br><strong>Member Since:</strong> {$membersince}<br>
				    Gender: {$this->gender}<br>
				    Favorite Color: {$this->color}<br>
				    Nickname: {$this->nickname}<br>
				    Bio: {$this->bio}";
with this (we're added stripslashes)
PHP:
 $str_bio = stripslashes($this->bio);
      $basicinfo = "<br><strong>Member Since:</strong> {$membersince}<br>
				    Gender: {$this->gender}<br>
				    Favorite Color: {$this->color}<br>
				    Nickname: {$this->nickname}<br>
				    Bio: {$str_bio}";

________________

Short of asking the hosting provider what timezone it is (or checking the php.ini file), you could try running this code to find that out?
PHP:
if (date_default_timezone_get()) {
    echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />';
}

if (ini_get('date.timezone')) {
    echo 'date.timezone: ' . ini_get('date.timezone');
}
 
Thank you so much! :D that worked, time zone is apparently UTC. Do you know how I would change it to EST? and the stripslashes worked! I appreciate you.
 
Usually hosting providers can't or won't change the entire server's timezone, as its usually shared hosting, and they'd rather it be local to timezone the server is physically in.

You can change the default time zone for use in particular code on a particular page but don't expect it to carry between pages without specifically making sure its set. (And, of course, this makes the code local to whatever YOU set it to be, not whatever the timezone it currently is for any viewer, so it'll be off for anyone who doesn't share your timezone. Dynamically getting the appropriate timezone is not quite possible without a bit of hackery, which users will always be able to find ways around, anyway.)

But if it helps your mental math to have things based around your own understanding of what time it is, I don't blame you!

Since you're wanting to display code between particular hours, it's worth noting that hours can be checked between midnight 0000 and the minute just before midnight 2359 -- military time. I'm not sure what exactly you're up to, but I hope this can help!

PHP:
date_default_timezone_set('America/New_York');
// echo date('Y-m-d H:i:s');

$currentTime = date('Hi');
$breakfastStart = "0200"; $breakfastEnd = "1129";
$lunchStart = "1130"; $lunchEnd = "1559";
$dinnerStart = "1600"; $dinnerEnd = "2129";
$lateStart = "2130"; $lateEnd = "0159";

if( $currentTime >= $breakfastStart && $currentTime <= $breakfastEnd ){ 
  /*BREAKFAST*/
    $timefor = 'Breakfast';
} elseif( $currentTime >= $lunchStart && $currentTime <= $lunchEnd ){ 
  /*LUNCH*/
    $timefor = 'Lunch';
} elseif( $currentTime >= $dinnerStart && $currentTime <= $dinnerEnd ){ 
  /*DINNER*/
    $timefor = 'Dinner';
} else { 
  /*LATE NIGHT SNACK*/
    $timefor = 'Late Night';
}

Just know that it won't necessarily make sense to everyone viewing it because they won't be in the same time you are. While you're eating breakfast, they could be eating dinner. Even though its dinner time for them in the real world, on your website it's breakfast time because it is where you are. Hope that makes sense!
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,119
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top