Jump to content

LLLLLLL

Members
  • Posts

    306
  • Joined

  • Last visited

Posts posted by LLLLLLL

  1. Thousands of strings?  And how do you make sure that they are current?  What happens when visitor A arrives and the current set of the strings is read and stored.  Every body after that sees the same data.  But what about when you must alter some strings - how do the users see that updated info without you destroying the current copy of the settings?

     

    Really?  "Thousands of strings"?  And you don't have a paid consultant working on this design for you?

     

    I should clarify that it's hundreds of strings, but with multiple languages. So there are like 600 identifiers, for example "General.Cancel" represents the text "Cancel" in English, and whatever its counterpart in Russian, French, German, Chinese, etc. So it's thousands once all the languages are considered.

     

    I'm not sure why you're asking about altering strings; you just update the cache as you would with any application, simple stuff. Not sure why I'd need to pay someone to work on something here. This design has been tried and tested in global POS applications for years with no issues.

     

    I guess the bottom line is that I'll keep loading these and storing them in the session. It's only 600 rows. I was just hoping to load them once.

  2. I think you're misunderstanding my intention. When visitor A comes to the site, the session for that visitor loads up all the strings from the DB and stores them. No more DB calls for visitor A. When visitor B comes to the site, another DB call and storage in session. Visitor C, so on and so forth.

     

    But there are thousands of strings, and the load time isn't terribly slow but it could be faster. Why can't I...

    1. When visitor A comes, load the stuff from the DB and then store in $_SERVER or whatever
    2. Visitors B and C will read from that same cache

    It doesn't seem necessary to store things per-session if there's something more global that would cut down that time. But where is that storage?

  3. What's the best way to cache things on the server? I've found some SetEnv things but this all seems to be a single key/value.

     

    I'd like to cache an array of things that I can access later. Right now it's cached in $_SESSION which is fine, but still there's overhead on every first-time visitor to a site. Is there a way to add something to $_SERVER or elsewhere that ALL visitors to a website will ultimately be able to access?

     

    I guess I want something like web.config in C#, where the first time a page is visited, the "app starts", as it were, and those things are now in cache on the server.

     

    What's the best way to do this?

  4. The situation is that I have a large string with some identifiers to say "replace me" with something else. My goal is to replace the values, but if one replacement includes one of the other keys, I don't want to replace it.

     

    For example:

    <?php
    $str = 'some blob ~abc~ followed by ~def~';
    
    $arr_orig = array(
    	'~abc~',
    	'~def~'
    );
    
    $arr_new  = array(
    	'value~def~',
    	'blah'
    );
    
    echo str_replace( $arr_orig, $arr_new, $str );
    ?>
    

    This will echo:

    some blob valueblah followed by blah

     

    But that's not what I'm trying to accomplish. Basically, I want ~abc~ to be replaced with the literal: value~def~ and for the ~def~ that happens to be part of that string to NOT be replaced. I hope what I'm asking is clear. Basically, preg_replace/str_replace with arrays seems no different than just doing a FOR loop and replacing ~abc~ and then ~def~. But that's not what I need.

     

    I'm hoping that if ~abc~ is replaced with text that happens to be another identifier -- ~def~, ~xyz~, whatever -- that this already replaced text is not again replaced. Is there a built-in function to do something like this? If not, should I just parse the whole string and count characters or something? Seems like a pain (and slow!)

  5. First, most of the web requires javascript these days. Anyone trying to use this web app knows JS is required and they cannot do it without JS. So I'm fine leaving the login page as is. (And it's ridiculous to say he's surprised this works in any browser; it works in all browsers; it's simple, lightweight code.)

     

    As I described initially, I've wrapped the whole thing in a form tag. I've given all the inputs names. I've added a submit button. The form does return false... it doesn't matter. FF does see all these hacks and it recognizes it's a username/password form and prompts. Chrome, Safari, IE... they don't.

  6. No, I was looking for intelligent answers. StackExchange and some others have ideas but those don't work. I go to PHP Freaks to see who has actually used something that worked. Since you're unable to answer that question, your answers here are completely worthless. Please do not reply unless you can actually answer what was being asked

  7. I didn't include the code because I'm looking for what others have done. FWIW, here's the original AJAX-only code. As stated, I can make some alterations to get FF working (form tags, submit input, names on inputs) but other browsers don't work with that.

    		<script type="text/javascript">
    			
    			function do_login() {
    				$( "a" ).text( "Logging in..." );
    				$( "#message" ).hide();
    				$( "a" ).addClass( "disabled_opacity" );
    			
    				// send the request
    				$.post( "handlers/login.php", {
    					username : $( "#username" ).val(),
    					password : $( "#password" ).val()
    					}, function ( data ) {	
    						if ( data == 'true' ) {
    							window.location.href = "index.php";
    							return;
    						}	
    						
    						restore_login( "Invalid username or password." );
    					}
    				)
    				.error( function() { 
    					restore_login( 'Error encountered.' );
    				});
    			}
    			
    			function restore_login( text ) {
    				$( "a" ).text( "Log In" );
    				$( "#message" ).text( text );
    				$( "#message" ).show();	
    				$( "a" ).removeClass( "disabled_opacity" );
    			}
    		</script>
    	
    	<body>	
    			<div id="box">
    				<label for="username">Username:</label>
    				<input type="text" id="username">
    		
    				<label for="password">Password:</label>
    				<input type="password" id="password">							
    		
    				<a href="javascript:void(0);" onclick="do_login();">Log In</a>				
    				<div id="message"></div>
    			</div>
    
    
  8. I have a basic username/password form that uses AJAX to login:

    1. Submit the two values in an AJAX request
    2. If the values are correct, sets session variable for the user and returns success
    3. Client receives success and redirects to the start page.

    All of this is basic stuff, works fine. But now some customers say they want the form to remember passwords. I've done some basic work:

    • Added FORM tags around these input fields. Returns false
    • Gave the input fields NAME attributes

    This seems to make Firefox prompt to remember the password. But I'm having no luck with Chrome, IE, or Safari.

     

    I've googled extensively and there are basically two or three solutions, but I can't get anything to work on these other browsers. It's getting to be quite frustrating. I'm thinking of abandoning this AJAX form and just going to crappy old POST.

     

    What are you using for AJAX login pages? Are passwords remembered by the browser? How are you doing it?

  9. I'm wondering the best way to handle validation messages for blind people, or sight-impaired.

     

    In my application, the situation on a save with errors is:

    1. User clicks save
    2. AJAX call goes to save the record; wait bar appears on the page's status bar
    3. Error is returned. The wait bar changes to show "Error on save"
    4. Below the status bar, each field name is listed with the appropriate error message. ("Name - Cannot be blank" or whatever)
    5. Within the fields themselves, the same message is shown again. (Next to the "Name" label on the page, "cannot be blank" would show up.)

    This functionality is great for sighted people. But for non-sighted, I'm not sure exactly how to handle it. Should an error become "selected" or something? I mean, it's just a div. I don't really have the answer.

     

    I posted this in general HTML but it could frankly be AJAX or JS or something. I think HTML is probably the most correct.

  10. (As usual, this is a different type of question; if it's in the wrong forum please move it.)

     

    I own two domains: example.com and example.ru. These sites are essentially mirrors of each other but they provide better geo-awareness than having only one site.

     

    If I have files that I need to copy from example.com to example.ru on a semi-regular basis, how do I do this programmatically? Obviously I have the login credentials, nameservers, IP addresses, and whatever else of both servers. What's the code to accomplish this? I have not ever tried to send files from one server to another. It certainly would be better than FTPing the files down to a local machine and then FTPing back up to the other server.

     

    Thanks...

  11. This forum is "programming theory" so I assume this is the most appropriate place to put this. (Admins or someone feel free to move this if the location is incorrect.)

     

    The issue is that a site, example.com, loads slowly to international users because of its US-based host. So the thought is to buy...

    example.co.uk

    example.in

    example.br

    example.cn

    ... and host those domains on servers near the respective location. Or something like this.

     

    So the question is... what's the best way to handle users getting to the right site from the right location? There are google results out there that sort of address this question, but I'm wondering what has worked for others, or what you've heard of working.

     

    I think the solution will be to install a package on my server that can tell where the user is from, and to either redirect the user outright or to let them click a link to go to a more "local" version of the website. 

     

    Thoughts? Have you handled this? Howso?

     

    Thanks

  12. So in the code above, there's a user-configured option $download_attempts_allowed. This person had it set to 1, and most people set it to 2.  Because each Android request to download is two calls:

    1) One call is made (now that's one attempt)

    2) Another call is made  (now the attempt is too many, so it wants to return to the other page; everything is confused which is why the new header request probably overrides the first one or something).

     

    So by changing this person's configuration to allow two calls, the second call works. It's a hack. What I'll have to do for real is to disallow an attempt when there's already one file downloading, or to check the timestamp on when it started. But for right now I can change this person's attempts allowed to 2 and there's no issue. 

     

    On iOS it appears to be similar, but no one has yet to determine if there's a good way to download mp3s onto iOS, because Apple wants people to use iTunes only. Some people have issues with mp3s on Apple, others don't. I'm not sure what the answer is there but it's not for this forum.

  13. Well done, SocialCloud, what you've posted there definitely is the answer on Android. I am having someone else verify iOS right now. Basically the fix is to bump up the number of retry attempts that the user has configured. (It was 1; should change to 2.) Seems like a hack...

     

    But as expected, it's not a code issue. Thanks for finding that. I'll mark something solved as soon as I know about iOS.

  14. https://code.google.com/p/android/issues/detail?id=1978

     

    As stated about half way down, it is an intended part of the android system. It has nothing to do with not working on one server. Not sure why you are not experiencing it on another server, but it is intended. You will have to rewrite your code to comply with android.

    I don't think this has anything to do with the current topic.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.