• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 23:02
CEST 05:02
KST 12:02
  • 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
Serral wins HomeStory Cup 2910Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
Reynor: GSL Loss Wasn't About Preparation Format9[IPSL] Spring 2026 Grand Finals - This Weekend!0Weekly Cups (July 6 - 12): Protoss strike back5BSL Season 22 Full Overview & Conclusion8BSL Season 22 Full Overview & Conclusion8
StarCraft 2
General
Weekly Cups (July 6 - 12): Protoss strike back Reynor: GSL Loss Wasn't About Preparation Format Co-op Commander Guide: Kerrigan Serral wins HomeStory Cup 29 Is the larve respawn broken?
Tourneys
GSL CK #5 Race War WardiTV Summer Cup 2026 RSL Revival: Season 6 - Qualifiers and Main Event HomeStory Cup 29 Vespene Cup #1 — $300+ USD, July 10
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together Mutation # 532 Nuclear Family
Brood War
General
Pros Debate: Zerg Unfairly Nerfed? (ASL S22 map) screpdb: new Starcraft reporting tool BSL Season 22 Full Overview & Conclusion BGH Auto Balance -> http://bghmmr.eu/ ASL 22 Proposed Map Pool
Tourneys
[Megathread] Daily Proleagues [IPSL] Spring 2026 Grand Finals - This Weekend! [ASL22] Wildcard Qualifier IPSL Spring 2026 Top 4!
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Creating a full chart of Zerg builds Relatively freeroll strategies
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Stormgate/Frost Giant Megathread Path of Exile Summer Games Done Quick 2026!
Dota 2
Looking for a Dota Mentor 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
TL Mafia
NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread TL Mafia Power Rank Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread UK Politics Mega-thread YouTube Thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion! Series you have seen recently...
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Tennis[sport] Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
Simple Questions Simple Answers FPS when play League Of Legend on laptop How to clean a TTe Thermaltake keyboard?
TL Community
The Automated Ban List
Blogs
The Experiences We Want and …
TrAiDoS
An Exploration of th…
waywardstrategy
Gauntlet SC2: A Retrospectiv…
Ctone23
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 7592 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
Hyrule19228 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
Hyrule19228 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
Hyrule19228 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
Hyrule19228 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
PiGosaur Cup
00:00
#90
CranKy Ducklings198
davetesta61
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft615
Nina 150
RuFF_SC2 136
FoxeR 68
StarCraft: Brood War
Rain 3970
GuemChi 2769
NaDa 59
Counter-Strike
summit1g8287
tarik_tv4105
taco 288
minikerr30
Super Smash Bros
hungrybox553
Other Games
C9.Mang0413
ViBE234
Maynarde152
XaKoH 111
CosmosSc2 18
Organizations
Other Games
gamesdonequick2466
StarCraft: Brood War
lovetv 22
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 15 non-featured ]
StarCraft 2
• EnkiAlexander 58
• CranKy Ducklings SOOP43
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Scarra2924
• Lourlo1083
• Stunt250
Upcoming Events
The PondCast
6h 59m
Kung Fu Cup
7h 59m
Replay Cast
1d 5h
CrankTV Team League
1d 7h
Replay Cast
2 days
CrankTV Team League
2 days
Replay Cast
2 days
RSL Revival
3 days
Clem vs Lambo
Scarlett vs Cure
CranKy Ducklings
3 days
IPSL
3 days
Dragon vs Hawk
[ Show More ]
RSL Revival
4 days
Classic vs Trap
herO vs SHIN
Sparkling Tuna Cup
4 days
IPSL
4 days
Bonyth vs Ret
WardiTV Weekly
5 days
Monday Night Weeklies
5 days
PiGosaur Cup
6 days
Liquipedia Results

Completed

YSL S3
HSC XXIX
Eternal Conflict S2 E2

Ongoing

IPSL Spring 2026
Acropolis #4
CSL 2026 Summer (S21)
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
Stake Ranked Episode 3
XSE Pro League 2026
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

Upcoming

Escore Tournament S3: W3
ASL S22 SEASON OPEN Day 1
Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
CSLAN 4
Blizzard Classic Cup 2026
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
Eternal Conflict S2 E3
Logitech G Connect 2026
StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
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.