Jump to content

kyle

Members
  • Posts

    32
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by kyle

  1. It was an issue with vagrant. I have had the issue setting up laravel also. To fix it I just changed the user/group for apache to vagrant. Generally this wouldn't be safe at all in a production environment but access to the VM is limited to me, so I am not too concerned. To change the user/group will depend on your OS. In ubuntu the config file is located in /etc/apache2 and it is apache2.conf. Sometimes "apache2" will be swapped out for "http.d". You can edit the file using vim/nano and then save and restart apache.
  2. I have been able to easily install processwire in the past locally and on servers, but I recently added Vagrant to my development process, and I can't seem to get processwire installed correctly. Everything is right as far as the required components for the install. I go through ans rename the site-default to site and htacess.txt to .htaccess. Then I chmod /site/assets and /site/config.php to 777. Everything passes the check correctly, and then I enter the database info etc. There are no errors here. Everything looks like it gets installed correctly, but when I log in I get the "This request was aborted because it appears to be forged." error. I have come across this error before, and know how to fix it normally. I have confirmed that the sessions, cache, logs, files folders were created. I have even tried to chmod the whole site to 777, but nothing has worked. I have set $config->protectCSRF to false, and it gets rid of the error; however, it doesn't actually log me into the site but it redirects me back to the processwire login page with no errors and the form fields cleared. The owner and group when I ssh in are vagrant/vagrant, so I don't think that would be an issue. I have seen this post which seems to be having the same issue as me, but the index.php file has seemed to same, so the answer is outdated. Any ideas?
  3. I have been able to easily install processwire in the past locally and on servers, but I recently added Vagrant to my development process, and I can't seem to get processwire installed correctly. Everything is right as far as the required components for the install. I go through ans rename the site-default to site and htacess.txt to .htaccess. Then I chmod /site/assets and /site/config.php to 777. Everything passes the check correctly, and then I enter the database info etc. There are no errors here. Everything looks like it gets installed correctly, but when I log in I get the "This request was aborted because it appears to be forged." error. I have come across this error before, and know how to fix it normally. I have confirmed that the sessions, cache, logs, files folders were created. I have even tried to chmod the whole site to 777, but nothing has worked. I have set $config->protectCSRF to false, and it gets rid of the error; however, it doesn't actually log me into the site but it redirects me back to the processwire login page with no errors and the form fields cleared. Any ideas?
  4. kyle

    HallExchange

    @Gnuey I used bootstrap as a template and then tweaked it for a design that I made in photoshop. Currently all of the backend is handled by Processwire, but depending on how it scales, that could change in the future. @dragan I may supply a test account, but really the only features are being able to view the ads and contact ad posters. The links are actually a bug! Thanks for catching that! I have updated it so the prices display better now. Originally, I didn't know how people wanted to display a price, and I tried to force numbers only. That didn't exactly workout so it's much more flexible now. The data-rocketsrc is actually code provided by Google so I can used their jquery. It just uses their CDN so I can save bandwidth.
  5. kyle

    HallExchange

    HallExchange is a classifieds service exclusively for college students. Right now, it is only open to students from my school, but will expand to other college's in the future. What do you think? http://www.hallexchange.com/
  6. @kongondo thanks! I am pretty curious as to what computers people are using, about the hardware, and OS.
  7. What kind of set up do you have? What are some programs that you often use when creating websites? Any tips you can give the rest of the community? I recently switched to Mac and absolutely love it. I got the macbook pro so I was able to replace my big desktop. It's nice being able to code wherever I want. I mainly use phpstorm and photoshop. I develop locally and then push to development/production using git. I use to use FTP but it's really nice to just use a git pull and have everything update and working.
  8. I am getting and error with a front end login. It is only happening for one specific user, and I can't figure out what's going on. I turned on debug in the config and will attach the screen shot that he sent me. If you would prefer for me to type it out, please let me know and I will. The error seems to be the result of a selector, and it may be from my code; however, my template files aren't listed anywhere in the error stack. The screen shots are from when he tried to login on his phone, but he has tried on his computer and gets the error using IE and chrome. His username is set up has first-lastname.
  9. It is pretty amazing how much of a difference caching in general makes. I ended up enabling template caching for everything but the register, login, and account management page and plan to add procache when I get money. edit: I had the caching enabled but it prevented people from using the frontend login form
  10. Is there any disadvantage to using template caching? I will look into ProCache.
  11. @SiNNuT thanks for the link. The target of the site for right now is ~30,000 people, and I really think that about 1/3 of the people will regularly use it. The site is classifieds service. So there are always new posts. It is organized like this: > Location >Category >Ads >Category >Ads >Category >Ads I gave APC a about 700M of memory to use so hopefully that helps out. I ran it though a blitz stress test and it started off really well but after about 1,000 hits it starts to time out.
  12. I am working on a little project that is highly dynamic. It relies heavily on forms and sessions. What are some caching options available? I have looked at the MarkupCache and the ProCache module. Should I use template caching? The site is a little bit like the Skyscrapers example site in the way it lists the pages, but pages are constantly being added. I have APC enabled for the site and I run it through cloudflare. Anything else I can do to keep it fast?
  13. The forged request was an issue with the apache config Apache was running with the user and group _www. I had to change it to my username and then the group I belong to.
  14. @arjen The short tags was in fact the issue! Thank you very much. I had previously seen that post and tried the suggestions but I have the cache, logs, and sessions folders created and set to the right permissions. When I add $config->protectCSRF = false; to the config file the error doesn't display anymore but it doesn't log me in. Also commenting out Options +FollowSymLinks and Options +SymLinksifOwnerMatch did not help. All the files should be the same because I am using git for version control. I previously had the issue when I pushed the site to my development server on my VPS, but that was due to me not having the sessions and cache folders.
  15. I don't think there is an easy way since Jekyll doesn't seem to us a DB. You could probably write an automated method to do this for you. Do you have all the files on git or something similar so I could take a look?
  16. I got a new mac today and I am trying to get everything up and running. I have PHP, mySql, and apache installed and running. But I am having issues getting processwire to work correctly. Previously I had windows and was running XAMPP and everything was working great. Right now I am having issues logging in and displaying content using <?=?> syntax. Loggin In I am getting the "This request was aborted because it appears to be forged." error. I have created the cache and sessions folder in assets. Their permissions are 755 (drwxr-xr-x). There is a config file with permissions 644 (-rw-r--r--). Syntax It wont let me use the <?=?> syntax. In the code I typed <?=$results->title?> but it was rendered as <!--?=$results--->title?>. I really have no idea about this one... I'm assuming the two are related, but I am not really sure... Any insight would be extremely helpful. Edit: php is version 5.3.15
  17. Ah thanks for the help this does give me some good direction. So what I wanted to do was actually have it so if you're not logged it you see all the ads, and if you are logged in you can only see ads from your city. So I guess the user would kind of belong to a city.
  18. @kongodo Thanks for your help again! So to answers these questions: no, an ad can only belong to one category and one city. So I guess I am having a little trouble understanding the fundamentals of page reference fields. With this link: http://processwire.com/videos/page-fieldtype/ it goes about showing related pages. So how would that work into sorting ads by categories and cities? How is that an advantage to sorting things differently than: City 1 -- Electronics -- Furniture -- etc... City 2 -- Electronics -- Furniture -- etc..
  19. @diogo Thanks for the link. I wasn't sure if it was applicable to my situation, because I am not sure if this would be a good use case for pagefields. Do you think pagefields would work well with what I'm trying to accomplish? My main concern is that different ad types have different fields associated with them.
  20. I want to start using ProcessWire on larger projects, so I was going to start with a little personal project. I am going to attempt to make a Craigslist clone, but I am not sure the best way to structure the site. There will be cities and within the cities there will be ads. My original idea was this: Main Ad Pages -- Electronics -- Furniture -- etc.. If you are a registered user you have a city associated with your username. When you visit one of the categories it gets your city and finds all of the ads from the same city. I just don't know how scalable this would be. ------------------ Alternatively, my other idea was this: City 1 -- Electronics -- Furniture -- etc... City 2 -- Electronics -- Furniture -- etc.. Which idea would be the best? Or is there a different way to do this? Ideally, I am looking for the most scalable solution.
  21. @teppo Thanks for the feedback. I would definitely encourage salting the MD5 with something to keep people from cracking the activation code. I will update that in the tutorial. I wasn't sure if those sanitizer methods would work for this, so I made my own, but since they will I will take a look at them and then update the tutorial!
  22. Thanks for the feedback! I hope it helps some people out.
  23. This tutorial will outline how to create a membership system that requires account activation via email. If you have a decent understanding of ProcessWire it isn't difficult at all! Create additional fields By default ProcessWire has a name, email, and password field for the user template. To allow for account activation we will have to add a couple more fields. Create the following fields and add them to the systems default user template. You can make ProcessWire show the system templates by going to setup -> templates -> toggle the filter tab -> show system templates -> yes. user_real_name user_activation Okay great, now that you have added the two additional fields to the user template we can start to code the registration form. I am not going to spend a lot of time on this part, because there is a tutorial that describes creating forms via the API. Create the registration form Once you have followed the tutorial on creating forms, you will have to add a couple of sections to your new form! <?php include("./functions.php"); require("/phpmailer/class.phpmailer.php"); $out = ""; $errors = ""; //create form //full name field //email field //username field //password field //submit button //form submitted if($input->post->submit) { $form->processInput($input->post); //instantiate variables taking in the form data $full_name = $form->get("full-name")->value; .... /* * Create the activation code * You can add a random string onto the * the username variable to keep people * from cracking the hash * ex $activation = md5($username."processwire"); */ $activation = md5($username); $activation_code = $config->httpHost."/activation/?user=".$username."&hash=".$activation; //check for errors if($form->getErrors() || username_validation($username) == 0) { $out .= $form->render(); //process errors /* * this checks to makesure that no one has the username * I have a functions file that I import to the pages I * need it on */ if(strlen($username) != 0){ if(username_validation($username) == 0) { $username->error = " "; $errors .= "Sorry that username is already taken!"; } } } //the registration was successful else { $out = "Thank you for registering!<br><br>"; $out .= "An email has just been sent to " . $email . " with the url to activate your account"; /* * In this example I am using phpmailer to send the email * I prefer this, but you can also use the mail() function */ $mail = new PHPMailer(); $mail->IsHTML(true); $mail->From = "email@domain.com"; $mail->FromName = "Register @ Your Site"; $mail->AddAddress($email); $mail->AddReplyTo("email@domain.com","Register @ Your Site"); $mail->Subject = "Registration"; $mail->Body = " Hi " . $full_name. ", <br>" . "Thanks for registering at Your Site. To activate your email address click the link below! <br><br>" . "Activation Link: <a href='http://".$activation_code."'>".$activation_code."</a>"; $mail->send(); //create the new user $new_user = new User(); $new_user->of(false); $new_user->name = $username; $new_user->email = $email; $new_user->pass = $password; $new_user->addRole("guest"); $new_user->user_full_name = $full_name; $new_user->user_activation = $activation; $new_user->save(); $new_user->of(true); } } //form not submitted else { $out .= $form->render(); } ?> <h2>REGISTER</h2> <div class="errors"><?php echo $errors; ?></div> <?php echo $out; ?> Okay so that outlines the entire form. Let me get into the important parts. Checking for a unique username /* * check if username exists * return 1 username is valid * return 0 username is taken */ function username_validation($username) { $valid = 1; $check = wire("users")->get($username); if ($check->id) { $valid = 0; } return $valid; } We don't want to try and add a username if the username is already taken, so we need to make sure to validate it. If this returns 0 you should output that the username is already taken, and the user needs to choose a different one. Generating an activation code /* * Create the activation code */ $activation = md5($username); $activation_code = $config->httpHost."/activation/?user=".$username."&hash=".$activation; This generates an activation code. It does so by encrypting the username variable and then combines the username and activation code into a url for a user to visit. Now we have to process the activation code. As the teppo recommended, it is a good idea to add an extra string onto the $username when encrypting it with md5. If you don't do this, people may crack it and allow for mass signups. $activation = md5($username."Cech4tHe"); Activate the user <?php include("./head.inc"); include("./functions.php"); /* * this will pull the username and * activation code from the url * it is extremely important to * clean the string */ $activate_username = $sanitizer->text($_GET['user']); $activate_hash = $sanitizer->text($_GET['hash']); if(wire("users")->get($activate_username)->id) { if(strcmp(wire("users")->get($activate_username)->user_activation, $activate_hash) == 0 || wire("users")->get($activate_username)->user_activation == 0) { echo "Your account has been activated!<br><br>"; $activate_user = wire("users")->get($activate_username); $activate_user->of(false); $activate_user->user_activation = "0"; $activate_user->save(); } else { echo "There was an error activating your account! Please contact us!<br><br>"; } } else { echo "Sorry, but that we couldn't find your account in our database!<br><br>"; } include("./foot.inc"); This pulls the username and activation hash from the url. It then goes into the database and looks for the user. Once it finds the user, it get's the user_activation hash and compares it to the one in the URL. If it matches, it activates the user by setting user_activation to zero. Clean the url You can user the built in $sanitizer->text() method to clean the url. This will keep people from inserting special characters that can break the page. Keeping unactivated users out You aren't done yet! Now you will have to choose which areas you want to restrict to activated users only. An activated user's user_activation field will now equal zero. So if you want to restrict a section check to make sure it is zero...... if($user->user_activation != 0) { echo "Sorry, but you need to activate your account!"; } else { // activated users }
  24. This won't help with the database, but have you considered using git? For my workflow I develop on XAMPP and I use git. It allows me to easily work between my laptop and desktop. And when I am ready to show the site to a client, I log into my server do a git pull and then I update the database.
  25. @kongondo My mistake those were very clear. I was attempting to use an InputfieldImage rather than InputfieldFile. I really appreciate everyone's help.
×
×
  • Create New...