Thiết kế mạng xã hội với PHP - 2 pdf

10 346 0
Thiết kế mạng xã hội với PHP - 2 pdf

Đang tải... (xem toàn văn)

Thông tin tài liệu

Table of Contents [ ii ] Chapter 2: Planning and Developing the Core Framework 21 Designing the framework 22 Patterns—making life easier 22 MVC: Model-View-Controller 22 The Front Controller pattern 24 Registry 24 Folder structure 26 Building the framework 28 Registry 28 The registry object 28 Registry objects 31 Front Controller: single point of access 56 index.php 56 .htaccess 58 Summary 59 Chapter 3: Users, Registration, and Authentication 61 Privacy policies 62 Users 63 Our user object 63 Our authentication registry object 65 POST authentication 67 SESSION authentication 68 Structuring the database 69 Registration 70 Standard details 70 Hooking additional elds on 76 Processing the registration 80 Creating the prole 80 Putting it all together: registration constructor 81 CAPTCHA 82 General CAPTCHA 83 reCAPTCHA 83 Where do I sign up? 83 E-mail verication 86 Sending e-mails 86 Sending the e-mail verication e-mail 90 Authentication with our authentication object 90 Logging in 90 Are we logged in? 91 Logging out 91 Remember me 92 Help! I've forgotten! 92 Username 92 Download from Wow! eBook <www.wowebook.com> Table of Contents [ iii ] Password 94 Let them reset the password 96 Summary 98 Chapter 4: Friends and Relationships 99 Inviting friends 99 Manually inviting friends 100 Invitation controller 101 Automatically inviting friends 101 Google Friend Connect 101 Windows Live contacts 102 Yahoo! 102 Gmail contacts 102 Automatically connecting with friends 102 Members 102 Listing users 103 Pagination 103 Paginated members 110 Paginated users by letter 113 Searching for users 117 Custom relationships 121 Relationship types 121 Relationships 122 Adding friends 122 Forming a relationship 122 Relationship model 125 Relationship controller 129 Mutual relationships—accepting or rejecting a request 131 Pending requests 131 Accepting a pending request 133 Rejecting a pending request 134 Listing friends 134 Our friends 134 Their friends 136 Mutual friends 136 Friends in your prole 137 Summary 137 Chapter 5: Proles and Statuses 139 User proles 139 Extendable prole 140 Prole controller 140 Core shared information 142 Static prole 151 Viewing the prole 151 Download from Wow! eBook <www.wowebook.com> Table of Contents [ iv ] Relationships—some improvements 155 Editing the prole 157 Statuses 170 Statuses database table 170 Statuses types database table 170 Different types of status 171 Template improvements 171 Listing statuses 173 Templates 175 In action 176 Likes, dislikes, and comments 176 Comments 176 Summary 180 Chapter 6: Status Stream 181 What is a status stream? 181 Stream model 182 Building the stream 182 Relationships—get the IDs! 184 Friendly times 185 The rest… 188 Stream controller 189 Generating the stream 190 Comments, likes, and dislikes 193 Comments 193 Likes and dislikes 194 Views 195 Main template 195 Status type templates 196 In action 196 Room for improvement 196 A system stream for administrators 197 Summary 198 Chapter 7: Public and Private Messages 199 Public messages 199 Controller 199 Displaying prole messages 200 Displaying the post message box 201 Displaying a conrmation message 207 View 208 In action 209 Private messages 210 Database 210 Download from Wow! eBook <www.wowebook.com> Table of Contents [ v ] Message model 211 Messages model 217 Controllers and views 218 Listing messages 219 Reading a message 220 Deleting a message 223 Composing a new message 224 Creating a message template 227 In action 228 Room for improvement? 228 Sent items 228 Replies 229 Group messages 229 Summary 229 Chapter 8: Statuses—Other Media 231 Why support other media types? 231 Changes to the view 232 Template 232 jQuery to enhance the user experience 233 View in action 234 Images 234 Database table 234 Model 235 Class, variable, and constructor 235 Processing the image upload 236 Saving the status 244 Video (via YouTube) 244 Database 244 Model 245 Links 246 Database 246 Model 247 Extending the proles 248 Processing the new status posts 249 Altering our prole status' query 250 Status views 250 Images 250 Video 250 Links 251 In action 251 Images 251 Videos 252 Links 252 Download from Wow! eBook <www.wowebook.com> Table of Contents [ vi ] Repeat! 252 Summary 253 Chapter 9: Events and Birthdays 255 Let's plan 255 Calendars: what do we need to be able to do? 256 Calendar library 256 Generating the month 259 Days in the month 262 Ordered days 264 Previous month 264 Next month 265 Displaying a calendar 265 Generate and output 266 Multiple calendars 271 With events 272 Birthdays 272 Getting relationship IDs 273 Setting up the calendar 273 Getting the birthdays 275 Passing them to the calendar 275 The results 276 Events 277 Event model 277 Events model 284 Attendees, invitations, and RSVPs 288 RSVPs 290 Controller 290 Creating an event 290 Calendar of events 294 Viewing an event 294 Upcoming events 297 Reminders 298 On-site notications 298 E-mail notications 298 SMS notications 298 Summary 299 Chapter 10: Groups 301 Some planning 301 Group information 302 Types of groups 302 Ownership 303 Download from Wow! eBook <www.wowebook.com> Table of Contents [ vii ] Membership 303 Features 303 A group 303 Discussion 303 Database 304 Post 305 Topic 308 The group itself 315 Group table 315 Model 315 Creating a group 321 Controller 321 View 323 Creating a group—in action 324 Viewing a group 324 Membership 324 Controller 331 View 334 In action 335 Discussing within a group 335 Group controller additions 336 View 338 Discussion in action—viewing a topic 340 Joining a group 340 Joining (public) groups 340 Groups 342 Listing groups 342 Group controller addition 342 Template 344 In action 344 My groups 345 Addition to the group's controller 345 Template le 345 In action 346 Summary 346 Chapter 11: Developing an API 347 What is an API and why should we create one? 347 APIs in social networks 348 Facebook 348 MySpace 348 OpenSocial 349 Some planning 349 What should it do, and who should be able to do what? 349 How should it work? 350 How could it work? 351 Download from Wow! eBook <www.wowebook.com> Table of Contents [ viii ] Let's go with REST 352 Further reading 354 Implementation 354 Data format 354 API controller 355 Wait—no models? 359 Authentication 359 Delegating control: API controllers for our features 363 Prole's delegate 363 An Application Framework API 368 One solution: use OpenSocial 369 Consuming 369 POSTing data to our API with cURL 371 Summary 371 Chapter 12: Deployment, Security, and Maintenance 373 Deploying the site 373 Choosing a domain name 374 Registering a domain name 374 Popular domain name registrars 374 Signing up with a hosting provider 375 Choosing a web hosting provider 375 Considerations for hosts of social networking websites 377 Popular web hosting providers 377 Setting the nameservers for the domain 378 Creating a database on the hosting account 378 With cPanel hosting control panel 378 With appropriate privileges on phpMyAdmin 380 Exporting our local database 381 Importing our local database to the hosting account 382 Changing some of our database records 383 Changing our database conguration options 384 Uploading the les 384 Testing 385 Automating deployment 385 Security 386 Server Security 387 Software 387 Securing the site with a rewall 388 Shared hosting precautions 388 Passwords 388 Error reporting 389 Directory listings 390 SPAM 390 Download from Wow! eBook <www.wowebook.com> Table of Contents [ ix ] Maintenance 390 Backing up and restoring your social network 390 With cPanel 391 Using the command line 392 Do they work? 393 Access logs and statistics 393 Summary 394 Chapter 13: Marketing, SEO, User Retention, and Monetization Strategies 395 Marketing 396 Online advertising 396 Pay-Per-Click 396 Advertising space 398 Newsletter advertising 400 Newsletters 401 Social marketing 401 Viral marketing campaigns 402 Twitter 402 RSS feeds 402 Search engine optimization 403 On-site SEO 403 Headings 403 Links 404 Up to date, relevant content 404 Page metadata 404 Site speed 405 Search engine goodies—sitemaps and tools 405 Off-site SEO 406 What to look for in an SEO company 407 User retention 407 E-mails for the user's action 407 User feedback 408 Hello there! 408 Monetization options 408 Final tips: web stats 408 Summary 409 Chapter 14: Planning for Growth 411 Code performance 412 Code proling 412 Slow queries 412 Compression 413 Useful tools and resources 413 Download from Wow! eBook <www.wowebook.com> Table of Contents [ x ] Server performance 414 Apache 414 MySQL 415 Alternative web servers 415 Scaling 415 VPS Cloud Hosting 415 Additional servers 416 Caching systems 416 Memcached 417 Available caching systems 417 Redundancy 417 Content Delivery Networks 418 Message queues 419 Message queue versus database table 419 What can we queue? 419 Processing queued tasks 419 No SQL 420 Learn from the experts 420 Farm it out 421 Summary 421 Index 423 Download from Wow! eBook <www.wowebook.com> Preface Social networking has quickly become a very popular activity on the Internet, particularly with sites such as Facebook and MySpace. When it comes to creating social networks there are many options to chose from, including off-the-shelf systems, making use of existing social networks (for example, building a Facebook application or creating a Facebook page), or building something yourself. While it may be easy to nd existing solutions, the only way to have one looking and behaving exactly as you want is to build it yourself. By initially developing a light-weight Model-View-Controller-style framework with PHP, which can easily be extended to give us a stable and solid platform to work with making common tasks easier and giving us a structure for our social networking code, we can rapidly develop a custom, powerful social networking website. Within the rst few chapters, you will have a suite of les that deal with template management, database management, user authentication management, and e-mail sending. Once this is in place, social networking-centric features can be rapidly developed and plugged into the framework, including user registration and dealing with forgotten details, user proles, building connections with users, sending messages, sharing information, forming groups, a Developer API, and events and birthday calendars. At the end of this book, you will have a powerful social networking platform that can take the user all the way from the signup process to forming relationships and creating groups of users. The platform is developed in a very exible way, so the needs of any social networking site can be met, with new features easily and quickly added in as the needs of the site change. Download from Wow! eBook <www.wowebook.com> . improvement? 22 8 Sent items 22 8 Replies 22 9 Group messages 22 9 Summary 22 9 Chapter 8: Statuses—Other Media 23 1 Why support other media types? 23 1 Changes to the view 23 2 Template 23 2 jQuery to. model 21 1 Messages model 21 7 Controllers and views 21 8 Listing messages 21 9 Reading a message 22 0 Deleting a message 22 3 Composing a new message 22 4 Creating a message template 22 7 In action 22 8 Room. ] Chapter 2: Planning and Developing the Core Framework 21 Designing the framework 22 Patterns—making life easier 22 MVC: Model-View-Controller 22 The Front Controller pattern 24 Registry 24 Folder

Ngày đăng: 06/07/2014, 18:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan