Jump to content
Larry Ullman's Book Forums

Stuart

Members
  • Posts

    141
  • Joined

  • Last visited

  • Days Won

    12

Stuart last won the day on August 8 2011

Stuart had the most liked content!

Stuart's Achievements

Newbie

Newbie (1/14)

68

Reputation

  1. After posting I decided to stop reading forums and the docs and jump into the source code. You simply have to set the captchaAction using a route: $this->widget('CCaptcha', array('captchaAction'=>'feedback/captcha')); This wasn't that apparent to me when reading the docs but the source code comments provide an explicit example. So now I can render the CAPTCHA widget in the main.php and it works great! Sorry for wasting people's time who read this... its been a long few days
  2. Hi, Not been on here in a while! Doing lots of Yii work though so should be able to start helping people out now the books out. Bought a copy last week - only had chance to browse and already looks like it explains concepts far better than the other Yii book I have! I want to render a form inside a modal window that is part of the main.php layout file. The form needs a CAPTCHA which is where my problems start. Adding a CAPTCHA directly to an action's view works fine but as soon as I try and do it from main.php I'm running into all kinds of problems. It seems unless I'm on the page the form points to I have to enter the CAPTCHA twice - some issue where the value must be getting set twice/overwritten? At the moment I've had to add the action and access filter to all of my controllers (which I know is disgusting) but I can't see how to make this work? Thanks Stuart
  3. I don't have a copy of this book and you haven't posted any of the relevant code so it's difficult to say for sure. Looking at the code from the downloads section I suspect that's coming from the else clause of: if (mysqli_affected_rows($dbc) == 1) { // If it ran OK. This means that your database INSERT query is failing - possible causes: Database user doesn't have INSERT privileges Table structures does not match that at localhost causing a syntax error In the else clause where you have: trigger_error('You could not be registered due to a system error. We apologize for any inconvenience.'); Add a call to: echo mysqli_error($dbc); This will return more information about your specific database error.
  4. Thanks for your replies guys. Indeed Antonio the apps will be storing the primary key in their local storage and passing this up during any updates - deletes handled simply by their lack of presence in the uploaded data. As tempting as a NoSQL solution is in terms of the coding elegance of simply storing the objects I don't feel I know enough about NoSQL solutions in terms of security to ensure the protection of millions of people's data at this time. Some of the security features are either not present in NoSQL solutions or would require rolling my own versions. So for now at least I'm sticking with a the more mature MySQL database (time permitting I might build both to see which produces the best product in terms of security, scalability and elegance. Thanks again for your input.
  5. In a current project I have a large database that basically holds people and their personal information e.g. each contact can have multiple phone numbers, email addresses, residential addresses etc... As a result data security and integrity are very important. I started of sketching out the database schema and it seems fairly straight-forward. I'd create a people table which contains the individual people and then a series of other tables to hold their personal information each in a one-to-many relationship. E.g. Each person can have multiple phone numbers. All seemed fine until I started thinking through the use cases. If someone updates their mobile number and saves their details I would essentially have to delete all their numbers and then add them all again because you can't easily tell if details were deleted, updated or inserted to the contact. I think any effort to package the existing ID with each number would simply be messy. So first, is there anything wrong with deleting and re-inserting all one-to-many relationships? It will lead to big gaps in the primary key which I guess can be fixed by calling something like repair etc... For reference this database will have several million users. This seemed messy so I considered storing the one-to-many relationships as serialised objects within a single table because then I wouldn't have to worry about maintaining FK relationships and having large gaps in the primary keys. This led me to looking at NoSQL solutions as this seems to be basically what they do. I read the mogoDB article from Larry's newsletter and thought it might be worth considering. Any thoughts? PS. In general I only have to update or fetch the objects I don't have to search based on a phone number etc...
  6. Been thinking about this again tonight... is there any need to create a filter - couldn't I just customise the actionCreate method? Or is that bad practice?
  7. I know this issue is kind of cleared up but just explain a little more if you're interested. Your first example and second example are not the same - there are subtle nuances between the two. The first is considered in ECMA script as a function declaration while the second is considered a function expression. The differences are explained in the ECMA script spec. Basically (as you've described above) function declarations are parsed and evaluated before any other expressions are - irrespective of where that declaration is positioned in the source code. Another interesting point I found out today is that a function declaration cannot appear 'in block' e.g. within IF conditionals or any loops. Although they may work their implementation cross browser is not guaranteed in accordance with ECMAScript - this is where function expressions should be used. So not a quirk of the JS engine but intentional apparently.
  8. I'm starting to get to grips with Yii at last and am finding making progress slow. I've offered to build a forum for a network of local sports teams to let me dabble in Yii with no deadline pressures. I've read most of Agile Web Application Development endorsed by Yii and your blog articles on it but am still struggling. I used the forum schema from PHP 5 and MySQL 6 ed 3 adding a clubs model which sits above the users model and made a few adjustments to fields. I've used Gii to create models and CRUD functionality. In the forum chapter of your book you basically accept a post and then check for a thread/topic ID - if it's not present you create one. I can't quite get my head round how to achieve this. My best guess so far is to add a property to the PostsController called $_topic and then create a filter inside the PostsController that's called prior to the actionCreate method. In there I'd check for a topic ID in the POST array - if it exists assign it to the property if not do something like: $topic = new Topics; $topic->topic_title=$_POST['title']; if($topic->save()){ $this->_topic = $topic->getPrimaryKey(); } else { // Throw exception } Is that along the right lines? Any general pointers on what I need to do to create a forum greatly appreciated too. The book isn't the best (how long until your Yii book will be done Larry?) and the docs are only useful once you've got a little more experience. Thanks
  9. Prepending an IF statement with ! flips the value of the variable. So if $live is set to FALSE then: if(!$live) { //show the error in the browser Returns TRUE meaning the next code block is executed. So when the $live flag is set to FALSE the following code is executed: echo'<div class="error">'.nl2br($message).'</div>'; However when you change the value to TRUE the IF statement evaluates to FALSE meaning the ELSE block gets executed: //send the error in an email; error_log($message,1,$contact_email,'From:admin@example.com'); //only print an error message in the browser, if the error isn't a notice. if($e_number != E_NOTICE) { echo'<div class="error">A system error occurred. We apologize for the inconvenience.</div>'; }
  10. The password policy enforced by Larry's scripts via the REGEX only allow for letters, numbers and the underscore. Not sure if there's a technical reason for not allowing spaces in passwords but if you want to remove trim then you might aswel alter the REGEX also to allow for spaces. A lot of sites I can think of don't allow spaces in the password - presumably there's some reason for this. If you want to create more secure passwords enforce the use of upper and lowercase characters, numbers and symbols and a minimum length of say 8.
  11. You don't have the CURL extension enabled - run phpinfo() to clarify.
  12. Pretty sure you could use strftime() and set the locale to something like ar_SA.UTF-8 using setlocale().
  13. Never used stored procedures but it looks fairly straight forward that the SP select_products already exists. If you want to re-create it again: DROP PROCEDURE IF EXISTS select_products; Then run your code again.
  14. Common reasons for you not seeing step 2 here might be: Error in your query syntax but error reporting is not turned on e.g. column name mismatch Password column is defined as CHAR(32) it should be CHAR(40) You have more than 1 row with the same content e.g. Duplicate entries The password was originally stored in plain text not SHA1 hashed See if any of those apply.
×
×
  • Create New...