• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 00:35
CET 06:35
KST 14:35
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
StarCraft Evolution League (SC Evo Biweekly) RSL Offline Finals Info - Dec 13 and 14! RSL Offline FInals Sea Duckling Open (Global, Bronze-Diamond) $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
BW General Discussion Which season is the best in ASL? Data analysis on 70 million replays BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[BSL21] RO16 Group D - Sunday 21:00 CET [BSL21] RO16 Group A - Saturday 21:00 CET [Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET
Strategy
Current Meta Game Theory for Starcraft How to stay on top of macro? PvZ map balance
Other Games
General Games
ZeroSpace Megathread Stormgate/Frost Giant Megathread Nintendo Switch Thread The Perfect Game Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1830 users

The Big Programming Thread - Page 328

Forum Index > General Forum
Post a Reply
Prev 1 326 327 328 329 330 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
July 24 2013 19:07 GMT
#6541
On July 25 2013 02:55 tec27 wrote:
Decent programmers are not going to say "I like python" and think that's a good reason for choosing it for a project. If your company doesn't trust you to be able to pick the right tool for the job, they think you're a moron and unless you actually believe you are a moron, you should find a new job. Its really not that difficult.

There are plenty of companies that will treat you like shit, I'm not arguing that they don't exist. I'm just saying that if you have any self-respect and desire to actually work effectively, you shouldn't work for them.

If you're in a position to be pitching project details to management before the project is confirmed, you're not exactly a low level programmer.
Average means I'm better than half of you.
freelander
Profile Blog Joined December 2004
Hungary4707 Posts
July 24 2013 19:21 GMT
#6542
On July 25 2013 03:03 RoyGBiv_13 wrote:
Show nested quote +
On July 25 2013 02:55 tec27 wrote:
Decent programmers are not going to say "I like python" and think that's a good reason for choosing it for a project. If your company doesn't trust you to be able to pick the right tool for the job, they think you're a moron and unless you actually believe you are a moron, you should find a new job. Its really not that difficult.

There are plenty of companies that will treat you like shit, I'm not arguing that they don't exist. I'm just saying that if you have any self-respect and desire to actually work effectively, you shouldn't work for them.


+1
Programming is a creative profession. There's a ton of research on how to get the highest quality production out of a programmer. Agile methodologies have a pretty good track record of generating top notch code, while waterfall design is arguably the worst thing to happen to programming since PHP (har har har).


lol PHP is just comically weird

my favorite "feature" is that ternary operator is left associative and it causes things like this:
$transport = 'T';

$vehicle = (
( $transport == 'B' ) ? 'bus' :
( $transport == 'A' ) ? 'airplane' :
( $transport == 'T' ) ? 'train' :
( $transport == 'C' ) ? 'car' :
( $transport == 'H' ) ? 'horse' :
'feet' );

echo $vehicle;


this returns horse lol
And all is illuminated.
tofucake
Profile Blog Joined October 2009
Hyrule19173 Posts
July 24 2013 19:24 GMT
#6543
That's because it's constructed wrong.
Liquipediaasante sana squash banana
freelander
Profile Blog Joined December 2004
Hungary4707 Posts
July 24 2013 19:29 GMT
#6544
On July 25 2013 04:24 tofucake wrote:
That's because it's constructed wrong.


well yeah. in php context it's wrong. in every other language with a ternary it would work "correctly"
And all is illuminated.
czaku
Profile Joined June 2011
Poland429 Posts
July 24 2013 19:32 GMT
#6545
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?
Yoshi-
Profile Joined October 2008
Germany10227 Posts
July 24 2013 19:33 GMT
#6546
On July 25 2013 04:21 freelander wrote:
Show nested quote +
On July 25 2013 03:03 RoyGBiv_13 wrote:
On July 25 2013 02:55 tec27 wrote:
Decent programmers are not going to say "I like python" and think that's a good reason for choosing it for a project. If your company doesn't trust you to be able to pick the right tool for the job, they think you're a moron and unless you actually believe you are a moron, you should find a new job. Its really not that difficult.

There are plenty of companies that will treat you like shit, I'm not arguing that they don't exist. I'm just saying that if you have any self-respect and desire to actually work effectively, you shouldn't work for them.


+1
Programming is a creative profession. There's a ton of research on how to get the highest quality production out of a programmer. Agile methodologies have a pretty good track record of generating top notch code, while waterfall design is arguably the worst thing to happen to programming since PHP (har har har).


lol PHP is just comically weird

my favorite "feature" is that ternary operator is left associative and it causes things like this:
$transport = 'T';

$vehicle = (
( $transport == 'B' ) ? 'bus' :
( $transport == 'A' ) ? 'airplane' :
( $transport == 'T' ) ? 'train' :
( $transport == 'C' ) ? 'car' :
( $transport == 'H' ) ? 'horse' :
'feet' );

echo $vehicle;


this returns horse lol


That is PHP built in "if you stack multiple ternary, you deserve to die"-feature
fdsdfg
Profile Blog Joined February 2010
United States1251 Posts
July 24 2013 19:50 GMT
#6547
I'm a java programmer by trade. For the past couple months, I've been working on my own project using PHP and Javascript with AJAX. It's going really well, but there are a lot of things that every commercial site has solved in PHP (like sessions timing out from the server) that I need to implement.

Is there a source online for a lot of these basic functions? I can find so much reference for Javascript and Jquery, but so little for PHP.
aka Siyko
tofucake
Profile Blog Joined October 2009
Hyrule19173 Posts
July 24 2013 19:54 GMT
#6548
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?

Why?
Liquipediaasante sana squash banana
Yoshi-
Profile Joined October 2008
Germany10227 Posts
July 24 2013 19:57 GMT
#6549
On July 25 2013 04:50 fdsdfg wrote:
I'm a java programmer by trade. For the past couple months, I've been working on my own project using PHP and Javascript with AJAX. It's going really well, but there are a lot of things that every commercial site has solved in PHP (like sessions timing out from the server) that I need to implement.

Is there a source online for a lot of these basic functions? I can find so much reference for Javascript and Jquery, but so little for PHP.

http://php.net , which is maybe the best documentation of a language out there.
But I assume that you already know that site, could you maybe describe your problem further.
From what I understand you have e.g. a login system and you don't want that the user gets logged out, after the seesions has timed out.
Thats normally solved by using cookies to recreate the sessions after it has timed out.
fdsdfg
Profile Blog Joined February 2010
United States1251 Posts
July 24 2013 20:00 GMT
#6550
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?


Just write a 1-line batch file that calls format and throws the output away. You're reinventing the wheel if you try to write a new format utility for no reason.
aka Siyko
LukeNukeEm
Profile Joined February 2012
31 Posts
July 24 2013 20:02 GMT
#6551
Hi, I have a question for the c++-gurus:
given
template<class T = void>
class foo
{
};

int main(void)
{
foo<> foo1;
foo<int> foo2;
}
and that I am lazy, is there a way to make
foo foo1;
foo<int> foo2;
legal?
I know i can do this
namespace detail
{
template<class T = void>
class foo
{
};
}
using foo = detail::foo<>;

int main(void)
{
foo foo1;
detail::foo<int> foo2;
}
, but now i have to write detail:: for every class with a non-default template parameter.
Is there any magic available to make this work, perhaps with template aliases?
fdsdfg
Profile Blog Joined February 2010
United States1251 Posts
July 24 2013 20:05 GMT
#6552
On July 25 2013 04:57 Yoshi- wrote:
Show nested quote +
On July 25 2013 04:50 fdsdfg wrote:
I'm a java programmer by trade. For the past couple months, I've been working on my own project using PHP and Javascript with AJAX. It's going really well, but there are a lot of things that every commercial site has solved in PHP (like sessions timing out from the server) that I need to implement.

Is there a source online for a lot of these basic functions? I can find so much reference for Javascript and Jquery, but so little for PHP.

http://php.net , which is maybe the best documentation of a language out there.
But I assume that you already know that site, could you maybe describe your problem further.
From what I understand you have e.g. a login system and you don't want that the user gets logged out, after the seesions has timed out.
Thats normally solved by using cookies to recreate the sessions after it has timed out.


There are a few things. Right now the session never times out, if I stay on a page forever, my client keeps sending AJAX to the server and getting a reply. He appears in 'users online' for days. I want his session terminated and his client redirected to the login page.

Same for a user who logs onto the site, closes the tab, and leaves his window open. When you open a new window, you are still logged in - I would like to see 'your session has timed out'.

It's easy to do this in theory - build a simple timestamp and kill the session if he tries to do something after it has expired. But the web industry has been doing this for a decade in pretty much the same way - it seems there really should be robust implementations that have been refined and optimized that I can leverage instead of reinventing.

I could say the same about a chat room, registering a user, etc. I feel like I'm adding every new feature like it's a school project instead of having some reference toward what is a correct, robust implementation.
aka Siyko
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2013-07-24 20:07:03
July 24 2013 20:06 GMT
#6553
@lukem

typedef could be your friend!

typedef foo<int> int_foo;
conspired against by a confederacy of dunces.
Yoshi-
Profile Joined October 2008
Germany10227 Posts
July 24 2013 20:11 GMT
#6554
On July 25 2013 05:05 fdsdfg wrote:
Show nested quote +
On July 25 2013 04:57 Yoshi- wrote:
On July 25 2013 04:50 fdsdfg wrote:
I'm a java programmer by trade. For the past couple months, I've been working on my own project using PHP and Javascript with AJAX. It's going really well, but there are a lot of things that every commercial site has solved in PHP (like sessions timing out from the server) that I need to implement.

Is there a source online for a lot of these basic functions? I can find so much reference for Javascript and Jquery, but so little for PHP.

http://php.net , which is maybe the best documentation of a language out there.
But I assume that you already know that site, could you maybe describe your problem further.
From what I understand you have e.g. a login system and you don't want that the user gets logged out, after the seesions has timed out.
Thats normally solved by using cookies to recreate the sessions after it has timed out.


There are a few things. Right now the session never times out, if I stay on a page forever, my client keeps sending AJAX to the server and getting a reply. He appears in 'users online' for days. I want his session terminated and his client redirected to the login page.

Same for a user who logs onto the site, closes the tab, and leaves his window open. When you open a new window, you are still logged in - I would like to see 'your session has timed out'.

It's easy to do this in theory - build a simple timestamp and kill the session if he tries to do something after it has expired. But the web industry has been doing this for a decade in pretty much the same way - it seems there really should be robust implementations that have been refined and optimized that I can leverage instead of reinventing.

I could say the same about a chat room, registering a user, etc. I feel like I'm adding every new feature like it's a school project instead of having some reference toward what is a correct, robust implementation.


Well, is there even any sense to keep sending AJAX request, that is not only insanely inefficient, also apparently quite useless?
You could just say that it will only send a limited amount of requests.
czaku
Profile Joined June 2011
Poland429 Posts
Last Edited: 2013-07-24 20:14:03
July 24 2013 20:12 GMT
#6555
On July 25 2013 04:54 tofucake wrote:
Show nested quote +
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?

Why?


It's a project to pass the next semester from programming and she is not interested in learning it. So she asked for my help. Basically you show the teacher code, explain how it works and you passed.


On July 25 2013 05:00 fdsdfg wrote:
Show nested quote +
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?


Just write a 1-line batch file that calls format and throws the output away. You're reinventing the wheel if you try to write a new format utility for no reason.



The problem is it has to be in C/C++ and i prefer C at the moment.
tofucake
Profile Blog Joined October 2009
Hyrule19173 Posts
July 24 2013 20:24 GMT
#6556
On July 25 2013 05:05 fdsdfg wrote:
Show nested quote +
On July 25 2013 04:57 Yoshi- wrote:
On July 25 2013 04:50 fdsdfg wrote:
I'm a java programmer by trade. For the past couple months, I've been working on my own project using PHP and Javascript with AJAX. It's going really well, but there are a lot of things that every commercial site has solved in PHP (like sessions timing out from the server) that I need to implement.

Is there a source online for a lot of these basic functions? I can find so much reference for Javascript and Jquery, but so little for PHP.

http://php.net , which is maybe the best documentation of a language out there.
But I assume that you already know that site, could you maybe describe your problem further.
From what I understand you have e.g. a login system and you don't want that the user gets logged out, after the seesions has timed out.
Thats normally solved by using cookies to recreate the sessions after it has timed out.


There are a few things. Right now the session never times out, if I stay on a page forever, my client keeps sending AJAX to the server and getting a reply. He appears in 'users online' for days. I want his session terminated and his client redirected to the login page.

Same for a user who logs onto the site, closes the tab, and leaves his window open. When you open a new window, you are still logged in - I would like to see 'your session has timed out'.

It's easy to do this in theory - build a simple timestamp and kill the session if he tries to do something after it has expired. But the web industry has been doing this for a decade in pretty much the same way - it seems there really should be robust implementations that have been refined and optimized that I can leverage instead of reinventing.

I could say the same about a chat room, registering a user, etc. I feel like I'm adding every new feature like it's a school project instead of having some reference toward what is a correct, robust implementation.
The simple solution is to just use the session itself. Set $_SESSION['lastactivitytimestamporwhatetever'] when a user goes to a page, but not on ajax calls. If it's above some threshhold clear the session and redirect to login.
Liquipediaasante sana squash banana
fdsdfg
Profile Blog Joined February 2010
United States1251 Posts
Last Edited: 2013-07-24 20:34:22
July 24 2013 20:28 GMT
#6557
On July 25 2013 05:12 czaku wrote:
Show nested quote +
On July 25 2013 04:54 tofucake wrote:
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?

Why?


It's a project to pass the next semester from programming and she is not interested in learning it. So she asked for my help. Basically you show the teacher code, explain how it works and you passed.


Show nested quote +
On July 25 2013 05:00 fdsdfg wrote:
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?


Just write a 1-line batch file that calls format and throws the output away. You're reinventing the wheel if you try to write a new format utility for no reason.



The problem is it has to be in C/C++ and i prefer C at the moment.


You're asking for help on writing your friend's school project for her? She should fail if she can't learn the stuff. Programmers work on teams, and I wouldn't wish a useless teammate on any fellow programmer, which is what you're trying to inflict.

On July 25 2013 05:11 Yoshi- wrote:
Show nested quote +
On July 25 2013 05:05 fdsdfg wrote:
On July 25 2013 04:57 Yoshi- wrote:
On July 25 2013 04:50 fdsdfg wrote:
I'm a java programmer by trade. For the past couple months, I've been working on my own project using PHP and Javascript with AJAX. It's going really well, but there are a lot of things that every commercial site has solved in PHP (like sessions timing out from the server) that I need to implement.

Is there a source online for a lot of these basic functions? I can find so much reference for Javascript and Jquery, but so little for PHP.

http://php.net , which is maybe the best documentation of a language out there.
But I assume that you already know that site, could you maybe describe your problem further.
From what I understand you have e.g. a login system and you don't want that the user gets logged out, after the seesions has timed out.
Thats normally solved by using cookies to recreate the sessions after it has timed out.


There are a few things. Right now the session never times out, if I stay on a page forever, my client keeps sending AJAX to the server and getting a reply. He appears in 'users online' for days. I want his session terminated and his client redirected to the login page.

Same for a user who logs onto the site, closes the tab, and leaves his window open. When you open a new window, you are still logged in - I would like to see 'your session has timed out'.

It's easy to do this in theory - build a simple timestamp and kill the session if he tries to do something after it has expired. But the web industry has been doing this for a decade in pretty much the same way - it seems there really should be robust implementations that have been refined and optimized that I can leverage instead of reinventing.

I could say the same about a chat room, registering a user, etc. I feel like I'm adding every new feature like it's a school project instead of having some reference toward what is a correct, robust implementation.


Well, is there even any sense to keep sending AJAX request, that is not only insanely inefficient, also apparently quite useless?
You could just say that it will only send a limited amount of requests.


That comes from a chat interface - you have a chat room open and you're sending AJAX to the server to find out if there's any new messages or any new people in the chat lobby.

Also within the game (it's a turn-based game), you're polling the server to see if your opponent has submitted their turn yet.

These AJAX queries serve a distinct function, but when the user is away and has happened to leave his window open, they do not serve a function. I need to time him out.

Now I can write something that will time him out, but like I said, I want to do it in a clean and correct way. The industry has been doing this for a long time, so I'm sure the information is out there on the correct way to do something like this.

On July 25 2013 05:24 tofucake wrote:
The simple solution is to just use the session itself. Set $_SESSION['lastactivitytimestamporwhatetever'] when a user goes to a page, but not on ajax calls. If it's above some threshhold clear the session and redirect to login.


Yeah, but I feel like this is something common enough where I don't need to just write a simple solution. It seems like enough people have done this exact thing so there should be thorough implementations floating around that I can use.

For instance, I have a 'dbhelper' class that handles a lot of communication with my database. I don't need to use 'mysql_connect' or 'mysql_fetch_assoc' - I have a framework that I simply call 'buildSelectObject($sql)' and it handles all error handling and whatnot. I can't seem to find such a framework for other things in PHP so I just code a 'dumb' version myself
aka Siyko
Yoshi-
Profile Joined October 2008
Germany10227 Posts
Last Edited: 2013-07-24 20:43:30
July 24 2013 20:40 GMT
#6558
On July 25 2013 05:05 fdsdfg wrote:
Show nested quote +
On July 25 2013 05:11 Yoshi- wrote:
On July 25 2013 05:05 fdsdfg wrote:
On July 25 2013 04:57 Yoshi- wrote:
On July 25 2013 04:50 fdsdfg wrote:
I'm a java programmer by trade. For the past couple months, I've been working on my own project using PHP and Javascript with AJAX. It's going really well, but there are a lot of things that every commercial site has solved in PHP (like sessions timing out from the server) that I need to implement.

Is there a source online for a lot of these basic functions? I can find so much reference for Javascript and Jquery, but so little for PHP.

http://php.net , which is maybe the best documentation of a language out there.
But I assume that you already know that site, could you maybe describe your problem further.
From what I understand you have e.g. a login system and you don't want that the user gets logged out, after the seesions has timed out.
Thats normally solved by using cookies to recreate the sessions after it has timed out.


There are a few things. Right now the session never times out, if I stay on a page forever, my client keeps sending AJAX to the server and getting a reply. He appears in 'users online' for days. I want his session terminated and his client redirected to the login page.

Same for a user who logs onto the site, closes the tab, and leaves his window open. When you open a new window, you are still logged in - I would like to see 'your session has timed out'.

It's easy to do this in theory - build a simple timestamp and kill the session if he tries to do something after it has expired. But the web industry has been doing this for a decade in pretty much the same way - it seems there really should be robust implementations that have been refined and optimized that I can leverage instead of reinventing.

I could say the same about a chat room, registering a user, etc. I feel like I'm adding every new feature like it's a school project instead of having some reference toward what is a correct, robust implementation.


Well, is there even any sense to keep sending AJAX request, that is not only insanely inefficient, also apparently quite useless?
You could just say that it will only send a limited amount of requests.


That comes from a chat interface - you have a chat room open and you're sending AJAX to the server to find out if there's any new messages or any new people in the chat lobby.

Also within the game (it's a turn-based game), you're polling the server to see if your opponent has submitted their turn yet.

These AJAX queries serve a distinct function, but when the user is away and has happened to leave his window open, they do not serve a function. I need to time him out.

Now I can write something that will time him out, but like I said, I want to do it in a clean and correct way. The industry has been doing this for a long time, so I'm sure the information is out there on the correct way to do something like this.

There isn't really a proper way to do this, as the proper way to write a chat does not include AJAX. That is where you should use WebSockets.

And if you still want to do this the proper way, it would be that if a user hasn't used the chat in the last minutes, you would stop doing Ajax request and instead show a "You are now inactive in chat, click here to be active again" message, after you click on it the ajax request will continue.
fdsdfg
Profile Blog Joined February 2010
United States1251 Posts
July 24 2013 20:43 GMT
#6559
On July 25 2013 05:40 Yoshi- wrote:
Show nested quote +
On July 25 2013 05:05 fdsdfg wrote:
On July 25 2013 05:11 Yoshi- wrote:
On July 25 2013 05:05 fdsdfg wrote:
On July 25 2013 04:57 Yoshi- wrote:
On July 25 2013 04:50 fdsdfg wrote:
I'm a java programmer by trade. For the past couple months, I've been working on my own project using PHP and Javascript with AJAX. It's going really well, but there are a lot of things that every commercial site has solved in PHP (like sessions timing out from the server) that I need to implement.

Is there a source online for a lot of these basic functions? I can find so much reference for Javascript and Jquery, but so little for PHP.

http://php.net , which is maybe the best documentation of a language out there.
But I assume that you already know that site, could you maybe describe your problem further.
From what I understand you have e.g. a login system and you don't want that the user gets logged out, after the seesions has timed out.
Thats normally solved by using cookies to recreate the sessions after it has timed out.


There are a few things. Right now the session never times out, if I stay on a page forever, my client keeps sending AJAX to the server and getting a reply. He appears in 'users online' for days. I want his session terminated and his client redirected to the login page.

Same for a user who logs onto the site, closes the tab, and leaves his window open. When you open a new window, you are still logged in - I would like to see 'your session has timed out'.

It's easy to do this in theory - build a simple timestamp and kill the session if he tries to do something after it has expired. But the web industry has been doing this for a decade in pretty much the same way - it seems there really should be robust implementations that have been refined and optimized that I can leverage instead of reinventing.

I could say the same about a chat room, registering a user, etc. I feel like I'm adding every new feature like it's a school project instead of having some reference toward what is a correct, robust implementation.


Well, is there even any sense to keep sending AJAX request, that is not only insanely inefficient, also apparently quite useless?
You could just say that it will only send a limited amount of requests.


That comes from a chat interface - you have a chat room open and you're sending AJAX to the server to find out if there's any new messages or any new people in the chat lobby.

Also within the game (it's a turn-based game), you're polling the server to see if your opponent has submitted their turn yet.

These AJAX queries serve a distinct function, but when the user is away and has happened to leave his window open, they do not serve a function. I need to time him out.

Now I can write something that will time him out, but like I said, I want to do it in a clean and correct way. The industry has been doing this for a long time, so I'm sure the information is out there on the correct way to do something like this.

There isn't really a proper way to do this, as the proper way to write a chat does not include either php or AJAX. That is where you should use WebSockets, which PHP doesn't support.

And if you still want to do this the proper way, it would be that if a user hasn't used the chat in the last minutes, you would stop doing Ajax request and instead show a "You are now inactive in chat, click here to be active again" message, after you click on it the ajax request will continue.


Isn't google chat (chat from the gmail web interface) done using ajax?
aka Siyko
tofucake
Profile Blog Joined October 2009
Hyrule19173 Posts
July 24 2013 20:44 GMT
#6560
On July 25 2013 05:40 Yoshi- wrote:
Show nested quote +
On July 25 2013 05:05 fdsdfg wrote:
On July 25 2013 05:11 Yoshi- wrote:
On July 25 2013 05:05 fdsdfg wrote:
On July 25 2013 04:57 Yoshi- wrote:
On July 25 2013 04:50 fdsdfg wrote:
I'm a java programmer by trade. For the past couple months, I've been working on my own project using PHP and Javascript with AJAX. It's going really well, but there are a lot of things that every commercial site has solved in PHP (like sessions timing out from the server) that I need to implement.

Is there a source online for a lot of these basic functions? I can find so much reference for Javascript and Jquery, but so little for PHP.

http://php.net , which is maybe the best documentation of a language out there.
But I assume that you already know that site, could you maybe describe your problem further.
From what I understand you have e.g. a login system and you don't want that the user gets logged out, after the seesions has timed out.
Thats normally solved by using cookies to recreate the sessions after it has timed out.


There are a few things. Right now the session never times out, if I stay on a page forever, my client keeps sending AJAX to the server and getting a reply. He appears in 'users online' for days. I want his session terminated and his client redirected to the login page.

Same for a user who logs onto the site, closes the tab, and leaves his window open. When you open a new window, you are still logged in - I would like to see 'your session has timed out'.

It's easy to do this in theory - build a simple timestamp and kill the session if he tries to do something after it has expired. But the web industry has been doing this for a decade in pretty much the same way - it seems there really should be robust implementations that have been refined and optimized that I can leverage instead of reinventing.

I could say the same about a chat room, registering a user, etc. I feel like I'm adding every new feature like it's a school project instead of having some reference toward what is a correct, robust implementation.


Well, is there even any sense to keep sending AJAX request, that is not only insanely inefficient, also apparently quite useless?
You could just say that it will only send a limited amount of requests.


That comes from a chat interface - you have a chat room open and you're sending AJAX to the server to find out if there's any new messages or any new people in the chat lobby.

Also within the game (it's a turn-based game), you're polling the server to see if your opponent has submitted their turn yet.

These AJAX queries serve a distinct function, but when the user is away and has happened to leave his window open, they do not serve a function. I need to time him out.

Now I can write something that will time him out, but like I said, I want to do it in a clean and correct way. The industry has been doing this for a long time, so I'm sure the information is out there on the correct way to do something like this.

There isn't really a proper way to do this, as the proper way to write a chat does not include either php or AJAX. That is where you should use WebSockets, which PHP doesn't support.

And if you still want to do this the proper way, it would be that if a user hasn't used the chat in the last minutes, you would stop doing Ajax request and instead show a "You are now inactive in chat, click here to be active again" message, after you click on it the ajax request will continue.
There are a bunch of php websocket libraries. socketo.me is probably the most well known. And even without that PHP still supports sockets (I made a bnet bot in php+ajax almost a decade ago).
Liquipediaasante sana squash banana
Prev 1 326 327 328 329 330 1032 Next
Please log in or register to reply.
Live Events Refresh
Replay Cast
00:00
WardiTV Mondays #62
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 215
trigger 55
SortOf 37
StarCraft: Brood War
Stork 646
Tasteless 170
Shine 161
Bale 35
NaDa 30
Icarus 9
Dota 2
NeuroSwarm134
febbydoto0
League of Legends
JimRising 655
Other Games
summit1g11808
shahzam475
WinterStarcraft467
C9.Mang0364
ViBE145
Mew2King82
Organizations
Other Games
gamesdonequick951
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH81
• practicex 22
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki12
• Diggity4
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo1219
Upcoming Events
The PondCast
4h 25m
OSC
10h 25m
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
18h 25m
Korean StarCraft League
1d 21h
CranKy Ducklings
2 days
WardiTV 2025
2 days
SC Evo League
2 days
BSL 21
2 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
2 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
3 days
[ Show More ]
WardiTV 2025
3 days
OSC
3 days
BSL 21
3 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
4 days
Wardi Open
4 days
StarCraft2.fi
4 days
Monday Night Weeklies
4 days
Replay Cast
4 days
WardiTV 2025
5 days
StarCraft2.fi
5 days
PiGosaur Monday
5 days
StarCraft2.fi
6 days
Tenacious Turtle Tussle
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.