• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 01:23
CEST 07:23
KST 14:23
  • 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
[ASL22] Ro24 Preview: Siren's Call8[ASL22] Ro24 Preview: Summer's End9Serral wins HomeStory Cup 2915Serral wins Maestros of the Game 244ByuL, and the Limitations of Standard Play3
Community News
Stellar Fest TWO the Moon (Dec 16-20)8Weekly Cups (August 24-30): Patches' balance mod takes over2New 3v3 BGH Ladder (and more) on ShieldBattery!40Weekly Cups (August 17-23): Zerg dominate the week6Weekly Cups (August 10-16): SHIN doubles4
StarCraft 2
General
Weekly Cups (August 10-16): SHIN doubles Nexon wins bid to develop StarCraft IP content, distribute Overwatch mobile game SC4ALL II: SC2 Player Announcement 6/8 - Maru Weekly Cups (August 24-30): Patches' balance mod takes over How would you feel about frequent/monthly balance patches for SC2?
Tourneys
2026 GSTL Announcement Stellar Fest TWO the Moon (Dec 16-20) PIG STY FESTIVAL 8.0! (13 - 23 August) Sparkling Tuna Cup - Weekly Open Tournament IntoTheTV X SOOP SC2 League : Weekly & Monthly
Strategy
[G] Having the right mentality to improve
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
Mutation # 541 Binary Choice The PondCast: SC2 News & Results Mutation # 540 Dodge This Mutation # 539 Thunder Dome
Brood War
General
BW General Discussion ASL22 General Discussion BGH Auto Balance -> http://bghmmr.eu/ [Personal Project Share] Terran Defense v0.60 XUN appreciation thread
Tourneys
[Megathread] Daily Proleagues BSL LAN Party - Kraków 29-30 August - OPEN SIGNUPS [ASL22] Ro24 Group F Small VOD Thread 2.0
Strategy
Replay Review Process - What do you do? Game Theory for Starcraft Odyssey Mineral Stack Saturation Fighting Spirit mining rates
Other Games
General Games
[Maplestory Hardcore] Let's Play~!! General RTS Discussion Thread Stratus: Battle for the sky now on steam Early acc Nintendo Switch Thread Stormgate/Frost Giant Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank TL Mafia Community Thread NeO.D_StephenKing vs This Guy From 1 Million Dance
Community
General
US Politics Mega-thread Is a Spice Mill Worth It for Everyday Cooking? Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Canadian Politics Mega-thread
Fan Clubs
MarineLorD Fan Club The Creator Fan Club The ShoWTimE Fan Club
Media & Entertainment
Movie Discussion! Anime Discussion Thread
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023 NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Northern Ireland Global Starcraft
Blogs
Regacy Esports: The Bh…
regacyesports
Violent Games and Crime Rate…
TrAiDoS
LOCKPICKING NOOB
LUCKY_NOOB
Cathedral Of CS And NY pizza a…
FuDDx
Please support my new stand…
Peanutsc
Customize Sidebar...

Website Feedback

Closed Threads



Active: 7077 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
Hyrule19252 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
Hyrule19252 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
Hyrule19252 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
Hyrule19252 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
2026 GSTL: Main Stage Day 4
CranKy Ducklings152
Discussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech126
SortOf 74
EnDerr 1
StarCraft: Brood War
Rain 2602
GuemChi 1865
sSak 93
PianO 65
Noble 17
Icarus 6
Dota 2
NeuroSwarm178
League of Legends
JimRising 718
Counter-Strike
Coldzera 1178
Super Smash Bros
hungrybox482
Other Games
summit1g4845
XaKoH 311
C9.Mang0175
Livibee127
[ Show 12 non-featured ]
StarCraft 2
• practicex 10
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• RayReign 8
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota2751
League of Legends
• Lourlo1198
Upcoming Events
The PondCast
4h 37m
OSC
17h 7m
IntoTheTV X SOOP
1d 5h
CranKy Ducklings
2 days
Sparkling Tuna Cup
3 days
OSC
3 days
Shopify Rebellion Sundays
3 days
Mixu vs TBD
Spirit vs TBD
Clem vs TBD
Afreeca Starleague
4 days
Soma vs Shuttle
BeSt vs Rush
WardiTV Weekly
4 days
Afreeca Starleague
5 days
Leta vs ggaemo
Jaedong vs Queen
[ Show More ]
GSL
5 days
PiGosaur Cup
5 days
Kung Fu Cup
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-09-02
PiG Sty Festival 8.0
Light Tournament 2026

Ongoing

KCM Race Survival 2026 Season 3
K-JUNGMAN
ASL Season 22
Super Anchor Qualifying S3
CSL 2026 AUTUMN (S22)
RSL Revival: Season 6
Calamity Invitational
Big Dog Cup 2026 Div 1
BLAST Open Fall 2026
Esports World Cup 2026
Esports World Cup 2026: LCQ
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026

Upcoming

Acropolis #5
Acropolis #5 - TRS
Escore Tournament S3: King of Kings
Blizzard Classic Cup 2026
Acropolis #5 - GSA
Acropolis #5 - GSB
Acropolis #5 - GSC
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
BLAST Rivals Fall 2026
IEM Beijing 2026
Stake Ranked Episode 5
PGL Masters Bucharest 2026
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
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.