Jump to content

davo

Members
  • Posts

    283
  • Joined

  • Last visited

Everything posted by davo

  1. This module has settled in well to my live site. However, the client often presents the site 'offline'. To do this the client has made a copy of the site using httptrack. It's not my ideal solution but suits the client well. The problem is when the site tries to load a page with the map marker displayed they get this error: "Markup Google map error please add the maps.googleapis.com in your document head". Is there a possible way around this? Any suggestions welcome....
  2. davo

    Non uk test hrlp

    I have a fun project that I've been putting together, the idea is long term it collects some data about visitors and collates this against members to help them decide where to aim their efforts at! It sounds a bit silly but may help is understand some human behaviour. Really, I just wanted some testing help. I'd ideally like someone from a country other than uk to visit site, create an account (doesn't have to be real details!) and click on a few images and then let me know Whivh ones we're clicked on.., http://abandoman.co.uk It should collect some ip based country data which I hope to then work on. Any help appreciated. It's just a bit of fun with the aim of some knowledge and help everyone out.
  3. I don't know how you did it... but it all seems to work now! Thank you.
  4. So this is what i tried to use the session variable in the module settings: Welcome {first_name} {last_name} Your photo has been submitted! Login to judge yourself against others. Please login in at: http://abandoman.co.uk/login/{name}/{pass}{$session->password} the email was just blank for both pass and session->password parts. don't worry too much, I know what i'm trying to get it to do is a bit beyond it's original purpose
  5. Unfortunately I don't know the exact code as I use form builder to match fields into the user template, but I'll walk you through the process.... I have a template that loads the module on the page and then loads the form in form builder like this: <?php $modules->get("EmailNewUser"); echo $forms->embed('new-user'); ?> Then, in the form there is a field called title which maps to 'name' in a user page. There is also a password field which also maps to 'password'. The new user is created. In the form builder include file i have the following code: <?php wire()->addHookAfter('FormBuilderProcessor::formSubmitSuccess', function($event) { $form = $event->arguments(0); if($form->name != 'new-user') return; $field = $form->get('password'); $value = $field->attr('value'); wire('session')->set('password', $value); $field = $form->get('title'); $value = $field->attr('value'); wire('session')->set('title', $value); $field = $form->get('dob'); $value = $field->attr('value'); wire('session')->set('dob', $value); $field = $form->get('email'); $value = $field->attr('value'); wire('session')->set('email', $value); }); The above code helps me then store the newly created variables as session variables so I can use them on the following page. On successful page creation (user) , the user is redirections to my acc_success page which consists of the following:: <?php $dob = $session->dob; $email = $session->email; $new_user = $pages->get("email=$email"); $password = $session->password; $username = $new_user->name; if($session->login($username, $password)){ $session->redirect("/");} echo "<p>Thats great. Now just click below to log in and help judge - <i>its ok, its for science!</i></p><p><a href='/login/{$new_user->name}/{$password}'>Log in {$new_user->name} with the password {$password}</a></P>"; ?> This should look for a user matching the email address supplied and look up the user name and use the previously supplied password to log the user in. The odd behaviour i'm suffering is that if the create user password is ticked, it over rides the user created password and the automatic login fails. I check the email sent and it references a newly created password. If the create password is not ticked then the automatic login succeeds but of course no password is supplied by the module. Suddenly typing this out it makes more sense! I guess the situation I want to get to is for the module to only to create a password if it were left blank, but also to be able to include the password supplied by by the session variable.... I guess that's my next move to try.
  6. I'm sure that a couple of versions ago, it was set to only create a password if one had not already been set. Now, if I have the 'create password' checked it's creating one regardless, meaning my login mechanism isn't working as it's immediately been over written by the module. If I uncheck the field, the password sent in the email is blank. I assumed you'd changed something a version or two ago. I was sure it said in the text next to that field a password would only be created if the field was blank?
  7. Have you changed in the latest update to force a password even if it is not blank?
  8. I've just foolishly made two changes, and although it now works, I don't know which it was! First I put this on the page that loads the form: $modules->get("EmailNewUser"); Second I refreshed the module And now it works!
  9. Could that be the issue you think? form builder publishes the form as a new page rather than calling a hook to make a new user?
  10. Ah! I don't use a hook for that purpose. I let form builder process the form and publish as a new user 'user page'.
  11. That change made sense, but unfortunately didn't work. Looks like this: { "title": "Email New User", "summary": "Email new user their account details, and optionally automatically generate a password for them.", "version": 14, "author": "Adrian Jones", "autoload": true, "requires": "ProcessWire>=2.4.3", "icon": "envelope-o" } I'm sure this was working a while ago, but now I'm starting to doubt myself. Thanks for your help with this. Any ideas? Maybe I'll have to look again with a fresh head from another angle.
  12. I've been testing a bit further and have noticed some anomalies which you may be able to advise on. The module works great when creating a user from the back end, but when I create a user using form builder 2.4 dev to create a page user details, the email fails to send. I'm using the following hook to push the password and title into a session variable for later user: wire()->addHookAfter('FormBuilderProcessor::formSubmitSuccess', function($event) { $form = $event->arguments(0); if($form->name != 'new-user') return; $field = $form->get('password'); $value = $field->attr('value'); wire('session')->set('password', $value); $field = $form->get('title'); $value = $field->attr('value'); wire('session')->set('title', $value); }); I'm sure that prior 'email new user' was sending out an email on creation of a user from the front end. The things that have changed are: I've added the hook upgraded for builder from 2.2 to 2.4 dev upgraded the module Could any of these thing have affected it's behaviour?
  13. That's great. Logs in first time. I don't need nca proof passwords for this site and if it got sent or intercepted by email I don't think there's too much damage that could be done anyway. Awesome module
  14. There is something you could explain though. I'm still working on an easy login process for people so i tried putting the following in the welcome email: Welcome {first_name} {last_name} Please login in at: http://abandoman.co.uk/login/{name}/{pass} Username: {name} Password: {pass} If you have any questions, please email us at: {fromEmail} I enable url segments and put the following in my login page: if($input->urlSegment(1) && $input->urlSegment(2)) { $username = $sanitizer->username($input->urlSegment(1)); $pass = $input->urlSegment(2); $u = $session->login($username, $pass); if ($u && $u->id) { // user is logged in, get rid of tmp_pass $u->of(false); $u->tmp_pass = ''; $u->save(); } $session->redirect("/"); } Works great if you have a simple user name and password, but with a system generated one it throws a page not found error. I'm assuming that's because of all the stars and @s in the password. Is there anyway around this?
  15. I'm trying to get back to this again now. It's not currently sending emails for new users. Do you think it would be a good idea to in the module settings to add a 'send test email' button?
  16. That works - thank you. but just to clarify so i understand what i'm doing, "if($u && $u->id)" checks to see if the variable $u exists AND $u->id exists?
  17. Soma, I thought I had this sorted but I'm still getting the same behaviour. I moved the session redirect to after the login lines of code hoping that this time the user would have been logged in and trigger the redirection. Can you advise what I'm doing wrong please. ~David <?php if($input->post->username && $input->post->pass) { $username = $sanitizer->username($input->post->username); $pass = $input->post->pass; $u = $users->get($username); if($u->id && $u->tmp_pass && $u->tmp_pass === $pass) { // user logging in with tmp_pass, so change it to be their real pass $u->of(false); $u->pass = $u->tmp_pass; $u->save(); $u->of(true); } // this part actually logs the user in $u = $session->login($username, $pass); if($u) { // user is logged in, get rid of tmp_pass $u->of(false); $u->tmp_pass = ''; $u->save(); } } // redirect if the user is login is successful which should have happened above if($user->isLoggedin()) { $message = "good!"; $session->redirect("/processwire"); } // present the login form $headline = $input->post->username ? "$message Login failed {$input->post->username} " : "$message Please login {$input->post->username} "; $page->body = " <h2>$headline</h2> <form role='form' action='./' method='post'> <div class='form-group'> <label for='username'>Username </label> <input type='text' class='form-control' style='border-radius:0px' id='username' placeholder='username' name='username'> </div> <div class='form-group'> <label for='pass'>Password</label> <input type='password' class='form-control' style='border-radius:0px' id='pass' placeholder='Password' name='pass'> </div> <button type='submit' class='btn btn-sm btn-default'>Sign in</button> </form> <p><a href='/reset-pass/'>Forgot your password?</a></p> <p><a href='/forms/registration/'>Don't yet have a login?</a></p> "; $page->editor = "Login to view content editor"; include("./main.php"); // main markup template
  18. Of course! Thank you. I was showing the login and redirect test before the login was actually taking place. Hence they were logged in by the time of the end of parsing the whole page but not at test time. Which also explains why when I then visited a different page I did appear to be logged in (because by then they were!) Thank you for helping me see this.
  19. I can't understand what is wrong with my login template. It's the same one I've used before and not had issues. when a user submits the form back to itself I get the 'login failed' message and $message is equal to 'not logged in', however, other parts of the experience would indicate the use IS logged in. If a user were to submit the form a second time, the page loads correctly and directs them to /contest. I've been banging my head for three days with this and still can't work out the logic that is wrong with it. any help much appreciated. <?php if($user->isLoggedin()) { $mydash = "/contest"; $session->redirect($mydash); $message = "logged in"; }else{ $message = "not logged in"; if($input->post->username && $input->post->pass) { $username = $sanitizer->username($input->post->username); $pass = $input->post->pass; $u = $users->get($username); if($u->id && $u->tmp_pass && $u->tmp_pass === $pass) { // user logging in with tmp_pass, so change it to be their real pass $u->of(false); $u->pass = $u->tmp_pass; $u->save(); $u->of(true); } $u = $session->login($username, $pass); if($u) { // user is logged in, get rid of tmp_pass $u->of(false); $u->tmp_pass = ''; $u->save(); } } // present the login form $headline = $input->post->username ? "$message Login failed {$input->post->username} " : "$message Please login {$input->post->username} "; $page->body = " <h2>$headline</h2> <form role='form' action='./' method='post'> <div class='form-group'> <label for='username'>Username </label> <input type='text' class='form-control' style='border-radius:0px' id='username' placeholder='username' name='username'> </div> <div class='form-group'> <label for='pass'>Password</label> <input type='password' class='form-control' style='border-radius:0px' id='pass' placeholder='Password' name='pass'> </div> <button type='submit' class='btn btn-sm btn-default'>Sign in</button> </form> <p><a href='/reset-pass/'>Forgot your password?</a></p> <p><a href='/forms/registration/'>Don't yet have a login?</a></p> "; $page->editor = "Login to view content editor"; include("./main.php"); // main markup template }
  20. I'm making my 'just for fun' site to compare two portraits and the user selects the better looking one. I'm looking for ideas around security. The following code selects two users and the user clicks on one of them, submitting it back to the current page which then updates the scores by 1 point. One issue that i've come across is, if the just refreshes the page then the same score is updated again... meaning once you've found an image that you want to support you keep hitting refresh. Any simple ideas how I can prevent this? <?php $p1 = $_SESSION['p1']; //load up the previous person 1 $p2 = $_SESSION['p2']; //load up the previous person 2 $winner = $input->urlSegment1; //winner is the first segment $person1 = $input->urlSegment2; //person 1 is the 2nd segment $person2 = $input->urlSegment3; //person 2 is the 3rd segment if (($winner !=="")&&($winner == $p1 || $p2)){ //if the winner value is not blank and it is also equal to p1 or p2 $update_user = $pages->get("id=$winner"); //find the winning user by id $update_user->score = ++$update_user->score; //add 1 to the score $update_user->of(false); //something about entities $update_user->save(); //save it all up if ($person1 !== $winner){ //ooh.. time to update the loser $update_user = $pages->get("id=$person1"); $update_user->score = --$update_user->score; $update_user->of(false); $update_user->save(); } if ($person2 !== $winner){ //ooh.. time to update the loser $update_user = $pages->get("id=$person2"); $update_user->score = --$update_user->score; $update_user->of(false); $update_user->save(); } //let us find some detail about the current user $user_gender = $user->Gender; $user_ethnicity = $user->ethnicity; if($user->isLoggedin()) { $user_id = $user->id; }else{$user_id = $_COOKIE[id];} $user_country = $user->country; $user_sexual_preference = $user->sexual_preference; if($user->isLoggedin()) { $visits = wire('users')->get("$winner"); $visits->of(false); $visit = $visits->visiting_person_data->makeBlankItem(); $visit->date = date("Y-m-d H:i"); $visit->visitor_id = $user->id; $visit->gender = $user_gender; //used only for testing $visit->ethnicity = $user_ethnicity; //used only for testing $visit->country = $user_country; //used only for testing $visit->sexual_preference = $user_sexual_preference; //used only for testing $visits->visiting_person_data->add($visit); $visits->save("visiting_person_data"); } } //close the if winner set // echo "$result score = {$update_user->score}"; // time to make the new set of contestants $gender_array = $pages->find("parent=1016"); //this parent holds child pages to specify gender $gender_select = $gender_array->findRandom(1); //select the gender so we can compare like for like - its only fair // echo "$gender_select"; $contestantarray = $pages->find("template=user, profile_image>0, Gender=$gender_select, include=all"); //get all the users that have images and the gender matches the selection to compare like for like $contestants = $contestantarray->findRandom(2); //grab two random contestants $p1 = $contestants[0]; $p2 = $contestants[1]; // echo "p1 $p1 p2 $p2"; $_SESSION['p1'] = $p1; //send contestand 1 to the next page for security $_SESSION['p2'] = $p2; //send contestant 2 to the next page for security foreach ($contestants as $contestant) { $lineup = $contestant->profile_image; //create the contestant $thumb_contest = $lineup->size(200, 200); //create a thumbnail echo "<div class='col-md-3'><a href='/contest/{$contestant->id}/$contestants[0]/$contestants[1]'><img class='img-thumbnail' src='{$thumb_contest->url}'></a></div>" ; //output the thumbnail } ?>
  21. It was being defined on another page. I was trying to state if a user was logged in then to use the current user, but if they weren't but had been and an id cookie had been dropped then to use the id of the cookie instead. Like this: <?php if($user->isLoggedin()) { $me = $user; $score_me = $me->id; $log_message = "you are logged in"; } else{ $me = $_COOKIE[id]; $score_me = $me; $log_message = "you are not logged in ";} $myname = $pages->get("id=$me"); myscore($score_me); echo "<a href='/logout'>Not {$myname->name}? </a>"; myrank($me);
  22. It was the first example that seemed to cause me so many problems. Whenever I used get($me), it always returned details for accounts 41, presumably because that was the first (lowest) user, unless problem was actually somewhere else.
×
×
  • Create New...