Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/17/2014 in all areas

  1. Just as I always was thinking "you can find anything on the internet" - why need it? But a member of this community (don't know if I can say the name) was so kind to arrange for me to follow a php course. And I must say "1 day has given me so much more tips which I consider to be gold"! Array, loops, strings, operators, and more. Never knew there were so many things possible in the right context... I really like the way it is explained, for instance the =, == and ===. Or even the ' ' and " " differences.
    7 points
  2. Well, since Teppo doesn't announce it himself (Twitter doesn't count), here it goes http://www.flamingruby.com/blog/processwire-weekly-1/ What a great idea! Now I won't have the feeling that I'm missing important things on those weeks where work (or vacations) brings me away from the forums. Thanks Teppo!
    7 points
  3. Best tutorial: http://codebabes.com
    4 points
  4. Yes. I did apologized for not hearing the message itself. Did not grasp the underlying messages at first. Meanwhile I learn PHP as suggested by Martijn and others. And I hope, one day we can all drink a beer together (or some other flavor).
    3 points
  5. Not sure exactly what you mean here - don't know whether you wish php was actually a client side language or whether you just want to be able to test your code in the browser. If by chance it is just the latter, then one of these might help: http://sandbox.onlinephpfunctions.com/ http://phptester.net/ http://writecodeonline.com/php/ http://phpfiddle.org/ Anyone feel like porting PW to nodejs
    3 points
  6. Each thing in it's place. If you learn JS you won't feel the need to use PHP in the browser. JS is a beautiful language also, and the only reason I'm not committed in using it in the server as well as in the browser is PW
    3 points
  7. http://www.owengildersleeve.com/ - illustrator (built by CodeByBoy and edited by myself) http://ciaraphelan.com/ - illustrator (built by CodeByBoy and edited by myself) http://thehackneypeddler.co.uk/ - vintage bike shop (built myself)
    2 points
  8. http://praegnanz.de/weblog/cms-einkaufsfuehrer-2014
    2 points
  9. Yep thanks for the follow up in the PM's Speaking native language is so much more comfortable in some cases...
    2 points
  10. Congrats !!! Goood step bwaked !
    2 points
  11. Marcus and me are trying to meet tomorrow evening at the BT WarmUp Event. If anyone else wants to join us, send me a message here and we will try to find you. Or you can walk around there and show your smartphone with the ProcessWire website or something like this. I hope I meet some of you tomorrow!
    2 points
  12. I'm going and really looking forward to it! Anyone in for a ProcessBeer on sunday night?
    2 points
  13. I recently had to setup front-end system to handle logins, password resets and changing passwords, so here's about how it was done. This should be functional code, but consider it pseudocode as you may need to make minor adjustments here and there. Please let me know if anything that doesn't compile and I'll correct it here. The template approach used here is the one I most often use, which is that the templates may generate output, but not echo it. Instead, they stuff any generated output into a variable ($page->body in this case). Then the main.php template is included at the end, and it handles sending the output. This 'main' template approach is preferable to separate head/foot includes when dealing with login stuff, because we can start sessions and do redirects before any output is actually sent. For a simple example of a main template, see the end of this post. 1. In Admin > Setup > Fields, create a new text field called 'tmp_pass' and add it to the 'user' template. This will enable us to keep track of a temporary, randomly generated password for the user, when they request a password reset. 2a. Create a new template file called reset-pass.php that has the following: /site/templates/reset-pass.php $showForm = true; $email = $sanitizer->email($input->post->email); if($email) { $u = $users->get("email=$email"); if($u->id) { // generate a random, temporary password $pass = ''; $chars = 'abcdefghjkmnopqrstuvwxyz23456789'; // add more as you see fit $length = mt_rand(9,12); // password between 9 and 12 characters for($n = 0; $n < $length; $n++) $pass .= $chars[mt_rand(0, strlen($chars)-1)]; $u->of(false); $u->tmp_pass = $pass; // populate a temporary pass to their profile $u->save(); $u->of(true); $message = "Your temporary password on our web site is: $pass\n"; $message .= "Please change it after you login."; mail($u->email, "Password reset", $message, "From: noreply@{$config->httpHost}"); $page->body = "<p>An email has been dispatched to you with further instructions.</p>"; $showForm = false; } else { $page->body = "<p>Sorry, account doesn't exist or doesn't have an email.</p>"; } } if($showForm) $page->body .= " <h2>Reset your password</h2> <form action='./' method='post'> <label>E-Mail <input type='email' name='email'></label> <input type='submit'> </form> "; // include the main HTML/markup template that outputs at least $page->body in an HTML document include('./main.php'); 2b. Create a page called /reset-pass/ that uses the above template. 3a. Create a login.php template. This is identical to other examples you may have seen, but with one major difference: it supports our password reset capability, where the user may login with a temporary password, when present. When successfully logging in with tmp_pass, the real password is changed to tmp_pass. Upon any successful authentication tmp_pass is cleared out for security. /site/templates/login.php if($user->isLoggedin()) $session->redirect('/profile/'); 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(); // now redirect to the profile edit page $session->redirect('/profile/'); } } // present the login form $headline = $input->post->username ? "Login failed" : "Please login"; $page->body = " <h2>$headline</h2> <form action='./' method='post'> <p> <label>Username <input type='text' name='username'></label> <label>Password <input type='password' name='pass'></label> </p> <input type='submit'> </form> <p><a href='/reset-pass/'>Forgot your password?</a></p> "; include("./main.php"); // main markup template 3b. Create a /login/ page that uses the above template. 4a. Build a profile editing template that at least lets them change their password (but take it further if you want): /site/templates/profile.php // if user isn't logged in, then we pretend this page doesn't exist if(!$user->isLoggedin()) throw new Wire404Exception(); // check if they submitted a password change $pass = $input->post->pass; if($pass) { if(strlen($pass) < 6) { $page->body .= "<p>New password must be 6+ characters</p>"; } else if($pass !== $input->post->pass_confirm) { $page->body .= "<p>Passwords do not match</p>"; } else { $user->of(false); $user->pass = $pass; $user->save(); $user->of(true); $page->body .= "<p>Your password has been changed.</p>"; } } // display a password change form $page->body .= " <h2>Change password</h2> <form action='./' method='post'> <p> <label>New Password <input type='password' name='pass'></label><br> <label>New Password (confirm) <input type='password' name='pass_confirm'></label> </p> <input type='submit'> </form> <p><a href='/logout/'>Logout</a></p> "; include("./main.php"); 4b. Create a page called /profile/ that uses the template above. 5. Just to be complete, make a logout.php template and create a page called /logout/ that uses it. /site/templates/logout.php if($user->isLoggedin()) $session->logout(); $session->redirect('/'); 6. The above templates include main.php at the end. This should just be an HTML document that outputs your site's markup, like a separate head.inc or foot.inc would do, except that it's all in one file and called after the output is generated, and we leave the job of sending the output to main.php. An example of the simplest possible main.php would be: /site/templates/main.php <html> <head> <title><?=$page->title?></title> </head> <body> <?=$page->body?> </body> </html>
    2 points
  14. Previously I posted about Textareas. The next field coming in ProFields is called Multiplier. This field lets you take almost any existing single-value Fieldtype, and use it as a multi-value Fieldtype. Single value Fieldtypes are those that store one piece of information at a time, for example: Text, Textarea, Integer, Float, Email, URL, etc. Any of these, and more can be multiplied with Multiplier. Here's a short video introduction to Multiplier. Like with the previous screencast, I recommend upping the quality to 720p and viewing full screen. This one also includes narration, though we're in allergy season here so my voice is a little rough. The next fields I have to tell you about in a few days are: Table, PageTable and AutoLinks.
    1 point
  15. 1 point
  16. I don't think that's the case, but still here's another one: http://www.tehplayground.com/
    1 point
  17. Yeah... php.net is a good resource, although the community always have examples which look way to complicated for beginners. Anyways, I enjoy the course (lynda.com).
    1 point
  18. Great to see you on the right track
    1 point
  19. I believe this has to do with access being controlled by a template on that page.
    1 point
  20. I guess you have a javascript error somewhere. Check the js console for errors for example with chrome's devtools or firebug. Also I noticed that you include jquery two times. Cheers
    1 point
  21. Email is responsive by default.
    1 point
  22. Restructuring is in that I make new template with all of mentioned repeater fields and I remove 2 "massive" textarea fields from repeater. they.not massive unless you fill. thems up textarea with.5k text takes up 5 kilobites not 16 megobytes Then I launched script to clear values in these fields (set to ""). This was slow and boring but it's done. this do.nothing see above How I can remove these fields? The only solution is to temporarily give PW more RAM by performing ini_set( )? you see this -> dev commit mabe u need dev branch ?
    1 point
  23. @bwakad, just one more thing: if you feel that asking questions is the best for you, then ask. No one here is annoyed by them, or we would just ignore. As you must have noticed, people here like to answer to questions, even if they are basic or don't even seem to make sense. When someone points it out to you that you shouldn't be making a specific question, it's not because they don't want to answer, but because that question shows that you didn't look for things the right way. When Martijn points out that you need some basic knowledge of PHP before asking about site optimisation, it's because you are clearly inverting the priorities on your learning process, not to criticise. Sometimes it feels like your learning process is a bit like the sentence you have on your profile
    1 point
  24. Wished I was there awesome list of people, only 50 minutes driving from here. Have fun!
    1 point
  25. I know three members of this forum who will be there. Not sure if I am allowed to tell, so I leave it to them =) Unfortunately I will not be there =( Have fun!
    1 point
  26. This is my version of Ryan's starter: $requested_pid = (int) $input->get->pid; $t = $pages->get($requested_pid)->path; if($user->isLoggedin()){ if($requested_pid == ''){ $session->redirect('/'); } else{ $session->redirect($t); } } 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); $tmp_pass = $u->tmp_pass; $u->tmp_pass = ''; $u->save(); // now redirect to the profile edit page if($tmp_pass == $pass){ $session->redirect('/profile/'); } else{ $session->redirect($t); } } } // present the login form $headline = $input->post->username ? "Login failed" : "Please login"; $content = " <h2>$headline</h2> <form action='./?pid=".$requested_pid."' method='post'> <p> <label>Username <input type='text' name='username'></label> <label>Password <input type='password' name='pass'></label> </p> <input class='bluebutton' type='submit' name='login' value='Login'> </form><hr /><br /> <p><a href='/reset-pass/'>Forgot Password?</a></p> "; Then wherever you have a link to login: <a href="/logout/?pid='.$page->id.'">Login</a> Of course you can do the same with logout too. Hope that helps
    1 point
×
×
  • Create New...