• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 09:27
CEST 15:27
KST 22:27
  • 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
[ASL21] Ro16 Preview Pt1: Fresh Flow5[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy21ByuL: The Forgotten Master of ZvT30
Community News
MaNa leaves Team Liquid13$5,000 WardiTV TLMC tournament - Presented by Monster Energy5GSL CK: More events planned pending crowdfunding7Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win0[BSL22] RO32 Group Stage5
StarCraft 2
General
MaNa leaves Team Liquid Team Liquid Map Contest #22 - Presented by Monster Energy Quebec Clan still alive ? BGE Stara Zagora 2026 cancelled Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament $5,000 WardiTV TLMC tournament - Presented by Monster Energy RSL Revival: Season 5 - Qualifiers and Main Event GSL CK: More events planned pending crowdfunding Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 521 Memorable Boss The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power
Brood War
General
ASL21 General Discussion [ASL21] Ro16 Preview Pt1: Fresh Flow BGH Auto Balance -> http://bghmmr.eu/ JD's Ro24 review The Korean Terminology Thread
Tourneys
[ASL21] Ro16 Group A Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues [ASL21] Ro24 Group F
Strategy
Any training maps people recommend? Fighting Spirit mining rates Muta micro map competition What's the deal with APM & what's its true value
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Battle Aces/David Kim RTS Megathread General RTS Discussion Thread Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
Canadian Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread US Politics Mega-thread The China Politics Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
lurker extra damage testi…
StaticNine
How Streamers Inspire Gamers…
TrAiDoS
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2168 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
Hyrule19202 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
Hyrule19202 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
Hyrule19202 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
Hyrule19202 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
Wardi Open
11:00
#82
WardiTV679
OGKoka 365
Rex107
Liquipedia
Afreeca Starleague
10:00
Ro16 Group A
Soma vs YSC
Sharp vs sSak
Afreeca ASL 12767
StarCastTV_EN344
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
OGKoka 365
Lowko301
ProTech138
Rex 107
Codebar 20
StarCraft: Brood War
Sea 24274
Calm 15079
Bisu 7769
Jaedong 3062
Horang2 1897
BeSt 1044
EffOrt 848
Mini 650
Stork 559
firebathero 530
[ Show more ]
Light 438
Zeus 363
Pusan 358
actioN 339
ZerO 228
Soulkey 220
Hyun 164
Larva 148
Mind 88
Rush 72
Killer 70
Barracks 51
ToSsGirL 50
yabsab 36
zelot 25
Nal_rA 19
soO 18
Terrorterran 18
Movie 17
Hm[arnc] 16
Shinee 16
[sc1f]eonzerg 15
GoRush 14
Bale 12
Sacsri 12
Noble 12
IntoTheRainbow 12
scan(afreeca) 11
SilentControl 9
Icarus 8
Dota 2
qojqva1064
syndereN42
febbydoto11
Counter-Strike
olofmeister3194
fl0m2176
x6flipin414
byalli385
markeloff86
Other Games
singsing1733
B2W.Neo1047
hiko676
crisheroes298
Pyrionflax151
Liquid`LucifroN98
Liquid`VortiX88
QueenE78
Mew2King49
KnowMe47
RotterdaM29
Organizations
Other Games
BasetradeTV778
Counter-Strike
PGL302
StarCraft: Brood War
UltimateBattle 302
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• StrangeGG 56
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis2899
• TFBlade1533
• Stunt580
Upcoming Events
Monday Night Weeklies
2h 33m
OSC
10h 33m
Afreeca Starleague
20h 33m
Snow vs PianO
hero vs Rain
WardiTV Map Contest Tou…
20h 33m
GSL
22h 33m
PiGosaur Cup
1d 10h
CranKy Ducklings
1d 19h
Kung Fu Cup
1d 22h
Replay Cast
2 days
The PondCast
2 days
[ Show More ]
WardiTV Map Contest Tou…
2 days
Replay Cast
3 days
Escore
3 days
WardiTV Map Contest Tou…
3 days
Korean StarCraft League
4 days
CranKy Ducklings
4 days
WardiTV Map Contest Tou…
4 days
IPSL
5 days
WolFix vs nOmaD
dxtr13 vs Razz
BSL
5 days
Sparkling Tuna Cup
5 days
WardiTV Map Contest Tou…
5 days
Ladder Legends
6 days
BSL
6 days
IPSL
6 days
JDConan vs TBD
Aegong vs rasowy
Replay Cast
6 days
Replay Cast
6 days
Wardi Open
6 days
Afreeca Starleague
6 days
Bisu vs Ample
Jaedong vs Flash
Liquipedia Results

Completed

Escore Tournament S2: W2
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
StarCraft2 Community Team League 2026 Spring
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W3
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
RSL Revival: Season 5
WardiTV TLMC #16
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
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 © 2026 TLnet. All Rights Reserved.