Healthy Eating Alert System: Food Intake Monitor
Transcription
Healthy Eating Alert System: Food Intake Monitor
University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and Mathematics Healthy Eating Alert System: Food Intake Monitor A special problem in partial fulfillment of the requirements for the degree of Bachelor of Science in Computer Science Submitted by: Precious Joy U. Dizon May 2015 Permission is given for the following people to have access to this SP: Available to the general public Yes Available only after consultation with author/SP adviser No Available only to those bound by confidentiality agreement No ACCEPTANCE SHEET The Special Problem entitled “Healthy Eating Alert System: Food Intake Monitor” prepared and submitted by Precious Joy U. Dizon in partial fulfillment of the requirements for the degree of Bachelor of Science in Computer Science has been examined and is recommended for acceptance. Avegail D. Carpio, M.Sc. Adviser EXAMINERS: Approved 1. 2. 3. 4. 5. 6. Disapproved Gregorio B. Baes, Ph.D. (candidate) Avegail D. Carpio, M.Sc. Perlita E. Gasmen, M.Sc. (candidate) Ma. Sheila A. Magboo, M.Sc. Vincent Peter C. Magboo, M.D., M.Sc. Bernie B. Terrado, M.Sc. (candidate) Accepted and approved as partial fulfillment of the requirements for the degree of Bachelor of Science in Computer Science. Ma. Sheila A. Magboo, M.Sc. Marcelina B. Lirazan, Ph.D. Unit Head Chair Mathematical and Computing Sciences Unit Department of Physical Sciences Department of Physical Sciences and Mathematics and Mathematics Alex C. Gonzaga, Ph.D., Dr.Eng. Dean College of Arts and Sciences i Abstract HEAS:FIM (Healthy Eating Alert System: Food Intake Monitor) is a system that helps monitor fitness and calorie intake towards a healthier living. There may be existing applications but what makes it different is that it automatically computes the amount of calories per serving and restricts certain ingredients based on health conditions, and allows creation of recipes and daily meal planning with corresponding calorific values. Achievements can be shared and there can be health tips, recommended recipes and meals that can be recommended by a nutrition expert. Keywords: HEAS:FIM, Food Intake Monitor, Nutrition, Health Condition Contents Acceptance Sheet i Abstract ii List of Figures vii List of Tables ix I. Introduction 1 A. Background of the Study . . . . . . . . . . . . . . . . . . . . . . 1 B. Statement of the Problem . . . . . . . . . . . . . . . . . . . . . . 2 C. Objectives of the Study . . . . . . . . . . . . . . . . . . . . . . . 2 D. Significance of the Project . . . . . . . . . . . . . . . . . . . . . 4 E. Scope and Limitations . . . . . . . . . . . . . . . . . . . . . . . 4 F. Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 II. Review of Related Literature 6 III. Theoretical Framework 9 A. Nutrition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 B. IBW (Ideal Body Weight) . . . . . . . . . . . . . . . . . . . . . 11 C. BMI (Body Mass Index) . . . . . . . . . . . . . . . . . . . . . . 11 D. Nutrition Information[5] . . . . . . . . . . . . . . . . . . . . . . 12 E. Health Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . 29 F. Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 34 G. Database Management System . . . . . . . . . . . . . . . . . . . 35 IV. Design and Implementation 36 A. Context Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 36 B. Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 B..1 Top Level Use Case Diagram iii . . . . . . . . . . . . . . . . . 37 B..2 Profile Management . . . . . . . . . . . . . . . . . . . . . . 38 B..3 Content Management . . . . . . . . . . . . . . . . . . . . . . 39 B..4 Input Health Tips . . . . . . . . . . . . . . . . . . . . . . . . 40 B..5 Browse Recipes, Food Nutritional Contents, Health Tips . . 41 B..6 Account Management . . . . . . . . . . . . . . . . . . . . . . 42 B..7 Add User . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 B..8 View Users . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 B..9 Delete User . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 B..10 Manage Password . . . . . . . . . . . . . . . . . . . . . . . . 46 B..11 Plan Daily Meals . . . . . . . . . . . . . . . . . . . . . . . . 47 C. V. VI. Database Structure . . . . . . . . . . . . . . . . . . . . . . . . . 48 C..1 Entity Relationship Diagram . . . . . . . . . . . . . . . . . . 48 C..2 Data Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . 49 Architecture 57 A. System Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 57 B. Technical Architecture . . . . . . . . . . . . . . . . . . . . . . . 57 Results A. 59 General View . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 A..1 HEAS:FIM Home Page . . . . . . . . . . . . . . . . . . . . . 59 A..2 Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 B. Administrator View . . . . . . . . . . . . . . . . . . . . . . . . . 60 B..1 Administrator Home Page . . . . . . . . . . . . . . . . . . . 60 B..2 Add User . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 B..3 View Users . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 C. Content Manager View . . . . . . . . . . . . . . . . . . . . . . . 62 C..1 Content Manager Home Page . . . . . . . . . . . . . . . . . 62 C..2 View, Edit, or Delete Food Exchange List Item/s . . . . . . 62 C..3 View, Edit, or Delete Health Tip/s . . . . . . . . . . . . . . 63 iv C..4 Add Content . . . . . . . . . . . . . . . . . . . . . . . . . . 64 C..5 Add Food Exchange List Item . . . . . . . . . . . . . . . . . 64 C..6 Create Recipe . . . . . . . . . . . . . . . . . . . . . . . . . . 65 C..7 Recommend Daily Meals . . . . . . . . . . . . . . . . . . . . 65 C..8 Add Meal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 C..9 View or Delete Meal/s . . . . . . . . . . . . . . . . . . . . . 67 C..10 Add Health Tip . . . . . . . . . . . . . . . . . . . . . . . . . 68 C..11 View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 C..12 View Created Recipes . . . . . . . . . . . . . . . . . . . . . 69 D. User View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 D..1 User Home Page . . . . . . . . . . . . . . . . . . . . . . . . 70 D..2 Fitness Profile . . . . . . . . . . . . . . . . . . . . . . . . . . 71 D..3 View Information . . . . . . . . . . . . . . . . . . . . . . . . 71 D..4 Add Information . . . . . . . . . . . . . . . . . . . . . . . . 72 D..5 Recipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 D..6 Create Recipe . . . . . . . . . . . . . . . . . . . . . . . . . . 73 D..7 View Created Recipes . . . . . . . . . . . . . . . . . . . . . 74 D..8 Plan Daily Meals . . . . . . . . . . . . . . . . . . . . . . . . 74 D..9 Add Meal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 D..10 View or Delete Meal/s . . . . . . . . . . . . . . . . . . . . . 76 D..11 Share Achievement . . . . . . . . . . . . . . . . . . . . . . . 77 D..12 Share Achievement on Site . . . . . . . . . . . . . . . . . . . 77 D..13 Share Achievement on Facebook . . . . . . . . . . . . . . . . 78 D..14 Browse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 D..15 Browse Shared Recipes . . . . . . . . . . . . . . . . . . . . . 79 D..16 Browse Recommended Recipes . . . . . . . . . . . . . . . . . 79 D..17 Browse Recommended Daily Meals . . . . . . . . . . . . . . 79 D..18 Browse Food Nutritional Information . . . . . . . . . . . . . 80 VII. Discussions 81 v VIII. Conclusions 83 IX. Recommendations 84 X. Bibliography 85 XI. Appendix 88 A. Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 B. Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 B..1 Configs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 B..2 Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 B..3 Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 B..4 Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 B..5 Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 XII. Acknowledgement 271 vi List of Figures 1 Context Diagram of HEAS:FIM . . . . . . . . . . . . . . . . . . . . 36 2 Top Level Use Case Diagram of HEAS:FIM . . . . . . . . . . . . . 37 3 Activity Diagram: HEAS:FIM Profile Management . . . . . . . . . 38 4 Use Case (HEAS:FIM Content Management) . . . . . . . . . . . . . 39 5 Activity Diagram: HEAS:FIM Input Health Tips . . . . . . . . . . 40 6 Activity Diagram: HEAS:FIM Browse Recipes, Food Nutritional Contents, Health Tips . . . . . . . . . . . . . . . . . . . . . . . . . 41 7 Use Case (HEAS:FIM Account Management) . . . . . . . . . . . . 42 8 Activity Diagram: HEAS:FIM Add User . . . . . . . . . . . . . . . 43 9 Activity Diagram: HEAS:FIM View Users . . . . . . . . . . . . . . 44 10 Activity Diagram: HEAS:FIM Delete User . . . . . . . . . . . . . . 45 11 Activity Diagram: HEAS:FIM Manage Password . . . . . . . . . . 46 12 Flow Chart: HEAS:FIM Plan Daily Meals . . . . . . . . . . . . . . 47 13 HEAS:FIM Entity Relationship Diagram . . . . . . . . . . . . . . . 48 14 HEAS:FIM System Architecture . . . . . . . . . . . . . . . . . . . . 57 15 HEAS:FIM Home Page . . . . . . . . . . . . . . . . . . . . . . . . . 59 16 HEAS:FIM Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 17 HEAS:FIM Administrator Home Page . . . . . . . . . . . . . . . . 60 18 Add User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 19 View Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 20 HEAS:FIM Content Manager Home Page . . . . . . . . . . . . . . . 62 21 View, Edit, or Delete Food Exchange List Item/s . . . . . . . . . . 62 22 View, Edit, or Delete Health Tip/s . . . . . . . . . . . . . . . . . . 63 23 Add Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 24 Add Food Exchange List Item . . . . . . . . . . . . . . . . . . . . . 64 25 Create Recipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 26 Recommend Daily Meals . . . . . . . . . . . . . . . . . . . . . . . . 65 27 Add Meal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 vii 28 Add Recipe Meal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 29 View Recipe Meal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 30 View Meal/s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 31 View Added Meals . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 32 Add Health Tip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 33 View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 34 View Created Recipes . . . . . . . . . . . . . . . . . . . . . . . . . 69 35 HEAS:FIM User Home Page . . . . . . . . . . . . . . . . . . . . . . 70 36 Fitness Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 37 View Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 38 Add Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 39 Recipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 40 Create Recipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 41 View Created Recipes . . . . . . . . . . . . . . . . . . . . . . . . . 74 42 Plan Daily Meals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 43 Add Meal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 44 Add Recipe Meal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 45 View or Delete Added Meals . . . . . . . . . . . . . . . . . . . . . . 76 46 Share Achievement . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 47 Share Achievement on Site . . . . . . . . . . . . . . . . . . . . . . . 77 48 Share Achievement on Facebook . . . . . . . . . . . . . . . . . . . . 78 49 Browse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 50 Browse Shared Recipes . . . . . . . . . . . . . . . . . . . . . . . . . 79 51 Browse Recommended Recipes . . . . . . . . . . . . . . . . . . . . . 79 52 Browse Recommended Daily Meals . . . . . . . . . . . . . . . . . . 79 53 Browse Food Nutritional Information . . . . . . . . . . . . . . . . . 80 viii List of Tables 1 The Calorie Need for Male . . . . . . . . . . . . . . . . . . . . . . . 10 2 The Calorie Need for Female . . . . . . . . . . . . . . . . . . . . . . 10 3 The Calorie Need for Pregnancy and Lactating . . . . . . . . . . . . 11 4 Body Mass Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 5 Composition of Food Exchanges . . . . . . . . . . . . . . . . . . . . 13 6 Vegetable Exchanges Equivalent . . . . . . . . . . . . . . . . . . . . 13 7 Vegetable Exchanges . . . . . . . . . . . . . . . . . . . . . . . . . . 15 8 Processed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 9 Fruit Exchange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 10 Milk Exchanges Equivalent . . . . . . . . . . . . . . . . . . . . . . . 18 11 Milk Exchanges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 12 Rice Exchanges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 13 Meat and Fish Exchange Equivalent . . . . . . . . . . . . . . . . . . 20 14 A. Low Fat Meat and Fish Exchanges . . . . . . . . . . . . . . . . . 20 15 B. Medium Fat Meat and Fish Exchanges . . . . . . . . . . . . . . 25 16 C. High Fat Meat and Fish Exchanges . . . . . . . . . . . . . . . . 27 17 Fat Exchange List . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 18 Daily Calorie Meal Plans . . . . . . . . . . . . . . . . . . . . . . . . 30 19 Dietary Approach to Stop Hypertension . . . . . . . . . . . . . . . 31 20 users table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 21 fitness profile table . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 22 health conditions table . . . . . . . . . . . . . . . . . . . . . . . . . 51 23 own recipes table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 24 recommended recipes table . . . . . . . . . . . . . . . . . . . . . . . 52 25 shared recipes table . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 26 recipe images table . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 27 recipe images recommended table . . . . . . . . . . . . . . . . . . . 53 28 plan daily meals table . . . . . . . . . . . . . . . . . . . . . . . . . 53 ix 29 recommended daily meals table . . . . . . . . . . . . . . . . . . . . 54 30 shared achievements table . . . . . . . . . . . . . . . . . . . . . . . 54 31 health tips table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 32 ingredients table 33 ingredients recommended table . . . . . . . . . . . . . . . . . . . . 55 34 food exchange list table . . . . . . . . . . . . . . . . . . . . . . . . 56 35 health conditions restrictions table . . . . . . . . . . . . . . . . . . 56 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 x I. Introduction A. Background of the Study Nutrition, nourishment, or aliment, is the supply of materials, specifically food, required by organisms and cells in order to survive[1]. In science and human medicine, nutrition is the consumption and utilization of food[1]. Food is a material that consists essentially of protein, carbohydrate, and fat used by the body of an organism in growth sustenance, repair, vital processes and in furnishing of energy[2]. It is a basic necessity of every human being and is the body’s main source of nutrients. A nutrient is a source of nourishment, an ingredient in food, e.g. protein, carbohydrate, fat, vitamin, mineral, fiber and water[1]. The nutritional condition of a person is linked with his/her diet. Diet is the measure of the state of one’s health[3]. Proper nutrition can be attained through proper diet. Food may be the driving force that the body needs but there are certain limitations in order to achieve a healthier diet. One needs a sufficient allowance of food in order to meet the nutritional needs of the body[4]. A sensible diet ensures that all food groups are represented in daily meals[5]. Improper diet can be the cause of certain health problems and conditions. A person’s diet may depend on factors like nationality, culture, influence, present health condition, nature of work, or simply on the available food. The Filipino diet is as much a reflection of its history as it is a reflection of the country’s geography and natural resources[6]. Filipinos have a vast variety of food to choose from. Aside from the local dishes, the Filipino cuisine was further compounded by the coming of several foreign influences[6]. The current Filipino diet is said to be very high in sodium and fat owing perhaps to predominant cooking techniques such as deep frying, the increasing preference for meat products such as pork, and the heavy seasoning that comes along with every dish[6]. This is a 1 far cry from the traditional practices of just boiling vegetables and grilling fish, foods that are now only commonly consumed in some provinces[6]. There are existing diet applications that monitor food intake. SparkPeople[7] is a web application that allows daily meal planning, takes note of health conditions and has a reward system. NutriCoach[8] analyzes nutritional and calorific information of food intake for one day meal. Fat Secret[9] offers the same functionalities as SparkPeople[7]. B. Statement of the Problem Existing diet applications such as SparkPeople[7] does not allow creation of recipes from scratch and restriction of ingredients for every health condition. NutriCoach[8] does not allow creation of recipes from scratch, saving of data for history, and also does not take note of health conditions. Fat Secret[9] does not take note of health conditions and there is no automatic counting of calorie need. Although there are a lot of web and mobile applications that monitor food intake, there is no application that allows daily meal planning, creation of recipes from scratch with corresponding calorific values, restriction of ingredients considering health conditions, weight and calorie monitor, daily health tips, and reward system all at the same time. C. Objectives of the Study The main function of the system is the ability to plan daily meals from created or browsed recipes with ingredient/intake restrictions taking into consideration Health Conditions. It allows computation and classification of BMI (Body Mass Index) and Nutritional Status. The calorie need is determined based on sex, gender, weight, height and health conditions. 2 This research will create a Food Intake Monitoring system with the following functionalities: 1. Allows the Registered User to (a) Input and Edit Profile Information (b) Input Health Conditions (c) Input Daily Calorie Intake (d) Browse for Recommended Recipes (e) Browse Food Nutritional Information (f) Compute Body Mass Index (g) Monitor Weight via Graph (h) Monitor the Calorie Balance (i) Create Own Recipes with Corresponding Calorific Values based on Health Conditions (j) Plan Daily Meals Considering the Health Conditions (k) Share Achievements and Recipes to Other Registered Users, on Facebook or Twitter 2. Allow the Content Manager to (a) Input and Share Recommended Recipes with the Corresponding Nutritional Contents Considering Health Conditions (b) Recommend Daily Meals Considering the Health Conditions (c) Input and Share Health Tips (d) Input Calorific Equivalent of Food Items and Ingredients in the Food Exchange List 3. Allow the Administrator to (a) Manage User Accounts and Their Roles 3 D. Significance of the Project Filipinos love to eat. How could one resist having a vast, insanely delicious variety of food to choose from? But most of the time, our taste buds crave for the unhealthy ones for they seem to be more tasty. When the food tastes so good, we tend to be indulgent and eat more. Sometimes, we are unaware of the nutritional contents of what we eat and we exceed beyond the recommended daily calorie intake. Among the six nutrients that are vital to optimal health, fat receives the most attention among weight watchers and those with health conditions[10]. According to the National Institute of Health, Filipinos are at high risk of having fatty liver syndrome, hypertension, atherosclerosis, heart attack and stroke[10]. The lack of monitoring of food intake, nutritional information, content per serving, and weight constitute to unhealthy diet that may lead to certain health problems and conditions. This system will help monitor the calories of food and regulate food intake towards a healthier diet and ideal weight. The Body Mass Index can be computed to know if one is underweight, normal weight, overweight, or obese. There would be a recommendation to gain, maintain, or lose weight depending on the BMI Classification and Nutritional Status. With the current weight, the goal weight can be set up. To achieve the goal weight, the weight progress, calorie intake and daily meals can be monitored, considering the health conditions linked to diet, accompanied by recommended, custom, and shared recipes with the corresponding nutritional information. E. Scope and Limitations 1. This system will focus on the general Filipino diet. 2. There will be no recommendations for cultural or religious restrictions. 3. The target weight is based on the Body Mass Index. 4 4. The nutritional information will depend on the Food Exchange List from Food and Nutrition Research Institute. 5. The Health Conditions considered are Diabetes, Hypertension, and Kidney Stones. F. Assumptions 1. The weight condition is determined by the Body Mass Index. 2. The monitoring of the calorie intake is based on the daily meals. 3. The Content Manager is a Nutrition Expert. 4. The restrictions of the amount of ingredients for the health conditions shall be based on existing guidelines from the National Institutes of Health. 5 II. Review of Related Literature Self-monitoring is the centerpiece of behavioral weight loss intervention programs[11]. Diet is one component of self-monitoring in behavioral weight loss studies that includes recording dietary intake so that individuals are aware of their current behaviors[11]. There are many factors that may impact successful long-term change in eating habits[12]. For people who make a commitment to changing their eating habits, accurate logs of what they eat may help in monitoring progress toward set goals[12]. Monitoring food intake has been shown to help individuals become more aware of what and how much they eat and drink[13]. There are a number of different types of data that have a part to play in comprehensive nutritional intake information capture which may include: Food Type (where no food identifier is available), Food Portion Size, Food Identifier Information (Food identifiers including barcodes, are not always available, but when they are available, they provide a powerful and unambiguous information input.), Nutrition Fact Panels, Recipe Information, Aggregate Intake Information, Estimation Approaches[14]. The Nutrition Fact panel on food packaging provides calorie information for each serving of food or beverage and can assist consumers in monitoring their intake[13]. Currently, food logging is typically done by hand using paper diaries, spreadsheets, or a growing number of specialized applications[12]. Nutritionists have explored alternative methods such as daily interviews with trained experts[12]. While these methods improve accuracy, they are costly and still require substantial time investment[12]. Thus, the benefit of specialized applications to an individual is the reduction in the cost of healthcare.[15] There are existing applications for self-monitoring of diet. SparkPeople[7] is an application that considers if a female is pregnant and lactat6 ing, monitors weight and weight goal if one wants to lose weight 1 kg or 2 kg per week or just maintain, takes note of one’s activeness to be sedentary, lightly active, or active, takes note of health conditions, offers parenting tips if one has kids, allows daily meal planning with nutritional information, and offers a reward system. PlateMate is a system that allows users to take photos of their meals and receive estimates of food intake and composition[12]. It crowdsources nutritional analysis from photographs using Amazon Mechanical Turk, automatically coordinating untrained workers to estimate a meal’s calories, fat, carbohydrates, and protein[12]. It reduces user effort but is not always accurate because sometimes, the food on the photo taken is not properly recognized. Similar to PlateMate is the FoodLog[16]. It is a multimedia food-recording system where users upload photographs of their meals then a food diary is automatically constructed using image-processing functions such as food-image detection and food-balance estimation[16]. The dietary composition of the meal is recorded and the information is recorded for later viewing in formats such as a figure or a symbolic graphical representation[16]. It provides a convenient way of recording a users diet, but in the current state, the image-processing algorithms for estimating dietary composition are not very accurate[16]. The main reason for this is the use of a single global model for analyzing the photographs from users who may have different dietary preferences and habits[16]. Lose It is an application that allows the user to set weight loss goals and establish a daily calorie budget based on the Mifflin-St. Jeor equation (Estimating Percent Calorie Restriction, scientificpsychic.com)[17]. The user enters the food consumed and the program subtracts the caloric amount of the food from the total calories allowed per day[17]. The allowable caloric recommendation can be altered by entering exercise activities and durations, which are also tracked and can add 7 calories to the overall caloric budget[17]. Diet and exercise data are entered using a searchable database (loseit.com)[17]. Weight may be entered on a daily basis and feedback regarding macronutrient percentages and calories burned through exercise is given via a daily report[17]. Food Fight is an application that collects dietary and lifestyle data from the user[18]. There is a reward system for those who have achieved the goal based on actual results. There are more similar diet self-monitoring applications such as SapoFitness[19], Hyperfit[18], POND(Pattern-Oriented Nutrition Diary)[20], SuperTracker[13], Calorie Counter[21], My Diet Diary Calorie Counter[22], MyFitnessPal[23], NutriCoach[8], and Fat Secret[9] that serve as a reminder tool, calorie tracker, meal planner, or simply a food diary. 8 III. A. Theoretical Framework Nutrition One of the important things in health information is nutrition[15]. Food intake and nutritional status affect health significantly[15]. Every food has more than one type of nutrients[15]. Since every food has different nutrients, it is advisable to consume various food in one meal that have the source of energy substance (carbohydrates), builder substance (protein), and regulator substance (vitamin and mineral)[15]. The nutritional needs of a person vary depending on factors such as weight, height, and age. For the male calorie need, where C is calories, W is weight, H is height, and A is age[15]: C = 66 + (13.7 * W) + 5 (H) - (6.8 * A) For the female calorie need, where C is calories, W is weight, H is height, and A is age[15]: C = 655 + (9.6 * W) + (1.7 * H) - (4.7 * A) For the male and female protein need, where C is calories and NC is the need of calories[15]: C = 0.25 * NC For the male and female fat need, where C is calories and NC is the need of calories[15]: C = 0.70 * NC 9 For the male and female carbohydrate need, where C is calories and NC is the need of calories[15]: C = 0.65 * NC Based on age group (year), weight (kilogram=kg), height (centimeter=cm), energy (kilocalories=kcal), protein (gram=gr), and activity, the calorie needs for male, female and daily menu for household dose and nutritional needs of families in a day can be seen in Table 1,Table 2, and Table 3[15]: Age group (year) 3-9 10-12 13-15 16-19 20-59 20-59 20-59 60+ Table 1: The Calorie Need for Male Weight (kg) Height (cm) Energy (kcal) 12 90 1500 30 135 2000 45 150 2400 56 160 2500 62 165 2800 62 165 3600 62 165 3600 62 165 2200 Protein (gr) Activity 35 Normal 45 Normal 69 Normal 66 Normal 55 Light 55 Medium 55 Heavy 55 Normal Age group (year) 3-9 10-12 13-15 16-19 20-59 20-59 20-59 60+ Table 2: The Calorie Need for Female Weight (kg) Height (cm) Energy (kcal) 12 90 1500 35 149 1900 46 153 21200 50 156 2000 54 156 2050 54 156 2250 54 156 2600 54 54 1850 Protein (gr) Activity 35 Normal 54 Normal 62 Normal 51 Normal 48 Light 48 Medium 48 Heavy 48 Normal 10 Table 3: The Calorie Need for Pregnancy and Lactating Age group (year) Weight (kg) Height (cm) Energy (kcal) Protein (gr) Activity +285 +12 Pregnant 0-6 month +70 +16 Lactating 7-12 month +500 +12 Lactating 60+ +400 +11 Lactating B. IBW (Ideal Body Weight) The Ideal Body Weight (IBW) in kg can be computed with the given formula below [24]: Males: IBW = 50 kg + 2.3 kg for each inch over 5 feet. Females: IBW = 45.5 kg + 2.3 kg for each inch over 5 feet. C. BMI (Body Mass Index) Body Mass Index (BMI) is an inexpensive and easy-to-perform method used to find out if a person is underweight, normal weight, overweight, or obese[15]. It is obtained from a persons weight and height. It provides a reliable indicator of body fatness for most people and is used to screen for weight categories that may lead to health problems[15]. It can be considered an alternative for direct measures of body fat[15]. However, it is not a diagnostic tool[15]. For children and teens, BMI is age and sex-specific and is often referred to as BMI-for-age[15]. For adults, BMI is interpreted through categories that do not take into account sex or age[15]. The Body Mass Index (BMI) where BMI is Body Mass Index, W is weight and H is height[15]: BMI = W / H2 11 BMI Classification and Nutritional Status can be seen in Table 4[15]: BMI <18.5 18.5 - 24.9 25.0 - 34.9 >35.0 D. Table 4: Body Mass Index Classification Nutritional Status Under weight Malnutrition Healthy weight Normal Over weight Over Nutrition Obese Very Excess Nutrition Nutrition Information[5] Food Exchange List A sensible diet ensures that all food groups are represented in daily meals. The exchange list provides a good base for planning meals by classifying foods into seven groups. These are: vegetables, fruits, milk, rice, meat, fat and sugar. Each item in any of the groups may be substituted for any other item in the same group, as long as it is taken in the amount indicated. But foods listed in different groups are not of equal value and may not be interchanged. From the Rice Exchange List for instance, you may have 2 slices of bread in exchange for half a cup of rice. But you may not substitute half a cup of mongo since this belongs to a different group altogether. Legend: g = gram, EP = edible portion, AP = as purchased Each exchange in the list contains: 12 Table 5: Composition of Food Exchanges List I-A Food Measure (g) Veg. A Carbohydrate (g) 1 cup raw cup cooked 2 cups raw 1 cup cooked or 1 2 cup raw 1 2 cup cooked varies 10 varies 4 tbsp varies varies 12 12 12 23 Protein Fat Energy (Kcal) (Kj) 1 2 I-A Veg. A I-B Veg. B II III Fruit Milk Whole Low Fat Skimmed Rice Meat Low Fat Medium Fat High Fat Fat IV V VI varies varies varies 1tbsp 3 1 16 67 3 1 16 67 40 167 8 8 8 2 10 5 tr 170 125 80 100 711 523 335 418 8 8 8 1 6 10 5 41 86 122 45 172 360 510 188 Table 6: Vegetable Exchanges Equivalent CHO PRO FAT ENERGY (g) (g) (g) (KCalories) Group A Group B 3 1 16 13 Group A vegetables contain negligible carbohydrates, protein, and energy if 1 exchange or less is used. When 2 exchanges are used, compute as one Group B Vegetable. Unless otherwise specified, the portion size for one vegetable exchange is: Vegetable A: 1 exchange = 1 cup raw (25g) or Vegetable B: 1 exchange = 1 2 cup raw (40g) or 1 2 cup cooked (45g) 1 2 cup cooked (45 g) This list shows the kind of vegetables to use for one vegetable exchange: 1 exchange = 10 grams carbohydrate = 40 Kcalories The list shows the kind and amounts of foods to use for one fruit exchange: 14 Table 7: Vegetable Exchanges Group A Acelgas Alagaw Leaves Alugbati Leaves Ampalaya Fruit Balbalulang (Seaweed) Bamboo Shoot (Labong) Banana Heart (Puso ng Saging) Bataw Pods Beets Cabbage Camote Leaves Cassava Leaves and Tops Cauliflower Celery Chayote Fruit Chayote Leaves Cucumber Eggplant Gabi Leaves Himbabao Kangkong Katuray Katuray Flowers Lettuce Malunggay Leaves Malunggay Pods Mushroom Fresh Mustard Leaves Okra Onion Bulb Pako Papaya Green Patola Pepper Fruit Pepper Leaves Petchay Pokpoklo (seaweed) Radish Saluyot Sigarilyas Pods Spinach Squash Flower (kalabasa, bulaklak) Squash Leaves (kalabasa, dahon) Sweet pea pods (sitsaro) Talinum Tomato Unsoy Upo Group B Fresh; Abitsuela, bunga (snap green beans pod) Carrot Coconut Shoot Cowpea, pods (bunga) Lima, beans, pods (patani) Langka, hilaw Mungbean Sprout (toge) Pigeon Pea Pods Rimas Singkamas Pods (bunga) Singkamas Tuber (lamang gubat) Squash Fruit Stringbeans Pod (sitaw, bunga) 15 Table 8: Processed FOOD Asparagus Tips Baby Corn Weight (g) Edible Portion 90 15 Green Peas, canned (gisantes, canned) Golden Sweet Corn, canned Mushroom, canned Tomato Juice, canned Water Chestnut, canned 15 20 110 60 25 MEASURE 1 cup 2 (8 cm long x 5- 12 cm circumference each) 1 tablespoon 2 tablespoons 1 3 cup 1 2 cup undiluted 3 (2cm diameter each) One exchange of each of the sub-groups of milk contains: 1 Exchange = 23 grams carbohydrate (2 grams protein) = 100 Calories This list shows the kinds and amounts of rice, rice equivalents, bread and bakery products to use for one rice exchange: 16 Table 9: Fruit Exchange FOOD Fresh: Anonas Apple Atis Balimbing Banana Bungulan Lakatan Saba Cashew Chico Dalanghita Datiles Duhat Durian Grapes Guava Guyabano Jackfruit, ripe Kamachile Lanzones Lychees Mabolo Makopa Mango, green Medium ripe Ripe Indian Paho Mangosteen Marang Melon Kastila Papaya, ripe Pear Rambutan Santol Singkamas tuber Siniguelas Star Apple Strawberry Suha Tamarind, ripe Tiesa Watermelon Weight (g) A. P. 65 86 70 153 MEASURE E.P. 35 65 45 135 60 51 70 78 54 300 61 80 150 69 81 86 118 110 103 77 83 169 90 90 103 140 92 212 21 40 40 40 70 45 135 50 60 130 55 80 60 40 55 70 50 50 135 65 65 60 80 70 55 35 of 15 x 4 cm 1 (9 x 3 cm) 1 (1 x 4 cm) 1 (7 x 6 - 21 cm) 1 (4 cm diameter) 2 (6 cm diameter each) 1 cup 20 (2 cm diameter each) 1 segment of 6 - 32 x 4 12 cm or 1 12 tbsp. 10 (2 cm diameter each) or 4 (3 cm diameter each) 2 (4 cm diameter each) 1 slice (8 x 6 x 2 cm) or 12 cup 3 segments (6 cm diameter each) 7 pods 7 (4 x 2 cm each) 5 (3 cm diameter each) 2 3 of 6 cm diameter 3 (4 cm diameter each) 1 slice (11 x 6 cm) 1 slice (11 x 6 cm) 1 slice (12 x 7 cm) 12 cup cubed 1 (6 cm diameter) 9 small 3 (6 cm diameter each) 1 2 of 12 x 10 cm 317 133 118 139 127 124 78 123 168 160 34 41 226 200 85 85 50 75 110 50 65 165 90 15 30 140 1 slice (12 x 10 x 3 cm) or 1 - 13 cup 1 slice (10 x 6 x 2 cm) or 43 cup 1 slice (10 x 6 x 2 cm) or 12 cup 8 (3 cm diameter each) 1 (7 cm diameter each) 1 of (9 cm diameter each) or 1 cup 2 5 (3 cm diameter each) 1 2 of 6 cm diameter 1 14 cups 3 segments (8 x 4 x 3 cm each) 2 of 6 cm diameter 1 4 of 10 cm diameter 1 slice (12 x 6 x 3 cm) or 1 cup 1 2 1 2 of 5 x 8 cm of 8 cm diameter or 1 (6 cm diameter) 1 (5 cm diameter) 1 12 of 9 x 5 cm 1 2 17 Table 10: Milk Exchanges Equivalent CHO PRO FAT Whole Milk Low Fat Milk Skimmed/Very Low Fat Milk 12 12 12 8 8 8 ENERGY (KCalories) 10 170 5 125 Trace 80 Table 11: Milk Exchanges FOOD Weight (g) A.P. / E.P. *Whole Milk Milk, evaporated undiluted 125 Milk, evaporated filled undiluted 125 Milk, fresh carabao’s 250 Milk, fresh cow’s 250 Milk, powdered 30 *Low Fat Milk Powdered 30 Lite Low Fat Milk 250 *Skimmed (Non-Fat)/Very Low Fat Milk Buttermilk Liquid 185 Powdered 25 Long Life Skimmed Milk 250 Yoghurt 125 18 MEASURE 1 2 1 2 1 4 1 4 1 4 cup cup 1 cup 1 cup cup or 4 level tbsp. cup or 4 level tbsp 1 tetra-brick 2/3 cup cup or 4 level tbsp 1 cup 1 cup 2 Table 12: Rice Exchanges FOOD Weight (g) A.P. / E.P. A. RICE AND RICE PRODUCTS 1. Rice, cooked 2. Rice, gruel (lugaw) Thin consistency Medium consistency Thick consistency B. RICE EQUIVALENTS 1. Bread Pan Americano Pan de Bonete Pan de Leche Pan de Monay Pan de Sal Rolls (hotdog/hamburger) Whole wheat bread MEASURE 80 705 435 250 1 2 cup,packed 4- 12 cups 3 cups 1- 12 cups 40 40 40 40 40 45 2. Corn and Corn Products Binatog Corn/Rice curls and the like Corn, boiled Baby corn 3. Noodles, cooked Bihon Macaroni, Sotanghon, Spaghetti 4. Oatmeal 5. Rootcrops Sweet Potato 120 90 25 65 90 75 1 cup 185 1 cup 1 2 91 80 Cassava 115 85 Gabi 130 100 Potato 195 165 Ube 155 130 6. Beans and Nuts Chestnuts, roasted 55 40 11 pieces large or 20 pieces small 25 25 120 5 teaspoons 3 tablespoons 1 2 , cooked (Kastanyas, binusa) 7. Other Cornstarch Flour, all purpose Sago, cooked 19 of 11 cm long x 4- 12 cm diameter or 12 cup 1 (5cm long x 4 cm diameter) or 1 cup 2 (6cm long x 4cm diameter each) or 1 cup 2- 21 (7 cm long x 4cm diameter each) or 1- 13 cups 1 (8- 12 cm long x 4- 12 cm diameter) This list is subdivided into 3 sub-groups based on the amount of fat and calories: Low Fat, Medium Fat and High Fat meat and fish. Each exchange of meat and fish or substitute in the sub-group contains: Table 13: Meat and Fish Exchange Equivalent CHO PRO FAT - 8 8 8 1 6 10 Low Fat Meat and Fish Medium Fat Meat and Fish High Fat Meat and Fish ENERGY (KCalories) 41 86 122 List 5 Meat and Fish Exchange This list shows the kinds and amounts of low fat meat and fish to use for one low fat meat and fish exchange: Table 14: A. Low Fat Meat and Fish Exchanges FOOD Wt. (g) MEASURE E. P. cooked I. Lean Meat a. Beef Shank (bias, lean meat, laman) Round (pierna corta or pierna larga) 30 1 slice, matchbox size (5 x 3- 12 x1- 1 2 cm) Tenderloin (solomilyo), Sirloin Steak (tagiliran, hulihan) Centerloin (tagiliran, unahan) b. Carabeef Shank (bias) round (hita) Continued on next page 20 Table 14 – Continued from previous page FOOD Wt. (g) MEASURE E. P. cooked Meat (laman) bahagya, 30 1 slice matchbox size (5 x 3- 12 x 1- 21 cm) Katamtaman at walang taba Shoulder (paypay), round (pierna corta at pierna larga) Rump (tapadera) c. Lean Pork Tenderloin, well trimmed 30 1 slice matchbox size (5 x 3- 21 x 1- 1 2 cm) d. Chicken Leg (hita) or 30 1 small leg (13 - 1 2 cm long x 3 cm diameter ) Meat (laman) or 30 1 slice matchbox slice (5x3- 12 cm x 1- 12 cm) Breast meat (pitso) 30 1 4 breast (6cm long) 2. Variety Meats/ Internal Organs Blood (dugo) - pork, beef, chicken Continued on next page 21 Table 14 – Continued from previous page FOOD Wt. (g) MEASURE E. P. cooked Gizzard (balun-balunan) - chicken Heart (puso) - pork, beef, carabeef Liver (atay) - pork, beef, carabeef, chicken Lungs (baga) - pork, beef, carabeef, chicken 35 3 4 cup Omassum (librilyo) - beef, carabeef Small Intestine (bitukang maliit) - pork, beef, carabeef Spleen (lapay) - pork, beef, carabeef Tripe (goto) - beef Uterus (bahay guya) - pork, beef 3. Fish Large Variety: (e.g. bakoko, bangus, dalag, labahita, lapulapu, etc,) 35 1 slice (7 x 3 x 2 cm) Hasa-hasa, dalagang bukid 35 1 (18 x 4- 12 cm) Galunggong 35 1 (14 x 3- 12 cm) Medium Variety: Continued on next page 22 Table 14 – Continued from previous page FOOD Wt. (g) MEASURE E. P. cooked 1 2 Hito 35 of 22 x 5 cm Small Variety: Sapsap 35 2 (10 x 5 cm each) Tilapya 35 2 (12 x 5 cm each) Tamban 35 2 (12 - 1 2 x 3 cm each) Dilis 1 4 35 cup 4. Other Seafoods 30 1- 14 tablespoons Alimango 15 1 tablespoon Alimasag 50 3 tablespoons Alimango/Alimasag, laman 20 Alamang, tagunton Aligue: 1 4 1 2 cup or piece medium Lobster 30 2 tablespoons Talangka 30 75 pieces A. P. Shrimps: Puti 25 5 (12cm each) Sugpo 25 2 (13cm each) Suwahe 25 5 (12cm each) Octopus (pugita) 30 Squid (pusit) 25 Shells: Halaan 75 1 2 cup 3 (7 x 3 cm each) 1 3 cup shelled or 3 cups with shell Kuhol 50 1 2 cup shelled or 3 cups with shell Susong pilipit 65 1 3 cup shelled or Continued on next page 23 Table 14 – Continued from previous page FOOD Wt. (g) MEASURE E. P. cooked 2 cups with shell Paros 60 1 cup shelled or 2- 32 cups with shell 5. Beans Pigeon pea seeds, dried (kadyos, buto, tuyo) 55 1 3 cup 60 1 3 cup 6. Cheese Cottage cheese 7. Processed Foods Dried: Daing: Alakaak, Alumahan, 1 (15- 12 20 x 8 cm) Bisugo, Biyang puti 1 4 Lapu-lapu 20 of 30 x 40 cm Sapsap 20 3 (9 x 5 cm each) Tamban 20 1 (16 x 3 cm) Bangus 30 1 4 Galunggong 30 1 (16 x 4 cm) Tamban 25 1 (16 x 5 cm) Tinapa: of 20 x 8 cm Tuyo: Alamang 15 Ayungin, dilis sapsap 20 1 3 cup 3 (11 - 1 2 x 8cm each) Tunsoy 15 1 (8 x 1 cm) Continued on next page 24 Table 14 – Continued from previous page FOOD Wt. (g) MEASURE E. P. cooked Pusit Canned: Salmon 40 1 3 cup flaked Tuna in brine 30 1 3 cup flaked This list shows the kinds and amounts of medium fat meat and fish to use for one medium fat meat and fish exchange: Table 15: B. Medium Fat Meat and Fish Exchanges FOOD Wt. (g) E. P. cooked MEASURE 30 1 slice I. Lean Meat a. Beef Flank (kabilugan) matchbox size (5 x 3- 12 1 2 x 1- 21 cm) Brisket (punta y pecho) Plate (tadyang) Chuck (paypay) b. Pork Leg (pata) 30 1 slice (4 cm dia. x 2 leg (pata) cm thick) 2. Variety 35 1 4 cup Meats/Internal Organs Continued on next page 25 Table 15 – Continued from previous page FOOD Wt. (g) E. P. cooked MEASURE 35 1 slice Brain (utak) - pork, beef, carabeef 3. Fish Carpa (15 x 7 x 2 cm) 4. Egg Chicken 60 1 piece Quail’s egg 70 9 pieces Salted duck’s egg 60 1 piece 35 1 slice 5. Cheese Cheese, cheddar (6 x 3 x 2 cm) 6. Chicken Wings (pakpak) 25 1 medium or 2 small Head (ulo) 35 2 heads 7. Beans Soybeans (utaw) 40 1 2 cup 8. Processed foods a. Fish Products Sardines canned in oil/tomato sauce 45 1 (10 x 4- 12 cm) Tuna sardines 50 1- 12 of 6 x 4 x 3 cm each Tuna spread, 30 2 tablespoons Continued on next page 26 Table 15 – Continued from previous page FOOD Wt. (g) E. P. cooked MEASURE Corned beef 40 3 tablespoons Ham sausage 55 3 of 9cm diameter canned b. Meat Products x 0.3 thick each c. Bean Products Soybean cheese, soft (tofu) 100 Soybean cheese, 60 1 2 cup 1 (6 x 6 x 2 cm) soft (tokwa) The list shows the kinds and amounts of high fat meat and fish to use for one high fat meat and fish exchange: Table 16: C. High Fat Meat and Fish Exchanges FOOD Wt. (g) E. P. cooked MEASURE 35 1 slice (3 cm cube) 1. Pork Ham (pigue) 2. Variety meats/internal organ Tongue (dila) - pork, beef 35 3 4 cup 3.Egg Duck’s egg 70 1 piece Balut 65 1 piece Penoy 60 1 piece Continued on next page 27 Table 16 – Continued from previous page FOOD Wt. (g) E. P. cooked MEASURE 4. Nuts Peanuts, roasted 1 3 25 cup 5. Cheese Cheese, filled 50 1 slice (6 x 3 2- 12 cm) Cheese, pimiento flavored 40 1 slice (6 x 3 x 2 cm) 6. Processed foods Meat Products Frankfurters 1- 12 of 60 12 x 1- 13 cm Salami 50 3 slices (8 x 8 x 1 cm each) Vienna sausage 70 4 (5 x 2 x 2 cm) This list shows the kinds and amounts of fat to use for one fat exchange: Table 17: Fat Exchange List FOOD Wt. (g) E. P. cooked MEASURE POLYUNSATURATED FATS/OIL (corn, margarine, soybean Continued on next page 28 Table 17 – Continued from previous page FOOD Wt. (g) E. P. cooked MEASURE 5 1 teaspoon pili nut 5 5 pieces peanut oil, olive oil 5 1 teaspoon shortening 5 1 teaspoon rapeseed-canola, rice sunflower, safflower and sesame MONOUNSATURATED FATS E. Health Conditions A persons diet may be different from the usual depending on certain health conditions. There are a lot but the focus will be on the three major health conditions linked with diet, namely, diabetes, hypertension, and kidney stones. Diabetes is a health condition where the body cannot produce or properly use insulin, a substance that helps the body use sugar (glucose) for energy[25]. The body is incapable of using glucose, letting it stay in the blood stream, resulting in high levels of sugar[25]. There are two main types of diabetes: Type 1 or insulindependent which is treated with daily insulin injections, regular exercise, and a balanced meal plan and Type 2 or non-insulin dependent which is treated with an individualized diet plan that usually restricts calories especially from fat, so that a healthy weight can be reached and maintained[26]. In Type 1, the daily meal plan is customized to an individuals needs, which is likely to include 2-3 snacks eaten at set times each day[26]. In Type 2, treatment may include a regular exercise plan and if diet and exercise cannot control blood glucose, oral medication or insulin injections may be needed[26]. 29 Carbohydrate counting is a meal planning method for people with diabetes that allows diabetes to be managed through diet[27]. In monitoring the amount of carbohydrates, there is a better control over blood sugar levels[27]. Typically, 3045 grams of carbohydrate for females and 45-60 grams of carbohydrate for males are allowed at a meal[27].The table below shows the Daily Calorie Meal Plans (Table 18) for the Type 2 Diabetes[28]. Table 18: Daily Calorie Meal Plans Calorie 1,200 1,500 1,800 2,000 Meal Plans (Daily) Starch 5 7 8 9 Fruit 3 3 4 4 Milk 2 2 3 3 Vegetables 2 2 3 4 Meat and 4 4 6 6 Meat Substitutes Fat 3 4 4 5 2,500 11 6 3 5 8 6 Hypertension is having a high blood pressure[29]. According to the Philippine Society of Hypertension (PSH), more than 10 million Filipinos suffer from hypertension of which half are not aware of their condition, which prompted them to recommend a specialized diet plan for those suffering from abnormal blood pressure[30]. Based on studies conducted in four medical centers in the United States is the Dietary Approach to Stop Hypertension or DASH, in which findings showed that blood pressures were reduced with an eating plan that is low in saturated fat, cholesterol, and total fat that gives emphasis on fruits, vegetables, and fat-free or low-fat milk and milk products[30]. Table 19 shows the DASH Diet[31]. 30 Table 19: Dietary Approach to Stop Hypertension Food Group Daily Servings Serving Sizes (except as) Examples and Significance of Notes Each Food noted) Group to the DASH Eating Plan Grains and 7-8 Grain Products 1 slice bread Whole wheat Major 1 oz dry cereal* bread, English sources of energy cup cooked muffin, pita and fiber rice, pasta, or bread, bagel cereal cereals, grits 1 2 oatmeal crackers unsalted pretzels and popcorn Vegetables 4-5 1 2 cup cooked Tomatoes, Rich sources of vegetable potatoes, potassium, 6oz vegetable carrots, green magnesium and juice peas, squash, fiber 6 oz fruit juice Apricots, Important 1 medium fruit bananas, dates sources of grapes, oranges potassium, orange juice, magnesium and grapefruit fiber broccoli, turnip, greens, collards, kale, spinach, artichokes, green beans, lima beans, sweet potatoes Fruits 4-5 1 4 cup dried fruit 1 2 cup fresh, frozen or grapefruit juice, canned fruit mangoes, Continued on next page 31 Table 19 – Continued from previous page Food Daily Serving Examples Significance of Group Servings Sizes and Notes Each Food (except as noted) Group to the DASH Eating Plan melons, peaches, pineapples, prunes, raisins, strawberries, tangerines Low fat or fat 2-3 free dairyfoods 8 oz milk Fat free (skim) Major sources 1 cup yogurt or low fat (1 %) of calcium milk, fat free and protein 1 2 1 oz cheese or lowfat buttermilk, fat free or lowfat regular or frozen yogurt, lowfat and fat free cheese Meats, poultry, 2 or less and fish 3oz cooked Select only lean: Rich sources of meats, poultry, trim away visible protein and or fish fats: broil, roast magnesium or boil, instead of frying; remove skin from poultry Nuts, seeds, and dry beans 4-5 per week 1 3 cup or 1 1 2 oz nuts 2 Tbsp seeds Continued on next page 32 Almonds, Rich sources filberts, mixed of energy, 1 2 oz nuts, peanut, walnuts, magnesium, or Table 19 – Continued from previous page Food Daily Serving Examples Significance of Group Servings Sizes and Notes Each Food (except as noted) Group to the DASH Eating Plan 1 2 cup cooked sunflower seeds, potassium, kidney beans, protein and lentils, peas fiber 1 tsp soft Soft margarine, DASH has 27 margarine lowfat percent of 1 Tbsp lowfat mayonnaise, calories as fat, mayonnaise light salad including 2 Tbsp light dressing, that in salad dressing vegetable oil or added 1 tsp vegetable (such as olive, to foods oil corn, canola or dry beans Fats and oils ** 2-3 safflower Sweets 5 per week 1 Tbsp sugar Maple syrup, Sweets should 1 Tbsp jelly or sugar, jelly, jam, be low in fat jam fruit-flavored 1 2 oz jelly beans 8 oz lemonade gelatin, jelly beans, hard candy, fruit punch, sorbet, ices *Equals 12 -1 1 4 cup, depending on cereal type. Check the products nutrition label. *Fat content changes serving counts for fats and oils: For example, 1 Tbsp of regular salad dressing equals 1 serving: 1 Tbsp of a low fat dressing equals 1 2 serving: 1 Tbsp of a fat free dressing equals 0 servings. Kidney stones form when substances in the urine such as calcium, oxalate, and 33 phosphorus become highly concentrated[32]. Studies have shown that the Dietary Approaches to Stop Hypertension (DASH), shown in Table 19, can reduce the risk of kidney stones, for it is high in fruits and vegetables, moderate in low-fat dairy products, and low in animal protein[32]. F. Web Applications A web application is an application utilizing web and [web] browser technologies to accomplish one or more tasks over a network, typically through a [web] browser[33]. Below is the breakdown of web applications[33]: Application [Software]: Application software, also known as an application or an app, is computer software designed to help the user to perform singular or multiple related specific tasks. Web technologies: Flash, Silverlight, JavaScript, HTML and CSS, Java, various other programming languages and other computer technology intended for the use across networks. Network: The internet or intranet. Browser: Firefox, Chrome, Safari, Opera, Internet Explorer and various others. Different web application technologies aside, the most confusion as to what qualifies as a web app comes from so many websites out there with varying degrees of usefulness[33]. Not all websites are web apps. If it doesnt perform some sort of task, functioning in some way, its probably not a web app[33]. A simple web application is compatible on all mobile devices, laptop computers, and desktop computers that have an internet connection. 34 G. Database Management System A database management system is a set of software programs that allows users to create, edit, and update data in database files, and store and retrieve data from those database files[34]. Using DBMS, data can be added, deleted, changed, sorted, or searched[34]. Examples include MySQL, PostgreSQL, Microsoft Access, SQL Server, FileMaker, Oracle, RDBMS, dBASE, Clipper, and FoxPro[35]. 35 IV. A. Design and Implementation Context Diagram Healthy Eating Alert System: Food Intake Monitor (HEAS: FIM) has three user types: Registered User, Content Manager, and Administrator. Figure 1: Context Diagram of HEAS:FIM Figure 1 shows the context diagram of the system. HEAS:FIM system interaction with the three external actors is shown. The Registered User is responsible for his/her own profile. He/she will add fitness profile information to his/her own fitness profile. He/she could also create his/her own recipes with corresponding calorific values and consideration of health conditions. He/she can then make daily meal plans with the recipes he/she created. Achievement can also be shared on the system. The Content Manager is responsible for the health tips that would be seen by the registered users, entries in the food exchange list coming from reliable sources such as FNRI, and recommended recipes and daily meals with corresponding calorific values and consideration of health conditions that the reg- 36 istered users can browse. Lastly, the Administrator is responsible for account management, with functionalities such as creating another administrator or content manager, activation/deactivation of accounts and editing of account details, and data backup. B. B..1 Use Cases Top Level Use Case Diagram Figure 2: Top Level Use Case Diagram of HEAS:FIM Figure 2 shows the three actors in the HEAS:FIM: the Registered User, the Content Manager, and the Administrator. The main role of the Registered User shall be to fill out and manage own profile. The content manager shall provide content for some recommended recipes, daily meals, and health tips. The Administrator shall manage accounts of all actors of the HEAS:FIM and shall backup system data. 37 B..2 Profile Management Figure 3: Activity Diagram: HEAS:FIM Profile Management Figure 3 shows the Activity Diagram of the Registered User Profile Management. The Registered User, before becoming one, shall first register as a user. The User Information Form will be shown. The form shall be filled out completely, and then the system will verify the registration. If successful, the user may login. Otherwise, there would be an alert to fill out the User Information Form correctly and completely. Next, the Fitness Profile Form will be shown. If the form is filled out, Health Information such as BMI, Calorie Need, and Restrictions will be calculated. The Registered User can then Browse Recipes, Create Recipes, and finally, Plan Daily Meals. 38 B..3 Content Management Figure 4: Use Case (HEAS:FIM Content Management) Figure 4 shows the sub explosion of the HEAS:FIM Content Management. The Content Manager shall input health tips and recommended recipes. The data will then be stored in the database as shown in Figure 5. After which, he/she can browse recipes, nutritional contents, and health tips to choose which to share as shown in Figure 6. Then, the system will recommend daily meals. 39 B..4 Input Health Tips Figure 5: Activity Diagram: HEAS:FIM Input Health Tips 40 B..5 Browse Recipes, Food Nutritional Contents, Health Tips Figure 6: Activity Diagram: HEAS:FIM Browse Recipes, Food Nutritional Contents, Health Tips 41 B..6 Account Management Figure 7: Use Case (HEAS:FIM Account Management) Figure 7 shows that the Administrator shall manage accounts. He/she can manually add user (Figure 8), view users (Figure 9), delete user (Figure 10), and manage password (Figure 11). 42 B..7 Add User Figure 8: Activity Diagram: HEAS:FIM Add User The Administrator can add users particularly Content Managers by filling out and completing the Add User Form. The data will be stored in the database after submitting the form. 43 B..8 View Users Figure 9: Activity Diagram: HEAS:FIM View Users The Administrator can view users by selecting Show Users. A particular user can be viewed by selecting Choose User. The User Information will be shown. 44 B..9 Delete User Figure 10: Activity Diagram: HEAS:FIM Delete User The Administrator, when necessary, can delete a particular user by first selecting the user (Figure 9). After clicking the Delete Button, a confirmation message whether to continue or not the deletion will be shown. When chosen to continue, User Data will be deleted. 45 B..10 Manage Password Figure 11: Activity Diagram: HEAS:FIM Manage Password The Administrator can manage password by first choosing the user then by sending a forgotten password link to the e-mail address linked to the account. 46 B..11 Plan Daily Meals Figure 12: Flow Chart: HEAS:FIM Plan Daily Meals 47 C. C..1 Database Structure Entity Relationship Diagram Figure 13: HEAS:FIM Entity Relationship Diagram Figure 13 shows the Entity Relationship Diagram of the HEAS:FIM. Each registered user has his/her own user information. He/she can have one and only one fitness profile (fitness profile table). In a fitness profile, there can be more than one health condition linked to the profile owner (health conditions table). He/she can create (own recipes table) or share more than one recipe (shared recipes table) and share achievements (shared achievements table) such as achieved goal weight. Every created and shared recipe is linked to health conditions, if exists. The Content Manager can create and share health tips (health tips table) and recommend recipes customized with particular health conditions. The food exchange list (food exchange list table) contains the composition and exchanges equivalent of food exchanges. The health conditions restrictions table contain certain restrictions for Diabetes, Hypertension, and Kidney Stones. 48 C..2 Data Dictionary Attribute user id username password confirm password first name middle name last name user type email address gender birthday status Table 20: users table Data Type int (20) varchar (20) varchar (50) varchar (50) varchar (20) varchar (20) varchar (20) enum (’Administrator’, ’Content Manager’, ’User’) varchar (50) enum (’Male’, ’Female’) date enum (’Activated’, ’Deactivated’) 49 Description Primary Key, User ID User Username User Password User Confirm Password User First Name User Middle Name (optional) User Last Name User User Type User E-mail Address User Gender User Date of Birth User Account Status Table 21: fitness profile table Attribute Data Type Description fitness info id int (20) Primary Key, Fitness Info ID user id int (20) Foreign Key, References users (user id), User ID float Stores the Goal Weight goal weight entered by the Registered User current weight float Stores the Current Weight entered by the Registered User height float Stores the Height entered by the Registered User float Daily Calorie Limit calorie limit of the Registered User in Kcal float Daily Carbohydrate Limit carbohydrate limit of the Registered User in g protein limit float Daily Protein Limit of the Registered User in g float Daily Fat Limit fat limit of the Registered User in g record date date Date when the record was entered 50 Attribute health condition id Table 22: health conditions table Data Type int (20) Description Primary Key, Health Condition ID Foreign Key, References users (user id), User ID user id int (20) fitness info id int (20) Foreign Key, References fitness profile (fitness info id), Fitness Info ID health condition set (’Diabetes’,’Hypertension’, ’Kidney Stones’,’None’) date Health Condition record date Attribute own recipe id Table 23: own recipes table Data Type int (20) user id int (20) health condition recipe name serving sugg preparation procedure set (’Diabetes’,’Hypertension’, ’Kidney Stones’,’None’) enum (’Breakfast’, ’Lunch’, ’Dinner, ’Snack’) varchar (50) float longtext calories carbohydrate protein fat float float float float meal type 51 Date when the record was entered Description Primary Key, Own Recipe ID Foreign Key, References users (user id), User ID Health Condition Meal Type Recipe Name Recipe Serving Size Recipe Preparation Procedure Recipe Calories in Kcal Recipe Carbohydrate in g Recipe Protein in g Recipe Fat in g Table 24: recommended recipes table Attribute Data Type recommended recipe id int (20) user id int (20) health condition recipe name serving sugg preparation procedure set (’Diabetes’,’Hypertension’, ’Kidney Stones’,’None’) enum (’Breakfast’, ’Lunch,’ ’Dinner, ’Snack’) varchar (50) float longtext calories carbohydrate protein fat float float float float meal type Description Primary Key, Recommended Recipe ID Foreign Key, References users (user id), User ID Health Condition Meal Type Recipe Name Recipe Preparation Procedure Recipe Calories in Kcal Recipe Carbohydrate in g Recipe Protein in g Recipe Fat in g Table 25: shared recipes table Attribute Data Type Description shared recipe id int (20) Primary Key, Shared Recipe ID user id int (20) Foreign Key, References users (user id), User ID own recipe id int (20) Foreign Key, References own recipes (own recipe id), Own Recipe ID 52 Table 26: recipe images table Attribute Data Type Description recipe image id int (20) Primary Key, Recipe Image ID own recipe id int (20) Foreign Key, References own recipes (own recipe id), Own Recipe ID varchar (40) Image Name img name varchar (40) Image Thumbnail Name thumb name ext varchar (8) Image File Extension upload date varchar (20) Image Upload Date Table 27: recipe images recommended table Attribute Data Type Description recipe image id int (20) Primary Key, Recipe Image ID int (20) Foreign Key, recommended recipe id References recommended recipes (recommended recipe id), Recommended Recipe ID varchar (40) Image Name img name thumb name varchar (40) Image Thumbnail Name ext varchar (8) Image File Extension varchar (20) Image Upload Date upload date Table 28: plan daily meals table Attribute Data Type plan daily meal id int (20) user id own recipe id meal group record date Description Primary Key, Plan Daily Meal ID int (20) Foreign Key, References users (user id), User ID int (20) Foreign Key, References own recipes (own recipe id), Own Recipe ID enum (’Breakfast’, ’Lunch’, Meal Group ’Dinner’, ’Snack’) date Date when the record was entered 53 Table 29: recommended daily meals table Attribute Data Type recommended daily meal id int (20) user id recommended recipe id meal group record date Description Primary Key, Recommended Daily Meal ID int (20) Foreign Key, References users (user id), User ID int (20) Foreign Key, References recommended recipes (recommended recipe id), Recommended Recipe ID enum (’Breakfast’, ’Lunch’, Meal Group ’Dinner’, ’Snack’) date Date when the record was entered Table 30: shared achievements table Attribute Data Type Description shared achievement id int (20) Primary Key, Shared Achievement ID int (20) Foreign Key, user id References users (user id), User ID achievement longtext Achievement Table 31: health tips table Attribute Data Type Description health tip id int (20) Primary Key, Health Tip ID user id int (20) Foreign Key, References users (user id), User ID health tip longtext Health Tip post date date Date when the record was posted 54 Table 32: ingredients table Attribute Data Type Description ingredient id int (20) Primary Key, Ingredient ID int (20) Foreign Key, own recipe id References own recipes (own recipe id), Own Recipe ID food group varchar (50) Food Group food name varchar (50) Food Name measure varchar (50) Measure with Unit float Serving Size serving size Table 33: ingredients recommended table Attribute Data Type Description ingredient id int (20) Primary Key, Ingredient ID recommended recipe id int (20) Foreign Key, References recommended recipes (recommended recipe id), Recommended Recipe ID food group varchar (50) Food Group food name varchar (50) Food Name measure varchar (50) Measure with Unit serving size float Serving Size 55 Table 34: food exchange list table Attribute Data Type food exchange list id int (20) list group food group food group category food name measure carbohydrate protein fat energy weight as purchased weight edible portion varchar (50) (’I-A’,’I-B’,’I-P’,’II’,’III’, ’IV’,’V’,’VI’,’Other’) varchar (50) (’Vegetable’,’Fruit’,’Milk’, ’Rice’,’Meat’,’Fat’,’Other’) varchar (50) (’Vegetable’,’Fruit’,’Milk’, ’Rice’,’Meat’,’Fat’,’Other’) varchar (50) varchar (50) float float float float float float Description Primary Key, Food Exchange List ID List Group Food Group Food Group + Category Food Name Measure with Unit Carbohydrate in g Protein in g Fat in g Calories, in Kcal Weight in g Weight in g Table 35: health conditions restrictions table Attribute Data Type Description health conditions restrictions id int (20) Primary Key, Health Conditions Restrictions ID varchar (50) Food Group food group diabetes restriction float Restriction Quantity by Food Group hypertension restriction float Restriction Quantity by Food Group kidney stones restriction float Restriction Quantity by Food Group 56 V. A. Architecture System Architecture Figure 14: HEAS:FIM System Architecture Figure 14 shows the three layers of HEAS:FIM. The Presentation Layer contains the web user interface encoded in HTML, Jquery, Javascript, and PHP. The Service Layer is linked to the Presentation Layer through the Codeigniter Framework which is based on the MVC(Model-View-Controller) development pattern and uses the PHP language.The Database Layer is linked to the Service Layer in which MySQL is used by HEAS:FIM as its main database. B. Technical Architecture The minimum requirements for Healthy Eating Alert System: Food Intake Monitor: • Web Server: Apache • Database Server: MySQL • MySQL Administration Tool: phpMyAdmin • PHP Framework: CodeIgniter 57 • Web Browser: best on Google Chrome • Stable Internet Connection • 1.4 GHz Solo Core • 1 GB RAM 58 VI. A. A..1 Results General View HEAS:FIM Home Page Figure 15: HEAS:FIM Home Page Figure 15 shows the home page of Healthy Eating Alert System: Food Intake Monitor. The administrator, content manager, and user can login to their accounts through this page. If a user does not have an account yet, he/she may register also through this page. A content manager account is created by the administrator. In case of forgotten password, there is a Forgot password link. 59 A..2 Profile Figure 16: HEAS:FIM Profile Figure 16 shows the common button for the administrator, content manager, and user. It displays the name and user type of the one logged in. Profile information can be viewed and edited. Password can be changed. It contains the logout link. B. B..1 Administrator View Administrator Home Page Figure 17: HEAS:FIM Administrator Home Page Figure 17 shows the administrator home page. Administrative functions can be accessed through the buttons. He/She can manage accounts. 60 B..2 Add User Figure 18: Add User By clicking the Add User button on the administrator home page, the administrator can create an account for administrator or content manager. (Figure 18). B..3 View Users Figure 19: View Users By clicking the Search button on the administrator home page, the administrator can view, edit, activate/deactivate, or delete existing accounts. (Figure 19). 61 C. C..1 Content Manager View Content Manager Home Page Figure 20: HEAS:FIM Content Manager Home Page Figure 20 shows the content manager home page. Content Manager functions can be accessed through the buttons. He/She can add content (Food Exchange Item, Recommended Recipe, Recommended Daily Meal Plan, Health Tip), view the content/s he/she added, and delete content/s (Food Exchange Item, Recommended Recipe, Recommended Daily Meal Plan, Health Tip). C..2 View, Edit, or Delete Food Exchange List Item/s Figure 21: View, Edit, or Delete Food Exchange List Item/s 62 By clicking the Search button for Food Exchange List on the content manager home page, the content manager can view, edit, or delete Food Exchange List item/s. (Figure 21). C..3 View, Edit, or Delete Health Tip/s Figure 22: View, Edit, or Delete Health Tip/s By clicking the Search button for Health Tips on the content manager home page, the content manager can view, edit, or delete Health Tip/s. (Figure 22). 63 C..4 Add Content Figure 23: Add Content By clicking the Add Content button, links to add Food Exchange Item, Recommended Recipe, Recommended Daily Meal Plan, and Health Tip can be accessed. (Figure 23). C..5 Add Food Exchange List Item Figure 24: Add Food Exchange List Item By selecting the Food Exchange Item under Add Content, the content manager can add item/s to the Food Exchange List. (Figure 24). 64 C..6 Create Recipe Figure 25: Create Recipe By selecting the Recipe under Add Content, the content manager can create recipe/s that would be recommended to the users. (Figure 25). C..7 Recommend Daily Meals Figure 26: Recommend Daily Meals By selecting the Daily Meal Plan under Add Content, the content manager can 65 add meals that would be recommended to the users by clicking Search Meal or view or delete added meals by choosing a date and clicking Go. (Figure 26). C..8 Add Meal Figure 27: Add Meal Figure 28: Add Recipe Meal 66 Figure 29: View Recipe Meal (Figure 26). The content manager can add the recipe meal to a chosen date (Figure 28) or view the recipe first (Figure 29). C..9 View or Delete Meal/s Figure 30: View Meal/s 67 Figure 31: View Added Meals (Figure 30). The content manager can view added meals and details (Figure 31) by choosing a date and view or delete each recipe. (Figure 31). C..10 Add Health Tip Figure 32: Add Health Tip By selecting the Health Tip under Add Content, the content manager can add health tip that would be shared to users. (Figure 32). 68 C..11 View Figure 33: View By clicking the View button, link to Recipes Created can be accessed. (Figure 33). C..12 View Created Recipes Figure 34: View Created Recipes By selecting Recipes Created under View, recipes created can be viewed, edited, or deleted. (Figure 34). 69 D. D..1 User View User Home Page Figure 35: HEAS:FIM User Home Page Figure 35 shows the user home page. User functions can be accessed through the buttons. He/She can view shared achievements and health tips, view, add or delete fitness information from his/her Fitness Profile, create recipes, view or delete created recipes, plan daily meals, share achievement, and browse shared and recommended recipes, recommended daily meal plan, and food nutritional information. 70 D..2 Fitness Profile Figure 36: Fitness Profile By clicking the Fitness Profile button, links to view, add or delete Fitness Profile information can be accessed. (Figure 36). D..3 View Information Figure 37: View Information By selecting View Information under Fitness Profile, Fitness Profile information can be viewed or deleted. (Figure 37). 71 D..4 Add Information Figure 38: Add Information By selecting Add Information under Fitness Profile, Fitness Profile information can be added. (Figure 38). D..5 Recipes Figure 39: Recipes By clicking the Recipes button, links to create, view, or delete created recipes, 72 and plan, view, or delete daily meals can be accessed. (Figure 39). D..6 Create Recipe Figure 40: Create Recipe By selecting the Create Recipe under Recipes, the user can create recipe/s considering health conditions if any. (Figure 40). 73 D..7 View Created Recipes Figure 41: View Created Recipes By selecting Created Recipes under Recipes, recipes created can be viewed, edited, deleted, or shared. (Figure 41). D..8 Plan Daily Meals Figure 42: Plan Daily Meals By selecting Plan Daily Meals under Recipes, the user can add meals by clicking Search Meal or view or delete added meals by choosing a date and clicking Go. (Figure 42). 74 D..9 Add Meal Figure 43: Add Meal Figure 44: Add Recipe Meal (Figure 43). The user can add the recipe meal to a chosen date (Figure 44) or view the recipe first. 75 D..10 View or Delete Meal/s Figure 45: View or Delete Added Meals The user can view added meals and details by choosing a date and view or delete each recipe. (Figure 45). 76 D..11 Share Achievement Figure 46: Share Achievement By clicking the Share Achievement button, links to share achievement on site or on Facebook can be accessed. (Figure 46). D..12 Share Achievement on Site Figure 47: Share Achievement on Site By selecting on this Site under Share Achievement, the user can share his/her achievement/s on the site. (Figure 47). 77 D..13 Share Achievement on Facebook Figure 48: Share Achievement on Facebook By selecting on Facebook under Share Achievement, the user can share his/her achievement/s on Facebook. (Figure 48). D..14 Browse Figure 49: Browse By clicking the Browse button, the user can browse for shared and recommended recipes, recommended daily meals, and food nutritional information. (Figure 49). 78 D..15 Browse Shared Recipes Figure 50: Browse Shared Recipes By selecting Shared Recipes under Browse, the user can view recipes shared by other users. (Figure 50). D..16 Browse Recommended Recipes Figure 51: Browse Recommended Recipes By selecting Recommended Recipes under Browse, the user can view recommended recipes. (Figure 51). D..17 Browse Recommended Daily Meals Figure 52: Browse Recommended Daily Meals 79 By selecting Recommended Daily Meals under Browse, the user can view recommended daily meals by date. (Figure 52). D..18 Browse Food Nutritional Information Figure 53: Browse Food Nutritional Information By selecting Food Nutritional Information under Browse, the user can view the nutritional information of food. (Figure 53). 80 VII. Discussions Healthy Eating Alert System:Food Intake Monitor or HEAS:FIM is a system that helps monitor fitness and calorie intake towards a healthier living that focuses mainly on the Filipino diet. In this special problem, the application that has been developed is a combination of some of the separate functionalities of existing similar applications and an advancement as it allows creation of recipes from scratch and considers some of the health conditions. With the Codeigniter Framework having an MVC (Model-View-Controller) development pattern, there was not much difficulty experienced in developing the system aside from some Javascript coding, restriction of the amount of ingredients when needed due to health conditions, and integration with social media such as Facebook. Creation of forms with the Codeigniter validation and designing of forms were done using HTML, PHP, Jquery, Javascript, and CSS through Notepad++. The view files, which are in the presentation layer of the system architecture, contain the web interface made using the mentioned programming languages. The controller files, which contain the functionalities, serve as the link between the service layer and the database layer in which MySQL queries are made through the model files using PHP. Codeigniter’s database class containing database functions made it easier to perform MySQL queries. Given this flow, it was not too difficult combining the three parts. HEAS:FIM offers daily meal planning, recipe creation from scratch with corresponding calorific values, restriction of the amount of ingredients considering health conditions, current weight versus goal weight and calorie monitor, recommendation of recipes, daily meals, and health tips, and sharing of achievements that will help monitor the calories of food to regulate food intake towards a healthier diet and ideal weight. Although the use of Codeigniter made the creation of HEAS:FIM somewhat secure and efficient, there were still some difficulties. One of which was on the creation of the Create Recipe form. The built-in Codeigniter form validation cannot seem 81 to validate the added ingredients along with restrictions of which are contained in Javascript dynamic textboxes. After taking some time searching for a possible solution, the solution was to perform the validation both on the client-side, using Javascript, and the server-side. The data from the client-side should already be in the right form before passing to the server-side. Still, these difficulties did not hinder in achieving the goals of the system. 82 VIII. Conclusions Healthy Eating Alert System:Food Intake Monitor allows users to plan daily meals, create recipes from scratch with corresponding calorific values and restriction of the amount of ingredients considering health conditions, monitor calorie intake and goal weight if achieved, share achievements, and view health tips, recommended recipes and recommended meals. The system could help them monitor fitness and calorie intake towards a healthier living. Access to these functionalities could be gained by registering an account and logging in using the registered username and password provided that the account is activated. A content manager is in charge of managing some of the information namely creation of recipes from scratch with corresponding calorific values and restriction of the amount of ingredients considering health conditions that would be recommended to users along with daily meal plans, health tips, and the entries in the Food Exchange List. An administrator is responsible for managing user accounts. He/she can add, edit, delete, activate/deactivate an account. 83 IX. Recommendations Healthy Eating Alert System:Food Intake Monitor is a Health and Fitness application whose goal is to help monitor fitness and calorie intake for a healthier living. In this version, three health conditions: Diabetes, Hypertension, Kidney Stones were considered. The contents in the Food Exchange List were based from a diet guide from a hospital. The measurement used for the ingredients is grams, for the weight, kilograms, and for the height, centimeters. To have a more powerful HEAS:FIM, other health conditions can be added, more entries to the Food Exchange List from reliable sources to have a bigger database of ingredients, and automatic conversion of the measurement units to other desired units so there would be no need to manually convert, making the system much more efficient. Integration of the other social media can be done. Development of a mobile version and connection to physical hardware or health gears such as the existing android wear run accessories can also be done to make the system more handy. Other advanced functionalities can be added to the system. 84 X. Bibliography [1] “What is nutrition? why is nutrition important?.” http://www. medicalnewstoday.com/articles/160774.php, July 2013. [2] “Food.” http://global.britannica.com/EBchecked/topic/212568/food. [3] “How your health.” nutritional status affects your http://www.dummies.com/how-to/content/ how-your-nutritional-status-affects-your-health.html, May 2011. [4] N. M. S. T. M. City, “Guide to a computed diet,” [5] N. M. S. T. M. City, “Food exchange list,” [6] “Filipino diet.” http://famouswonders.com/filipino-diet/, 2011. [7] “Sparkpeople.” http://www.sparkpeople.com. [8] “Nutricoach.” http://www.centrum.com.ph/node/13. [9] “Fat secret.” http://www.fatsecret.com. [10] “How much fat is in your diet?.” http://www.gnc.com.ph/home/article/ how-much-fat-is-in-your-diet, 2013. [11] M. S. L. E. Burke, J. Wang, “Self-monitoring in weight loss: A systematic review of the literature,” American Dietetic Association, vol. 111, no. 1, 2011. [12] H. Z. K. Z. G. J. Noronha, E.Hysen, “Platemate: Crowdsourcing nutrition analysis from food photographs,” Harvard School of Engineering and Applied Sciences, 2011. [13] C. for Nutrition Policy and P. U. D. of Agriculture, “Diet self-monitoring and body weight: A review of the evidence,” Nutrition Insight, vol. 48, 2012. 85 [14] R. Steele, “An overview of the state of the art of automated capture of dietary intake information,” The University of Sydney Discipline of Health Informatics, 2013. [15] D. S. Adriyendi, “Prediction nutrition status using body mass index on mobile device,” International Journal of Bio-Science and Bio-Technology, vol. 5, no. 1, 2013. [16] H. L. G. C. d. S. K. Aizawa, Y. Maruyama, “Food balance estimation by using personal dietary tendencies in a multimedia food log,” Journal of Latex Class Files, vol. 6, no. 1, 2013. [17] B. Cunningham, “Smart phones and dietary tracking: Afeasbility study,” Arizona State University, 2012. [18] T. Chang, “Food fight a social diet network mobile application,” University of California at Berkeley Electrical Engineering and Computer Sciences, 2012. [19] J. J. P. C. R. B. M. Silva, I. M. Lopes and P. Ray, “Sapofitness: A mobile health application for dietary evaluation in e-health networking applications and services (healthcom),” 2011 13th IEEE International Conference On, pp. 375–380, 2011. [20] J. F. A. H Andrew, G. Borriello, “Simplifying mobile phone food diaries,” University of Washington Computer Science & Engineering DUB Group, 2013. [21] I. Everyday Health, “Calorie counter.” https://itunes.apple.com/ph/ app/calorie-counter-dining-out/id375176386?mt=8, 2014. [22] MedHelp, “My diet diary calorie counter.” https://itunes.apple.com/ph/ app/my-diet-diary-calorie-counter/id414169919?mt=8, 2012–2015. 86 [23] MyFitnessPal.com, “Calorie counter & diet tracker by myfitnesspal.” https://itunes.apple.com/ph/app/calorie-counter-diet-tracker/ id341232718?mt=8, 2009–2015. [24] “Ideal body weight.” http://www.manuelsweb.com/IBW.html. [25] “Healthy asian recipes,” Racial and Ethnic Approaches to Community Health. [26] R. Rodibaugh, “The exchange list system for diabetic meal planning,” Family and Consumer Sciences University of Arkansas: Division of Agriculture. [27] “Carbohydrate counting with filipino foods,” San Jose State University, 2012. [28] “The type 2 diabetes meal planner.” http://www.mydrs.com/data/files/ Type2DiabetesMealPlanner.pdf. [29] “Eat heart smart filipino style,” American Heart Association. [30] “Promoting good nutrition and healthy diet module 3.” http://www.wpro. who.int/philippines/publications/module3.pdf. [31] “The dash diet,” National Institutes of Health. [32] “Diet for kidney stone prevention,” National Kidney and Urologic Diseases Information Clearinghouse, 2013. [33] “What is a web app? heres our definition.” http://web.appstorm.net/ general/opinion/what-is-a-web-app-heres-our-definition/, January 2011. [34] “An introduction to database management systems.” http://www. personal.psu.edu/glh10/ist110/topic/topic07/topic07_05.html. [35] “Dbms.” http://www.techterms.com/definition/dbms. 87 XI. A. Appendix Forms <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#addFPButton , #addFPBackButton , #addFPHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e maxDate : ’ 0 ’ , dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; }, gotoCurrent : true }) . d a t e p i c k e r ( ’ setDate ’ , ” 0 ” ) ; $ ( ”#addFPDialog ” ) . d i a l o g ( { autoOpen : t r u e , width : 400 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , dialogClass : ” noclose ” ui ) { return false ; }, }) ; }) ; function confirm add fitness profile () { // v a r c u r r e n t w e i g h t = document . g e t E l e m e n t B y I d ( ” c u r r e n t w e i g h t ” ) . v a l u e ; // v a r g o a l w e i g h t = document . g e t E l e m e n t B y I d ( ” g o a l w e i g h t ” ) . v a l u e ; // v a r h e i g h t = document . g e t E l e m e n t B y I d ( ” h e i g h t ” ) . v a l u e ; // v a r h e a l t h c o n d i t i o n = document . g e t E l e m e n t B y I d ( ” h e a l t h c o n d i t i o n ” ) . v a l u e ; // v a r r e c o r d d a t e = document . g e t E l e m e n t B y I d ( ” r e c o r d d a t e ” ) . v a l u e ; // v a r msg = ” Are you s u r e you want t o s u b m i t t h e f o l l o w i n g i n f o r m a t i o n ?” + ”\ n” + ” C u r r e n t Weight ( kg ) : ” + c u r r e n t w e i g h t + ”\ n” + ” Goal Weight ( kg ) : ” + g o a l w e i g h t + ”\ n” + ” H e i g h t (cm) : ” + h e i g h t + ”\ n” + ” H e a l t h C o n d i t i o n : ” + h e a l t h c o n d i t i o n + ”\ n” + ” Record Date : ” +r e c o r d d a t e ; v a r msg = ” Are you s u r e you want t o s u b m i t t h e f o l l o w i n g i n f o r m a t i o n ? ” ; r e t u r n c o n f i r m ( msg ) ; } </ s c r i p t > </head> <body> <d i v i d =”addFPDialog ” t i t l e =”Add F i t n e s s P r o f i l e I n f o r m a t i o n ”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ’ h o m e u s e r / a d d f i t n e s s p r o f i l e s a v e ’ ) ; ?> <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><l a b e l f o r =” c u r r e n t w e i g h t”>  ; C u r r e n t Weight ( kg ) : </ l a b e l > <td><i n p u t i d =” c u r r e n t w e i g h t ” name=” c u r r e n t w e i g h t ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ c u r r e n t w e i g h t ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” g o a l w e i g h t”>  ; Goal Weight ( kg ) : </ l a b e l > <td><i n p u t i d =” g o a l w e i g h t ” name=” g o a l w e i g h t ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ g o a l w e i g h t ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” h e i g h t”>  ; H e i g h t (cm) : </ l a b e l > 88 <td><i n p u t i d =” h e i g h t ” name=” h e i g h t ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ h e i g h t ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” h e a l t h c o n d i t i o n ”>  ; H e a l t h C o n d i t i o n : </ l a b e l > <td><i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =” D i a b e t e s ” <? php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” D i a b e t e s ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>D i a b e t e s <br> <i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =” H y p e r t e n s i o n ” <? php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” H y p e r t e n s i o n ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>H y p e r t e n s i o n <br> <i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =”Kidney S t o n e s ” <?php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” Kidney S t o n e s ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>Kidney S t o n e s <br> <i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =”None ” <?php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” None ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>None<br> <!−−<td><s e l e c t i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n ”> <o p t i o n v a l u e =” D i a b e t e s ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” D i a b e t e s ” ) e c h o ” s e l e c t e d ”;?>> D i a b e t e s </o p t i o n > <o p t i o n v a l u e =” H y p e r t e n s i o n ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” H y p e r t e n s i o n ” ) e c h o ” s e l e c t e d ”;?>> H y p e r t e n s i o n </o p t i o n > <o p t i o n v a l u e =”Kidney S t o n e s ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” Kidney S t o n e s ” ) e c h o ” s e l e c t e d ”;?>> Kidney S t o n e s </o p t i o n > <o p t i o n v a l u e =”None ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” None ” ) e c h o ” s e l e c t e d ”;?>>None</o p t i o n > </ s e l e c t >−−> </t r > <!−−<t r > <td><l a b e l f o r =” h e a l t h c o n d i t i o n s ”>  ; H e a l t h C o n d i t i o n s ( i f any , e . g . D i a b e t e s Type I I , H y p e r t e n s i o n , Kidney S t o n e s ) : </ l a b e l > <td><i n p u t i d =” h e a l t h c o n d i t i o n s ” name=” h e a l t h c o n d i t i o n s ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ h e a l t h c o n d i t i o n s ’ ) ; ?>” > </t r >−−> <t r > <td><l a b e l f o r =” r e c o r d d a t e ”>  ; Date : </ l a b e l > <td><i n p u t i d =” r e c o r d d a t e ” name=” r e c o r d d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ r e c o r d d a t e ’ ) ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#r e c o r d d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> </t r > <t r > <td><b u t t o n i d =”addFPButton ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t ” o n c l i c k =” r e t u r n c o n f i r m a d d f i t n e s s p r o f i l e ( ) ”>Add I n f o r m a t i o n </button> <td><b u t t o n i d =”addFPBackButton ” t y p e=”b u t t o n ” name=”addFPBackButton ” v a l u e =”Back ” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”addFPHomeButton” t y p e=”b u t t o n ” name=”addFPHomeButton” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#addFELItemButton , #addFELItemBackButton , #addFELItemHomeButton ” ) . b u t t o n ( ) ; $ ( ’ amf ’ ) . c s s ( ’ d i s p l a y ’ , ’ none ’ ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#addFELItemDialog ” ) . d i a l o g ( { autoOpen : t r u e , width : 750 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }) ; }) ; 89 }, $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# l i s t g r o u p ” ) . c h a n g e ( f u n c t i o n ( ) { /∗ dropdown p o s t ∗/// $ . ajax ({ u r l :” <? php e c h o b a s e u r l ( ) ;? > i n d e x . php / home cmanager / buildDropFEL ” , data : { l i s t g r o u p : $( this ) . val () } , t y p e : ”POST” , s u c c e s s : f u n c t i o n ( data ) { $(”# f o o d g r o u p ” ) . html ( d a t a ) ; } }) ; toggleTextBox ( t h i s ) ; }) ; $(”# l i s t g r o u p ” ) . c h a n g e ( f u n c t i o n ( ) { /∗ dropdown p o s t ∗/// $ . ajax ({ u r l :” <? php e c h o b a s e u r l ( ) ;? > i n d e x . php / home cmanager / buildDropFEL2 ” , data : { l i s t g r o u p : $( this ) . val () } , t y p e : ”POST” , s u c c e s s : f u n c t i o n ( data ) { $(”# f o o d g r o u p c a t e g o r y ” ) . html ( d a t a ) ; } }) ; toggleTextBox ( t h i s ) ; }) ; }) ; f u n c t i o n toggleTextBox ( element ) { // a l e r t ( e l e m e n t . v a l u e ) ; i f ( e l e m e n t . v a l u e == ” Other ” ) { i f ( document . g e t E l e m e n t B y I d ( e l e m e n t . i d +” o t h e r ” ) == n u l l ) $ ( $ ( document . c r e a t e E l e m e n t ( ” i n p u t ” ) ) . a t t r ( { type : ” t e x t ” , i d : e l e m e n t . i d +” o t h e r ” , name : e l e m e n t . name+” o t h e r ” }) ) . i n s e r t A f t e r ( element ) ; } else { $(”#”+ e l e m e n t . i d +” o t h e r ” ) . remove ( ) ; } } </ s c r i p t > </head> <body> <d i v i d =”addFELItemDialog ” t i t l e =”Add Food Exchange L i s t Item”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ’ home cmanager / a d d f e l i t e m s a v e ’ ) ; ?> <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><l a b e l f o r =” l i s t g r o u p ”>  ; L i s t Group : </ l a b e l > <td><?php e c h o form dropdown ( ’ l i s t g r o u p ’ , $ l g , ’ ’ , ’ c l a s s =” r e q u i r e d ” i d =” l i s t g r o u p ” ’ ) ; ?> </t r > <t r > <td><l a b e l f o r =” f o o d g r o u p”>  ; Food Group : </ l a b e l > <td><s e l e c t i d =” f o o d g r o u p ” name=” f o o d g r o u p ” c l a s s =” f o o d g r o u p ” o n c h a n g e =’ t o g g l e T e x t B o x ( t h i s ) ’> <o p t i o n v a l u e =”” >P l e a s e s e l e c t Food Group</o p t i o n > </ s e l e c t > </t r > <t r > <td><l a b e l f o r =” f o o d g r o u p c a t e g o r y”>  ; Food Group C a t e g o r y : </ l a b e l > <td><s e l e c t i d =” f o o d g r o u p c a t e g o r y ” name=” f o o d g r o u p c a t e g o r y ” c l a s s =” f o o d g r o u p c a t e g o r y ” o n c h a n g e =’ t o g g l e T e x t B o x ( t h i s ) ’> <o p t i o n v a l u e =””> P l e a s e s e l e c t Food Group C a t e g o r y </o p t i o n > </ s e l e c t > </t r > <t r > <td><l a b e l f o r =”f o o d n a m e”>  ; Food Name: </ l a b e l > <td><i n p u t i d =”f o o d n a m e ” name=”f o o d n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ food name ’ ) ; ?> ” > </t r > <t r > <td><l a b e l f o r =”measure”>  ; Measure : </ l a b e l > <td><i n p u t i d =”measure ” name=”measure ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ measure ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” c a r b o h y r a t e”>  ; C a r b o h y d r a t e ( g ) : </ l a b e l > <td><i n p u t i d =” c a r b o h y d r a t e ” name=” c a r b o h y d r a t e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ c a r b o h y d r a t e ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” p r o t e i n ”>  ; P r o t e i n ( g ) : </ l a b e l > <td><i n p u t i d =” p r o t e i n ” name=” p r o t e i n ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ p r o t e i n ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” f a t ”>  ; Fat ( g ) : </ l a b e l > <td><i n p u t i d =” f a t ” name=” f a t ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ f a t ’ ) ; ?>” > </t r > 90 <t r > <td><l a b e l f o r =” e n e r g y”>  ; Energy ( Kcal ) : </ l a b e l > <td><i n p u t i d =” e n e r g y ” name=” e n e r g y ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ e n e r g y ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” w e i g h t a s p u r c h a s e d”>  ; Weight a s P u r c h a s e d ( g ) : </ l a b e l > <td><i n p u t i d =” w e i g h t a s p u r c h a s e d ” name=” w e i g h t a s p u r c h a s e d ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ w e i g h t a s p u r c h a s e d ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” w e i g h t e d i b l e p o r t i o n ”>  ; Weight E d i b l e P o r t i o n ( g ) : </ l a b e l > <td><i n p u t i d =” w e i g h t e d i b l e p o r t i o n ” name=” w e i g h t e d i b l e p o r t i o n ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ w e i g h t e d i b l e p o r t i o n ’ ) ; ?>” > </t r > <t r > <td><b u t t o n i d =”addFELItemButton ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Add Item </button> <td><b u t t o n i d =”addFELItemBackButton ” t y p e=”b u t t o n ” name=”addFELItemBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” > Back</button> <b u t t o n i d =”addFELItemHomeButton ” t y p e=”b u t t o n ” name=”addFELItemHomeButton ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#addHealthTipButton , #addHealthTipBackButton , #addHealthTipHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#a d d H e a l t h T i p D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 530 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =”a d d H e a l t h T i p D i a l o g ” t i t l e =”Add H e a l t h Tip”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ’ home cmanager / a d d h e a l t h t i p s a v e ’ ) ; ?> <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><t e x t a r e a rows =”4” c o l s =”50” i d =” h e a l t h t i p ” name=” h e a l t h t i p ” t y p e=” l o n g t e x t ” v a l u e =”<? php e c h o s e t v a l u e ( ’ h e a l t h t i p ’ ) ; ?>” ></t e x t a r e a > </t r > <t r > <td><b u t t o n i d =”a d d H e a l t h T i p B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Add H e a l t h Tip </button> <b u t t o n i d =”addHealthTipBackButton ” t y p e=”b u t t o n ” name=”addHealthTipBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” > Back</button> <b u t t o n i d =”addHealthTipHomeButton ” t y p e=”b u t t o n ” name=”addHealthTipHomeButton ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> 91 <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#addMealBackButton , #addMealButton , #addMealHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e minDate : ’ 0 ’ , dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; }, gotoCurrent : true }) . d a t e p i c k e r ( ’ setDate ’ , ” 0 ” ) ; $ ( ”#a d d M e a l D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 850 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =”a d d M e a l D i a l o g ” t i t l e =”Add Meal”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ” home cmanager / a d d m e a l / $ r e c o m m e n d e d r e c i p e i d ” ) ;? > <c e n t e r > <t a b l e > <t r s t y l e =” d i s p l a y : none ;” > <td><l a b e l f o r =” r e c o m m e n d e d r e c i p e i d”>  ; R e c i p e ID: </ l a b e l > <td><i n p u t i d =” r e c o m m e n d e d r e c i p e i d ” name=” r e c o m m e n d e d r e c i p e i d ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ r e c o m m e n d e d r e c i p e i d ; ?>” r e a d o n l y =” r e a d o n l y ”> </t r > <t r > <td><l a b e l f o r =” r e c o r d d a t e ”>  ; For Date : </ l a b e l > <td><i n p u t i d =” r e c o r d d a t e ” name=” r e c o r d d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ r e c o r d d a t e ’ ) ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#r e c o r d d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> </t r > <t r > <td><l a b e l f o r =”m e a l g r o u p”>  ; For Meal : </ l a b e l > <td><s e l e c t i d =”m e a l g r o u p ” name=”m e a l g r o u p”> <o p t i o n v a l u e =” B r e a k f a s t ” <?php i f ( i s s e t ( $ POST [ ” m e a l g r o u p ” ] ) && $ POST [ ” m e a l g r o u p ” ] == ” B r e a k f a s t ” ) e c h o ” s e l e c t e d ”;?>> B r e a k f a s t </o p t i o n > <o p t i o n v a l u e =”Lunch ” <?php i f ( i s s e t ( $ POST [ ” m e a l g r o u p ” ] ) && $ POST [ ” m e a l g r o u p ” ] == ” Lunch ” ) e c h o ” s e l e c t e d ” ; ?>>Lunch</o p t i o n > == ” <o p t i o n v a l u e =”D i n n e r ” <?php i f ( i s s e t ( $ POST [ ” m e a l g r o u p ” ] ) && $ POST [ ” m e a l g r o u p ” ] D i n n e r ” ) e c h o ” s e l e c t e d ” ; ?>>Dinner </o p t i o n > <o p t i o n v a l u e =”Snack ” <?php i f ( i s s e t ( $ POST [ ” m e a l g r o u p ” ] ) && $ POST [ ” m e a l g r o u p ” ] == ” Snack ” ) e c h o ” s e l e c t e d ” ; ?>>Snack </o p t i o n > </ s e l e c t > </t r > <t r > <td><b u t t o n i d =”addMealButton ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Add Meal</button> <td><b u t t o n i d =”addMealBackButton ” t y p e=”b u t t o n ” name=”addMealBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager / s e a r c h m e a l ’” > Back</button> <b u t t o n i d =”addMealHomeButton ” t y p e=”b u t t o n ” name=”addMealHomeButton ” v a l u e =”Home” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> 92 <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#addMealBackButton , #addMealButton , #addMealHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e minDate : ’ 0 ’ , dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; }, gotoCurrent : true }) . d a t e p i c k e r ( ’ setDate ’ , ” 0 ” ) ; $ ( ”#a d d M e a l D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 850 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =”a d d M e a l D i a l o g ” t i t l e =”Add Meal”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ” h o m e u s e r / a d d m e a l / $ o w n r e c i p e i d ” ) ;? > <c e n t e r > <t a b l e > <t r s t y l e =” d i s p l a y : none ;” > <td><l a b e l f o r =” o w n r e c i p e i d ”>  ; R e c i p e ID: </ l a b e l > <td><i n p u t i d =” o w n r e c i p e i d ” name=” o w n r e c i p e i d ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ o w n r e c i p e i d ; ?>” r e a d o n l y =” r e a d o n l y ”> </t r > <t r > <td><l a b e l f o r =” r e c o r d d a t e ”>  ; For Date : </ l a b e l > <td><i n p u t i d =” r e c o r d d a t e ” name=” r e c o r d d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ r e c o r d d a t e ’ ) ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#r e c o r d d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> </t r > <t r > <td><l a b e l f o r =”m e a l g r o u p”>  ; For Meal : </ l a b e l > <td><s e l e c t i d =”m e a l g r o u p ” name=”m e a l g r o u p”> <o p t i o n v a l u e =” B r e a k f a s t ” <?php i f ( i s s e t ( $ POST [ ” m e a l g r o u p ” ] ) && $ POST [ ” m e a l g r o u p ” ] == ” B r e a k f a s t ” ) e c h o ” s e l e c t e d ”;?>> B r e a k f a s t </o p t i o n > <o p t i o n v a l u e =”Lunch ” <?php i f ( i s s e t ( $ POST [ ” m e a l g r o u p ” ] ) && $ POST [ ” m e a l g r o u p ” ] == ” Lunch ” ) e c h o ” s e l e c t e d ” ; ?>>Lunch</o p t i o n > == ” <o p t i o n v a l u e =”D i n n e r ” <?php i f ( i s s e t ( $ POST [ ” m e a l g r o u p ” ] ) && $ POST [ ” m e a l g r o u p ” ] D i n n e r ” ) e c h o ” s e l e c t e d ” ; ?>>Dinner </o p t i o n > <o p t i o n v a l u e =”Snack ” <?php i f ( i s s e t ( $ POST [ ” m e a l g r o u p ” ] ) && $ POST [ ” m e a l g r o u p ” ] == ” Snack ” ) e c h o ” s e l e c t e d ” ; ?>>Snack </o p t i o n > </ s e l e c t > </t r > <t r > <td><b u t t o n i d =”addMealButton ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Add Meal</button> <td><b u t t o n i d =”addMealBackButton ” t y p e=”b u t t o n ” name=”addMealBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s e a r c h m e a l ’” > Back</button> <b u t t o n i d =”addMealHomeButton ” t y p e=”b u t t o n ” name=”addMealHomeButton ” v a l u e =”Home” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> 93 <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > var quantity ; $( function () { var data2 = [ ] ; var index = 0 ; $ ( ”#a d dR e ci pe B ut to n , #addRecipeBackButton , #addRecipeHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; } }) ; $ ( ”#a d d R e c i p e D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 600 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” }) ; var id ; $ ( ’ . i n g r e d i e n t s ’ ) . autocomplete ({ minLength : 0 , source : function ( request , response ) { i d = t h i s . e l e m e n t . c o n t e x t . a t t r i b u t e s [ name=” i d ” ] . v a l u e ; // c o n s o l e . l o g ( i d ) ; $ . ajax ( { u r l : ”<?php e c h o s i t e u r l ( ’ home cmanager / s u g g e s t i o n s ’ ) ; ? >” , data : request , dataType : ” j s o n ” , t y p e : ”POST” , s u c c e s s : f u n c t i o n ( data ) { // c o n s o l e . l o g (JSON . s t r i n g i f y ( d a t a ) ) ; r e s p o n s e ( $ . map ( data , f u n c t i o n ( v , i ) { i f ( v . measure != n u l l ) d a t a 2 [ d a t a 2 . l e n g t h ] = v . measure ; e l s e i f ( v . f o o d n a m e != n u l l ) data2 [ data2 . l e n g t h ] = v . food name ; e l s e i f ( v . e n e r g y != n u l l ) data2 [ data2 . l e n g t h ] = v . energy ; e l s e i f ( v . c a r b o h y d r a t e != n u l l ) data2 [ data2 . l e n g t h ] = v . carbohydrate ; e l s e i f ( v . p r o t e i n != n u l l ) data2 [ data2 . l e n g t h ] = v . p r o t e i n ; e l s e i f ( v . f a t != n u l l ) data2 [ data2 . l e n g t h ] = v . f a t ; e l s e i f ( v . f o o d g r o u p != n u l l ) data2 [ data2 . l e n g t h ] = v . food group ; return { l a b e l : v . food name }; }) ) ; } }) ; }, s e l e c t : f u n c t i o n ( event , u i ) { v a r num = i d . s u b s t r i n g ( i d . i n d e x O f ( ” s ” ) + 1 , v a r measure = n u l l ; var food group = n u l l ; var c a l o r i e , carbohydrate , protein , f a t ; f o r ( v a r i = 0 ; i < d a t a 2 . l e n g t h ; i +=7){ i f ( d a t a 2 [ i ] == u i . i t e m . v a l u e ) { measure = d a t a 2 [ i + 1 ] ; c a l o r i e = data2 [ i + 2 ] ; carbohydrate = data2 [ i + 3 ] ; id . length ) ; 94 p r o t e i n = data2 [ i + 4 ] ; f a t = data2 [ i + 5 ] ; food group = data2 [ i +6]; } } // c o n s o l e . l o g ( c a l o r i e ) ; $ ( ’# i n g r e d i e n t m e a s u r e ’+num) . v a l ( measure ) ; $ ( ’# f o o d g r o u p ’+num) . v a l ( f o o d g r o u p ) ; /∗ $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) + + c a l o r i e ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) + +c a r b o h y d r a t e ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) + +p r o t e i n ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) + +f a t ) ; ∗ / } /∗ f o c u s : f u n c t i o n ( e v e n t , u i ) { $ ( ” . i n g r e d i e n t s ” ) . v a l ( u i . item . l a b e l ) ; }, s e l e c t : f u n c t i o n ( event , u i ) { }∗/ }) ; }) ; f u n c t i o n update ( i d ) { v a r r e q u e s t = new XMLHttpRequest ( ) , u r l = ”<?php e c h o s i t e u r l ( ’ home cmanager / g e t f a ’ ) ; ? >” , params = ” i n g r e d i e n t =”+$(”# i n g r e d i e n t s ”+ i d ) . v a l ( ) ; request . onreadystatechange = function () { i f ( r e q u e s t . r e a d y S t a t e == 4 && r e q u e s t . s t a t u s == 2 0 0 ) { v a r temp = r e q u e s t . r e s p o n s e T e x t . s p l i t ( ” , ” ) , i ; $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) − (+temp [ 0 ] ∗ q u a n t i t y [ i d ] ) ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) − (+temp [ 1 ] ∗ q u a n t i t y [ i d ] ) ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) − (+temp [ 2 ] ∗ q u a n t i t y [ i d ] ) ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) − (+temp [ 3 ] ∗ q u a n t i t y [ i d ] ) ) ; f o r ( i = 0 ; i < temp . l e n g t h ; i ++) temp [ i ] = +temp [ i ] ∗ $(”# i n g r e d i e n t q u a n t i t y ”+ i d ) . v a l ( ) ; $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) + temp [ 0 ] ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) + temp [ 1 ] ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) + temp [ 2 ] ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) + temp [ 3 ] ) ; q u a n t i t y [ i d ] = $(”# i n g r e d i e n t q u a n t i t y ”+ i d ) . v a l ( ) ; } } r e q u e s t . open ( ”POST” , u r l , t r u e ) ; r e q u e s t . s e t R e q u e s t H e a d e r ( ” Content−t y p e ” , ” a p p l i c a t i o n /x−www−form−u r l e n c o d e d ” ) ; r e q u e s t . s e n d ( params ) ; } $ ( document ) . r e a d y ( f u n c t i o n ( ) { var counter = 1 ; var data2 = [ ] ; q u a n t i t y = new Array ( ) ; q u a n t i t y [ 0 ] = $(”# i n g r e d i e n t q u a n t i t y 0 ” ) . v a l ( ) == ”” ? 0 : $(”# i n g r e d i e n t q u a n t i t y 0 ” ) . v a l ( ) ; $(”# a d d I n g r e d i e n t B u t t o n ” ) . c l i c k ( f u n c t i o n /∗ i f ( c o u n t e r >10) { a l e r t ( ” Only 10 t e x t b o x e s return f a l s e ; } ∗/ () { allow ”) ; quantity [ counter ] = 0; v a r newTextBoxDiv = $ ( document . c r e a t e E l e m e n t ( ’ d i v ’ ) ) . a t t r ( ” i d ” , ’ TextBoxDiv ’ + c o u n t e r ) ; newTextBoxDiv . a f t e r ( ) . html ( ’ < br><l a b e l >I n g r e d i e n t :   ;& nbsp ;& nbsp ; </ l a b e l >’ + ’< i n p u t t y p e=” t e x t ” c l a s s =” i n g r e d i e n t s ” name=” i n g r e d i e n t s [ ’ + c o u n t e r + ’ ] ” i d =” i n g r e d i e n t s ’ + c o u n t e r + ’ ” v a l u e =”” > ’) ; v a r newTextBoxDiv1= $ ( document . c r e a t e E l e m e n t ( ’ d i v ’ ) ) . a t t r ( ” i d ” , ’ TextBoxDiv1 ’ + c o u n t e r ) ; newTextBoxDiv1 . a f t e r ( ) . html ( ’ < l a b e l >Measure ( g ) : </ l a b e l >’ + ’< i n p u t t y p e=” t e x t ” c l a s s =”measure ” name=” i n g r e d i e n t m e a s u r e [ ’ + c o u n t e r + ’ ] ” i d =” i n g r e d i e n t m e a s u r e ’ + c o u n t e r + ’ ” v a l u e =”” > ’) ; v a r newTextBoxDiv2= $ ( document . c r e a t e E l e m e n t ( ’ d i v ’ ) ) . a t t r ( ” i d ” , ’ TextBoxDiv2 ’ + c o u n t e r ) ; newTextBoxDiv2 . a f t e r ( ) . html ( ’ < l a b e l >Q u a n t i t y :   ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; </ l a b e l >’ + ’< i n p u t t y p e=” t e x t ” name=” i n g r e d i e n t q u a n t i t y [ ’ + c o u n t e r + ’ ] ” i d =” i n g r e d i e n t q u a n t i t y ’ + c o u n t e r + ’ ” v a l u e =”” o n c h a n g e=”u p d a t e ( ’+ c o u n t e r + ’) ” > ’) ; v a r newTextBoxDiv3= $ ( document . c r e a t e E l e m e n t ( ’ d i v ’ ) ) . a t t r ( ” i d ” , ’ TextBoxDiv3 ’ + c o u n t e r ) ; newTextBoxDiv3 . a f t e r ( ) . html ( ’ < l a b e l >Food Group : </ l a b e l >’ + ’< i n p u t t y p e=” t e x t ” c l a s s =” f o o d g r o u p ” name=” f o o d g r o u p [ ’ + c o u n t e r + ’ ] ” i d =” f o o d g r o u p ’ + c o u n t e r + ’ ” v a l u e =”” > ’) ; newTextBoxDiv . appendTo(”# TextBoxesGroup ” ) ; newTextBoxDiv3 . appendTo(”# TextBoxesGroup ” ) ; newTextBoxDiv1 . appendTo(”# TextBoxesGroup ” ) ; newTextBoxDiv2 . appendTo(”# TextBoxesGroup ” ) ; document . g e t E l e m e n t B y I d ( ” i n g r e d i e n t m e a s u r e ” + c o u n t e r ) . r e a d O n l y=t r u e ; document . g e t E l e m e n t B y I d ( ” f o o d g r o u p ” + c o u n t e r ) . r e a d O n l y=t r u e ; var id ; $ ( ’ . i n g r e d i e n t s ’ ) . autocomplete ({ minLength : 0 , source : function ( request , response ) { i d = t h i s . e l e m e n t . c o n t e x t . a t t r i b u t e s [ name=” i d ” ] . v a l u e ; 95 // c o n s o l e . l o g ( i d ) ; $ . ajax ( { u r l : ”<?php e c h o s i t e u r l ( ’ home cmanager / s u g g e s t i o n s ’ ) ; ? >” , data : request , dataType : ” j s o n ” , t y p e : ”POST” , s u c c e s s : f u n c t i o n ( data ) { r e s p o n s e ( $ . map ( data , f u n c t i o n ( v , i ) { i f ( v . measure != n u l l ) d a t a 2 [ d a t a 2 . l e n g t h ] = v . measure ; e l s e i f ( v . f o o d n a m e != n u l l ) data2 [ data2 . l e n g t h ] = v . food name ; e l s e i f ( v . e n e r g y != n u l l ) data2 [ data2 . l e n g t h ] = v . energy ; e l s e i f ( v . c a r b o h y d r a t e != n u l l ) data2 [ data2 . l e n g t h ] = v . carbohydrate ; e l s e i f ( v . p r o t e i n != n u l l ) data2 [ data2 . l e n g t h ] = v . p r o t e i n ; e l s e i f ( v . f a t != n u l l ) data2 [ data2 . l e n g t h ] = v . f a t ; e l s e i f ( v . f o o d g r o u p != n u l l ) data2 [ data2 . l e n g t h ] = v . food group ; return { l a b e l : v . food name }; }) ) ; } }) ; }, s e l e c t : f u n c t i o n ( event , u i ) { v a r num = i d . s u b s t r i n g ( i d . i n d e x O f ( ” s ” ) + 1 , i d . l e n g t h ) ; v a r measure = n u l l ; var food group = n u l l ; var c a l o r i e , carbohydrate , protein , f a t ; f o r ( v a r i = 0 ; i < d a t a 2 . l e n g t h ; i +=7){ i f ( d a t a 2 [ i ] == u i . i t e m . v a l u e ) { measure = d a t a 2 [ i + 1 ] ; c a l o r i e = data2 [ i + 2 ] ; carbohydrate = data2 [ i + 3 ] ; p r o t e i n = data2 [ i + 4 ] ; f a t = data2 [ i + 5 ] ; food group = data2 [ i +6]; } } // c o n s o l e . l o g ( c a l o r i e ) ; $ ( ’# i n g r e d i e n t m e a s u r e ’+num) . v a l ( measure ) ; $ ( ’# f o o d g r o u p ’+num) . v a l ( f o o d g r o u p ) ; /∗ $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) + + c a l o r i e ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) + +c a r b o h y d r a t e ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) + +p r o t e i n ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) + +f a t ) ; ∗/ } }) ; c o u n t e r ++; }) ; $(”# r e m o v e I n g r e d i e n t B u t t o n ” ) . c l i c k ( f u n c t i o n i f ( c o u n t e r ==1){ a l e r t ( ” No more t e x t b o x t o remove ” ) ; return f a l s e ; } c o u n t e r −−; var () { r e q u e s t = new XMLHttpRequest ( ) , u r l = ”<?php e c h o s i t e u r l ( ’ home cmanager / g e t f a ’ ) ; ? >” , params = ” i n g r e d i e n t =”+($(”# i n g r e d i e n t s ”+ c o u n t e r ) . v a l ( ) == ”” ? 0 : $(”# i n g r e d i e n t s ”+ counter ) . val () ) ; request . onreadystatechange = function () { i f ( r e q u e s t . r e a d y S t a t e == 4 && r e q u e s t . s t a t u s == 2 0 0 ) { v a r temp = r e q u e s t . r e s p o n s e T e x t . s p l i t ( ” , ” ) ; $(”#TextBoxDiv ” + c o u n t e r ) . remove ( ) ; $(”# TextBoxDiv3 ” + c o u n t e r ) . remove ( ) ; $(”# TextBoxDiv1 ” + c o u n t e r ) . remove ( ) ; $(”# TextBoxDiv2 ” + c o u n t e r ) . remove ( ) ; i f ( q u a n t i t y [ c o u n t e r ] != ”” && q u a n t i t y [ c o u n t e r ] != n u l l ) { $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) − (+temp [ 0 ] ∗ q u a n t i t y [ c o u n t e r ] ) ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) − (+temp [ 1 ] ∗ q u a n t i t y [ c o u n t e r ] ) ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) − (+temp [ 2 ] ∗ q u a n t i t y [ c o u n t e r ] ) ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) − (+temp [ 3 ] ∗ q u a n t i t y [ c o u n t e r ] ) ) ; } } } r e q u e s t . open ( ”POST” , u r l , t r u e ) ; r e q u e s t . s e t R e q u e s t H e a d e r ( ” Content−t y p e ” , ” a p p l i c a t i o n /x−www−form−u r l e n c o d e d ” ) ; r e q u e s t . s e n d ( params ) ; }) ; }) ; function healthConditionsGuidelinesModal () { $(”# h e a l t h C o n d i t i o n s G u i d e l i n e s M o d a l D i a l o g ” ) . d i a l o g ( { autoOpen : f a l s e , modal : t r u e , t i t l e : ’ G u i d e l i n e s f o r Health Conditions ’ , w i d t h : ’ auto ’ , h e i g h t : ’ auto ’ , buttons : { 96 ”Ok ” : f u n c t i o n ( ) { $ ( t h i s ) . d i a l o g (” c l o s e ”) ; } }, } ) . d i a l o g ( ’ open ’ ) ; return f a l s e ; } function validate () { v a r e r r o r s = ”<p s t y l e =’ c o l o r : r e d ; f o n t −w e i g h t : b o l d ’ > ” ; i f ( $(”# r e c i p e n a m e ” ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The R e c i p e Name f i e l d i s r e q u i r e d .< br >”; i f ( $(”# s e r v i n g s u g g ” ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The S e r v i n g S i z e f i e l d i s r e q u i r e d .< br >”; i f ( $(”# p r e p a r a t i o n p r o c e d u r e ” ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The P r o c e d u r e f i e l d i s r e q u i r e d .< br >”; i f ( $(”# i n g r e d i e n t s 0 ” ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The I n g r e d i e n t s f i e l d i s r e q u i r e d .< br >”; v a r f i l e = $ ( ” i n p u t [ name=’ u s e r f i l e ’ ] ” ) . v a l ( ) ; i f ( f i l e != ” ” ) { v a r f i l e t y p e s = [ ” g i f ” , ” j p g ” , ” j p e g ” , ” png ” ] ; v a r e x t = f i l e . s u b s t r ( f i l e . l a s t I n d e x O f ( ” . ” ) + 1 , f i l e . l e n g t h ) . toLowerCase ( ) ; i f ( f i l e t y p e s . indexOf ( ext ) < 0) e r r o r s += ”The image f i l e t y p e i s i n v a l i d .< br >”; } var i n g r e d i e n t s = new Array ( ) ; $(”# i n g r c o n t i n p u t [ t y p e =’ t e x t ’ ] ” ) . e a c h ( f u n c t i o n ( ) { i f ( $ ( t h i s ) . a t t r ( ” i d ” ) . i n d e x O f ( ” i n g r e d i e n t s ” ) > −1 && $ ( t h i s ) . v a l ( ) . t r i m ( ) != ” ” ) { var id = $ ( t h i s ) . a t t r (” id ”) . s u b s t r ( $ ( t h i s ) . a t t r (” id ”) . indexOf (” s ”) + 1 , $ ( t h i s ) . a t t r (” id ”) . length ) ; v a r v a l u e = { i n g r e d i e n t : $ ( t h i s ) . v a l ( ) . t r i m ( ) , f o o d g r o u p : $(”# f o o d g r o u p ”+ i d ) . v a l ( ) . t r i m ( ) } ; i f ( $(”# i n g r e d i e n t q u a n t i t y ”+ i d ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The Q u a n t i t y f i e l d i s r e q u i r e d .< br >”; else v a l u e . q u a n t i t y = $(”# i n g r e d i e n t q u a n t i t y ”+ i d ) . v a l ( ) . t r i m ( ) ; i f ( v a l u e . q u a n t i t y != n u l l ) i n g r e d i e n t s . push ( v a l u e ) ; } }) ; var h e a l t h c o n d i t i o n = $(”# h e a l t h c o n d i t i o n ” ) . v a l ( ) , for ( i = 0; i < ingredients . length ; i; i ++) { var food group = i n g r e d i e n t s [ i ] . foodgroup , count = 0 , j; f o r ( j = 0 ; j < i n g r e d i e n t s . l e n g t h ; j ++) i f ( i n g r e d i e n t s [ i ] . f o o d g r o u p == f o o d g r o u p ) c o u n t += p a r s e F l o a t ( i n g r e d i e n t s [ i ] . q u a n t i t y ) ; c o n s o l e . l o g ( c o u n t +”;”+ f o o d g r o u p ) ; i f ( h e a l t h c o n d i t i o n == ” D i a b e t e s ” ) { i f ( ( f o o d g r o u p === ” V e g e t a b l e ” | | f o o d g r o u p === ” F r u i t ” ) && c o u n t > 4 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 4 s e r v i n g s o f ”+ f o o d g r o u p +” d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Milk ” && c o u n t > 3 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 3 s e r v i n g s o f Milk d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” R i c e ” && c o u n t > 9 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 9 s e r v i n g s o f R i c e d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Meat ” && c o u n t > 6 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 6 s e r v i n g s o f Meat d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Meat ” && c o u n t > 5 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f Fat d a i l y .< br >”; } } e l s e i f ( h e a l t h c o n d i t i o n == ’ H y p e r t e n s i o n ’ | | h e a l t h c o n d i t i o n == ’ Kidney S t o n e s ’ ) { i f ( ( f o o d g r o u p === ” V e g e t a b l e ” | | f o o d g r o u p === ” F r u i t ” ) && c o u n t > 5 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f ”+ f o o d g r o u p +” d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Milk ” && c o u n t > 5 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f Milk d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” R i c e ” && c o u n t > 8 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 8 s e r v i n g s o f R i c e d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Meat ” && c o u n t > 2 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 2 s e r v i n g s o f Meat d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Meat ” && c o u n t > 3 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 3 s e r v i n g s o f Fat d a i l y .< br >”; } } } e r r o r s += ”</p >”; i f ( e r r o r s != ”<p s t y l e =’ c o l o r : r e d ; f o n t −w e i g h t : b o l d ’></p>”) { $(”# a d d R e c i p e D i a l o g ” ) . p r e p e n d ( e r r o r s ) ; return f a l s e ; } } </ s c r i p t > </head> <body> <d i v i d =” h e a l t h C o n d i t i o n s G u i d e l i n e s M o d a l D i a l o g ” s t y l e =” d i s p l a y : none ;” > <c e n t e r > <t a b l e > <t r > <p>Below a r e t h e maximum d a i l y s e r v i n g s f o r e a c h f o o d g r o u p f o r e a c h h e a l t h </t r > <t r > <th><h4>Food Group</th> 97 condition : <th><h4>D i a b e t e s </th> <th><h4>H y p e r t e n s i o n </th> <th><h4>Kidney S t o n e s </th> </t r > <t r > <td>V e g e t a b l e <td >4 <td >5 <td >5 </t r > <t r > <td>F r u i t <td >4 <td >5 <td >5 </t r > <t r > <td>Milk <td >3 <td >5 <td >5 </t r > <t r > <td>R i c e <td >9 <td >8 <td >8 </t r > <t r > <td>Meat <td >6 <td >2 <td >2 </t r > <t r > <td>Fat <td >5 <td >3 <td >3 </t r > </ t a b l e > </ c e n t e r > </d i v> <d i v i d =”a d d R e c i p e D i a l o g ” t i t l e =”C r e a t e R e c i p e ”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?><?php i f ( i s s e t ( $ e r r o r d i s p l a y ) ) { e c h o $ e r r o r d i s p l a y ; } ?></b></f o n t > <?php e c h o f o r m o p e n m u l t i p a r t ( ’ home cmanager / a d d r e c i p e s a v e ’ , a r r a y ( ’ onsubmit ’=>’ r e t u r n validate () ’) ) ; ?> <c e n t e r > <t a b l e > <t r > <a h r e f =”#” o n c l i c k =” j a v a s c r i p t : h e a l t h C o n d i t i o n s G u i d e l i n e s M o d a l ( ) ;” > G u i d e l i n e s f o r H e a l t h C o n d i t i o n s </a> </t r > <t r ></t r ><t r ></t r > <t r > <td><l a b e l f o r =” h e a l t h c o n d i t i o n ”>  ; H e a l t h C o n d i t i o n : </ l a b e l > <td><i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =” D i a b e t e s ” <? php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” D i a b e t e s ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>D i a b e t e s <br> <i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =” H y p e r t e n s i o n ” <? php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” H y p e r t e n s i o n ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>H y p e r t e n s i o n <br> <i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =”Kidney S t o n e s ” <?php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” Kidney S t o n e s ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>Kidney S t o n e s <br> <i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =”None ” <?php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” None ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>None<br> <!−−<td><s e l e c t i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n ”> <o p t i o n v a l u e =” D i a b e t e s ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” D i a b e t e s ” ) e c h o ” s e l e c t e d ”;?>> D i a b e t e s </o p t i o n > <o p t i o n v a l u e =” H y p e r t e n s i o n ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” H y p e r t e n s i o n ” ) e c h o ” s e l e c t e d ”;?>> H y p e r t e n s i o n </o p t i o n > <o p t i o n v a l u e =”Kidney S t o n e s ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” Kidney S t o n e s ” ) e c h o ” s e l e c t e d ”;?>> Kidney S t o n e s </o p t i o n > <o p t i o n v a l u e =”None ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” None ” ) e c h o ” s e l e c t e d ”;?>>None</o p t i o n > </ s e l e c t >−−> </t r > <t r > <td><l a b e l f o r =” m e a l t y p e”>  ; Meal Type: </ l a b e l > <td><s e l e c t i d =” m e a l t y p e ” name=” m e a l t y p e ”> <o p t i o n v a l u e =” B r e a k f a s t ” <?php i f ( i s s e t ( $ POST [ ” m e a l t y p e ” ] ) && $ POST [ ” m e a l t y p e ” ] == ” B r e a k f a s t ” ) e c h o ” s e l e c t e d ”;?>> B r e a k f a s t </o p t i o n > <o p t i o n v a l u e =”Lunch ” <?php i f ( i s s e t ( $ POST [ ” m e a l t y p e ” ] ) && $ POST [ ” m e a l t y p e ” ] == ” Lunch ” ) e c h o ” s e l e c t e d ”;?>>Lunch</o p t i o n > <o p t i o n v a l u e =”D i n n e r ” <?php i f ( i s s e t ( $ POST [ ” m e a l t y p e ” ] ) && $ POST [ ” m e a l t y p e ” ] == ” D i n n e r ” ) e c h o ” s e l e c t e d ”;?>> Dinner </o p t i o n > <o p t i o n v a l u e =”Snack ” <?php i f ( i s s e t ( $ POST [ ” m e a l t y p e ” ] ) && $ POST [ ” m e a l t y p e ” ] == ” Snack ” ) e c h o ” s e l e c t e d ”;?>>Snack </o p t i o n > </ s e l e c t > </t r > <t r > <td><l a b e l f o r =” u s e r f i l e ”>  ; R e c i p e Image : </ l a b e l > <td><i n p u t name=” u s e r f i l e ” t y p e=” f i l e ” s i z e =”20” > </t r > 98 <t r > <td><l a b e l f o r =” r e c i p e n a m e”>  ; R e c i p e Name: </ l a b e l > <td><i n p u t i d =” r e c i p e n a m e ” name=” r e c i p e n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ r e c i p e n a m e ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” s e r v i n g s u g g ”>  ; S e r v i n g S i z e : </ l a b e l > <td><i n p u t i d =” s e r v i n g s u g g ” name=” s e r v i n g s u g g ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ s e r v i n g s u g g ’ ) ; ?>” s i z e =”2” > </t r > <t r ><td><l a b e l f o r =” i n g r e d i e n t s ”>  ; I n g r e d i e n t s : </ l a b e l > <td> <b u t t o n i d =” a d d I n g r e d i e n t B u t t o n ” name=” a d d I n g r e d i e n t B u t t o n ” v a l u e =”” t y p e=”b u t t o n ” v a l u e =”Add ”><span c l a s s =”u i −i c o n u i −i c o n −p l u s t h i c k ”></span></button> <b u t t o n i d =” r e m o v e I n g r e d i e n t B u t t o n ” name=” r e m o v e I n g r e d i e n t B u t t o n ” v a l u e =”Remove” t y p e=”b u t t o n ”><span c l a s s =”u i −i c o n u i −i c o n −m i n u s t h i c k ”></span></button><br> I n g r e d i e n t :   ;& nbsp ;& nbsp ;< i n p u t i d =” i n g r e d i e n t s 0 ” name=” i n g r e d i e n t s [ 0 ] ” c l a s s =” i n g r e d i e n t s ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ i n g r e d i e n t s ’ ) ; ?>” ><br> Food Group : <i n p u t i d =” f o o d g r o u p 0 ” name=” f o o d g r o u p [ 0 ] ” c l a s s =” f o o d g r o u p ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ f o o d g r o u p ’ ) ; ?>” r e a d o n l y ><br> Measure ( g ) : <i n p u t i d =” i n g r e d i e n t m e a s u r e 0 ” name=” i n g r e d i e n t m e a s u r e [ 0 ] ” c l a s s =”measure ” t y p e =” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ i n g r e d i e n t m e a s u r e ’ ) ; ?>” r e a d o n l y ><br> Q u a n t i t y :   ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;< i n p u t i d =” i n g r e d i e n t q u a n t i t y 0 ” name=” i n g r e d i e n t q u a n t i t y [ 0 ] ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ i n g r e d i e n t q u a n t i t y ’ ) ; ?>” o n c h a n g e=”u p d a t e ( 0 ) ” > <br> <d i v i d =’ TextBoxesGroup ’></ d i v> </t r > <t r > <td><l a b e l f o r =” p r e p a r a t i o n p r o c e d u r e”>  ; P r o c e d u r e : </ l a b e l > <td><t e x t a r e a i d =” p r e p a r a t i o n p r o c e d u r e ” name=” p r e p a r a t i o n p r o c e d u r e ” t y p e=” t e x t ”><?php e c h o s e t v a l u e ( ’ p r e p a r a t i o n p r o c e d u r e ’ ) ; ?></ t e x t a r e a > </t r > <!−−<t r > <td><l a b e l f o r =” t o t a l q u a n t i t y ”>  ; T o t a l Q u a n t i t y : </ l a b e l > <td><i n p u t i d =” t o t a l q u a n t i t y ” name=” t o t a l q u a n t i t y ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ t o t a l q u a n t i t y ’ ) ; ?>”> </t r >−−> <t r > <td><l a b e l f o r =” c a l o r i e s ”>  ; T o t a l C a l o r i e s ( Kcal ) : </ l a b e l > <td><i n p u t i d =” c a l o r i e s ” name=” c a l o r i e s ” c l a s s =” c a l o r i e s ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ c a l o r i e s ’ ) ; ?>” r e a d o n l y > </t r > <t r > <td><l a b e l f o r =” c a r b o h y d r a t e”>  ; T o t a l C a r b o h y d r a t e s ( g ) : </ l a b e l > <td><i n p u t i d =” c a r b o h y d r a t e ” name=” c a r b o h y d r a t e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ c a r b o h y d r a t e ’ ) ; ?>” r e a d o n l y > </t r > <t r > <td><l a b e l f o r =” p r o t e i n ”>  ; T o t a l P r o t e i n ( g ) : </ l a b e l > <td><i n p u t i d =” p r o t e i n ” name=” p r o t e i n ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ p r o t e i n ’ ) ; ?>” r e a d o n l y > </t r > <t r > <td><l a b e l f o r =” f a t ”>  ; T o t a l Fat ( g ) : </ l a b e l > <td><i n p u t i d =” f a t ” name=” f a t ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ f a t ’ ) ; ?>” r e a d o n l y > </t r > <t r > <td><b u t t o n i d =”a d d R e c i p e B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>C r e a t e R e c i p e </ button> <td><b u t t o n i d =”addRecipeBackButton ” t y p e=”b u t t o n ” name=”addRecipeBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” > Back</button> <b u t t o n i d =”addRecipeHomeButton ” t y p e=”b u t t o n ” name=”addRecipeHomeButton ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > var quantity ; $( function () { var data2 = [ ] ; var index = 0 ; $ ( ”#a d dR e ci pe B ut to n , #addRecipeBackButton , #addRecipeHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e static widgets 99 $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; } }) ; $ ( ”#a d d R e c i p e D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 600 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” }) ; var id ; $ ( ’ . i n g r e d i e n t s ’ ) . autocomplete ({ minLength : 0 , source : function ( request , response ) { i d = t h i s . e l e m e n t . c o n t e x t . a t t r i b u t e s [ name=” i d ” ] . v a l u e ; // c o n s o l e . l o g ( i d ) ; $ . ajax ( { u r l : ”<?php e c h o s i t e u r l ( ’ h o m e u s e r / s u g g e s t i o n s ’ ) ; ? >” , data : request , dataType : ” j s o n ” , t y p e : ”POST” , s u c c e s s : f u n c t i o n ( data ) { // c o n s o l e . l o g (JSON . s t r i n g i f y ( d a t a ) ) ; r e s p o n s e ( $ . map ( data , f u n c t i o n ( v , i ) { i f ( v . measure != n u l l ) d a t a 2 [ d a t a 2 . l e n g t h ] = v . measure ; e l s e i f ( v . f o o d n a m e != n u l l ) data2 [ data2 . l e n g t h ] = v . food name ; e l s e i f ( v . e n e r g y != n u l l ) data2 [ data2 . l e n g t h ] = v . energy ; e l s e i f ( v . c a r b o h y d r a t e != n u l l ) data2 [ data2 . l e n g t h ] = v . carbohydrate ; e l s e i f ( v . p r o t e i n != n u l l ) data2 [ data2 . l e n g t h ] = v . p r o t e i n ; e l s e i f ( v . f a t != n u l l ) data2 [ data2 . l e n g t h ] = v . f a t ; e l s e i f ( v . f o o d g r o u p != n u l l ) data2 [ data2 . l e n g t h ] = v . food group ; return { l a b e l : v . food name }; }) ) ; } }) ; }, s e l e c t : f u n c t i o n ( event , u i ) { v a r num = i d . s u b s t r i n g ( i d . i n d e x O f ( ” s ” ) + 1 , i d . l e n g t h ) ; v a r measure = n u l l ; var food group = n u l l ; var c a l o r i e , carbohydrate , protein , f a t ; f o r ( v a r i = 0 ; i < d a t a 2 . l e n g t h ; i +=7){ i f ( d a t a 2 [ i ] == u i . i t e m . v a l u e ) { measure = d a t a 2 [ i + 1 ] ; c a l o r i e = data2 [ i + 2 ] ; carbohydrate = data2 [ i + 3 ] ; p r o t e i n = data2 [ i + 4 ] ; f a t = data2 [ i + 5 ] ; food group = data2 [ i +6]; } } // c o n s o l e . l o g ( c a l o r i e ) ; $ ( ’# i n g r e d i e n t m e a s u r e ’+num) . v a l ( measure ) ; $ ( ’# f o o d g r o u p ’+num) . v a l ( f o o d g r o u p ) ; /∗ $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) + + c a l o r i e ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) + +c a r b o h y d r a t e ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) + +p r o t e i n ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) + +f a t ) ; ∗ / } /∗ f o c u s : f u n c t i o n ( e v e n t , u i ) { $ ( ” . i n g r e d i e n t s ” ) . v a l ( u i . item . l a b e l ) ; }, s e l e c t : f u n c t i o n ( event , u i ) { }∗/ }) ; }) ; f u n c t i o n update ( i d ) { v a r r e q u e s t = new XMLHttpRequest ( ) , u r l = ”<?php e c h o s i t e u r l ( ’ h o m e u s e r / g e t f a ’ ) ; ? >” , params = ” i n g r e d i e n t =”+$(”# i n g r e d i e n t s ”+ i d ) . v a l ( ) ; 100 request . onreadystatechange = function () { i f ( r e q u e s t . r e a d y S t a t e == 4 && r e q u e s t . s t a t u s == 2 0 0 ) { v a r temp = r e q u e s t . r e s p o n s e T e x t . s p l i t ( ” , ” ) , i ; $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) − (+temp [ 0 ] ∗ q u a n t i t y [ i d ] ) ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) − (+temp [ 1 ] ∗ q u a n t i t y [ i d ] ) ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) − (+temp [ 2 ] ∗ q u a n t i t y [ i d ] ) ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) − (+temp [ 3 ] ∗ q u a n t i t y [ i d ] ) ) ; f o r ( i = 0 ; i < temp . l e n g t h ; i ++) temp [ i ] = +temp [ i ] ∗ $(”# i n g r e d i e n t q u a n t i t y ”+ i d ) . v a l ( ) ; $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) + temp [ 0 ] ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) + temp [ 1 ] ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) + temp [ 2 ] ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) + temp [ 3 ] ) ; q u a n t i t y [ i d ] = $(”# i n g r e d i e n t q u a n t i t y ”+ i d ) . v a l ( ) ; } } r e q u e s t . open ( ”POST” , u r l , t r u e ) ; r e q u e s t . s e t R e q u e s t H e a d e r ( ” Content−t y p e ” , ” a p p l i c a t i o n /x−www−form−u r l e n c o d e d ” ) ; r e q u e s t . s e n d ( params ) ; } $ ( document ) . r e a d y ( f u n c t i o n ( ) { var counter = 1 ; var data2 = [ ] ; q u a n t i t y = new Array ( ) ; q u a n t i t y [ 0 ] = $(”# i n g r e d i e n t q u a n t i t y 0 ” ) . v a l ( ) == ”” ? 0 : $(”# i n g r e d i e n t q u a n t i t y 0 ” ) . v a l ( ) ; $(”# a d d I n g r e d i e n t B u t t o n ” ) . c l i c k ( f u n c t i o n /∗ i f ( c o u n t e r >10) { a l e r t ( ” Only 10 t e x t b o x e s return f a l s e ; } ∗/ () { allow ”) ; quantity [ counter ] = 0; v a r newTextBoxDiv = $ ( document . c r e a t e E l e m e n t ( ’ d i v ’ ) ) . a t t r ( ” i d ” , ’ TextBoxDiv ’ + c o u n t e r ) ; newTextBoxDiv . a f t e r ( ) . html ( ’ < br><l a b e l >I n g r e d i e n t :   ;& nbsp ;& nbsp ; </ l a b e l >’ + ’< i n p u t t y p e=” t e x t ” c l a s s =” i n g r e d i e n t s ” name=” i n g r e d i e n t s [ ’ + c o u n t e r + ’ ] ” i d =” i n g r e d i e n t s ’ + c o u n t e r + ’ ” v a l u e =”” > ’) ; v a r newTextBoxDiv1= $ ( document . c r e a t e E l e m e n t ( ’ d i v ’ ) ) . a t t r ( ” i d ” , ’ TextBoxDiv1 ’ + c o u n t e r ) ; newTextBoxDiv1 . a f t e r ( ) . html ( ’ < l a b e l >Measure ( g ) : </ l a b e l >’ + ’< i n p u t t y p e=” t e x t ” c l a s s =”measure ” name=” i n g r e d i e n t m e a s u r e [ ’ + c o u n t e r + ’ ] ” i d =” i n g r e d i e n t m e a s u r e ’ + c o u n t e r + ’ ” v a l u e =”” > ’) ; v a r newTextBoxDiv2= $ ( document . c r e a t e E l e m e n t ( ’ d i v ’ ) ) . a t t r ( ” i d ” , ’ TextBoxDiv2 ’ + c o u n t e r ) ; newTextBoxDiv2 . a f t e r ( ) . html ( ’ < l a b e l >Q u a n t i t y :   ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; </ l a b e l >’ + ’< i n p u t t y p e=” t e x t ” name=” i n g r e d i e n t q u a n t i t y [ ’ + c o u n t e r + ’ ] ” i d =” i n g r e d i e n t q u a n t i t y ’ + c o u n t e r + ’ ” v a l u e =”” o n c h a n g e=”u p d a t e ( ’+ c o u n t e r + ’) ” > ’) ; v a r newTextBoxDiv3= $ ( document . c r e a t e E l e m e n t ( ’ d i v ’ ) ) . a t t r ( ” i d ” , ’ TextBoxDiv3 ’ + c o u n t e r ) ; newTextBoxDiv3 . a f t e r ( ) . html ( ’ < l a b e l >Food Group : </ l a b e l >’ + ’< i n p u t t y p e=” t e x t ” c l a s s =” f o o d g r o u p ” name=” f o o d g r o u p [ ’ + c o u n t e r + ’ ] ” i d =” f o o d g r o u p ’ + c o u n t e r + ’ ” v a l u e =”” > ’) ; newTextBoxDiv . appendTo(”# TextBoxesGroup ” ) ; newTextBoxDiv3 . appendTo(”# TextBoxesGroup ” ) ; newTextBoxDiv1 . appendTo(”# TextBoxesGroup ” ) ; newTextBoxDiv2 . appendTo(”# TextBoxesGroup ” ) ; document . g e t E l e m e n t B y I d ( ” i n g r e d i e n t m e a s u r e ” + c o u n t e r ) . r e a d O n l y=t r u e ; document . g e t E l e m e n t B y I d ( ” f o o d g r o u p ” + c o u n t e r ) . r e a d O n l y=t r u e ; var id ; $ ( ’ . i n g r e d i e n t s ’ ) . autocomplete ({ minLength : 0 , source : function ( request , response ) { i d = t h i s . e l e m e n t . c o n t e x t . a t t r i b u t e s [ name=” i d ” ] . v a l u e ; // c o n s o l e . l o g ( i d ) ; $ . ajax ( { u r l : ”<?php e c h o s i t e u r l ( ’ h o m e u s e r / s u g g e s t i o n s ’ ) ; ? >” , data : request , dataType : ” j s o n ” , t y p e : ”POST” , s u c c e s s : f u n c t i o n ( data ) { r e s p o n s e ( $ . map ( data , f u n c t i o n ( v , i ) { i f ( v . measure != n u l l ) d a t a 2 [ d a t a 2 . l e n g t h ] = v . measure ; e l s e i f ( v . f o o d n a m e != n u l l ) data2 [ data2 . l e n g t h ] = v . food name ; e l s e i f ( v . e n e r g y != n u l l ) data2 [ data2 . l e n g t h ] = v . energy ; e l s e i f ( v . c a r b o h y d r a t e != n u l l ) data2 [ data2 . l e n g t h ] = v . carbohydrate ; e l s e i f ( v . p r o t e i n != n u l l ) data2 [ data2 . l e n g t h ] = v . p r o t e i n ; e l s e i f ( v . f a t != n u l l ) data2 [ data2 . l e n g t h ] = v . f a t ; e l s e i f ( v . f o o d g r o u p != n u l l ) data2 [ data2 . l e n g t h ] = v . food group ; return { l a b e l : v . food name 101 }; }) ) ; } }) ; }, s e l e c t : f u n c t i o n ( event , u i ) { v a r num = i d . s u b s t r i n g ( i d . i n d e x O f ( ” s ” ) + 1 , i d . l e n g t h ) ; v a r measure = n u l l ; var food group = n u l l ; var c a l o r i e , carbohydrate , protein , f a t ; f o r ( v a r i = 0 ; i < d a t a 2 . l e n g t h ; i +=7){ i f ( d a t a 2 [ i ] == u i . i t e m . v a l u e ) { measure = d a t a 2 [ i + 1 ] ; c a l o r i e = data2 [ i + 2 ] ; carbohydrate = data2 [ i + 3 ] ; p r o t e i n = data2 [ i + 4 ] ; f a t = data2 [ i + 5 ] ; food group = data2 [ i +6]; } } // c o n s o l e . l o g ( c a l o r i e ) ; $ ( ’# i n g r e d i e n t m e a s u r e ’+num) . v a l ( measure ) ; $ ( ’# f o o d g r o u p ’+num) . v a l ( f o o d g r o u p ) ; /∗ $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) + + c a l o r i e ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) + +c a r b o h y d r a t e ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) + +p r o t e i n ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) + +f a t ) ; ∗/ } }) ; c o u n t e r ++; }) ; $(”# r e m o v e I n g r e d i e n t B u t t o n ” ) . c l i c k ( f u n c t i o n i f ( c o u n t e r ==1){ a l e r t ( ” No more t e x t b o x t o remove ” ) ; return f a l s e ; } c o u n t e r −−; var () { r e q u e s t = new XMLHttpRequest ( ) , u r l = ”<?php e c h o s i t e u r l ( ’ h o m e u s e r / g e t f a ’ ) ; ? >” , params = ” i n g r e d i e n t =”+($(”# i n g r e d i e n t s ”+ c o u n t e r ) . v a l ( ) == ”” ? 0 : $(”# i n g r e d i e n t s ”+ counter ) . val () ) ; request . onreadystatechange = function () { i f ( r e q u e s t . r e a d y S t a t e == 4 && r e q u e s t . s t a t u s == 2 0 0 ) { v a r temp = r e q u e s t . r e s p o n s e T e x t . s p l i t ( ” , ” ) ; $(”#TextBoxDiv ” + c o u n t e r ) . remove ( ) ; $(”# TextBoxDiv3 ” + c o u n t e r ) . remove ( ) ; $(”# TextBoxDiv1 ” + c o u n t e r ) . remove ( ) ; $(”# TextBoxDiv2 ” + c o u n t e r ) . remove ( ) ; i f ( q u a n t i t y [ c o u n t e r ] != ”” && q u a n t i t y [ c o u n t e r ] != n u l l ) { $ ( ’# c a l o r i e s ’ ) . v a l (+$ ( ’# c a l o r i e s ’ ) . v a l ( ) − (+temp [ 0 ] ∗ q u a n t i t y [ c o u n t e r ] ) ) ; $ ( ’# c a r b o h y d r a t e ’ ) . v a l (+$ ( ’# c a r b o h y d r a t e ’ ) . v a l ( ) − (+temp [ 1 ] ∗ q u a n t i t y [ c o u n t e r ] ) ) ; $ ( ’# p r o t e i n ’ ) . v a l (+$ ( ’# p r o t e i n ’ ) . v a l ( ) − (+temp [ 2 ] ∗ q u a n t i t y [ c o u n t e r ] ) ) ; $ ( ’# f a t ’ ) . v a l (+$ ( ’# f a t ’ ) . v a l ( ) − (+temp [ 3 ] ∗ q u a n t i t y [ c o u n t e r ] ) ) ; } } } r e q u e s t . open ( ”POST” , u r l , t r u e ) ; r e q u e s t . s e t R e q u e s t H e a d e r ( ” Content−t y p e ” , ” a p p l i c a t i o n /x−www−form−u r l e n c o d e d ” ) ; r e q u e s t . s e n d ( params ) ; }) ; }) ; function healthConditionsGuidelinesModal () { $(”# h e a l t h C o n d i t i o n s G u i d e l i n e s M o d a l D i a l o g ” ) . d i a l o g ( { autoOpen : f a l s e , modal : t r u e , t i t l e : ’ G u i d e l i n e s f o r Health Conditions ’ , w i d t h : ’ auto ’ , h e i g h t : ’ auto ’ , buttons : { ”Ok ” : f u n c t i o n ( ) { $ ( t h i s ) . d i a l o g (” c l o s e ”) ; } }, } ) . d i a l o g ( ’ open ’ ) ; return f a l s e ; } function validate () { v a r e r r o r s = ”<p s t y l e =’ c o l o r : r e d ; f o n t −w e i g h t : b o l d ’ > ” ; i f ( $(”# r e c i p e n a m e ” ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The R e c i p e Name f i e l d i s r e q u i r e d .< br >”; i f ( $(”# s e r v i n g s u g g ” ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The S e r v i n g S i z e f i e l d i s r e q u i r e d .< br >”; i f ( $(”# p r e p a r a t i o n p r o c e d u r e ” ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The P r o c e d u r e f i e l d i s r e q u i r e d .< br >”; i f ( $(”# i n g r e d i e n t s 0 ” ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The I n g r e d i e n t s f i e l d i s r e q u i r e d .< br >”; v a r f i l e = $ ( ” i n p u t [ name=’ u s e r f i l e ’ ] ” ) . v a l ( ) ; i f ( f i l e != ” ” ) { v a r f i l e t y p e s = [ ” g i f ” , ” j p g ” , ” j p e g ” , ” png ” ] ; v a r e x t = f i l e . s u b s t r ( f i l e . l a s t I n d e x O f ( ” . ” ) + 1 , f i l e . l e n g t h ) . toLowerCase ( ) ; i f ( f i l e t y p e s . indexOf ( ext ) < 0) e r r o r s += ”The image f i l e t y p e i s i n v a l i d .< br >”; } 102 var i n g r e d i e n t s = new Array ( ) ; $(”# i n g r c o n t i n p u t [ t y p e =’ t e x t ’ ] ” ) . e a c h ( f u n c t i o n ( ) { i f ( $ ( t h i s ) . a t t r ( ” i d ” ) . i n d e x O f ( ” i n g r e d i e n t s ” ) > −1 && $ ( t h i s ) . v a l ( ) . t r i m ( ) != ” ” ) { var id = $ ( t h i s ) . a t t r (” id ”) . s u b s t r ( $ ( t h i s ) . a t t r (” id ”) . indexOf (” s ”) + 1 , $ ( t h i s ) . a t t r (” id ”) . length ) ; v a r v a l u e = { i n g r e d i e n t : $ ( t h i s ) . v a l ( ) . t r i m ( ) , f o o d g r o u p : $(”# f o o d g r o u p ”+ i d ) . v a l ( ) . t r i m ( ) } ; i f ( $(”# i n g r e d i e n t q u a n t i t y ”+ i d ) . v a l ( ) . t r i m ( ) == ” ” ) e r r o r s += ”The Q u a n t i t y f i e l d i s r e q u i r e d .< br >”; else v a l u e . q u a n t i t y = $(”# i n g r e d i e n t q u a n t i t y ”+ i d ) . v a l ( ) . t r i m ( ) ; i f ( v a l u e . q u a n t i t y != n u l l ) i n g r e d i e n t s . push ( v a l u e ) ; } }) ; var h e a l t h c o n d i t i o n = $(”# h e a l t h c o n d i t i o n ” ) . v a l ( ) , for ( i = 0; i < ingredients . length ; i; i ++) { var food group = i n g r e d i e n t s [ i ] . foodgroup , count = 0 , j; f o r ( j = 0 ; j < i n g r e d i e n t s . l e n g t h ; j ++) i f ( i n g r e d i e n t s [ i ] . f o o d g r o u p == f o o d g r o u p ) c o u n t += p a r s e F l o a t ( i n g r e d i e n t s [ i ] . q u a n t i t y ) ; c o n s o l e . l o g ( c o u n t +”;”+ f o o d g r o u p ) ; i f ( h e a l t h c o n d i t i o n == ” D i a b e t e s ” ) { i f ( ( f o o d g r o u p === ” V e g e t a b l e ” | | f o o d g r o u p === ” F r u i t ” ) && c o u n t > 4 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 4 s e r v i n g s o f ”+ f o o d g r o u p +” d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Milk ” && c o u n t > 3 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 3 s e r v i n g s o f Milk d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” R i c e ” && c o u n t > 9 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 9 s e r v i n g s o f R i c e d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Meat ” && c o u n t > 6 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 6 s e r v i n g s o f Meat d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Meat ” && c o u n t > 5 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f Fat d a i l y .< br >”; } } e l s e i f ( h e a l t h c o n d i t i o n == ’ H y p e r t e n s i o n ’ | | h e a l t h c o n d i t i o n == ’ Kidney S t o n e s ’ ) { i f ( ( f o o d g r o u p === ” V e g e t a b l e ” | | f o o d g r o u p === ” F r u i t ” ) && c o u n t > 5 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f ”+ f o o d g r o u p +” d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Milk ” && c o u n t > 5 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f Milk d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” R i c e ” && c o u n t > 8 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 8 s e r v i n g s o f R i c e d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Meat ” && c o u n t > 2 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 2 s e r v i n g s o f Meat d a i l y .< br >”; } e l s e i f ( f o o d g r o u p === ” Meat ” && c o u n t > 3 ) { e r r o r s += ”You a r e o n l y a l l o w e d a maximum o f 3 s e r v i n g s o f Fat d a i l y .< br >”; } } } e r r o r s += ”</p >”; i f ( e r r o r s != ”<p s t y l e =’ c o l o r : r e d ; f o n t −w e i g h t : b o l d ’></p>”) { $(”# a d d R e c i p e D i a l o g ” ) . p r e p e n d ( e r r o r s ) ; return f a l s e ; } } </ s c r i p t > </head> <body> <d i v i d =” h e a l t h C o n d i t i o n s G u i d e l i n e s M o d a l D i a l o g ” s t y l e =” d i s p l a y : none ;” > <c e n t e r > <t a b l e > <t r > <p>Below a r e t h e maximum d a i l y s e r v i n g s f o r e a c h f o o d g r o u p f o r e a c h h e a l t h </t r > <t r > <th><h4>Food Group</th> <th><h4>D i a b e t e s </th> <th><h4>H y p e r t e n s i o n </th> <th><h4>Kidney S t o n e s </th> </t r > <t r > <td>V e g e t a b l e <td >4 <td >5 <td >5 </t r > <t r > <td>F r u i t <td >4 <td >5 <td >5 </t r > <t r > <td>Milk <td >3 <td >5 <td >5 </t r > <t r > <td>R i c e <td >9 103 condition : <td >8 <td >8 </t r > <t r > <td>Meat <td >6 <td >2 <td >2 </t r > <t r > <td>Fat <td >5 <td >3 <td >3 </t r > </ t a b l e > </ c e n t e r > </d i v> <d i v i d =”a d d R e c i p e D i a l o g ” t i t l e =”C r e a t e R e c i p e ”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?><?php i f ( i s s e t ( $ e r r o r d i s p l a y ) ) { e c h o $ e r r o r d i s p l a y ; } ?></b></f o n t > <?php e c h o f o r m o p e n m u l t i p a r t ( ’ h o m e u s e r / a d d r e c i p e s a v e ’ , a r r a y ( ’ onsubmit ’=>’ r e t u r n v a l i d a t e ( ) ’ ) ) ; ?> <c e n t e r > <t a b l e > <t r > <a h r e f =”#” o n c l i c k =” j a v a s c r i p t : h e a l t h C o n d i t i o n s G u i d e l i n e s M o d a l ( ) ;” > G u i d e l i n e s f o r H e a l t h C o n d i t i o n s </a> </t r > <t r ></t r ><t r ></t r > <t r > <td><l a b e l f o r =” h e a l t h c o n d i t i o n ”>  ; H e a l t h C o n d i t i o n : </ l a b e l > <td><i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =” D i a b e t e s ” <? php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” D i a b e t e s ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>D i a b e t e s <br> <i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =” H y p e r t e n s i o n ” <? php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” H y p e r t e n s i o n ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>H y p e r t e n s i o n <br> <i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =”Kidney S t o n e s ” <?php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” Kidney S t o n e s ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>Kidney S t o n e s <br> <i n p u t t y p e=”c h e c k b o x ” i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n [ ] ” v a l u e =”None ” <?php i f ( ( ! empty ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && i n a r r a y ( ” None ” , $ POST [ ” h e a l t h c o n d i t i o n ” ] ) ) ) { e c h o ” c h e c k e d ” ; } ?>>None<br> <!−−<td><s e l e c t i d =” h e a l t h c o n d i t i o n ” name=” h e a l t h c o n d i t i o n ”> <o p t i o n v a l u e =” D i a b e t e s ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” D i a b e t e s ” ) e c h o ” s e l e c t e d ”;?>> D i a b e t e s </o p t i o n > <o p t i o n v a l u e =” H y p e r t e n s i o n ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” H y p e r t e n s i o n ” ) e c h o ” s e l e c t e d ”;?>> H y p e r t e n s i o n </o p t i o n > <o p t i o n v a l u e =”Kidney S t o n e s ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” Kidney S t o n e s ” ) e c h o ” s e l e c t e d ”;?>> Kidney S t o n e s </o p t i o n > <o p t i o n v a l u e =”None ” <?php i f ( i s s e t ( $ POST [ ” h e a l t h c o n d i t i o n ” ] ) && $ POST [ ” h e a l t h c o n d i t i o n ” ] == ” None ” ) e c h o ” s e l e c t e d ”;?>>None</o p t i o n > </ s e l e c t >−−> </t r > <t r > <td><l a b e l f o r =” m e a l t y p e”>  ; Meal Type: </ l a b e l > <td><s e l e c t i d =” m e a l t y p e ” name=” m e a l t y p e ”> == ” <o p t i o n v a l u e =” B r e a k f a s t ” <?php i f ( i s s e t ( $ POST [ ” m e a l t y p e ” ] ) && $ POST [ ” m e a l t y p e ” ] B r e a k f a s t ” ) e c h o ” s e l e c t e d ”;?>> B r e a k f a s t </o p t i o n > <o p t i o n v a l u e =”Lunch ” <?php i f ( i s s e t ( $ POST [ ” m e a l t y p e ” ] ) && $ POST [ ” m e a l t y p e ” ] == ” Lunch ” ) e c h o ” s e l e c t e d ”;?>>Lunch</o p t i o n > <o p t i o n v a l u e =”D i n n e r ” <?php i f ( i s s e t ( $ POST [ ” m e a l t y p e ” ] ) && $ POST [ ” m e a l t y p e ” ] == ” D i n n e r ” ) e c h o ” s e l e c t e d ”;?>> Dinner </o p t i o n > <o p t i o n v a l u e =”Snack ” <?php i f ( i s s e t ( $ POST [ ” m e a l t y p e ” ] ) && $ POST [ ” m e a l t y p e ” ] == ” Snack ” ) e c h o ” s e l e c t e d ”;?>>Snack </o p t i o n > </ s e l e c t > </t r > <t r > <td><l a b e l f o r =” u s e r f i l e ”>  ; R e c i p e Image : </ l a b e l > <td><i n p u t name=” u s e r f i l e ” t y p e=” f i l e ” s i z e =”20” > </t r > <t r > <td><l a b e l f o r =” r e c i p e n a m e”>  ; R e c i p e Name: </ l a b e l > <td><i n p u t i d =” r e c i p e n a m e ” name=” r e c i p e n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ r e c i p e n a m e ’ ) ; ?>” > </t r > <t r > <td><l a b e l f o r =” s e r v i n g s u g g ”>  ; S e r v i n g S i z e : </ l a b e l > <td><i n p u t i d =” s e r v i n g s u g g ” name=” s e r v i n g s u g g ” t y p e=”number ” v a l u e =”<?php e c h o s e t v a l u e ( ’ s e r v i n g s u g g ’ ) ; ?>” s i z e =”2” min=”1” > </t r > <t r ><td><l a b e l f o r =” i n g r e d i e n t s ”>  ; I n g r e d i e n t s : </ l a b e l > <t d i d =” i n g r c o n t ”> <b u t t o n i d =” a d d I n g r e d i e n t B u t t o n ” name=” a d d I n g r e d i e n t B u t t o n ” v a l u e =”” t y p e=”b u t t o n ” v a l u e =”Add ”><span c l a s s =”u i −i c o n u i −i c o n −p l u s t h i c k ”></span></button> <b u t t o n i d =” r e m o v e I n g r e d i e n t B u t t o n ” name=” r e m o v e I n g r e d i e n t B u t t o n ” v a l u e =”Remove” t y p e=”b u t t o n ”><span c l a s s =”u i −i c o n u i −i c o n −m i n u s t h i c k ”></span></button> <br> I n g r e d i e n t :   ;& nbsp ;& nbsp ;< i n p u t i d =” i n g r e d i e n t s 0 ” name=” i n g r e d i e n t s [ 0 ] ” c l a s s =” i n g r e d i e n t s ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ i n g r e d i e n t s ’ ) ; ?>” ><br> Food Group : <i n p u t i d =” f o o d g r o u p 0 ” name=” f o o d g r o u p [ 0 ] ” c l a s s =” f o o d g r o u p ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ f o o d g r o u p ’ ) ; ?>” r e a d o n l y ><br> Measure ( g ) : <i n p u t i d =” i n g r e d i e n t m e a s u r e 0 ” name=” i n g r e d i e n t m e a s u r e [ 0 ] ” c l a s s =”measure ” t y p e =” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ i n g r e d i e n t m e a s u r e ’ ) ; ?>” r e a d o n l y ><br> Q u a n t i t y :   ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;< i n p u t i d =” i n g r e d i e n t q u a n t i t y 0 ” name=” i n g r e d i e n t q u a n t i t y [ 0 ] ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ i n g r e d i e n t q u a n t i t y ’ ) ; ?>” o n c h a n g e=”u p d a t e ( 0 ) ” > 104 <br> <d i v i d =’ TextBoxesGroup ’></ d i v> </t r > <t r > <td><l a b e l f o r =” p r e p a r a t i o n p r o c e d u r e”>  ; P r o c e d u r e : </ l a b e l > <td><t e x t a r e a i d =” p r e p a r a t i o n p r o c e d u r e ” name=” p r e p a r a t i o n p r o c e d u r e ” t y p e=” t e x t ”><?php e c h o s e t v a l u e ( ’ p r e p a r a t i o n p r o c e d u r e ’ ) ; ?></ t e x t a r e a > </t r > <!−−<t r > <td><l a b e l f o r =” t o t a l q u a n t i t y ”>  ; T o t a l Q u a n t i t y : </ l a b e l > <td><i n p u t i d =” t o t a l q u a n t i t y ” name=” t o t a l q u a n t i t y ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ t o t a l q u a n t i t y ’ ) ; ?>”> </t r >−−> <t r > <td><l a b e l f o r =” c a l o r i e s ”>  ; T o t a l C a l o r i e s ( Kcal ) : </ l a b e l > <td><i n p u t i d =” c a l o r i e s ” name=” c a l o r i e s ” c l a s s =” c a l o r i e s ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ c a l o r i e s ’ ) ; ?>” r e a d o n l y > </t r > <t r > <td><l a b e l f o r =” c a r b o h y d r a t e”>  ; T o t a l C a r b o h y d r a t e s ( g ) : </ l a b e l > <td><i n p u t i d =” c a r b o h y d r a t e ” name=” c a r b o h y d r a t e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ c a r b o h y d r a t e ’ ) ; ?>” r e a d o n l y > </t r > <t r > <td><l a b e l f o r =” p r o t e i n ”>  ; T o t a l P r o t e i n ( g ) : </ l a b e l > <td><i n p u t i d =” p r o t e i n ” name=” p r o t e i n ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ p r o t e i n ’ ) ; ?>” r e a d o n l y > </t r > <t r > <td><l a b e l f o r =” f a t ”>  ; T o t a l Fat ( g ) : </ l a b e l > <td><i n p u t i d =” f a t ” name=” f a t ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ f a t ’ ) ; ?>” r e a d o n l y > </t r > <t r > <td><b u t t o n i d =”a d d R e c i p e B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>C r e a t e R e c i p e </ button> <td><b u t t o n i d =”addRecipeBackButton ” t y p e=”b u t t o n ” name=”addRecipeBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”addRecipeHomeButton ” t y p e=”b u t t o n ” name=”addRecipeHomeButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#addUserButton , #addUserBackButton , #addUserHomeButton ” ) . b u t t o n ( ) ; $ ( ”#u s e r T y p e R a d i o B u t t o n S e t , #g e n d e r R a d i o B u t t o n S e t ” ) . b u t t o n s e t ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# b i r t h d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# b i r t h d a t e ’ ) . v a l i d ( ) ; i f ( $ ( ’# b i r t h d a t e ’ ) . v a l ( ) != ’ ’ ) { $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b i r t h d a t e r e q u i r e d e r r o r . png ’ ) ” } ) ; } } }) ; $ ( ”#a d d U s e r D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , 105 b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , dialogClass : ” noclose ” ui ) { return false ; }, }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# username ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# username ” ) . v a l ( ) . l e n g t h >= 4 ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > home admin / c h e c k u s e r ” , d a t a : ”name=”+$(”# username ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o . png ’ ) ” } ) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e e x i s t s e r r o r . png ’ ) ” } ) ; } } }) ; } e l s e i f ( $(”# username ” ) . v a l ( ) . l e n g t h < 4 ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / $(”# p a s s w o r d ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) . l e n g t h >= 8 ) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) != $(”# p a s s w o r d ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; } else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } e l s e i f ( $(”# p a s s w o r d ” ) . v a l ( ) . l e n g t h < 8 ) { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) } }) ; $(”# c o n f i r m p a s s w o r d ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# p a s s w o r d ” ) . v a l ( ) . l e n g t h >=8) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) != $(”# p a s s w o r d ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; } else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } }) ; $(”# e m a i l a d d r e s s ” ) . keyup ( f u n c t i o n ( ) { v a r e m a i l = $(”# e m a i l a d d r e s s ” ) . v a l ( ) ; i f ( e m a i l != 0 ) { i f ( isValidEmailAddress ( email ) ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > home admin / c h e c k e m a i l ” , d a t a : ” e m a i l=”+$(”# e m a i l a d d r e s s ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; e m a i l c o n=t r u e ; register show () ; } 106 b a s e u r l ( ) ;? > l a y o u t / i m a g e s / else { $(”# e m a i l email } } }) ; } else { $(”# e m a i l email } } else { $(”# e m a i l } }) ; v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o e x i s t s e r r o r . png ’ ) ” } ) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o i n v a l i d e r r o r . png ’ ) ” } ) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; $(”# f i r s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# f i r s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o f i r s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; $(”# l a s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# l a s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o l a s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / function isValidEmailAddress ( emailAddress ) { v a r p a t t e r n = new RegExp ( / ˆ ( ( ” [ \ w−\s ] + ” ) | ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) | ( ” [ \ w−\s ] + ” ) ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) ) (@ ( ( ? : [ \ w−]+\.) ∗\w[ \ w− ] { 0 , 6 6 } ) \ . ( [ a−z ] { 2 , 6 } ( ? : \ . [ a−z ] { 2 } ) ? ) $ ) | ( @ \[?((25[0 −5]\.|2[0 −4][0 −9]\.|1[0 −9]{2}\.|[0 −9]{1 ,2}\.) ) ((25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \.) {2}(25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \]? $ ) / i ) ; return pattern . t e s t ( emailAddress ) ; } </ s c r i p t > </head> <body> <d i v i d =”a d d U s e r D i a l o g ” t i t l e =”Add U s e r”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ’ home admin / s a v e ’ , a r r a y ( ’ username ’ => ’ myform ’ ) ) ; ?> <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><l a b e l f o r =” f i r s t n a m e ”>  ; F i r s t Name: </ l a b e l > <td><i n p u t i d =” f i r s t n a m e ” name=” f i r s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ f i r s t n a m e ’ ) ; ?>”> <span i d =” f i r s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”middle name”>  ; M i d d l e Name: </ l a b e l > <td><i n p u t i d =”middle name ” name=”middle name ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ middle name ’ ) ; ?>”>( O p t i o n a l ) </t r > <t r > <td><l a b e l f o r =” l a s t n a m e”>  ; L a s t Name: </ l a b e l > <td><i n p u t i d =” l a s t n a m e ” name=” l a s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ l a s t n a m e ’ ) ; ?>”> <span i d =” l a s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” b i r t h d a t e”>  ; B i r t h d a t e : </ l a b e l > <td><i n p u t i d =” b i r t h d a t e ” name=” b i r t h d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<? php e c h o s e t v a l u e ( ’ b i r t h d a t e ’ ) ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#b i r t h d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> <span i d =” b i r t h d a t e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”g e n d e r”>  ; Gender : </ l a b e l > <td> <d i v i d =”g e n d e r R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =”g e n d e r M a l e ” name=”g e n d e r R a d i o ” v a l u e =”Male ” <?php e c h o s e t r a d i o ( ’ g e n d e r R a d i o ’ , ’ Male ’ , TRUE) ; ?> ><l a b e l f o r =”g e n d e r M a l e”>Male</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”g e n d e r F e m a l e ” name=”g e n d e r R a d i o ” v a l u e =”Female ” <?php e c h o s e t r a d i o ( ’ g e n d e r R a d i o ’ , ’ Female ’ ) ; ?>>< l a b e l f o r =”g e n d e r F e m a l e”>Female </ l a b e l > </d i v> </t r > <t r > <td><l a b e l f o r =” u s e r t y p e ”>  ; U s e r Type: </ l a b e l > <td> <d i v i d =”u s e r T y p e R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =” u s e r T y p e A d m i n i s t r a t o r ” name=”u s e r T y p e R a d i o ” v a l u e =” A d m i n i s t r a t o r ” <? php e c h o s e t r a d i o ( ’ userTypeRadio ’ , ’ A d m i n i s t r a t o r ’ , TRUE) ; ?>>< l a b e l f o r =” u s e r T y p e A d m i n i s t r a t o r ”> A d m i n i s t r a t o r </ l a b e l > 107 <i n p u t t y p e=” r a d i o ” i d =”userTypeContentManager ” name=”u s e r T y p e R a d i o ” v a l u e =”Content Manager ” <?php e c h o s e t r a d i o ( ’ userTypeRadio ’ , ’ Content Manager ’ ) ; ?>>< l a b e l f o r =” userTypeContentManager”>Content Manager</ l a b e l > <!−−<i n p u t t y p e=” r a d i o ” i d =”u s e r T y p e U s e r ” name=”u s e r T y p e R a d i o ” v a l u e =”U s e r ” <?php e c h o s e t r a d i o ( ’ userTypeRadio ’ , ’ User ’ ) ; ?>>< l a b e l f o r =”u s e r T y p e U s e r”>User </ l a b e l >−−> </d i v> </t r > <t r > <td><l a b e l f o r =” e m a i l a d d r e s s”>  ; E−m a i l A d d r e s s : </ l a b e l > <td><i n p u t i d =” e m a i l a d d r e s s ” name=” e m a i l a d d r e s s ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ e m a i l a d d r e s s ’ ) ; ?>”> <span i d =” e m a i l v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”username”>  ; Username : </ l a b e l > <td><i n p u t i d =”username ” name=”username ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ username ’ ) ; ?>” > <span i d =” u s r v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”p a s s w o r d”>  ; Password : </ l a b e l > <td><i n p u t i d =”p a s s w o r d ” name=”p a s s w o r d ” t y p e=”p a s s w o r d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ password ’ ) ; ?>” > <span i d =” p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” c o n f i r m p a s s w o r d”>  ; Confirm Password : </ l a b e l > <td><i n p u t i d =” c o n f i r m p a s s w o r d ” name=” c o n f i r m p a s s w o r d ” t y p e=”p a s s w o r d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ c o n f i r m p a s s w o r d ’ ) ; ?>”> <span i d =” c o n f i r m p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><b u t t o n i d =”addUserButton ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Add User </button> <td><b u t t o n i d =”addUserBackButton ” t y p e=”b u t t o n ” name=”addUserBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home admin ’” > Back</button> <b u t t o n i d =”addUserHomeButton ” t y p e=”b u t t o n ” name=”addUserHomeButton ” v a l u e =”Home” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home admin ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#e d i t U s e r B u t t o n , #e d i t U s e r B a c k B u t t o n , #ed itUserHome Button ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# e d i t U s e r D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 650 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# p a s s w o r d ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) . l e n g t h >= 8 ) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) != $(”# p a s s w o r d ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; } 108 else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } e l s e i f ( $(”# p a s s w o r d ” ) . v a l ( ) . l e n g t h < 8 ) { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) } }) ; $(”# c o n f i r m p a s s w o r d ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# p a s s w o r d ” ) . v a l ( ) . l e n g t h >=8) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) != $(”# p a s s w o r d ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; } else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” e d i t U s e r D i a l o g ” t i t l e =”Change Password”> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ” home admin / e d i t p a s s w o r d u s e r / $username ” ) ;? > <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><i n p u t i d =”username ” name=”username ” t y p e=” t e x t ” s t y l e =” v i s i b i l i t y : h i d d e n ” v a l u e =”<?php e c h o $username ; ?>” r e a d o n l y =” r e a d o n l y ” > </t r > <t r > <td><l a b e l f o r =” o l d p a s s w o r d”>  ; Old Password : </ l a b e l > <td><i n p u t i d =” o l d p a s s w o r d ” name=” o l d p a s s w o r d ” t y p e=”p a s s w o r d ” > </t r > <t r > <td><l a b e l f o r =”p a s s w o r d”>  ; Password : </ l a b e l > <td><i n p u t i d =”p a s s w o r d ” name=”p a s s w o r d ” t y p e=”p a s s w o r d”><span i d =” p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” c o n f i r m p a s s w o r d”>  ; Confirm Password : </ l a b e l > <td><i n p u t i d =” c o n f i r m p a s s w o r d ” name=” c o n f i r m p a s s w o r d ” t y p e=”p a s s w o r d”><span i d =” c o n f i r m p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><b u t t o n i d =” e d i t U s e r B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Change Password </ button> <td><b u t t o n i d =”e d i t U s e r B a c k B u t t o n ” t y p e=”b u t t o n ” name=”e d i t U s e r B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home admin ’” > Back</button> <b u t t o n i d =”editUs erHomeButto n ” t y p e=”b u t t o n ” name=”editU serHomeButt on ” v a l u e =”Back ” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home admin ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > 109 $( function () { $ ( ”#e d i t U s e r B u t t o n , #e d i t U s e r B a c k B u t t o n , #ed itUserHome Button ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# e d i t U s e r D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 650 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# p a s s w o r d ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) . l e n g t h >= 8 ) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) != $(”# p a s s w o r d ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; } else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } e l s e i f ( $(”# p a s s w o r d ” ) . v a l ( ) . l e n g t h < 8 ) { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) } }) ; $(”# c o n f i r m p a s s w o r d ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# p a s s w o r d ” ) . v a l ( ) . l e n g t h >=8) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) != $(”# p a s s w o r d ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; } else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” e d i t U s e r D i a l o g ” t i t l e =”Change Password”> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ” home cmanager / e d i t p a s s w o r d u s e r / $username ” ) ;? > <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><i n p u t i d =”username ” name=”username ” t y p e=” t e x t ” s t y l e =” v i s i b i l i t y : h i d d e n ” v a l u e =”<?php e c h o $username ; ?>” r e a d o n l y =” r e a d o n l y ” > </t r > <t r > <td><l a b e l f o r =” o l d p a s s w o r d”>  ; Old Password : </ l a b e l > <td><i n p u t i d =” o l d p a s s w o r d ” name=” o l d p a s s w o r d ” t y p e=”p a s s w o r d ” > </t r > <t r > <td><l a b e l f o r =”p a s s w o r d”>  ; Password : </ l a b e l > <td><i n p u t i d =”p a s s w o r d ” name=”p a s s w o r d ” t y p e=”p a s s w o r d”><span i d =” p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” c o n f i r m p a s s w o r d”>  ; Confirm Password : </ l a b e l > 110 <td><i n p u t i d =” c o n f i r m p a s s w o r d ” name=” c o n f i r m p a s s w o r d ” t y p e=”p a s s w o r d”><span i d =” c o n f i r m p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><b u t t o n i d =” e d i t U s e r B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Change Password </ button> <td><b u t t o n i d =”e d i t U s e r B a c k B u t t o n ” t y p e=”b u t t o n ” name=”e d i t U s e r B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” > Back</button> <b u t t o n i d =”editUs erHomeButto n ” t y p e=”b u t t o n ” name=”editU serHomeButt on ” v a l u e =”Back ” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#e d i t U s e r B u t t o n , #e d i t U s e r B a c k B u t t o n , #ed itUserHome Button ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# e d i t U s e r D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 650 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# p a s s w o r d ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) . l e n g t h >= 8 ) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) != $(”# p a s s w o r d ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; } else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } e l s e i f ( $(”# p a s s w o r d ” ) . v a l ( ) . l e n g t h < 8 ) { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) } }) ; $(”# c o n f i r m p a s s w o r d ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# p a s s w o r d ” ) . v a l ( ) . l e n g t h >=8) { i f ( $(”# c o n f i r m p a s s w o r d ” ) . v a l ( ) != $(”# p a s s w o r d ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; 111 } else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” e d i t U s e r D i a l o g ” t i t l e =”Change Password”> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ” h o m e u s e r / e d i t p a s s w o r d u s e r / $username ” ) ;? > <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><i n p u t i d =”username ” name=”username ” t y p e=” t e x t ” s t y l e =” v i s i b i l i t y : h i d d e n ” v a l u e =”<?php e c h o $username ; ?>” r e a d o n l y =” r e a d o n l y ” > </t r > <t r > <td><l a b e l f o r =” o l d p a s s w o r d”>  ; Old Password : </ l a b e l > <td><i n p u t i d =” o l d p a s s w o r d ” name=” o l d p a s s w o r d ” t y p e=”p a s s w o r d ” > </t r > <t r > <td><l a b e l f o r =”p a s s w o r d”>  ; Password : </ l a b e l > <td><i n p u t i d =”p a s s w o r d ” name=”p a s s w o r d ” t y p e=”p a s s w o r d”><span i d =” p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” c o n f i r m p a s s w o r d”>  ; Confirm Password : </ l a b e l > <td><i n p u t i d =” c o n f i r m p a s s w o r d ” name=” c o n f i r m p a s s w o r d ” t y p e=”p a s s w o r d”><span i d =” c o n f i r m p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><b u t t o n i d =” e d i t U s e r B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Change Password </ button> <td><b u t t o n i d =”e d i t U s e r B a c k B u t t o n ” t y p e=”b u t t o n ” name=”e d i t U s e r B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”editUs erHomeButto n ” t y p e=”b u t t o n ” name=”editU serHomeButt on ” v a l u e =”Back ” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#e d i t U s e r B u t t o n , #e d i t U s e r B a c k B u t t o n , #ed itUserHome Button ” ) . b u t t o n ( ) ; $ ( ”#u s e r T y p e R a d i o B u t t o n S e t , #g e n d e r R a d i o B u t t o n S e t ” ) . b u t t o n s e t ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# b i r t h d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# b i r t h d a t e ’ ) . v a l i d ( ) ; i f ( $ ( ’# b i r t h d a t e ’ ) . v a l ( ) != ’ ’ ) { $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { 112 b a s e u r l ( ) ;? > l a y o u t / i m a g e s / $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b i r t h d a t e r e q u i r e d e r r o r . png ’ ) ” } ) ; } } }) ; $ ( ”# e d i t U s e r D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 650 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” b a s e u r l ( ) ;? > l a y o u t / i m a g e s / }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# username ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# username ” ) . v a l ( ) . l e n g t h >= 4 ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > home admin / c h e c k u s e r ” , d a t a : ”name=”+$(”# username ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o . png ’ ) ” } ) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e e x i s t s e r r o r . png ’ ) ” } ) ; } } }) ; } e l s e i f ( $(”# u s e r n a m e r e g ” ) . v a l ( ) . l e n g t h < 4 ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / $(”# e m a i l a d d r e s s ” ) . keyup ( f u n c t i o n ( ) { v a r e m a i l = $(”# e m a i l a d d r e s s ” ) . v a l ( ) ; i f ( e m a i l != 0 ) { i f ( isValidEmailAddress ( email ) ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > home admin / c h e c k e m a i l ” , d a t a : ” e m a i l=”+$(”# e m a i l a d d r e s s ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; e m a i l c o n=t r u e ; register show () ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o e m a i l e x i s t s e r r o r . png ’ ) ” } ) ; } } }) ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o e m a i l i n v a l i d e r r o r . png ’ ) ” } ) ; } } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / $(”# f i r s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# f i r s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o f i r s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; $(”# l a s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# l a s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o l a s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; }) ; function isValidEmailAddress ( emailAddress ) { 113 b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / v a r p a t t e r n = new RegExp ( / ˆ ( ( ” [ \ w−\s ] + ” ) | ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) | ( ” [ \ w−\s ] + ” ) ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) ) (@ ( ( ? : [ \ w−]+\.) ∗\w[ \ w− ] { 0 , 6 6 } ) \ . ( [ a−z ] { 2 , 6 } ( ? : \ . [ a−z ] { 2 } ) ? ) $ ) | ( @ \[?((25[0 −5]\.|2[0 −4][0 −9]\.|1[0 −9]{2}\.|[0 −9]{1 ,2}\.) ) ((25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \.) {2}(25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \]? $ ) / i ) ; return pattern . t e s t ( emailAddress ) ; } </ s c r i p t > </head> <body> <d i v i d =” e d i t U s e r D i a l o g ” t i t l e =”E d i t P r o f i l e I n f o r m a t i o n ”> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ” home admin / e d i t p r o f i l e u s e r / $username ” ) ;? > <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><l a b e l f o r =”username”>  ; Username : </ l a b e l > <td><i n p u t i d =”username ” name=”username ” t y p e=” t e x t ” v a l u e =”<?php e c h o $username ; ?>” r e a d o n l y =” r e a d o n l y ”> <span i d =” u s r v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” f i r s t n a m e ”>  ; F i r s t Name: </ l a b e l > <td><i n p u t i d =” f i r s t n a m e ” name=” f i r s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ f i r s t n a m e ; ?>”> <span i d =” f i r s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”middle name”>  ; M i d d l e Name: </ l a b e l > <td><i n p u t i d =”middle name ” name=”middle name ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ m i d d l e n a m e ; ?>”>( O p t i o n a l ) </t r > <t r > <td><l a b e l f o r =” l a s t n a m e”>  ; L a s t Name: </ l a b e l > <td><i n p u t i d =” l a s t n a m e ” name=” l a s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ l a s t n a m e ; ?>”> <span i d =” l a s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” b i r t h d a t e”>  ; B i r t h d a t e : </ l a b e l > <td><i n p u t i d =” b i r t h d a t e ” name=” b i r t h d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<? php e c h o $ b i r t h d a y ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#b i r t h d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> <span i d =” b i r t h d a t e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”g e n d e r”>  ; Gender : </ l a b e l > <td> <d i v i d =”g e n d e r R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =”g e n d e r M a l e ” name=”g e n d e r R a d i o ” v a l u e =”Male ” <?php i f ( $ g e n d e r == ” Male ”) echo ” checked ” ; ?>>< l a b e l f o r =”g e n d e r M a l e”>Male</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”g e n d e r F e m a l e ” name=”g e n d e r R a d i o ” v a l u e =”Female ” <?php i f ( $ g e n d e r== ” Female ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =”g e n d e r F e m a l e”>Female </ l a b e l > </d i v> </t r > <t r > <td><l a b e l f o r =” u s e r t y p e ”>  ; U s e r Type: </ l a b e l > <td> <d i v i d =”u s e r T y p e R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =” u s e r T y p e A d m i n i s t r a t o r ” name=”u s e r T y p e R a d i o ” v a l u e =” A d m i n i s t r a t o r ” <? php i f ( $ u s e r t y p e == ” A d m i n i s t r a t o r ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =” u s e r T y p e A d m i n i s t r a t o r ”> A d m i n i s t r a t o r </ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”userTypeContentManager ” name=”u s e r T y p e R a d i o ” v a l u e =”Content Manager ” <?php i f ( $ u s e r t y p e== ” Content Manager ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =” userTypeContentManager”>Content Manager</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”u s e r T y p e U s e r ” name=”u s e r T y p e R a d i o ” v a l u e =”U s e r ” <?php i f ( $ u s e r t y p e == ” User ”) echo ” checked ” ; ?>>< l a b e l f o r =”u s e r T y p e U s e r”>User </ l a b e l > </d i v> </t r > <t r > <td><l a b e l f o r =” e m a i l a d d r e s s”>  ; E−m a i l A d d r e s s : </ l a b e l > <td><i n p u t i d =” e m a i l a d d r e s s ” name=” e m a i l a d d r e s s ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ e m a i l a d d r e s s ; ?>”> <span i d =” e m a i l v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><b u t t o n i d =” e d i t U s e r B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Update P r o f i l e </ button> <td><b u t t o n i d =”e d i t U s e r B a c k B u t t o n ” t y p e=”b u t t o n ” name=”e d i t U s e r B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home admin ’” > Back</button> <b u t t o n i d =”editUs erHomeButto n ” t y p e=”b u t t o n ” name=”editU serHomeButt on ” v a l u e =”Home” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home admin ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> 114 r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#e d i t U s e r B u t t o n , #e d i t U s e r B a c k B u t t o n , #ed itUserHome Button ” ) . b u t t o n ( ) ; $ ( ”#u s e r T y p e R a d i o B u t t o n S e t , #g e n d e r R a d i o B u t t o n S e t ” ) . b u t t o n s e t ( ) ; <l i n k // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# b i r t h d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# b i r t h d a t e ’ ) . v a l i d ( ) ; i f ( $ ( ’# b i r t h d a t e ’ ) . v a l ( ) != ’ ’ ) { $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b i r t h d a t e r e q u i r e d e r r o r . png ’ ) ” } ) ; } } }) ; $ ( ”# e d i t U s e r D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 650 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# username ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# username ” ) . v a l ( ) . l e n g t h >= 4 ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > home cmanager / c h e c k u s e r ” , d a t a : ”name=”+$(”# username ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o . png ’ ) ” } ) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e e x i s t s e r r o r . png ’ ) ” } ) ; } } }) ; } e l s e i f ( $(”# u s e r n a m e r e g ” ) . v a l ( ) . l e n g t h < 4 ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / $(”# e m a i l a d d r e s s ” ) . keyup ( f u n c t i o n ( ) { v a r e m a i l = $(”# e m a i l a d d r e s s ” ) . v a l ( ) ; i f ( e m a i l != 0 ) { i f ( isValidEmailAddress ( email ) ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > home cmanager / c h e c k e m a i l ” , d a t a : ” e m a i l=”+$(”# e m a i l a d d r e s s ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; e m a i l c o n=t r u e ; register show () ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o e m a i l e x i s t s e r r o r . png ’ ) ” } ) ; } 115 b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / } }) ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o e m a i l i n v a l i d e r r o r . png ’ ) ” } ) ; } } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / $(”# f i r s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# f i r s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o f i r s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; $(”# l a s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# l a s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o l a s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / function isValidEmailAddress ( emailAddress ) { v a r p a t t e r n = new RegExp ( / ˆ ( ( ” [ \ w−\s ] + ” ) | ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) | ( ” [ \ w−\s ] + ” ) ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) ) (@ ( ( ? : [ \ w−]+\.) ∗\w[ \ w− ] { 0 , 6 6 } ) \ . ( [ a−z ] { 2 , 6 } ( ? : \ . [ a−z ] { 2 } ) ? ) $ ) | ( @ \[?((25[0 −5]\.|2[0 −4][0 −9]\.|1[0 −9]{2}\.|[0 −9]{1 ,2}\.) ) ((25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \.) {2}(25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \]? $ ) / i ) ; return pattern . t e s t ( emailAddress ) ; } </ s c r i p t > </head> <body> <d i v i d =” e d i t U s e r D i a l o g ” t i t l e =”E d i t P r o f i l e I n f o r m a t i o n ”> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ” home cmanager / e d i t p r o f i l e u s e r / $username ” ) ;? > <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <t d s t y l e =” v i s i b i l i t y : h i d d e n”> <d i v i d =”u s e r T y p e R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =” u s e r T y p e A d m i n i s t r a t o r ” name=”u s e r T y p e R a d i o ” v a l u e =” A d m i n i s t r a t o r ” <? php i f ( $ u s e r t y p e == ” A d m i n i s t r a t o r ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =” u s e r T y p e A d m i n i s t r a t o r ”> A d m i n i s t r a t o r </ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”userTypeContentManager ” name=”u s e r T y p e R a d i o ” v a l u e =”Content Manager ” ?>>< l a b e l f o r =” <?php i f ( $ u s e r t y p e== ” Content Manager ” ) e c h o ” c h e c k e d ” ; userTypeContentManager”>Content Manager</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”u s e r T y p e U s e r ” name=”u s e r T y p e R a d i o ” v a l u e =”U s e r ” <?php i f ( $ u s e r t y p e == ” User ”) echo ” checked ” ; ?>>< l a b e l f o r =”u s e r T y p e U s e r”>User </ l a b e l > </d i v> </t r > <t r > <td><l a b e l f o r =”username”>  ; Username : </ l a b e l > <td><i n p u t i d =”username ” name=”username ” t y p e=” t e x t ” v a l u e =”<?php e c h o $username ; ?>” r e a d o n l y =” r e a d o n l y ” > <span i d =” u s r v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” f i r s t n a m e ”>  ; F i r s t Name: </ l a b e l > <td><i n p u t i d =” f i r s t n a m e ” name=” f i r s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ f i r s t n a m e ; ?>”> <span i d =” f i r s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”middle name”>  ; M i d d l e Name: </ l a b e l > <td><i n p u t i d =”middle name ” name=”middle name ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ m i d d l e n a m e ; ?>”>( O p t i o n a l ) </t r > <t r > <td><l a b e l f o r =” l a s t n a m e”>  ; L a s t Name: </ l a b e l > <td><i n p u t i d =” l a s t n a m e ” name=” l a s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ l a s t n a m e ; ?>”> <span i d =” l a s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” b i r t h d a t e”>  ; B i r t h d a t e : </ l a b e l > <td><i n p u t i d =” b i r t h d a t e ” name=” b i r t h d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<? php e c h o $ b i r t h d a y ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#b i r t h d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> <span i d =” b i r t h d a t e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”g e n d e r”>  ; Gender : </ l a b e l > <td> <d i v i d =”g e n d e r R a d i o B u t t o n S e t”> 116 <i n p u t t y p e=” r a d i o ” i d =”g e n d e r M a l e ” name=”g e n d e r R a d i o ” v a l u e =”Male ” <?php i f ( $ g e n d e r == ” Male ”) echo ” checked ” ; ?>>< l a b e l f o r =”g e n d e r M a l e”>Male</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”g e n d e r F e m a l e ” name=”g e n d e r R a d i o ” v a l u e =”Female ” <?php i f ( $ g e n d e r== ” Female ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =”g e n d e r F e m a l e”>Female </ l a b e l > </d i v> </t r > <t r > <td><l a b e l f o r =” e m a i l a d d r e s s”>  ; E−m a i l A d d r e s s : </ l a b e l > <td><i n p u t i d =” e m a i l a d d r e s s ” name=” e m a i l a d d r e s s ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ e m a i l a d d r e s s ; ?>”> <span i d =” e m a i l v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><b u t t o n i d =” e d i t U s e r B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Update P r o f i l e </ button> <td><b u t t o n i d =”e d i t U s e r B a c k B u t t o n ” t y p e=”b u t t o n ” name=”e d i t U s e r B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” > Back</button> <td><b u t t o n i d =”editUs erHomeButt on ” t y p e=”b u t t o n ” name=”editU serHomeButt on ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#e d i t U s e r B u t t o n , #e d i t U s e r B a c k B u t t o n , #ed itUserHome Button ” ) . b u t t o n ( ) ; $ ( ”#u s e r T y p e R a d i o B u t t o n S e t , #g e n d e r R a d i o B u t t o n S e t ” ) . b u t t o n s e t ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# b i r t h d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# b i r t h d a t e ’ ) . v a l i d ( ) ; i f ( $ ( ’# b i r t h d a t e ’ ) . v a l ( ) != ’ ’ ) { $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b i r t h d a t e r e q u i r e d e r r o r . png ’ ) ” } ) ; } } }) ; $ ( ”# e d i t U s e r D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 650 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# username ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# username ” ) . v a l ( ) . l e n g t h >= 4 ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > h o m e u s e r / c h e c k u s e r ” , d a t a : ”name=”+$(”# username ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o . png ’ ) ” } ) ; } 117 b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e e x i s t s e r r o r . png ’ ) ” } ) ; } } }) ; } e l s e i f ( $(”# u s e r n a m e r e g ” ) . v a l ( ) . l e n g t h < 4 ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / $(”# e m a i l a d d r e s s ” ) . keyup ( f u n c t i o n ( ) { v a r e m a i l = $(”# e m a i l a d d r e s s ” ) . v a l ( ) ; i f ( e m a i l != 0 ) { i f ( isValidEmailAddress ( email ) ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > h o m e u s e r / c h e c k e m a i l ” , d a t a : ” e m a i l=”+$(”# e m a i l a d d r e s s ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; e m a i l c o n=t r u e ; register show () ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o e m a i l e x i s t s e r r o r . png ’ ) ” } ) ; } } }) ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o e m a i l i n v a l i d e r r o r . png ’ ) ” } ) ; } } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / $(”# f i r s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# f i r s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o f i r s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; $(”# l a s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# l a s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o l a s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / function isValidEmailAddress ( emailAddress ) { v a r p a t t e r n = new RegExp ( / ˆ ( ( ” [ \ w−\s ] + ” ) | ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) | ( ” [ \ w−\s ] + ” ) ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) ) (@ ( ( ? : [ \ w−]+\.) ∗\w[ \ w− ] { 0 , 6 6 } ) \ . ( [ a−z ] { 2 , 6 } ( ? : \ . [ a−z ] { 2 } ) ? ) $ ) | ( @ \[?((25[0 −5]\.|2[0 −4][0 −9]\.|1[0 −9]{2}\.|[0 −9]{1 ,2}\.) ) ((25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \.) {2}(25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \]? $ ) / i ) ; return pattern . t e s t ( emailAddress ) ; } </ s c r i p t > </head> <body> <d i v i d =” e d i t U s e r D i a l o g ” t i t l e =”E d i t P r o f i l e I n f o r m a t i o n ”> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ” h o m e u s e r / e d i t p r o f i l e u s e r / $username ” ) ;? > <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <t d s t y l e =” v i s i b i l i t y : h i d d e n”> <d i v i d =”u s e r T y p e R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =” u s e r T y p e A d m i n i s t r a t o r ” name=”u s e r T y p e R a d i o ” v a l u e =” A d m i n i s t r a t o r ” <? php i f ( $ u s e r t y p e == ” A d m i n i s t r a t o r ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =” u s e r T y p e A d m i n i s t r a t o r ”> A d m i n i s t r a t o r </ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”userTypeContentManager ” name=”u s e r T y p e R a d i o ” v a l u e =”Content Manager ” <?php i f ( $ u s e r t y p e== ” Content Manager ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =” userTypeContentManager”>Content Manager</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”u s e r T y p e U s e r ” name=”u s e r T y p e R a d i o ” v a l u e =”U s e r ” <?php i f ( $ u s e r t y p e == ” User ”) echo ” checked ” ; ?>>< l a b e l f o r =”u s e r T y p e U s e r”>User </ l a b e l > 118 </d i v> </t r > <t r > <td><l a b e l f o r =”username”>  ; Username : </ l a b e l > <td><i n p u t i d =”username ” name=”username ” t y p e=” t e x t ” v a l u e =”<?php e c h o $username ; ?>” r e a d o n l y =” r e a d o n l y ” > <span i d =” u s r v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” f i r s t n a m e ”>  ; F i r s t Name: </ l a b e l > <td><i n p u t i d =” f i r s t n a m e ” name=” f i r s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ f i r s t n a m e ; ?>”> <span i d =” f i r s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”middle name”>  ; M i d d l e Name: </ l a b e l > <td><i n p u t i d =”middle name ” name=”middle name ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ m i d d l e n a m e ; ?>”>( O p t i o n a l ) </t r > <t r > <td><l a b e l f o r =” l a s t n a m e”>  ; L a s t Name: </ l a b e l > <td><i n p u t i d =” l a s t n a m e ” name=” l a s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ l a s t n a m e ; ?>”> <span i d =” l a s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” b i r t h d a t e”>  ; B i r t h d a t e : </ l a b e l > <td><i n p u t i d =” b i r t h d a t e ” name=” b i r t h d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<? php e c h o $ b i r t h d a y ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#b i r t h d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> <span i d =” b i r t h d a t e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”g e n d e r”>  ; Gender : </ l a b e l > <td> <d i v i d =”g e n d e r R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =”g e n d e r M a l e ” name=”g e n d e r R a d i o ” v a l u e =”Male ” <?php i f ( $ g e n d e r == ” Male ”) echo ” checked ” ; ?>>< l a b e l f o r =”g e n d e r M a l e”>Male</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”g e n d e r F e m a l e ” name=”g e n d e r R a d i o ” v a l u e =”Female ” <?php i f ( $ g e n d e r== ” Female ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =”g e n d e r F e m a l e”>Female </ l a b e l > </d i v> </t r > <t r > <td><l a b e l f o r =” e m a i l a d d r e s s”>  ; E−m a i l A d d r e s s : </ l a b e l > <td><i n p u t i d =” e m a i l a d d r e s s ” name=” e m a i l a d d r e s s ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ e m a i l a d d r e s s ; ?>”> <span i d =” e m a i l v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><b u t t o n i d =” e d i t U s e r B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Update P r o f i l e </ button> <td><b u t t o n i d =”e d i t U s e r B a c k B u t t o n ” t y p e=”b u t t o n ” name=”e d i t U s e r B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”editUs erHomeButto n ” t y p e=”b u t t o n ” name=”editU serHomeButt on ” v a l u e =”Home” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#e d i t U s e r B u t t o n , #e d i t U s e r B a c k B u t t o n , #ed itUserHome Button ” ) . b u t t o n ( ) ; $ ( ”#u s e r T y p e R a d i o B u t t o n S e t , #g e n d e r R a d i o B u t t o n S e t , #s t a t u s R a d i o B u t t o n S e t ” ) . b u t t o n s e t ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# b i r t h d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , 119 onClose : f u n c t i o n ( ) { $ ( ’# b i r t h d a t e ’ ) . v a l i d ( ) ; i f ( $ ( ’# b i r t h d a t e ’ ) . v a l ( ) != ’ ’ ) { $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o y e s . png ’ ) ” } ) ; } else { $(”# b i r t h d a t e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o no . png ’ ) ” } ) ; } } }) ; $ ( ”# e d i t U s e r D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 650 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# username ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# username ” ) . v a l ( ) . l e n g t h >= 4 ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > home admin / c h e c k u s e r ” , d a t a : ”name=”+$(”# username ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o ’ ) ” }) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o ’ ) ” }) ; } } }) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / y e s . png b a s e u r l ( ) ;? > l a y o u t / i m a g e s / no . png $(”# e m a i l a d d r e s s ” ) . keyup ( f u n c t i o n ( ) { v a r e m a i l = $(”# e m a i l a d d r e s s ” ) . v a l ( ) ; i f ( e m a i l != 0 ) { i f ( isValidEmailAddress ( email ) ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > home admin / c h e c k e m a i l ” , d a t a : ” e m a i l=”+$(”# e m a i l a d d r e s s ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o png ’ ) ” } ) ; e m a i l c o n=t r u e ; register show () ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o png ’ ) ” } ) ; } } }) ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o png ’ ) ” } ) ; } } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / y e s . b a s e u r l ( ) ;? > l a y o u t / i m a g e s / no . b a s e u r l ( ) ;? > l a y o u t / i m a g e s / no . $(”# f i r s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# f i r s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o y e s . png ’ ) ” } ) ; } else { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o no . png ’ ) ” } ) ; } }) ; $(”# l a s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# l a s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o y e s . png ’ ) ” } ) ; } else { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o . png ’ ) ” } ) ; } }) ; }) ; 120 b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / no function isValidEmailAddress ( emailAddress ) { v a r p a t t e r n = new RegExp ( / ˆ ( ( ” [ \ w−\s ] + ” ) | ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) | ( ” [ \ w−\s ] + ” ) ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) ) (@ ( ( ? : [ \ w−]+\.) ∗\w[ \ w− ] { 0 , 6 6 } ) \ . ( [ a−z ] { 2 , 6 } ( ? : \ . [ a−z ] { 2 } ) ? ) $ ) | ( @ \[?((25[0 −5]\.|2[0 −4][0 −9]\.|1[0 −9]{2}\.|[0 −9]{1 ,2}\.) ) ((25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \.) {2}(25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \]? $ ) / i ) ; return pattern . t e s t ( emailAddress ) ; } </ s c r i p t > </head> <body> <d i v i d =” e d i t U s e r D i a l o g ” t i t l e =”E d i t U s e r”> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php $username = $ i t e m [ ’ username ’ ] ; ?> <?php $ f i r s t n a m e = $ i t e m [ ’ f i r s t n a m e ’ ] ; ?> <?php $ m i d d l e n a m e = $ i t e m [ ’ middle name ’ ] ; ?> <?php $ l a s t n a m e = $ i t e m [ ’ l a s t n a m e ’ ] ; ?> <?php $ b i r t h d a t e = $ i t e m [ ’ b i r t h d a y ’ ] ; ?> <?php $ g e n d e r R a d i o = $ i t e m [ ’ g e n d e r ’ ] ; ?> <?php $ u s e r T y p e R a d i o = $ i t e m [ ’ u s e r t y p e ’ ] ; ?> <?php $ e m a i l a d d r e s s = $ i t e m [ ’ e m a i l a d d r e s s ’ ] ; ?> <?php $ s t a t u s R a d i o = $ i t e m [ ’ s t a t u s ’ ] ; ?> <?php e c h o f o r m o p e n ( ” home admin / e d i t u s e r / $username ” ) ;? > <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><l a b e l f o r =”username”>  ; Username : </ l a b e l > <td><i n p u t i d =”username ” name=”username ” t y p e=” t e x t ” v a l u e =”<?php e c h o $username ; ?>” > <span i d =” u s r v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” f i r s t n a m e ”>  ; F i r s t Name: </ l a b e l > <td><i n p u t i d =” f i r s t n a m e ” name=” f i r s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ f i r s t n a m e ; ?>”> <span i d =” f i r s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”middle name”>  ; M i d d l e Name: </ l a b e l > <td><i n p u t i d =”middle name ” name=”middle name ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ m i d d l e n a m e ; ?>”>( O p t i o n a l ) </t r > <t r > <td><l a b e l f o r =” l a s t n a m e”>  ; L a s t Name: </ l a b e l > <td><i n p u t i d =” l a s t n a m e ” name=” l a s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ l a s t n a m e ; ?>”> <span i d =” l a s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” b i r t h d a t e”>  ; B i r t h d a t e : </ l a b e l > <td><i n p u t i d =” b i r t h d a t e ” name=” b i r t h d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<? php e c h o $ b i r t h d a t e ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#b i r t h d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> <span i d =” b i r t h d a t e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”g e n d e r”>  ; Gender : </ l a b e l > <td> <d i v i d =”g e n d e r R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =”g e n d e r M a l e ” name=”g e n d e r R a d i o ” v a l u e =”Male ” <?php i f ( $ g e n d e r R a d i o == ” Male ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =”g e n d e r M a l e”>Male</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”g e n d e r F e m a l e ” name=”g e n d e r R a d i o ” v a l u e =”Female ” <?php i f ( $ g e n d e r R a d i o == ” Female ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =”g e n d e r F e m a l e”>Female </ l a b e l > </d i v> </t r > <t r > <td><l a b e l f o r =” u s e r t y p e ”>  ; U s e r Type: </ l a b e l > <td> <d i v i d =”u s e r T y p e R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =” u s e r T y p e A d m i n i s t r a t o r ” name=”u s e r T y p e R a d i o ” v a l u e =” A d m i n i s t r a t o r ” <? php i f ( $ u s e r T y p e R a d i o == ” A d m i n i s t r a t o r ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =” u s e r T y p e A d m i n i s t r a t o r ”> A d m i n i s t r a t o r </ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”userTypeContentManager ” name=”u s e r T y p e R a d i o ” v a l u e =”Content Manager ” <?php i f ( $ u s e r T y p e R a d i o == ” Content Manager ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =” userTypeContentManager”>Content Manager</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”u s e r T y p e U s e r ” name=”u s e r T y p e R a d i o ” v a l u e =”U s e r ” <?php i f ( $ u s e r T y p e R a d i o == ” U s e r ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =”u s e r T y p e U s e r”>User </ l a b e l > </d i v> </t r > <t r > <td><l a b e l f o r =” e m a i l a d d r e s s”>  ; E−m a i l A d d r e s s : </ l a b e l > <td><i n p u t i d =” e m a i l a d d r e s s ” name=” e m a i l a d d r e s s ” t y p e=” t e x t ” v a l u e =”<?php e c h o $ e m a i l a d d r e s s ; ?>”> <span i d =” e m a i l v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” s t a t u s ”>  ; S t a t u s : </ l a b e l > <td> <d i v i d =” s t a t u s R a d i o B u t t o n S e t ”> <i n p u t t y p e=” r a d i o ” i d =” s t a t u s A c t i v a t e d ” name=” s t a t u s R a d i o ” v a l u e =” A c t i v a t e d ” <?php i f ( $ s t a t u s R a d i o == ” A c t i v a t e d ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =” s t a t u s A c t i v a t e d ”>A c t i v a t e d </ label> <i n p u t t y p e=” r a d i o ” i d =” s t a t u s D e a c t i v a t e d ” name=” s t a t u s R a d i o ” v a l u e =” D e a c t i v a t e d ” <?php i f ( $ s t a t u s R a d i o == ” D e a c t i v a t e d ” ) e c h o ” c h e c k e d ” ; ?>>< l a b e l f o r =” s t a t u s D e a c t i v a t e d ”> D e a c t i v a t e d </ l a b e l > </d i v> </t r > <t r > <td><b u t t o n i d =” e d i t U s e r B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Update User </button > 121 <td><b u t t o n i d =”e d i t U s e r B a c k B u t t o n ” t y p e=”b u t t o n ” name=”e d i t U s e r B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home admin ’” > Back</button> <b u t t o n i d =”editUs erHomeButto n ” t y p e=”b u t t o n ” name=”editU serHomeButt on ” v a l u e =”Back ” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home admin ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”#ad−i n n e r −nav ” ) . h i d e ( ) ; $ ( ” . ad−top−nav ” ) . m o u s e e n t e r ( f u n c t i o n ( ) { $(”#ad−i n n e r −nav ” ) . f a d e I n ( ) ; }) ; $ ( ” . ad−top−nav ” ) . m o u s e l e a v e ( f u n c t i o n ( ) { $(”#ad−i n n e r −nav ” ) . f a d e O u t ( ) ; }) ; $ ( ”# v i e w P r o f i l e B o x D i a l o g ” ) . d i a l o g ( { autoOpen : f a l s e , width : 650 , modal : t r u e , closeOnEscape : f a l s e }) ; // L i n k t o open t h e d i a l o g $ ( ”#v i e w P r o f i l e B o x D i a l o g B u t t o n ” ) . c l i c k ( f u n c t i o n ( e v e n t ) { $ ( ”# v i e w P r o f i l e B o x D i a l o g ” ) . d i a l o g ( ” open ” ) ; event . preventDefault ( ) ; }) ; $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; $( function () { $ ( ”#l o g o u t B u t t o n , #u s e r S e a r c h B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# s e a r c h ” ) . a u t o c o m p l e t e ( { source : function ( request , response ) { $ . ajax ( { u r l : ”<?php e c h o s i t e u r l ( ’ home admin / s u g g e s t i o n s ’ ) ; ? >” , data : { term : $(”# s e a r c h ” ) . v a l ( ) }, dataType : ” j s o n ” , t y p e : ”POST” , s u c c e s s : f u n c t i o n ( data ) { r e s p o n s e ( data ) ; } }) ; }, minLength : 1 }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” c o n t a i n e r ”> <d i v i d =”h e a d e r”></d i v> <d i v i d =”body”> <d i v i d =”l o g o u t B o x”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ad−top−nav”> 122 i d =” s e t t i n g s B u t t o n ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”<?php e c h o $ f i r s t n a m e ; ?>”> <span c l a s s =”u i −i c o n u i −i c o n −p e r s o n ”></span><span c l a s s =” s e t t i n g s −p e r s o n ”><?php e c h o $ f i r s t n a m e ; ?> (<?php e c h o $ u s e r t y p e ; ?>)</span> <span c l a s s =”u i −i c o n u i −i c o n −t r i a n g l e −1−s s e t t i n g s −t r i a n g l e ”></span> </ l i > < l i i d =”ad−i n n e r −nav ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ad−i n n e r −nav”> <d i v i d =” v i e w P r o f i l e B o x D i a l o g B u t t o n ” c l a s s =”ad−i n n e r −nav−o p t i o n ” t i t l e =” P r o f i l e I n f o r m a t i o n”>< span c l a s s =”u i −i c o n u i −i c o n −s c r i p t ”></span>P r o f i l e I n f o r m a t i o n </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home admin / e d i t p r o f i l e u s e r /<?php e c h o $username ; ?>”><d i v c l a s s =”ad−i n n e r −nav−o p t i o n ” t i t l e =”E d i t P r o f i l e ”><span c l a s s =”u i −i c o n u i −i c o n −p e n c i l ”></ span>E d i t P r o f i l e </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home admin / e d i t p a s s w o r d u s e r /<?php e c h o $username ; ?>”><d i v c l a s s =”ad−i n n e r −nav−o p t i o n ” t i t l e =”Change Password”><span c l a s s =”u i −i c o n u i −i c o n −g e a r ”></ span>Change Password </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home admin / l o g o u t”><d i v c l a s s =”ad−i n n e r −nav−o p t i o n ” t i t l e =” Logout”><span c l a s s =”u i −i c o n u i −i c o n −key”></span>Logout </d i v ></a> </ l i > </u l > </d i v> <d i v i d =” v i e w P r o f i l e B o x D i a l o g ” t i t l e =” P r o f i l e I n f o r m a t i o n ”> <t a b l e > <t r > <td>Name : <td><?php e c h o $ f i r s t n a m e ; ?> <?php e c h o $ l a s t n a m e ; ?> </t r > <t r > <td>Username : <td><?php e c h o $username ; ?> </t r > <t r > <td>U s e r Type : <td><?php e c h o $ u s e r t y p e ; ?> </t r > <t r > <td>E−m a i l A d d r e s s : <td><?php e c h o $ e m a i l a d d r e s s ; ?> </t r > <t r > <td>Gender : <td><?php e c h o $ g e n d e r ; ?> </t r > <t r > <td>B i r t h d a y : <td><?php e c h o $ b i r t h d a y ; ?> </t r > </ t a b l e > </d i v> <l i <d i v i d =”manageUserAccountsBox”> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <d i v i d =”manageUserAccountsHeading ” c l a s s =”u i −w i d g e t −h e a d e r u i −c o r n e r − a l l ”> <c e n t e r ><h2>  ; Manage U s e r Accounts </h2></c e n t e r > </d i v> <d i v i d =”v i e w U s e r s B o x”> <br> <?=f o r m o p e n ( ’ home admin / s e a r c h ’ ) ;? > <?php $ s e a r c h = a r r a y ( ’ name’=>’ s e a r c h ’ , ’ i d ’=>’ s e a r c h ’ , ’ v a l u e ’ = > ’ ’ , ) ; ?> <c e n t e r ><?=f o r m i n p u t ( $ s e a r c h ) ;?>< b u t t o n i d =” u s e r S e a r c h B u t t o n ” t y p e=”s u b m i t ” v a l u e =””>S e a r c h </ button ></c e n t e r > <?= f o r m c l o s e ( ) ;? > <d i v i d =”addUserBox”> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home admin / a d d u s e r ”> <p> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i i d =”a d d U s e r D i a l o g B u t t o n ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” c l a s s =”u i −i c o n u i −i c o n −p l u s t h i c k ”></span>Add U s e r   ; </ l i > </u l > </p> </a> </d i v> <?php i f ( i s a r r a y ( $ q u e r y ) && c o u n t ( $ q u e r y ) ) { ?> <c e n t e r > <t a b l e > <t r > <t h s t y l e =” d i s p l a y : none ;” >ID</th> <th>Username</th> <th>F i r s t Name</th> <th>M i d d l e Name</th> <th>L a s t Name</th> <th>U s e r Type</th> <th>E−m a i l Address </th> <th>Gender</th> <th>B i r t h d a y </th> <th>Age</th> <th>A c t i o n s </th> <th>S t a t u s </th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $username= $item−>username ; ?> <t r > <t d s t y l e =” d i s p l a y : none;”><?= $item−>u s e r i d ?></td> <td><?= $item−>username ?></td> 123 t i t l e =”Add U s e r”><span <td><?= $item−>f i r s t n a m e ?></td> <td><?= $item−>middle name ?></td> <td><?= $item−>l a s t n a m e ?></td> <td><?= $item−>u s e r t y p e ?></td> <td><?= $item−>e m a i l a d d r e s s ?></td> <td><?= $item−>g e n d e r ?></td> <td><?= d a t e ( ”Y−M−d ” , s t r t o t i m e ( $item−>b i r t h d a y ) ) ; ?></td> <td><?= d a t e d i f f ( d a t e c r e a t e ( $item−>b i r t h d a y ) , d a t e c r e a t e ( ’ today ’ ) )−>y ; ?></td> <td> <a i d =” e d i t U s e r D i a l o g B u t t o n ” c l a s s =” e d i t U s e r D i a l o g B u t t o n ” h r e f = ’ . . / home admin / e d i t u s e r /<?php e c h o $username ?>’> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”E d i t”> <span c l a s s =”u i −i c o n u i −i c o n −p e n c i l ”></span> </ l i > </u l > </a> <a h r e f = ” . . / home admin / d e l e t e u s e r /<?php e c h o $username ; ?>” o n c l i c k =” r e t u r n c o n f i r m ( ’ Are you s u r e you want t o d e l e t e ? ’ ) ”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” D e l e t e ”> <span c l a s s =”u i −i c o n u i −i c o n −t r a s h ”></span> </ l i > </u l > </a> </td> <td><?= $item−>s t a t u s ?></td> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > </ c e n t e r > <?php } ?> </d i v> </d i v> </d i v> </d i v> <p c l a s s =” f o o t e r ”>Page r e n d e r e d i n <s t r o n g >{ e l a p s e d t i m e }</ s t r o n g > s e c o n d s </p> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”#cm−i n n e r −nav ” ) . h i d e ( ) ; $ ( ” . cm−top−nav ” ) . m o u s e e n t e r ( f u n c t i o n ( ) { $(”#cm−i n n e r −nav ” ) . f a d e I n ( ) ; }) ; $ ( ” . cm−top−nav ” ) . m o u s e l e a v e ( f u n c t i o n ( ) { $(”#cm−i n n e r −nav ” ) . f a d e O u t ( ) ; }) ; $(”# c o n t e n t −i n n e r −nav ” ) . h i d e ( ) ; $ ( ” . c o n t e n t −top−nav ” ) . m o u s e e n t e r ( f u n c t i o n ( ) { $(”# c o n t e n t −i n n e r −nav ” ) . f a d e I n ( ) ; }) ; $ ( ” . c o n t e n t −top−nav ” ) . m o u s e l e a v e ( f u n c t i o n ( ) { $(”# c o n t e n t −i n n e r −nav ” ) . f a d e O u t ( ) ; }) ; $(”# c o n t e n t −c o n t e n t −i n n e r −nav ” ) . h i d e ( ) ; $ ( ” . c o n t e n t −c o n t e n t −top−nav ” ) . m o u s e e n t e r ( f u n c t i o n ( ) { $(”# c o n t e n t −c o n t e n t −i n n e r −nav ” ) . f a d e I n ( ) ; }) ; $ ( ” . c o n t e n t −c o n t e n t −top−nav ” ) . m o u s e l e a v e ( f u n c t i o n ( ) { $(”# c o n t e n t −c o n t e n t −i n n e r −nav ” ) . f a d e O u t ( ) ; }) ; $ ( ”# v i e w P r o f i l e B o x D i a l o g ” ) . d i a l o g ( { autoOpen : f a l s e , width : 650 , modal : t r u e , closeOnEscape : f a l s e }) ; // L i n k t o open t h e d i a l o g $ ( ”#v i e w P r o f i l e B o x D i a l o g B u t t o n ” ) . c l i c k ( f u n c t i o n ( e v e n t ) { $ ( ”# v i e w P r o f i l e B o x D i a l o g ” ) . d i a l o g ( ” open ” ) ; 124 event . preventDefault ( ) ; }) ; $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; $( function () { $ ( ”#l o g o u t B u t t o n , #u s e r S e a r c h B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); }) ; </ s c r i p t > </head> <body> <d i v i d =” c o n t a i n e r ”> <d i v i d =”h e a d e r”></d i v> <d i v i d =”body”> <d i v i d =”l o g o u t B o x”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x cm−top−nav”> < l i i d =” s e t t i n g s B u t t o n ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”<?php e c h o $ f i r s t n a m e ; ?>”> <span c l a s s =”u i −i c o n u i −i c o n −p e r s o n ”></span><span c l a s s =” s e t t i n g s −p e r s o n ”><?php e c h o $ f i r s t n a m e ; ?> (<?php e c h o $ u s e r t y p e ; ?>)</span> <span c l a s s =”u i −i c o n u i −i c o n −t r i a n g l e −1−s s e t t i n g s −t r i a n g l e ”></span> </ l i > < l i i d =”cm−i n n e r −nav ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l cm−i n n e r −nav”> <d i v i d =” v i e w P r o f i l e B o x D i a l o g B u t t o n ” c l a s s =”cm−i n n e r −nav−o p t i o n ” t i t l e =” P r o f i l e I n f o r m a t i o n”>< span c l a s s =”u i −i c o n u i −i c o n −s c r i p t ”></span>P r o f i l e I n f o r m a t i o n </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home cmanager / e d i t p r o f i l e u s e r /<?php e c h o $username ; ?>”>< d i v c l a s s =”cm−i n n e r −nav−o p t i o n ” t i t l e =”E d i t P r o f i l e ”><span c l a s s =”u i −i c o n u i −i c o n −p e n c i l ”></span>E d i t P r o f i l e </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home cmanager / e d i t p a s s w o r d u s e r /<?php e c h o $username ; ?>”>< d i v c l a s s =”cm−i n n e r −nav−o p t i o n ” t i t l e =”Change Password”><span c l a s s =”u i −i c o n u i −i c o n −g e a r ”></span>Change Password </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home cmanager / l o g o u t”><d i v c l a s s =”cm−i n n e r −nav−o p t i o n ” t i t l e =”Logout”><span c l a s s =”u i −i c o n u i −i c o n −key”></span>Logout </d i v ></a> </ l i > </u l > </d i v> <d i v i d =” v i e w P r o f i l e B o x D i a l o g ” t i t l e =” P r o f i l e I n f o r m a t i o n ”> <t a b l e > <t r > <td>Name : <td><?php e c h o $ f i r s t n a m e ; ?> <?php e c h o $ l a s t n a m e ; ?> </t r > <t r > <td>Username : <td><?php e c h o $username ; ?> </t r > <t r > <td>U s e r Type : <td><?php e c h o $ u s e r t y p e ; ?> </t r > <t r > <td>E−m a i l A d d r e s s : <td><?php e c h o $ e m a i l a d d r e s s ; ?> </t r > <t r > <td>Gender : <td><?php e c h o $ g e n d e r ; ?> </t r > <t r > <td>B i r t h d a y : <td><?php e c h o $ b i r t h d a y ; ?> </t r > </ t a b l e > </d i v> <d i v i d =”manageContentBox”> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <d i v i d =”manageContentHeading ” c l a s s =”u i −w i d g e t −h e a d e r u i −c o r n e r − a l l ”> <c e n t e r ><h2>  ; Manage Content </h2></c e n t e r > </d i v> <d i v i d =”contentMenuBox”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x c o n t e n t −top−nav”> < l i i d =”addContentButton ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”Add Content”> <span c l a s s =”u i −i c o n u i −i c o n −p l u s t h i c k ”></span><span c l a s s =”c o n t e n t −p l u s t h i c k ”>Add Content </ span> <span c l a s s =”u i −i c o n u i −i c o n −t r i a n g l e −1−s c o n t e n t −t r i a n g l e ”></span> </ l i > < l i i d =”c o n t e n t −i n n e r −nav ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l c o n t e n t −i n n e r −nav”> 125 <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home cmanager / a d d f e l i t e m ”><d i v c l a s s =”c o n t e n t −i n n e r −nav− o p t i o n ” t i t l e =”Add Food Exchange L i s t Item”><span c l a s s =”u i −i c o n u i −i c o n −pin−s”></span> Food Exchange Item </d i v ></a> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home cmanager / a d d r e c i p e ”><d i v c l a s s =”c o n t e n t −i n n e r −nav− o p t i o n ” t i t l e =”Add R e c i p e”><span c l a s s =”u i −i c o n u i −i c o n −c l i p b o a r d ”></span>R e c i p e </d i v ></a> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home cmanager / r e c o m m e n d d a i l y m e a l s”><d i v c l a s s =”c o n t e n t − i n n e r −nav−o p t i o n ” t i t l e =”Add D a i l y Meal Plan”><span c l a s s =”u i −i c o n u i −i c o n −l i g h t b u l b ”></ span>D a i l y Meal Plan </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home cmanager / a d d h e a l t h t i p ”><d i v c l a s s =”c o n t e n t −i n n e r −nav− o p t i o n ” t i t l e =”Add H e a l t h Tip”><span c l a s s =”u i −i c o n u i −i c o n −l i g h t b u l b ”></span>H e a l t h Tip</ d i v ></a> </ l i > </u l > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x c o n t e n t −c o n t e n t −top−nav”> < l i i d =”v i e w C o n t e n t B u t t o n ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View”> <span c l a s s =”u i −i c o n u i −i c o n −s t a r ”></span><span c l a s s =”c o n t e n t −c o n t e n t −s t a r ”>View</span> <span c l a s s =”u i −i c o n u i −i c o n −t r i a n g l e −1−s c o n t e n t −c o n t e n t −t r i a n g l e ”></span> </ l i > < l i i d =”c o n t e n t −c o n t e n t −i n n e r −nav ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l c o n t e n t −c o n t e n t −i n n e r −nav”> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>home cmanager / s h o w c r e a t e d r e c i p e s ”><d i v c l a s s =”c o n t e n t − c o n t e n t −i n n e r −nav−o p t i o n ” t i t l e =” R e c i p e s C r e a t e d”><span c l a s s =”u i −i c o n u i −i c o n −c l i p b o a r d ”></span>R e c i p e s C r e a t e d </d i v ></a> </ l i > </u l > </d i v> <d i v i d =”v i e w U s e r s B o x”> <br> <?=f o r m o p e n ( ’ home cmanager / s e a r c h f e l ’ ) ;? > <?php $ s e a r c h f e l = a r r a y ( ’ name’=>’ s e a r c h f e l ’ , ’ i d ’=>’ s e a r c h f e l ’ , ’ v a l u e ’ = > ’ ’ , ) ; ?> <c e n t e r >Food Exchange L i s t : <?=f o r m i n p u t ( $ s e a r c h f e l ) ;? > <b u t t o n i d =” u s e r S e a r c h B u t t o n ” t y p e=”s u b m i t ” v a l u e =”” t i t l e =”S e a r c h Food Exchange L i s t ”>S e a r c h </button> </ c e n t e r > <?= f o r m c l o s e ( ) ;? > <?=f o r m o p e n ( ’ home cmanager / s e a r c h h t ’ ) ;? > <?php $ s e a r c h h t = a r r a y ( ’ name’=>’ s e a r c h h t ’ , ’ i d ’=>’ s e a r c h h t ’ , ’ v a l u e ’ = > ’ ’ , ) ; ?> <c e n t e r >  ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; H e a l t h T i p s : <?=f o r m i n p u t ( $ s e a r c h h t ) ;? > <b u t t o n i d =” u s e r S e a r c h B u t t o n ” t y p e=”s u b m i t ” v a l u e =”” t i t l e =”S e a r c h H e a l t h T i p s”>S e a r c h </button > </ c e n t e r > <?= f o r m c l o s e ( ) ;? > <?php i f ( i s a r r a y ( $ q u e r y f e l ) ) { ?> <c e n t e r > <t a b l e > <t r > <th>L i s t Group</th> <th>Food Group</th> <th>Food Group C a t e g o r y </th> <th>Food Name</th> <th>Measure </th> <th>C a r b o h y d r a t e </th> <th>P r o t e i n </th> <th>Fat</th> <th>Energy </th> <th>Weight a s Purchased </th> <th>Weight E d i b l e P o r t i o n </th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y f e l a s $ i t e m ) : ?> <?php $ f o o d e x c h a n g e l i s t i d = $item−>f o o d e x c h a n g e l i s t i d ?> <t r > <td><?= $item−>l i s t g r o u p ?></td> <td><?= $item−>f o o d g r o u p ?></td> <td><?= $item−>f o o d g r o u p c a t e g o r y ?></td> <td><?= $item−>f o o d n a m e ?></td> <td><?= $item−>measure ?></td> <td><?= $item−>c a r b o h y d r a t e ?></td> <td><?= $item−>p r o t e i n ?></td> <td><?= $item−>f a t ?></td> <td><?= $item−>e n e r g y ?></td> <td><?= $item−>w e i g h t a s p u r c h a s e d ?></td> <td><?= $item−>w e i g h t e d i b l e p o r t i o n ?></td> <td> <a i d =”e d i t F E L D i a l o g B u t t o n ” c l a s s =”e d i t F E L D i a l o g B u t t o n ” h r e f = ’ . . / home cmanager / e d i t f e l /<?php e c h o $ f o o d e x c h a n g e l i s t i d ; ?>’> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”E d i t”> <span c l a s s =”u i −i c o n u i −i c o n −p e n c i l ”></span> </ l i > </u l > </a> <a h r e f = ” . . / home cmanager / d e l e t e f e l i t e m /<?php e c h o $ f o o d e x c h a n g e l i s t i d ; ?>” o n c l i c k =” r e t u r n c o n f i r m ( ’ Are you s u r e you want t o d e l e t e ? ’ ) ”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” D e l e t e ”> <span c l a s s =”u i −i c o n u i −i c o n −t r a s h ”></span> </ l i > </u l > </a> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <?php i f ( i s s e t ( $ p a g i n a t i o n ) ) { e c h o $ p a g i n a t i o n ; } ?> </t r > 126 </ t a b l e > </ c e n t e r > <?php } ?> <?php i f ( i s a r r a y ( $ q u e r y h t ) ) { ?> <c e n t e r > <t a b l e > <t r > <t h s t y l e =” d i s p l a y : none ;” >ID</th> <th>H e a l t h Tip</th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y h t a s $ i t e m ) : ?> <?php $ h e a l t h t i p i d = $item−>h e a l t h t i p i d ; ?> <t r > <t d s t y l e =” d i s p l a y : none;”><?= $item−>h e a l t h t i p i d ?></td> <td><?= $item−>h e a l t h t i p ?></td> <td> <a i d =”e d i t H T D i a l o g B u t t o n ” c l a s s =”e d i t H T D i a l o g B u t t o n ” h r e f = ’ . . / home cmanager / e d i t h t /<?php e c h o $ h e a l t h t i p i d ; ?>’> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”E d i t”> <span c l a s s =”u i −i c o n u i −i c o n −p e n c i l ”></span> </ l i > </u l > </a> <a h r e f = ” . . / home cmanager / d e l e t e h e a l t h t i p /<?php e c h o $ h e a l t h t i p i d ; ?>” o n c l i c k =” r e t u r n c o n f i r m ( ’ Are you s u r e you want t o d e l e t e ? ’ ) ”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” D e l e t e ”> <span c l a s s =”u i −i c o n u i −i c o n −t r a s h ”></span> </ l i > </u l > </a> </td> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > </ c e n t e r > <?php } ?> </d i v> </d i v> </d i v> <p c l a s s =” f o o t e r ”>Page r e n d e r e d i n <s t r o n g >{ e l a p s e d t i m e }</ s t r o n g > s e c o n d s </p> </body> </html> <?php i f ( $ u s e r t y p e == ” A d m i n i s t r a t o r ” ) { r e d i r e c t ( ’ home admin ’ , ’ r e f r e s h ’ ) ; } else // r e d i r e c t i f ( $ u s e r t y p e == ” Content Manager ” ) { r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; t o A d m i n i s t r a t o r Page // r e d i r e c t t o Content Manager Page } else i f ( $ u s e r t y p e == ” U s e r ” ) { r e d i r e c t ( ’ home user ’ , ’ r e f r e s h ’ ) ; // r e d i r e c t to R e g i s t e r e d U s e r Page } ?> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# us−i n n e r −nav ” ) . h i d e ( ) ; $ ( ” . us−top−nav ” ) . m o u s e e n t e r ( f u n c t i o n ( ) { $(”# us−i n n e r −nav ” ) . f a d e I n ( ) ; }) ; $ ( ” . us−top−nav ” ) . m o u s e l e a v e ( f u n c t i o n ( ) { $(”# us−i n n e r −nav ” ) . f a d e O u t ( ) ; }) ; $(”# u s e r −i n n e r −nav ” ) . h i d e ( ) ; $ ( ” . u s e r −top−nav ” ) . m o u s e e n t e r ( f u n c t i o n ( ) { $(”# u s e r −i n n e r −nav ” ) . f a d e I n ( ) ; }) ; 127 $ ( ” . u s e r −top−nav ” ) . m o u s e l e a v e ( f u n c t i o n ( ) { $(”# u s e r −i n n e r −nav ” ) . f a d e O u t ( ) ; }) ; $(”# u s e r −u s e r −i n n e r −nav ” ) . h i d e ( ) ; $ ( ” . u s e r −u s e r −top−nav ” ) . m o u s e e n t e r ( f u n c t i o n ( ) { $(”# u s e r −u s e r −i n n e r −nav ” ) . f a d e I n ( ) ; }) ; $ ( ” . u s e r −u s e r −top−nav ” ) . m o u s e l e a v e ( f u n c t i o n ( ) { $(”# u s e r −u s e r −i n n e r −nav ” ) . f a d e O u t ( ) ; }) ; $(”# u s e r −u s e r −u s e r −i n n e r −nav ” ) . h i d e ( ) ; $ ( ” . u s e r −u s e r −u s e r −top−nav ” ) . m o u s e e n t e r ( f u n c t i o n ( ) { $(”# u s e r −u s e r −u s e r −i n n e r −nav ” ) . f a d e I n ( ) ; }) ; $ ( ” . u s e r −u s e r −u s e r −top−nav ” ) . m o u s e l e a v e ( f u n c t i o n ( ) { $(”# u s e r −u s e r −u s e r −i n n e r −nav ” ) . f a d e O u t ( ) ; }) ; $(”# u s e r −u s e r −u s e r −u s e r −i n n e r −nav ” ) . h i d e ( ) ; $ ( ” . u s e r −u s e r −u s e r −u s e r −top−nav ” ) . m o u s e e n t e r ( f u n c t i o n ( ) { $(”# u s e r −u s e r −u s e r −u s e r −i n n e r −nav ” ) . f a d e I n ( ) ; }) ; $ ( ” . u s e r −u s e r −u s e r −u s e r −top−nav ” ) . m o u s e l e a v e ( f u n c t i o n ( ) { $(”# u s e r −u s e r −u s e r −u s e r −i n n e r −nav ” ) . f a d e O u t ( ) ; }) ; $ ( ”# v i e w P r o f i l e B o x D i a l o g ” ) . d i a l o g ( { autoOpen : f a l s e , width : 650 , modal : t r u e , closeOnEscape : f a l s e }) ; // L i n k t o open t h e d i a l o g $ ( ”#v i e w P r o f i l e B o x D i a l o g B u t t o n ” ) . c l i c k ( f u n c t i o n ( e v e n t ) { $ ( ”# v i e w P r o f i l e B o x D i a l o g ” ) . d i a l o g ( ” open ” ) ; event . preventDefault ( ) ; }) ; $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; $( function () { $ ( ”#l o g o u t B u t t o n , #u s e r S e a r c h B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); startRefresh () ; startRefresh1 () ; }) ; /∗ var a u t o r e f r e s h = s e t I n t e r v a l ( function () { $ ( ’# u s e r H e a l t h T i p s B o x ’ ) . f a d e O u t ( ’ s l o w ’ ) . l o a d ( ’ <? php e c h o ’ ) . fadeIn (” slow ”) ; } , 10000) ;∗/ function startRefresh () { setTimeout ( s t a r t R e f r e s h , 1 0 0 0 ) ; $ . g e t ( ’ <? php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / u s e r h t f e e d ’ , $ ( ’# u s e r H e a l t h T i p s B o x ’ ) . html ( d a t a ) ; }) ; } s i t e u r l ( ) ; ?>/ h o m e u s e r / u s e r h t f e e d f u n c t i o n ( data ) { function startRefresh1 () { setTimeout ( s t a r t R e f r e s h 1 , 1 0 0 0 ) ; $ . g e t ( ’ <? php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / u s e r a c h i e v e m e n t s f e e d ’ , f u n c t i o n ( d a t a ) { $ ( ’# u s e r A c h i e v e m e n t s B o x ’ ) . html ( d a t a ) ; }) ; } </ s c r i p t > </head> <body> <d i v i d =” c o n t a i n e r ”> <d i v i d =”h e a d e r”></d i v> <d i v i d =”body”> <d i v i d =”l o g o u t B o x”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x us−top−nav”> < l i i d =” s e t t i n g s B u t t o n ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”<?php e c h o $ f i r s t n a m e ; ?>”> 128 <span c l a s s =”u i −i c o n u i −i c o n −p e r s o n ”></span><span c l a s s =” s e t t i n g s −p e r s o n ”><?php e c h o $ f i r s t n a m e ; ?> (<?php e c h o $ u s e r t y p e ; ?>)</span> <span c l a s s =”u i −i c o n u i −i c o n −t r i a n g l e −1−s s e t t i n g s −t r i a n g l e ”></span> </ l i > < l i i d =”us−i n n e r −nav ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l us−i n n e r −nav”> <d i v i d =” v i e w P r o f i l e B o x D i a l o g B u t t o n ” c l a s s =”us−i n n e r −nav−o p t i o n ” t i t l e =” P r o f i l e I n f o r m a t i o n”>< span c l a s s =”u i −i c o n u i −i c o n −s c r i p t ”></span>P r o f i l e I n f o r m a t i o n </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / e d i t p r o f i l e u s e r /<?php e c h o $username ; ?>”><d i v c l a s s =”us−i n n e r −nav−o p t i o n ” t i t l e =”E d i t P r o f i l e ”><span c l a s s =”u i −i c o n u i −i c o n −p e n c i l ”></ span>E d i t P r o f i l e </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / e d i t p a s s w o r d u s e r /<?php e c h o $username ; ?>”><d i v c l a s s =”us−i n n e r −nav−o p t i o n ” t i t l e =”Change Password”><span c l a s s =”u i −i c o n u i −i c o n −g e a r ”></ span>Change Password </d i v> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / l o g o u t”><d i v c l a s s =”us−i n n e r −nav−o p t i o n ” t i t l e =” Logout”><span c l a s s =”u i −i c o n u i −i c o n −key”></span>Logout </d i v ></a> </ l i > </u l > </d i v> <d i v i d =” v i e w P r o f i l e B o x D i a l o g ” t i t l e =” P r o f i l e I n f o r m a t i o n ”> <t a b l e > <t r > <td>Name : <td><?php e c h o $ f i r s t n a m e ; ?> <?php e c h o $ l a s t n a m e ; ?> </t r > <t r > <td>Username : <td><?php e c h o $username ; ?> </t r > <t r > <td>U s e r Type : <td><?php e c h o $ u s e r t y p e ; ?> </t r > <t r > <td>E−m a i l A d d r e s s : <td><?php e c h o $ e m a i l a d d r e s s ; ?> </t r > <t r > <td>Gender : <td><?php e c h o $ g e n d e r ; ?> </t r > <t r > <td>B i r t h d a y : <td><?php e c h o $ b i r t h d a y ; ?> </t r > </ t a b l e > </d i v> <d i v i d =”u s e r C o n t e n t B o x”> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <d i v i d =”u s e r C o n t e n t H e a d i n g ” c l a s s =”u i −w i d g e t −h e a d e r u i −c o r n e r − a l l ”> <c e n t e r ><h2>  ; I n f o r m a t i o n Board</h2></c e n t e r > </d i v> <d i v i d =”u s e r F e e d H e a d i n g”> <c e n t e r > <t a b l e > <t r > <t d w i d t h = ” 3 2 8 . 3 3 px ;” > <d i v i d =”u s e r A c h i e v e m e n t s V i e w H e a d i n g”><c e n t e r ><h2>  ; </td> <t d w i d t h = ” 3 2 8 . 3 3 px ;” > <d i v i d =”u s e r H e a l t h T i p s V i e w H e a d i n g”><c e n t e r ><h2>  ; </d i v> </td> </t r > <t a b l e > </ c e n t e r > </d i v> Achiev ements </h2></c e n t e r ></d i v> H e a l t h Tips </h2></c e n t e r ></d i v> <d i v i d =”userMenuBox”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x u s e r −top−nav”> < l i i d =” F i t n e s s P r o f i l e B u t t o n ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” F i t n e s s P r o f i l e ”> <span c l a s s =”u i −i c o n u i −i c o n −n o t e”></span><span c l a s s =”u s e r −n o t e”> F i t n e s s P r o f i l e   ; </ span > <span c l a s s =”u i −i c o n u i −i c o n −t r i a n g l e −1−s u s e r −t r i a n g l e ”></span> </ l i > < l i i d =”u s e r −i n n e r −nav ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l u s e r −i n n e r −nav”> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h o w f i t n e s s p r o f i l e ”><d i v c l a s s =”u s e r −i n n e r −nav− o p t i o n ” t i t l e =”View F i t n e s s P r o f i l e ”><span c l a s s =”u i −i c o n u i −i c o n −s c r i p t ”></span>View I n f o r m a t i o n </d i v ></a> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / a d d f i t n e s s p r o f i l e ”><d i v c l a s s =”u s e r −i n n e r −nav− o p t i o n ” t i t l e =”Add I n f o r m a t i o n”><span c l a s s =”u i −i c o n u i −i c o n −p l u s t h i c k ”></span>Add I n f o r m a t i o n </d i v ></a> <!−−<d i v c l a s s =”u s e r −i n n e r −nav−o p t i o n ” t i t l e =”E d i t I n f o r m a t i o n”><span c l a s s =”u i −i c o n u i −i c o n − p e n c i l ”></span>E d i t I n f o r m a t i o n </d i v>−−> </ l i > </u l > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x u s e r −u s e r −top−nav”> < l i i d =”R e c i p e s B u t t o n ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” R e c i p e s ”> <span c l a s s =”u i −i c o n u i −i c o n −c l i p b o a r d ”></span><span c l a s s =”u s e r −u s e r −c l i p b o a r d”>  ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; R e c i p e s  ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; </ span> <span c l a s s =”u i −i c o n u i −i c o n −t r i a n g l e −1−s u s e r −u s e r −t r i a n g l e ”></span> </ l i > < l i i d =”u s e r −u s e r −i n n e r −nav ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l u s e r −u s e r −i n n e r −nav”> 129 <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / a d d r e c i p e ”><d i v c l a s s =”u s e r −u s e r −i n n e r −nav−o p t i o n ” t i t l e =”C r e a t e R e c i p e”><span c l a s s =”u i −i c o n u i −i c o n −p l u s t h i c k ”></span>C r e a t e R e c i p e </d i v ></a> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h o w c r e a t e d r e c i p e s ”><d i v c l a s s =”u s e r −u s e r −i n n e r − nav−o p t i o n ” t i t l e =”C r e a t e d R e c i p e s”><span c l a s s =”u i −i c o n u i −i c o n −s c r i p t ”></span>C r e a t e d R e c i p e s </d i v ></a> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / p l a n d a i l y m e a l s ”><d i v c l a s s =”u s e r −u s e r −i n n e r −nav− o p t i o n ” t i t l e =”Plan D a i l y Meals”><span c l a s s =”u i −i c o n u i −i c o n −l i g h t b u l b ”></span>Plan D a i l y Meals </d i v ></a> </ l i > </u l > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x u s e r −u s e r −u s e r −top−nav”> < l i i d =”recommendContentButton ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”S h a r e Achievement”> <span c l a s s =”u i −i c o n u i −i c o n −s t a r ”></span><span c l a s s =”u s e r −u s e r −u s e r −s t a r ”>S h a r e Achievement </span> <span c l a s s =”u i −i c o n u i −i c o n −t r i a n g l e −1−s u s e r −u s e r −u s e r −t r i a n g l e ”></span> </ l i > < l i i d =”u s e r −u s e r −u s e r −i n n e r −nav ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l u s e r −u s e r −u s e r −i n n e r − nav”> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h a r e a c h i e v e m e n t”><d i v c l a s s =”u s e r −u s e r −u s e r − i n n e r −nav−o p t i o n ” t i t l e =”S h a r e Achievement”><span c l a s s =”u i −i c o n u i −i c o n −l i g h t b u l b ”></span >on t h i s S i t e </d i v ></a> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h a r e a c h i e v e m e n t f b ”><d i v c l a s s =”u s e r −u s e r −u s e r − i n n e r −nav−o p t i o n ” t i t l e =”S h a r e on Facebook”><span c l a s s =”u i −i c o n u i −i c o n −l i g h t b u l b ”></span >on Facebook </d i v ></a> <!−−<a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>/ h o m e u s e r / s h a r e a c h i e v e m e n t t w i t t e r ”><d i v c l a s s =”u s e r − u s e r −u s e r −i n n e r −nav−o p t i o n ” t i t l e =”S h a r e on T w i t t e r”><span c l a s s =”u i −i c o n u i −i c o n − l i g h t b u l b ”></span>on T w i t t e r </d i v ></a>−−> </ l i > </u l > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x u s e r −u s e r −u s e r −u s e r −top−nav”> < l i i d =”recommendContentButton ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”Browse”> <span c l a s s =”u i −i c o n u i −i c o n −s e a r c h ”></span><span c l a s s =”u s e r −u s e r −u s e r −u s e r −s e a r c h”>  ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; Browse  ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; </ span> <span c l a s s =”u i −i c o n u i −i c o n −t r i a n g l e −1−s u s e r −u s e r −u s e r −u s e r −t r i a n g l e ”></span> </ l i > < l i i d =”u s e r −u s e r −u s e r −u s e r −i n n e r −nav ” c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l u s e r −u s e r −u s e r − u s e r −i n n e r −nav”> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h o w s h a r e d r e c i p e s ”><d i v c l a s s =”u s e r −u s e r −u s e r − u s e r −i n n e r −nav−o p t i o n ” t i t l e =”S h a r e d R e c i p e s”><span c l a s s =”u i −i c o n u i −i c o n −c l i p b o a r d ”></ span>S h a r e d R e c i p e s </d i v ></a> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h o w r e c o m m e n d e d r e c i p e s”><d i v c l a s s =”u s e r −u s e r − u s e r −u s e r −i n n e r −nav−o p t i o n ” t i t l e =”Recommended R e c i p e s”><span c l a s s =”u i −i c o n u i −i c o n − c l i p b o a r d ”></span>Recommended R e c i p e s </d i v ></a> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h o w r e c o m m e n d e d d a i l y m e a l s”><d i v c l a s s =”u s e r − u s e r −u s e r −u s e r −i n n e r −nav−o p t i o n ” t i t l e =”Recommended D a i l y Meals”><span c l a s s =”u i −i c o n u i − i c o n −c l i p b o a r d ”></span>Recommended D a i l y Meals </d i v ></a> <a h r e f =”<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s e a r c h f e l ”><d i v c l a s s =”u s e r −u s e r −u s e r −u s e r −i n n e r − nav−o p t i o n ” t i t l e =”Food N u t r i t i o n a l I n f o r m a t i o n”><span c l a s s =”u i −i c o n u i −i c o n −l i g h t b u l b ”></span>Food N u t r i t i o n a l I n f o r m a t i o n </d i v ></a> </ l i > </u l > </d i v> <d i v i d =”userViewBox”> <c e n t e r > <t a b l e > <t r > <t d w i d t h = ” 3 2 8 . 3 3 px ; ” s t y l e =” d i s p l a y : none ;” > <d i v =”u s e r R e c i p e s V i e w B o x”> <d i v i d =”u s e r R e c i p e s V i e w H e a d i n g”><c e n t e r ><h2>  ; <d i v i d =” u s e r R e c i p e s B o x”></d i v> </d i v> </td> R e c i p e s </h2></c e n t e r ></d i v> <t d w i d t h = ” 3 2 8 . 3 3 px ;” > <d i v =”u s e r A c h i e v e m e n t s V i e w B o x”> <d i v i d =”u s e r A c h i e v e m e n t s B o x”></d i v> </d i v> </td> <t d w i d t h = ” 3 2 8 . 3 3 px ;” > <d i v =”u s e r H e a l t h T i p s V i e w B o x”> <d i v i d =”u s e r H e a l t h T i p s B o x”></d i v> </d i v> </td> </t r > <t a b l e > </ c e n t e r > </d i v> </d i v> </d i v> <p c l a s s =” f o o t e r ”>Page r e n d e r e d i n <s t r o n g >{ e l a p s e d t i m e }</ s t r o n g > s e c o n d s </p> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> 130 < s c r i p t s r c =”<?php e c h o script > < s c r i p t s r c =”<?php e c h o . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o <s c r i p t > $( function () { $ ( ”#r e s e t P a s s w o r d B u t t o n b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > , #r e s e t P a s s w o r d B a c k B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); }) ; </ s c r i p t > </head> <body> <d i v i d =” c o n t a i n e r ”> <d i v i d =”h e a d e r”></d i v> <d i v i d =”body”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t ></c e n t e r > <d i v i d =”r e s e t P a s s w o r d B o x”> <d i v i d =” r e s e t P a s s w o r d H e a d i n g ” c l a s s =”u i −w i d g e t −h e a d e r u i −c o r n e r − a l l ”> <c e n t e r ><h2>  ; R e s e t Password </h2></c e n t e r > </d i v> <?php e c h o f o r m o p e n ( ’ l o g i n / d o f o r g e t ’ ) ; ?> <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><l a b e l f o r =” e m a i l a d d r e s s”>  ; E−m a i l A d d r e s s : </ l a b e l > <td><i n p u t i d =” e m a i l a d d r e s s ” name=” e m a i l a d d r e s s ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ e m a i l a d d r e s s ’ ) ; ?>”> <span i d =” e m a i l v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><b u t t o n i d =” r e s e t P a s s w o r d B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>R e s e t Password </button> <td><b u t t o n i d =”r e s e t P a s s w o r d B a c k B u t t o n ” t y p e=”b u t t o n ” name=”r e s e t P a s s w o r d B a c k B u t t o n ” v a l u e =” Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?> l o g i n ’” > Back</button> </t r > <t r ></t r ><t r ></t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </d i v> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s h o r t c u t i c o n ” t y p e=”image /x−i c o n ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#l o g i n B u t t o n , #r e g i s t e r B u t t o n ” ) . b u t t o n ( ) ; $ ( ”#u s e r T y p e R a d i o B u t t o n S e t , #g e n d e r R a d i o B u t t o n S e t ” ) . b u t t o n s e t ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# b i r t h d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , / / t h i s o p t i o n c h a n g e Y e a r : t r u e , // t h i s o p t i o n maxDate : ’ 0 ’ , dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , for for allowing allowing user user 131 to to s e l e c t month s e l e c t from y e a r r a n g e onClose : f u n c t i o n ( ) { $ ( ’# b i r t h d a t e ’ ) . v a l i d ( ) i f ( $ ( ’# b i r t h d a t e ’ ) . v a l $(”# b i r t h d a t e v e r i f y ” ) . c o r r e c t . png ’ ) ” } ) ; } else { $(”# b i r t h d a t e v e r i f y ” ) . birthdate required } } }) ; }) ; ; ( ) != ’ ’ ) { c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o e r r o r . png ’ ) ” } ) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# u s e r n a m e r e g ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# u s e r n a m e r e g ” ) . v a l ( ) . l e n g t h >= 4 ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > i n d e x . php / l o g i n / c h e c k u s e r ” , d a t a : ”name=”+$(”# u s e r n a m e r e g ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o . png ’ ) ” } ) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e e x i s t s e r r o r . png ’ ) ” } ) ; } } }) ; } e l s e i f ( $(”# u s e r n a m e r e g ” ) . v a l ( ) . l e n g t h < 4 ) { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o u s e r n a m e l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# u s r v e r i f y ” ) . c s s ( { ” background−image ” : ” none ” } ) ; } }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / $(”# p a s s w o r d r e g ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# c o n f i r m p a s s w o r d r e g ” ) . v a l ( ) . l e n g t h >= 8 ) { i f ( $(”# c o n f i r m p a s s w o r d r e g ” ) . v a l ( ) != $(”# p a s s w o r d r e g ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; } else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } e l s e i f ( $(”# p a s s w o r d r e g ” ) . v a l ( ) . l e n g t h < 8 ) { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d l e n g t h e r r o r . png ’ ) ” } ) ; } else { $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) } }) ; $(”# c o n f i r m p a s s w o r d r e g ” ) . keyup ( f u n c t i o n ( ) { i f ( $(”# p a s s w o r d r e g ” ) . v a l ( ) . l e n g t h >=8) { i f ( $(”# c o n f i r m p a s s w o r d r e g ” ) . v a l ( ) != $(”# p a s s w o r d r e g ” ) . v a l ( ) ) { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / p a s s w o r d m a t c h e r r o r . png ’ ) ” } ) ; pwd= f a l s e ; register show () ; } else { $(”# c o n f i r m p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; $(”# p a s s w o r d v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / c o r r e c t . png ’ ) ” } ) ; } } }) ; $(”# e m a i l a d d r e s s ” ) . keyup ( f u n c t i o n ( ) { v a r e m a i l = $(”# e m a i l a d d r e s s ” ) . v a l ( ) ; i f ( e m a i l != 0 ) { i f ( isValidEmailAddress ( email ) ) { $ . ajax ({ t y p e : ”POST” , u r l : ”<?php e c h o b a s e u r l ( ) ;? > i n d e x . php / l o g i n / c h e c k e m a i l ” , d a t a : ” e m a i l=”+$(”# e m a i l a d d r e s s ” ) . v a l ( ) , s u c c e s s : f u n c t i o n ( msg ) { i f ( msg==”t r u e ” ) { 132 $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : c o r r e c t . png ’ ) ” } ) ; e m a i l c o n=t r u e ; register show () ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : e m a i l e x i s t s e r r o r . png ’ ) ” } ) ; } } }) ; } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : e m a i l i n v a l i d e r r o r . png ’ ) ” } ) ; } } else { $(”# e m a i l v e r i f y ” ) . c s s ( { ” background−image ” : } }) ; ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / ” u r l ( ’ <? php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / ” none ” } ) ; $(”# f i r s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# f i r s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# f i r s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o f i r s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; $(”# l a s t n a m e ” ) . keyup ( f u n c t i o n ( ) { i f ( $ ( ’# l a s t n a m e ’ ) . v a l ( ) != ’ ’ ) { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o c o r r e c t . png ’ ) ” } ) ; } else { $(”# l a s t n a m e v e r i f y ” ) . c s s ( { ” background−image ” : ” u r l ( ’ <? php e c h o l a s t n a m e r e q u i r e d e r r o r . png ’ ) ” } ) ; } }) ; }) ; b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / b a s e u r l ( ) ;? > l a y o u t / i m a g e s / function isValidEmailAddress ( emailAddress ) { v a r p a t t e r n = new RegExp ( / ˆ ( ( ” [ \ w−\s ] + ” ) | ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) | ( ” [ \ w−\s ] + ” ) ( [ \ w− ] + ( ? : \ . [ \ w−]+) ∗ ) ) (@ ( ( ? : [ \ w−]+\.) ∗\w[ \ w− ] { 0 , 6 6 } ) \ . ( [ a−z ] { 2 , 6 } ( ? : \ . [ a−z ] { 2 } ) ? ) $ ) | ( @ \[?((25[0 −5]\.|2[0 −4][0 −9]\.|1[0 −9]{2}\.|[0 −9]{1 ,2}\.) ) ((25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \.) {2}(25[0 −5]|2[0 −4][0 −9]|1[0 −9]{2}|[0 −9]{1 ,2}) \]? $ ) / i ) ; return pattern . t e s t ( emailAddress ) ; } f u n c t i o n aboutModal ( ) { $(”# aboutModal ” ) . d i a l o g ( { autoOpen : f a l s e , modal : t r u e , t i t l e : ’ About ’ , w i d t h : ’ auto ’ , h e i g h t : ’ auto ’ , buttons : { ”Ok ” : f u n c t i o n ( ) { $ ( t h i s ) . d i a l o g (” c l o s e ”) ; } }, } ) . d i a l o g ( ’ open ’ ) ; return f a l s e ; } </ s c r i p t > </head> <body> <d i v <d i v i d =” c o n t a i n e r ”> i d =”h e a d e r”></d i v> <d i v i d =”body”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o <d i v v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t ></c e n t e r > i d =”l o g i n M a i n B o x”> <d i v i d =”aboutModal ” s t y l e =” d i s p l a y : none ;” > <c e n t e r > HEAS : FIM ( H e a l t h y E a t i n g A l e r t System : Food I n t a k e M o n i t o r )<br> i s a s y s t e m t h a t h e l p s m o n i t o r f i t n e s s and c a l o r i e i n t a k e <br> t o w a r d s a h e a l t h i e r l i v i n g . I t a u t o m a t i c a l l y computes the<br> amount o f c a l o r i e s p e r s e r v i n g and r e s t r i c t s c e r t a i n <br> i n g r e d i e n t s b a s e d on h e a l t h c o n d i t i o n s . </ c e n t e r > </d i v> <d i v i d =” l o g i n H e a d i n g ” c l a s s =”u i −w i d g e t −h e a d e r u i −c o r n e r − a l l ”> <c e n t e r ><h2>  ; Login </h2></c e n t e r > </d i v> <d i v i d =” l o g i n B o x ”> <br> <?php e c h o f o r m o p e n ( ’ v e r i f y l o g i n ’ ) ; ?> <c e n t e r > <t a b l e > <t r ></t r > <t r > 133 <td><l a b e l f o r =”username”>Username : </ l a b e l > <td><i n p u t i d =”username ” name=”username ” t y p e=” t e x t ”> </t r > <t r > <td><l a b e l f o r =”p a s s w o r d”>Password : </ l a b e l > <td><i n p u t i d =”p a s s w o r d ” name=”p a s s w o r d ” t y p e=”p a s s w o r d”> </t r > <t r ></t r > <t r > <td><b u t t o n i d =” l o g i n B u t t o n ” t y p e=”s u b m i t”>Login </button> <td><a h r e f =”<?php s i t e u r l ( ) ?> l o g i n / f o r g e t p a s s w o r d ”>F o r g o t password </a> <a h r e f =”#” o n c l i c k =” j a v a s c r i p t : aboutModal ( ) ;” > About</a> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> <d i v i d =” r e g i s t e r H e a d i n g ” c l a s s =”u i −w i d g e t −h e a d e r u i −c o r n e r − a l l ”> <c e n t e r ><h2>  ; R e g i s t e r </h2></c e n t e r > </d i v> <d i v i d =”s i g n u p B o x”> <br> <?php e c h o f o r m o p e n ( ’ l o g i n / s a v e ’ , a r r a y ( ’ username ’ => ’ myform ’ ) ) ; ?> <c e n t e r > <t a b l e > <t r ></t r > <t r ></t r > <t r > <td><l a b e l f o r =” f i r s t n a m e ”>  ; F i r s t Name: </ l a b e l > <td><i n p u t i d =” f i r s t n a m e ” name=” f i r s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ f i r s t n a m e ’ ) ; ?>”> <td><span i d =” f i r s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”middle name”>  ; M i d d l e Name ( O p t i o n a l ) : </ l a b e l > <td><i n p u t i d =”middle name ” name=”middle name ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ middle name ’ ) ; ?>”> </t r > <t r > <td><l a b e l f o r =” l a s t n a m e”>  ; L a s t Name: </ l a b e l > <td><i n p u t i d =” l a s t n a m e ” name=” l a s t n a m e ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ l a s t n a m e ’ ) ; ?>”> <td><span i d =” l a s t n a m e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” b i r t h d a t e”>  ; B i r t h d a t e : </ l a b e l > <td><i n p u t i d =” b i r t h d a t e ” name=” b i r t h d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<? php e c h o s e t v a l u e ( ’ b i r t h d a t e ’ ) ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#b i r t h d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> <td><span i d =” b i r t h d a t e v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =”g e n d e r”>  ; Gender : </ l a b e l > <td> <d i v i d =”g e n d e r R a d i o B u t t o n S e t”> <i n p u t t y p e=” r a d i o ” i d =”g e n d e r M a l e ” name=”g e n d e r R a d i o ” v a l u e =”Male ” <?php e c h o s e t r a d i o ( ’ g e n d e r R a d i o ’ , ’ Male ’ , TRUE) ; ?>>< l a b e l f o r =”g e n d e r M a l e”>Male</ l a b e l > <i n p u t t y p e=” r a d i o ” i d =”g e n d e r F e m a l e ” name=”g e n d e r R a d i o ” v a l u e =”Female ” <?php e c h o s e t r a d i o ( ’ g e n d e r R a d i o ’ , ’ Female ’ ) ; ?>>< l a b e l f o r =”g e n d e r F e m a l e”>Female </ l a b e l > </d i v> </t r > <d i v i d =”u s e r T y p e R a d i o B u t t o n S e t ” s t y l e =” v i s i b i l i t y : h i d d e n”> <i n p u t t y p e=” r a d i o ” i d =”u s e r T y p e U s e r ” name=”u s e r T y p e R a d i o ” v a l u e =”U s e r ” c h e c k e d><l a b e l f o r =” u s e r T y p e U s e r”>User </ l a b e l > </d i v> <t r > <td><l a b e l f o r =” e m a i l a d d r e s s”>  ; E−m a i l A d d r e s s : </ l a b e l > <td><i n p u t i d =” e m a i l a d d r e s s ” name=” e m a i l a d d r e s s ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ e m a i l a d d r e s s ’ ) ; ?>”> <td><span i d =” e m a i l v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” u s e r n a m e r e g”>  ; Username : </ l a b e l > <td><i n p u t i d =” u s e r n a m e r e g ” name=” u s e r n a m e r e g ” t y p e=” t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ u s e r n a m e r e g ’ ) ; ?>” > <td><span i d =” u s r v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” p a s s w o r d r e g”>  ; Password : </ l a b e l > <td><i n p u t i d =” p a s s w o r d r e g ” name=” p a s s w o r d r e g ” t y p e=”p a s s w o r d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ p a s s w o r d r e g ’ ) ; ?>” > <td><span i d =” p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td><l a b e l f o r =” c o n f i r m p a s s w o r d r e g”>  ; Confirm Password : </ l a b e l > <td><i n p u t i d =” c o n f i r m p a s s w o r d r e g ” name=” c o n f i r m p a s s w o r d r e g ” t y p e=”p a s s w o r d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ c o n f i r m p a s s w o r d r e g ’ ) ; ?>”> <td><span i d =” c o n f i r m p a s s w o r d v e r i f y ” c l a s s =” v e r i f y ”></span> </t r > <t r > <td> <td><?php e c h o $ c a p i m g ?> </t r > <t r > <td>  ; P l e a s e t y p e t h e c o d e above : <td><i n p u t t y p e=” t e x t ” i d =”c a p t c h a ” name=”c a p t c h a ” v a l u e =”” /> 134 </t r > <t r > <td><b u t t o n i d =” r e g i s t e r B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”> R e g i s t e r </button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </d i v> <p c l a s s =” f o o t e r ”>Page r e n d e r e d i n <s t r o n g >{ e l a p s e d t i m e }</ s t r o n g > s e c o n d s </p> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#p l a n D a i l y M e a l s B a c k B u t t o n , #planDailyMealsHomeButton , #s e a r c h M e a l B u t t o n , #goButton ” ) . button ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; } }) ; $ ( ”#p l a n D a i l y M e a l s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 850 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” p l a n D a i l y M e a l s D i a l o g ” t i t l e =”Plan D a i l y Meals”> <br> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <c e n t e r > <t a b l e > <t r > <th><h3>Add Meals t o D a i l y Meal Plan </th> <?php e c h o f o r m o p e n ( ’ h o m e u s e r / s e a r c h m e a l ’ ) ; ?> <td><b u t t o n i d =”s e a r c h M e a l B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>S e a r c h Meal</ button ></td> <b u t t o n i d =”p l a n D a i l y M e a l s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”p l a n D a i l y M e a l s B a c k B u t t o n ” v a l u e =” Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”planDailyMealsHomeButton ” t y p e=”b u t t o n ” name=”planDailyMealsHomeButton ” v a l u e =” Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> <?php e c h o f o r m c l o s e ( ) ; ?> </t r > <?php e c h o f o r m o p e n ( ’ h o m e u s e r / s e l e c t b y d a t e ’ ) ; ?> <t r > <th><h3>S e a r c h D a i l y Meal Plan </th> <h5><th><l a b e l f o r =” r e c o r d d a t e ”>  ; Date : </ l a b e l ></th> 135 <td><i n p u t i d =” r e c o r d d a t e ” name=” r e c o r d d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ r e c o r d d a t e ’ ) ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#r e c o r d d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> <b u t t o n i d =”goButton ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Go</button> <t r ></t r ><t r ></t r > </t r > <?php i f ( i s s e t ( $ r e s u l t d i s p l a y ) ) { ?> <?php i f ( $ r e s u l t d i s p l a y == ’ No r e c o r d f o u n d ! ’ ) { echo $ r e s u l t d i s p l a y ; } e l s e { ?> <t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r > <t r > <th><h3>R e c i p e s </th> </t r > <t r > <!−−<th>ID</th>−−> <!−−<th>Record Date</th>−−> <th>H e a l t h C o n d i t i o n </th> <th>Meal Group</th> <th>R e c i p e Name</th> <th>C a l o r i e s ( Kcal )</th> <th>C a r b o h y d r a t e s ( g )</th> <th>P r o t e i n ( g )</th> <th>Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php $ s u m c a l o r i e s = 0 ; ?> <?php $ s u m c a r b o h y d r a t e s = 0 ; ?> <?php $ s u m p r o t e i n = 0 ; ?> <?php $ s u m f a t = 0 ; ?> <?php f o r e a c h ( $ r e s u l t d i s p l a y a s $ v a l u e ) { ?> <?php i f ( i s s e t ( $ v a l u e −>c a l o r i e s ) ) { $ c a l o r i e s = $ v a l u e −>c a l o r i e s ; $ s u m c a l o r i e s += $ c a l o r i e s ; } ?> <?php i f ( i s s e t ( $ v a l u e −>c a r b o h y d r a t e ) ) { $ c a r b o h y d r a t e s = $ v a l u e −>c a r b o h y d r a t e ; $ s u m c a r b o h y d r a t e s += $ c a r b o h y d r a t e s ; } ?> <?php i f ( i s s e t ( $ v a l u e −>p r o t e i n ) ) { $ p r o t e i n = $ v a l u e −>p r o t e i n ; $ s u m p r o t e i n += $ p r o t e i n ; } ?> <?php i f ( i s s e t ( $ v a l u e −>f a t ) ) { $ f a t = $ v a l u e −>f a t ; $ s u m f a t += $ f a t ; } ?> <?php $ c a l o r i e l i m i t = i s s e t ( $ v a l u e −> c a l o r i e l i m i t ) ? $ v a l u e −> c a l o r i e l i m i t : ”” ; ?> <?php $ c a r b o h y d r a t e l i m i t = i s s e t ( $ v a l u e −>c a r b o h y d r a t e l i m i t ) ? $ v a l u e −>c a r b o h y d r a t e l i m i t : ” ” ; ?> <?php $ p r o t e i n l i m i t = i s s e t ( $ v a l u e −>p r o t e i n l i m i t ) ? $ v a l u e −>p r o t e i n l i m i t : ” ” ; ?> <?php $ f a t l i m i t = i s s e t ( $ v a l u e −>f a t l i m i t ) ? $ v a l u e −>f a t l i m i t : ” ” ; ?> <?php $ h e a l t h c o n d i t i o n = i s s e t ( $ v a l u e −>h e a l t h c o n d i t i o n ) ? $ v a l u e −>h e a l t h c o n d i t i o n : ” ” ; ?> <t r > <!−−<td><?php $ p l a n d a i l y m e a l i d = $ v a l u e −>p l a n d a i l y m e a l i d ; e c h o $ p l a n d a i l y m e a l i d ; ?></ td>−−> <!−−<td><?php e c h o $ v a l u e −>r e c o r d d a t e ; ?></td>−−> <!−−<td><?php $ o w n r e c i p e i d = $ v a l u e −>o w n r e c i p e i d ; e c h o $ o w n r e c i p e i d ?></td>−−> <?php i f ( i s s e t ( $ v a l u e −>m e a l g r o u p ) ) : ?> <td><?php i f ( i s s e t ( $ v a l u e −>h e a l t h c o n d i t i o n ) ) { e c h o $ v a l u e −>h e a l t h c o n d i t i o n ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>m e a l g r o u p ) ) { e c h o $ v a l u e −>m e a l g r o u p ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>r e c i p e n a m e ) ) { e c h o $ v a l u e −>r e c i p e n a m e ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>c a l o r i e s ) ) { e c h o $ v a l u e −>c a l o r i e s ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>c a r b o h y d r a t e ) ) { e c h o $ v a l u e −>c a r b o h y d r a t e ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>p r o t e i n ) ) { e c h o $ v a l u e −>p r o t e i n ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>f a t ) ) { e c h o $ v a l u e −>f a t ; } ?></td> <td> <a h r e f = ” . . / h o m e u s e r / v i e w c r e a t e d p l a n r e c i p e /<?php e c h o $ o w n r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> 136 < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −f o l d e r −open”></span> </ l i > </u l > </a> <a h r e f = ” . . / h o m e u s e r / d e l e t e m e a l /<?php e c h o $ p l a n d a i l y m e a l i d ; ?>” o n c l i c k =” r e t u r n c o n f i r m ( ’ Are you s u r e you want t o d e l e t e ? ’ ) ”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” D e l e t e ”> <span c l a s s =”u i −i c o n u i −i c o n −t r a s h ”></span> </ l i > </u l > </a> </td> <?php e n d i f ; ?> <?php } ?> </t r > <t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r > <t r > <th><h3>R e c i p e N u t r i t i o n a l I n f o r m a t i o n </th> </t r > <t r > <th>T o t a l C a l o r i e s </th> <th>T o t a l C a r b o h y d r a t e s </th> <th>T o t a l P r o t e i n </th> <th>T o t a l Fat</th> </t r > <t r > <td><?php e c h o $ s u m c a l o r i e s ; ?> <td><?php e c h o $ s u m c a r b o h y d r a t e s ; ?> <td><?php e c h o $ s u m p r o t e i n ; ?> <td><?php e c h o $ s u m f a t ; ?> </t r > <t r ></t r ><t r ></t r > <t r ></t r ><t r ></t r > <t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r > <t r > <th><h3>F i t n e s s I n f o r m a t i o n </th> </t r > <t r ></t r ><t r ></t r > <t r ></t r ><t r ></t r > <t r > <th>C u r r e n t H e a l t h C o n d i t i o n </th> </t r > <t r > <td><?php e c h o $ h e a l t h c o n d i t i o n ; ?> </t r > <t r ></t r ><t r ></t r > <t r ></t r ><t r ></t r > <t r > <th></th> <th>L i m i t </th> <th>Remaining </th> <th>Consumed</th> <th>Recommendation</th> </t r > <t r > <t d c l a s s = ” r e d b o x”> C a l o r i e <td><?php e c h o $ c a l o r i e l i m i t ; ?> <td><?php e c h o $ c a l o r i e l i m i t − $ s u m c a l o r i e s ; ?> <td><?php e c h o $ s u m c a l o r i e s ; ?> <td> <?php i f ( ( $ c a l o r i e l i m i t − $ s u m c a l o r i e s ) < 0) { e c h o ”< f o n t c o l o r =’ red ’ s i z e =’2’><b>C a l o r i e L i m i t Exceeded ! </b></f o n t > You may want t o remove o r r e p l a c e a meal w i t h a n o t h e r meal o f l o w e r c a l o r i e c o n t e n t . ” ; } e l s e i f ( ( $ c a l o r i e l i m i t − $ s u m c a l o r i e s ) == 0 | | ( $ c a l o r i e l i m i t − $ s u m c a l o r i e s ) < 1 0 ) { e c h o ”You a r e a b o u t t o e x c e e d y o u r C a l o r i e L i m i t . You may want t o remove o r r e p l a c e a meal w i t h a n o t h e r meal o f l o w e r c a l o r i e c o n t e n t . ” ; } else i f ( $sum calories < $calorie limit ) { e c h o ”You may want t o have more m e a l s . ” ; } else { e c h o ” −”; } ?> </t r > <t r > <t d c l a s s = ” r e d b o x”>C a r b o h y d r a t e <td><?php e c h o $ c a r b o h y d r a t e l i m i t ; ?> <td><?php e c h o $ c a r b o h y d r a t e l i m i t − $ s u m c a r b o h y d r a t e s ; ?> <td><?php e c h o $ s u m c a r b o h y d r a t e s ; ?> <td> <?php i f ( ( $ c a r b o h y d r a t e l i m i t − $sum carbohydrates ) < 0) { e c h o ”< f o n t c o l o r =’ red ’ s i z e =’2’><b>C a r b o h y d r a t e L i m i t Exceeded ! </b></f o n t > You may want t o remove o r r e p l a c e a meal w i t h a n o t h e r meal o f l o w e r c a r b o h y d r a t e c o n t e n t . ” ; } e l s e i f ( ( $ c a r b o h y d r a t e l i m i t − $ s u m c a r b o h y d r a t e s ) == 0 | | ( $ c a r b o h y d r a t e l i m i t − $sum carbohydrates ) < 10) { e c h o ”You a r e a b o u t t o e x c e e d y o u r C a r b o h y d r a t e L i m i t . You may want t o remove o r r e p l a c e a meal w i t h a n o t h e r meal o f l o w e r c a r b o h y d r a t e c o n t e n t . ” ; } e l s e i f ( $sum carbohydrates < $carbohydrate limit ) { e c h o ”You may want t o have more m e a l s . ” ; } else { 137 e c h o ” −”; } ?> </t r > <t r > <t d c l a s s = ” r e d b o x”> P r o t e i n <td><?php e c h o $ p r o t e i n l i m i t ; ?> <td><?php e c h o $ p r o t e i n l i m i t − $ s u m p r o t e i n ; ?> <td><?php e c h o $ s u m p r o t e i n ; ?> <td> <?php i f ( ( $ p r o t e i n l i m i t − $sum protein ) < 0) { e c h o ”< f o n t c o l o r =’ red ’ s i z e =’2’><b>P r o t e i n L i m i t Exceeded ! </b></f o n t > You may want t o remove o r r e p l a c e a meal w i t h a n o t h e r meal o f l o w e r p r o t e i n c o n t e n t . ” ; } e l s e i f ( ( $ p r o t e i n l i m i t − $ s u m p r o t e i n ) == 0 | | ( $ p r o t e i n l i m i t − $ s u m p r o t e i n ) < 1 0 ) { e c h o ”You a r e a b o u t t o e x c e e d y o u r P r o t e i n L i m i t . You may want t o remove o r r e p l a c e a meal w i t h a n o t h e r meal o f l o w e r p r o t e i n c o n t e n t . ” ; } e l s e i f ( $sum protein < $ p r o t e i n l i m i t ) { e c h o ”You may want t o have more m e a l s . ” ; } else { e c h o ” −”; } ?> </t r > <t r > <t d c l a s s = ” r e d b o x”>Fat <td><?php e c h o $ f a t l i m i t ; ?> <td><?php e c h o $ f a t l i m i t − $ s u m f a t ; ?> <td><?php e c h o $ s u m f a t ; ?> <td> <?php i f ( ( $ f a t l i m i t − $sum fat ) < 0) { e c h o ”< f o n t c o l o r =’ red ’ s i z e =’2’><b>Fat L i m i t Exceeded ! </b></f o n t > You may want t o remove o r r e p l a c e a meal w i t h a n o t h e r meal o f l o w e r f a t c o n t e n t . ” ; } e l s e i f ( ( $ f a t l i m i t − $ s u m f a t ) == 0 | | ( $ f a t l i m i t − $ s u m f a t ) < 1 0 ) { e c h o ”You a r e a b o u t t o e x c e e d y o u r Fat L i m i t . You may want t o remove o r r e p l a c e a meal w i t h a n o t h e r meal o f l o w e r f a t c o n t e n t . ” ; } e l s e i f ( $sum fat < $ f a t l i m i t ) { e c h o ”You may want t o have more m e a l s . ” ; } else { e c h o ” −”; } ?> </t r > <?php } ?> <?php } ?> <?php e c h o f o r m c l o s e ( ) ; ?> </ t a b l e > </ c e n t e r > </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#recommendDailyMealsBackButton , #recommendDailyMealsHomeButton , #s e a r c h M e a l B u t t o n , # goButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , 138 onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; } }) ; $ ( ”#p l a n D a i l y M e a l s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 850 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; false ; }, $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” p l a n D a i l y M e a l s D i a l o g ” t i t l e =”Recommend D a i l y Meals”> <br> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <c e n t e r > <t a b l e > <t r > <th><h3>Add Meals t o Recommended D a i l y Meals </th> <?php e c h o f o r m o p e n ( ’ home cmanager / s e a r c h m e a l ’ ) ; ?> <td><b u t t o n i d =”s e a r c h M e a l B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>S e a r c h Meal</ button ></td> <b u t t o n i d =”recommendDailyMealsBackButton ” t y p e=”b u t t o n ” name=”recommendDailyMealsBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” > Back </button> <b u t t o n i d =”recommendDailyMealsHomeButton ” t y p e=”b u t t o n ” name=”recommendDailyMealsHomeButton ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home </button> <?php e c h o f o r m c l o s e ( ) ; ?> </t r > <?php e c h o f o r m o p e n ( ’ home cmanager / s e l e c t b y d a t e ’ ) ; ?> <t r > <th><h3>S e a r c h Recommended D a i l y Meals </th> <h5><th><l a b e l f o r =” r e c o r d d a t e ”>  ; Date : </ l a b e l ></th> <td><i n p u t i d =” r e c o r d d a t e ” name=” r e c o r d d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ r e c o r d d a t e ’ ) ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#r e c o r d d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> <b u t t o n i d =”goButton ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Go</button> <t r ></t r ><t r ></t r > </t r > <?php i f ( i s s e t ( $ r e s u l t d i s p l a y ) ) { ?> <?php i f ( $ r e s u l t d i s p l a y == ’ No r e c o r d f o u n d ! ’ ) { echo $ r e s u l t d i s p l a y ; } e l s e { ?> <t r > <th><h3>R e c i p e s </th> </t r > <t r > <!−−<th>ID</th>−−> <!−−<th>Record Date</th>−−> <th>H e a l t h C o n d i t i o n </th> <th>Meal Group</th> <th>R e c i p e Name</th> <th>C a l o r i e s ( Kcal )</th> <th>C a r b o h y d r a t e s ( g )</th> <th>P r o t e i n ( g )</th> <th>Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php $ s u m c a l o r i e s = 0 ; ?> <?php $ s u m c a r b o h y d r a t e s = 0 ; ?> <?php $ s u m p r o t e i n = 0 ; ?> <?php $ s u m f a t = 0 ; ?> <?php f o r e a c h ( $ r e s u l t d i s p l a y a s $ v a l u e ) { ?> <?php i f ( i s s e t ( $ v a l u e −>c a l o r i e s ) ) { $ c a l o r i e s = $ v a l u e −>c a l o r i e s ; $ s u m c a l o r i e s += $ c a l o r i e s ; } ?> <?php i f ( i s s e t ( $ v a l u e −>c a r b o h y d r a t e ) ) { $ c a r b o h y d r a t e s = $ v a l u e −>c a r b o h y d r a t e ; $ s u m c a r b o h y d r a t e s += $ c a r b o h y d r a t e s ; } ?> <?php i f ( i s s e t ( $ v a l u e −>p r o t e i n ) ) { $ p r o t e i n = $ v a l u e −>p r o t e i n ; $ s u m p r o t e i n += $ p r o t e i n ; } ?> <?php i f ( i s s e t ( $ v a l u e −>f a t ) ) { $ f a t = $ v a l u e −>f a t ; $ s u m f a t += $ f a t ; } 139 ?> <t r > <!−−<td><?php $ r e c o m m e n d e d d a i l y m e a l i d = $ v a l u e −>r e c o m m e n d e d d a i l y m e a l i d ; e c h o $ r e c o m m e n d e d d a i l y m e a l i d ; ?></td>−−> <!−−<td><?php $ r e c o m m e n d e d r e c i p e i d = $ v a l u e −>r e c o m m e n d e d r e c i p e i d ; e c h o $ r e c o m m e n d e d r e c i p e i d ; ?></td>−−> <!−−<td><?php e c h o $ v a l u e −>r e c o r d d a t e ; ?></td>−−> <td><?php i f ( i s s e t ( $ v a l u e −>h e a l t h c o n d i t i o n ) ) { e c h o $ v a l u e −>h e a l t h c o n d i t i o n ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>m e a l g r o u p ) ) { e c h o $ v a l u e −>m e a l g r o u p ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>r e c i p e n a m e ) ) { e c h o $ v a l u e −>r e c i p e n a m e ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>c a l o r i e s ) ) { e c h o $ v a l u e −>c a l o r i e s ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>c a r b o h y d r a t e ) ) { e c h o $ v a l u e −>c a r b o h y d r a t e ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>p r o t e i n ) ) { e c h o $ v a l u e −>p r o t e i n ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>f a t ) ) { e c h o $ v a l u e −>f a t ; } ?></td> <td> <a h r e f = ” . . / home cmanager / v i e w c r e a t e d r e c o m m e n d e d r e c i p e /<?php e c h o $ r e c o m m e n d e d r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −f o l d e r −open”></span> </ l i > </u l > </a> <a h r e f = ” . . / home cmanager / d e l e t e m e a l /<?php e c h o $ r e c o m m e n d e d d a i l y m e a l i d ; ?>” o n c l i c k =” r e t u r n c o n f i r m ( ’ Are you s u r e you want t o d e l e t e ? ’ ) ”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” D e l e t e ”> <span c l a s s =”u i −i c o n u i −i c o n −t r a s h ”></span> </ l i > </u l > </a> </td> <?php } ?> </t r > <t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r ><t r ></t r > <t r > <th><h3>R e c i p e N u t r i t i o n a l I n f o r m a t i o n </th> </t r > <t r > <th>T o t a l C a l o r i e s </th> <th>T o t a l C a r b o h y d r a t e s </th> <th>T o t a l P r o t e i n </th> <th>T o t a l Fat</th> </t r > <t r > <td><?php e c h o $ s u m c a l o r i e s ; ?> <td><?php e c h o $ s u m c a r b o h y d r a t e s ; ?> <td><?php e c h o $ s u m p r o t e i n ; ?> <td><?php e c h o $ s u m f a t ; ?> </t r > <?php } ?> <?php } ?> <?php e c h o f o r m c l o s e ( ) ; ?> </ t a b l e > </ c e n t e r > </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > 140 $( function () { $ ( ”#addMealBackButton , #addMealHomeButton , #addMealButton , #u s e r S e a r c h M e a l B u t t o n , # addMealButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; } }) ; $ ( ”#a d d M e a l D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 850 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; </ s c r i p t > </head> <body> <d i v i d =”a d d M e a l D i a l o g ” t i t l e =”Add Meal”> <br> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <!−−<?php e c h o $ r e c o r d d a t e ; ?>−−> <?=f o r m o p e n ( ’ home cmanager / s e a r c h m e a l ’ ) ;? > <?php $ s e a r c h m e a l = a r r a y ( ’ name’=>’ s e a r c h m e a l ’ , ’ i d ’=>’ s e a r c h m e a l ’ , ’ v a l u e ’ = > ’ ’ , ) ; ?> <c e n t e r >S e a r c h f o r R e c i p e : <?=f o r m i n p u t ( $ s e a r c h m e a l ) ;? > <b u t t o n i d =”u s e r S e a r c h M e a l B u t t o n ” t y p e=”s u b m i t ” v a l u e =”” t i t l e =”S e a r c h Meal”>S e a r c h </button> <b u t t o n i d =”addMealBackButton ” t y p e=”b u t t o n ” name=”addMealBackButton ” v a l u e =”Back ” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager / r e c o m m e n d d a i l y m e a l s ’” > Back </button> <b u t t o n i d =”addMealHomeButton ” t y p e=”b u t t o n ” name=”addMealHomeButton ” v a l u e =”Home” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home</button> </ c e n t e r > <?= f o r m c l o s e ( ) ;? > <?php i f ( i s a r r a y ( $ q u e r y m e a l ) ) { ?> <c e n t e r > <?php i f ( ! empty ( $ q u e r y m e a l ) ) : ?> <t a b l e > <t r > <t h s t y l e =” d i s p l a y : none ;” >ID</th> <th>H e a l t h C o n d i t i o n </th> <th>Meal Type</th> <th>R e c i p e Name</th> <th>S e r v i n g S i z e </th> <th>C a l o r i e s ( Kcal )</th> <th>C a r b o h y d r a t e ( g )</th> <th>P r o t e i n ( g )</th> <th>Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y m e a l a s $ i t e m ) : ?> <?php $ r e c o m m e n d e d r e c i p e i d = $item−>r e c o m m e n d e d r e c i p e i d ?> <t r > <t d s t y l e =” d i s p l a y : none;”><?= $item−>r e c o m m e n d e d r e c i p e i d ?></td> <td><?= $item−>h e a l t h c o n d i t i o n ?></td> <td><?= $item−>m e a l t y p e ?></td> <td><?= $item−>r e c i p e n a m e ?></td> <td><?= $item−>s e r v i n g s u g g ?></td> <td><?= $item−>c a l o r i e s ?></td> <td><?= $item−>c a r b o h y d r a t e ?></td> <td><?= $item−>p r o t e i n ?></td> <td><?= $item−>f a t ?></td> <td> <a h r e f = ” . . / home cmanager / v i e w c r e a t e d r e c i p e m e a l /<?php e c h o $ r e c o m m e n d e d r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −f o l d e r −open”></span> </ l i > </u l > </a> <a h r e f = ” . . / home cmanager / a d d m e a l /<?php e c h o $ r e c o m m e n d e d r e c i p e i d ; ?>”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”Add Meal”> 141 <span c l a s s =”u i −i c o n u i −i c o n −p l u s t h i c k ”></span> </ l i > </u l > </a> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > <?php e l s e : ?> <?php e c h o ”No d a t a t o d i s p l a y . ” ; ?> <?php e n d i f ; ?> </ c e n t e r > <?php } ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#addMealBackButton , #addMealHomeButton , #addMealButton , #u s e r S e a r c h M e a l B u t t o n , # addMealButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; } }) ; $ ( ”#a d d M e a l D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 850 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; false ; }, $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; </ s c r i p t > </head> <body> <d i v i d =”a d d M e a l D i a l o g ” t i t l e =”Add Meal”> <br> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <!−−<?php e c h o $ r e c o r d d a t e ; ?>−−> <?=f o r m o p e n ( ’ h o m e u s e r / s e a r c h m e a l ’ ) ;? > <?php $ s e a r c h m e a l = a r r a y ( ’ name’=>’ s e a r c h m e a l ’ , ’ i d ’=>’ s e a r c h m e a l ’ , ’ v a l u e ’ = > ’ ’ , ) ; ?> <c e n t e r >S e a r c h f o r R e c i p e : <?=f o r m i n p u t ( $ s e a r c h m e a l ) ;? > <b u t t o n i d =”u s e r S e a r c h M e a l B u t t o n ” t y p e=”s u b m i t ” v a l u e =”” t i t l e =”S e a r c h Meal”>S e a r c h </button> <b u t t o n i d =”addMealBackButton ” t y p e=”b u t t o n ” name=”addMealBackButton ” v a l u e =”Back ” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / p l a n d a i l y m e a l s ’” > Back</button> <b u t t o n i d =”addMealHomeButton ” t y p e=”b u t t o n ” name=”addMealHomeButton ” v a l u e =”Back ” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </ c e n t e r > <?= f o r m c l o s e ( ) ;? > <?php i f ( i s a r r a y ( $ q u e r y m e a l ) ) { ?> <c e n t e r > <?php i f ( ! empty ( $ q u e r y m e a l ) ) : ?> <t a b l e > 142 <t r > <t h s t y l e =” d i s p l a y : none ;” >ID</th> <th>H e a l t h C o n d i t i o n </th> <th>Meal Type</th> <th>R e c i p e Name</th> <th>S e r v i n g S i z e </th> <th>C a l o r i e s ( Kcal )</th> <th>C a r b o h y d r a t e ( g )</th> <th>P r o t e i n ( g )</th> <th>Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y m e a l a s $ i t e m ) : ?> <?php $ o w n r e c i p e i d = $item−>o w n r e c i p e i d ?> <t r > <t d s t y l e =” d i s p l a y : none;”><?= $item−>o w n r e c i p e i d ?></td> <td><?= $item−>h e a l t h c o n d i t i o n ?></td> <td><?= $item−>m e a l t y p e ?></td> <td><?= $item−>r e c i p e n a m e ?></td> <td><?= $item−>s e r v i n g s u g g ?></td> <td><?= $item−>c a l o r i e s ?></td> <td><?= $item−>c a r b o h y d r a t e ?></td> <td><?= $item−>p r o t e i n ?></td> <td><?= $item−>f a t ?></td> <td> <a h r e f = ” . . / h o m e u s e r / v i e w c r e a t e d r e c i p e m e a l /<?php e c h o $ o w n r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −f o l d e r −open”></span> </ l i > </u l > </a> <a h r e f = ” . . / h o m e u s e r / a d d m e a l /<?php e c h o $ o w n r e c i p e i d ; ?>”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”Add Meal”> <span c l a s s =”u i −i c o n u i −i c o n −p l u s t h i c k ”></span> </ l i > </u l > </a> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > <?php e l s e : ?> <?php e c h o ”No d a t a t o d i s p l a y . ” ; ?> <?php e n d i f ; ?> </ c e n t e r > <?php } ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#userSearchFELButton , #userSearchFELBackButton , #userSearchFELHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#u s e r S e a r c h F E L D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 925 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =”u s e r S e a r c h F E L D i a l o g ” t i t l e =”Food N u t r i t i o n a l <br> <?=f o r m o p e n ( ’ h o m e u s e r / s e a r c h f e l ’ ) ;? > 143 I n f o r m a t i o n ”> <?php $ s e a r c h f e l = a r r a y ( ’ name’=>’ s e a r c h f e l ’ , ’ i d ’=>’ s e a r c h f e l ’ , ’ v a l u e ’ = > ’ ’ , ) ; ?> <c e n t e r >Food N u t r i t i o n a l I n f o r m a t i o n : <?=f o r m i n p u t ( $ s e a r c h f e l ) ;? > <b u t t o n i d =”u s e r S e a r c h F E L B u t t o n ” t y p e=”s u b m i t ” v a l u e =”” t i t l e =”S e a r c h Food N u t r i t i o n a l I n f o r m a t i o n ”>S e a r c h </button> <b u t t o n i d =”userSearchFELBackButton ” t y p e=”b u t t o n ” name=”userSearchFELBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”userSearchFELHomeButton ” t y p e=”b u t t o n ” name=”userSearchFELHomeButton ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </ c e n t e r > <?= f o r m c l o s e ( ) ;? > <?php i f ( i s a r r a y ( $ q u e r y f e l ) ) { ?> <c e n t e r > <?php i f ( ! empty ( $ q u e r y f e l ) ) : ?> <t a b l e > <t r > <th>L i s t Group</th> <th>Food Group</th> <th>Food Group C a t e g o r y </th> <th>Food Name</th> <th>Measure </th> <th>C a r b o h y d r a t e ( g )</th> <th>P r o t e i n ( g )</th> <th>Fat ( g )</th> <th>Energy ( Kcal )</th> <th>Weight a s P u r c h a s e d ( g )</th> <th>Weight E d i b l e P o r t i o n ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y f e l a s $ i t e m ) : ?> <t r > <td><?= $item−>l i s t g r o u p ?></td> <td><?= $item−>f o o d g r o u p ?></td> <td><?= $item−>f o o d g r o u p c a t e g o r y ?></td> <td><?= $item−>f o o d n a m e ?></td> <td><?= $item−>measure ?></td> <td><?= $item−>c a r b o h y d r a t e ?></td> <td><?= $item−>p r o t e i n ?></td> <td><?= $item−>f a t ?></td> <td><?= $item−>e n e r g y ?></td> <td><?= $item−>w e i g h t a s p u r c h a s e d ?></td> <td><?= $item−>w e i g h t e d i b l e p o r t i o n ?></td> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > <?php e l s e : ?> <?php e c h o ”No d a t a t o d i s p l a y . ” ; ?> <?php e n d i f ; ?> </ c e n t e r > <?php } ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#s h a r e A c h i e v e m e n t B u t t o n , #s h a r e A c h i e v e m e n t B a c k B u t t o n , #shareAchievementHomeButton ” ) . b u t t o n () ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#s h a r e A c h i e v e m e n t D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 485 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }) ; }) ; </ s c r i p t > </head> <body> 144 }, <d i v i d =” s h a r e A c h i e v e m e n t D i a l o g ” t i t l e =”S h a r e Achievement”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ’ h o m e u s e r / p o s t f a c e b o o k ’ ) ; ?> <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><t e x t a r e a rows =”4” c o l s =”40” i d =”a c h i e v e m e n t ” name=”a c h i e v e m e n t ” t y p e=” l o n g t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ a c h i e v e m e n t ’ ) ; ?>”></ t e x t a r e a > </t r > <t r > <td><b u t t o n i d =”s h a r e A c h i e v e m e n t B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>S h a r e Achievement </button> <b u t t o n i d =”s h a r e A c h i e v e m e n t B a c k B u t t o n ” t y p e=”b u t t o n ” name=”s h a r e A c h i e v e m e n t B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”shareAchievementHomeButton ” t y p e=”b u t t o n ” name=”shareAchievementHomeButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#s h a r e A c h i e v e m e n t B u t t o n , #s h a r e A c h i e v e m e n t B a c k B u t t o n , #shareAchievementHomeButton ” ) . b u t t o n () ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#s h a r e A c h i e v e m e n t D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 485 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” s h a r e A c h i e v e m e n t D i a l o g ” t i t l e =”S h a r e Achievement”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ’ h o m e u s e r / s h a r e a c h i e v e m e n t s a v e ’ ) ; ?> <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><t e x t a r e a rows =”4” c o l s =”40” i d =”a c h i e v e m e n t ” name=”a c h i e v e m e n t ” t y p e=” l o n g t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ a c h i e v e m e n t ’ ) ; ?>” ></t e x t a r e a > </t r > <t r > <td><b u t t o n i d =”s h a r e A c h i e v e m e n t B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>S h a r e Achievement </button> <b u t t o n i d =”s h a r e A c h i e v e m e n t B a c k B u t t o n ” t y p e=”b u t t o n ” name=”s h a r e A c h i e v e m e n t B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”shareAchievementHomeButton ” t y p e=”b u t t o n ” name=”shareAchievementHomeButton ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> 145 <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#s h a r e A c h i e v e m e n t B u t t o n , #s h a r e A c h i e v e m e n t B a c k B u t t o n , #shareAchievementHomeButton ” ) . b u t t o n () ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#s h a r e A c h i e v e m e n t D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 485 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” s h a r e A c h i e v e m e n t D i a l o g ” t i t l e =”S h a r e Achievement”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <?php e c h o f o r m o p e n ( ’ h o m e u s e r / p o s t t w i t t e r ’ ) ; ?> <c e n t e r > <t a b l e > <t r ></t r ><t r ></t r > <t r > <td><t e x t a r e a rows =”4” c o l s =”40” i d =”a c h i e v e m e n t ” name=”a c h i e v e m e n t ” t y p e=” l o n g t e x t ” v a l u e =”<?php e c h o s e t v a l u e ( ’ a c h i e v e m e n t ’ ) ; ?>” ></t e x t a r e a > </t r > <t r > <td><b u t t o n i d =”s h a r e A c h i e v e m e n t B u t t o n ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>S h a r e Achievement </button> <td><b u t t o n i d =”s h a r e A c h i e v e m e n t B a c k B u t t o n ” t y p e=”b u t t o n ” name=”s h a r e A c h i e v e m e n t B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</ button> <b u t t o n i d =”shareAchievementHomeButton ” t y p e=”b u t t o n ” name=”shareAchievementHomeButton ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </t r > </ t a b l e > </ c e n t e r > <?php e c h o f o r m c l o s e ( ) ; ?> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#p l a n D a i l y M e a l s B a c k B u t t o n , #planDailyMealsHomeButton , #s e a r c h M e a l B u t t o n , #goButton ” ) . button ( ) ; // Hover s t a t e s on t h e s t a t i c $ ( ”# i c o n s l i ” ) . h o v e r ( function () { widgets 146 $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”# r e c o r d d a t e ” ) . d a t e p i c k e r ( { c l i c k I n p u t : true , changeMonth : t r u e , // a l l o w u s e r t o s e l e c t month changeYear : true , // a l l o w u s e r t o s e l e c t from y e a r r a n g e dateFormat : ’ yy−mm−dd ’ , yearRange : ” −100:+0” , onClose : f u n c t i o n ( ) { $ ( ’# r e c o r d d a t e ’ ) . v a l i d ( ) ; } }) ; $ ( ”#p l a n D a i l y M e a l s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 850 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n f a l s e ; } , dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” p l a n D a i l y M e a l s D i a l o g ” t i t l e =”Recommended D a i l y Meals”> <br> <f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o v a l i d a t i o n e r r o r s ( ) ; ?></b></f o n t > <c e n t e r > <t a b l e > <t r > <b u t t o n i d =”p l a n D a i l y M e a l s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”p l a n D a i l y M e a l s B a c k B u t t o n ” v a l u e =” Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”planDailyMealsHomeButton ” t y p e=”b u t t o n ” name=”planDailyMealsHomeButton ” v a l u e =” Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </t r > <?php e c h o f o r m o p e n ( ’ h o m e u s e r / r e c o m m e n d e d s e l e c t b y d a t e ’ ) ; ?> <t r > <th><h3>S e a r c h Recommended D a i l y Meals </th> <h5><th><l a b e l f o r =” r e c o r d d a t e ”>  ; Date : </ l a b e l ></th> <td><i n p u t i d =” r e c o r d d a t e ” name=” r e c o r d d a t e ” t y p e=” t e x t ” c l a s s =”d a t e−p i c k dp−a p p l i e d ” v a l u e =”<?php e c h o s e t v a l u e ( ’ r e c o r d d a t e ’ ) ; ?>” r e a d o n l y =” r e a d o n l y ”> <a h r e f=”#r e c o r d d a t e ” c l a s s =”dp−c h o o s e −d a t e ” t i t l e =”Choose d a t e”>Choose d a t e </a> <b u t t o n i d =”goButton ” t y p e=”s u b m i t ” name=”s u b m i t ” v a l u e =”s u b m i t”>Go</button> <t r ></t r ><t r ></t r > </t r > <?php i f ( i s s e t ( $ r e s u l t d i s p l a y ) ) { ?> <?php i f ( $ r e s u l t d i s p l a y == ’ No r e c o r d f o u n d ! ’ ) { echo $ r e s u l t d i s p l a y ; } e l s e { ?> <t r > <th><h3>R e c i p e s </th> </t r > <t r > <!−−<th>ID</th>−−> <!−−<th>Record Date</th>−−> <th>H e a l t h C o n d i t i o n </th> <th>Meal Group</th> <th>R e c i p e Name</th> <th>C a l o r i e s ( Kcal )</th> <th>C a r b o h y d r a t e s ( g )</th> <th>P r o t e i n ( g )</th> <th>Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php $ s u m c a l o r i e s = 0 ; ?> <?php $ s u m c a r b o h y d r a t e s = 0 ; ?> <?php $ s u m p r o t e i n = 0 ; ?> <?php $ s u m f a t = 0 ; ?> <?php f o r e a c h ( $ r e s u l t d i s p l a y a s $ v a l u e ) { ?> <?php i f ( i s s e t ( $ v a l u e −>c a l o r i e s ) ) { $ c a l o r i e s = $ v a l u e −>c a l o r i e s ; $ s u m c a l o r i e s += $ c a l o r i e s ; } ?> <?php i f ( i s s e t ( $ v a l u e −>c a r b o h y d r a t e ) ) { $ c a r b o h y d r a t e s = $ v a l u e −>c a r b o h y d r a t e ; $ s u m c a r b o h y d r a t e s += $ c a r b o h y d r a t e s ; } ?> <?php i f ( i s s e t ( $ v a l u e −>p r o t e i n ) ) { $ p r o t e i n = $ v a l u e −>p r o t e i n ; $ s u m p r o t e i n += $ p r o t e i n ; } ?> <?php i f ( i s s e t ( $ v a l u e −>f a t ) ) { $ f a t = $ v a l u e −>f a t ; $ s u m f a t += $ f a t ; } ?> 147 <t r > <!−−<td><?php $ p l a n d a i l y m e a l i d = $ v a l u e −>p l a n d a i l y m e a l i d ; e c h o $ p l a n d a i l y m e a l i d ; ?></ td>−−> <!−−<td><?php e c h o $ v a l u e −>r e c o r d d a t e ; ?></td>−−> <!−−<td><?php $ r e c o m m e n d e d r e c i p e i d = $ v a l u e −>r e c o m m e n d e d r e c i p e i d ; e c h o $ r e c o m m e n d e d r e c i p e i d ?></td>−−> <td><?php i f ( i s s e t ( $ v a l u e −>h e a l t h c o n d i t i o n ) ) { e c h o $ v a l u e −>h e a l t h c o n d i t i o n ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>m e a l g r o u p ) ) { e c h o $ v a l u e −>m e a l g r o u p ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>r e c i p e n a m e ) ) { e c h o $ v a l u e −>r e c i p e n a m e ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>c a l o r i e s ) ) { e c h o $ v a l u e −>c a l o r i e s ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>c a r b o h y d r a t e ) ) { e c h o $ v a l u e −>c a r b o h y d r a t e ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>p r o t e i n ) ) { e c h o $ v a l u e −>p r o t e i n ; } ?></td> <td><?php i f ( i s s e t ( $ v a l u e −>f a t ) ) { e c h o $ v a l u e −>f a t ; } ?></td> <td> <a h r e f = ” . . / h o m e u s e r / v i e w c r e a t e d r e c o m m e n d e d r e c i p e /<?php e c h o $ r e c o m m e n d e d r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −f o l d e r −open”></span> </ l i > </u l > </a> </td> <?php } ?> </t r > <t r > <th><h3>I n f o r m a t i o n </th> </t r > <t r > <h5><th><l a b e l f o r =” t o t a l c a l o r i e s ”>  ; T o t a l C a l o r i e s : </ l a b e l ></th> <td><?php e c h o $ s u m c a l o r i e s ; ?> </t r > <t r > <h5><th><l a b e l f o r =” t o t a l c a r b o h y d r a t e s ”>  ; T o t a l C a r b o h y d r a t e s : </ l a b e l ></th> <td><?php e c h o $ s u m c a r b o h y d r a t e s ; ?> </t r > <t r > <h5><th><l a b e l f o r =” t o t a l p r o t e i n ”>  ; T o t a l P r o t e i n : </ l a b e l ></th> <td><?php e c h o $ s u m p r o t e i n ; ?> </t r > <t r > <h5><th><l a b e l f o r =” t o t a l f a t ”>  ; T o t a l Fat : </ l a b e l ></th> <td><?php e c h o $ s u m f a t ; ?> </t r > <?php } ?> <?php } ?> <?php e c h o f o r m c l o s e ( ) ; ?> </ t a b l e > </ c e n t e r > </d i v> </body> </html> ( i s a r r a y ( $ a c h i e v e m e n t f e e d ) ) { ?> <c e n t e r > <?php f o r e a c h ( $ a c h i e v e m e n t f e e d a s $ i t e m ) : ?> <?= $item−>a c h i e v e m e n t ?><br><br> <?php e n d f o r e a c h ;? > </ c e n t e r > <?php } ?> <?php if ( i s a r r a y ( $ h t f e e d ) ) { ?> <c e n t e r > <?php f o r e a c h ( $ h t f e e d a s $ i t e m ) : ?> <?= $item−>h e a l t h t i p ?><br><br> <?php e n d f o r e a c h ;? > <!−−<t r > <?php i f ( i s s e t ( $ p a g i n a t i o n ) ) { echo $ p a g i n a t i o n ; } ?> </t r >−−> </ c e n t e r > <?php } ?> <?php if <html l a n g =”en”> 148 <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” t i t l e =”C r e a t e d R e c i p e s ”> <br> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <t a b l e > <t r > <th>ID</th> <th>H e a l t h C o n d i t i o n </th> <th>Meal Type</th> <th>R e c i p e Name</th> <th>S e r v i n g S i z e </th> <th>T o t a l C a l o r i e s ( Kcal )</th> <th>T o t a l C a r b o h y d r a t e ( g )</th> <th>T o t a l P r o t e i n ( g )</th> <th>T o t a l Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ o w n r e c i p e i d= $item−>o w n r e c i p e i d ?> <t r > <td><?= $item−>o w n r e c i p e i d ?></td> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</ button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</ button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > 149 < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” t i t l e =”C r e a t e d R e c i p e s ”> <br> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <?php i f ( ! empty ( $ q u e r y ) ) : ?> <t a b l e > <t r > <t h s t y l e =” d i s p l a y : none ;” >ID</th> <th>H e a l t h C o n d i t i o n </th> <th>Meal Type</th> <th>R e c i p e Name</th> <th>S e r v i n g S i z e </th> <th>T o t a l C a l o r i e s ( Kcal )</th> <th>T o t a l C a r b o h y d r a t e ( g )</th> <th>T o t a l P r o t e i n ( g )</th> <th>T o t a l Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ r e c o m m e n d e d r e c i p e i d= $item−>r e c o m m e n d e d r e c i p e i d ?> <?php $ r e c i p e n a m e= $item−>r e c i p e n a m e ?> <t r > <t d s t y l e =” d i s p l a y : none;”><?= $item−>r e c o m m e n d e d r e c i p e i d ?></td> <td><?= $item−>h e a l t h c o n d i t i o n ?></td> <td><?= $item−>m e a l t y p e ?></td> <td><?= $item−>r e c i p e n a m e ?></td> <td><?= $item−>s e r v i n g s u g g ?></td> <td><?= $item−>c a l o r i e s ?></td> <td><?= $item−>c a r b o h y d r a t e ?></td> <td><?= $item−>p r o t e i n ?></td> <td><?= $item−>f a t ?></td> <td> <a h r e f = ” . . / home cmanager / v i e w c r e a t e d r e c i p e /<?php e c h o $ r e c o m m e n d e d r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −f o l d e r −open”></span> </ l i > </u l > </a> <a h r e f = ” . . / home cmanager / e d i t c r e a t e d r e c i p e /<?php e c h o $ r e c o m m e n d e d r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”E d i t R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −p e n c i l ”></span> </ l i > </u l > </a> <a h r e f = ” . . / home cmanager / d e l e t e c r e a t e d r e c i p e /<?php e c h o $ r e c o m m e n d e d r e c i p e i d ; ?>” o n c l i c k =” r e t u r n c o n f i r m ( ’ Are you s u r e you want t o d e l e t e ? ’ ) ”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” D e l e t e ”> <span c l a s s =”u i −i c o n u i −i c o n −t r a s h ”></span> </ l i > </u l > </a> </td> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > <?php e l s e : ?> <?php e c h o ”No d a t a t o d i s p l a y . ” ; ?> <?php e n d i f ; ?> </ c e n t e r > <?php } ?> <br> 150 <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n </button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n </button> </d i v> </body> </html> t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” > Back t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” t i t l e =”C r e a t e d R e c i p e s ”> <br> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <?php i f ( ! empty ( $ q u e r y ) ) : ?> <t a b l e > <t r > <t h s t y l e =” d i s p l a y : none ;” >ID</th> <th>H e a l t h C o n d i t i o n </th> <th>Meal Type</th> <th>R e c i p e Name</th> <th>S e r v i n g S i z e </th> <th>T o t a l C a l o r i e s ( Kcal )</th> <th>T o t a l C a r b o h y d r a t e ( g )</th> <th>T o t a l P r o t e i n ( g )</th> <th>T o t a l Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ o w n r e c i p e i d= $item−>o w n r e c i p e i d ?> <?php $ r e c i p e n a m e= $item−>r e c i p e n a m e ?> <t r > <t d s t y l e =” d i s p l a y : none;”><?= $item−>o w n r e c i p e i d ?></td> <td><?= $item−>h e a l t h c o n d i t i o n ?></td> <td><?= $item−>m e a l t y p e ?></td> <td><?= $item−>r e c i p e n a m e ?></td> <td><?= $item−>s e r v i n g s u g g ?></td> <td><?= $item−>c a l o r i e s ?></td> <td><?= $item−>c a r b o h y d r a t e ?></td> <td><?= $item−>p r o t e i n ?></td> <td><?= $item−>f a t ?></td> <td> <a h r e f = ” . . / h o m e u s e r / v i e w c r e a t e d r e c i p e /<?php e c h o $ o w n r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View R e c i p e”> 151 <span c l a s s =”u i −i c o n u i −i c o n −f o l d e r −open”></span> </ l i > </u l > </a> <a h r e f = ” . . / h o m e u s e r / e d i t c r e a t e d r e c i p e /<?php e c h o $ o w n r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”E d i t R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −p e n c i l ”></span> </ l i > </u l > </a> <a h r e f = ” . . / h o m e u s e r / d e l e t e c r e a t e d r e c i p e /<?php e c h o $ o w n r e c i p e i d ; ?>” o n c l i c k =” r e t u r n c o n f i r m ( ’ Are you s u r e you want t o d e l e t e ? ’ ) ”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” D e l e t e ”> <span c l a s s =”u i −i c o n u i −i c o n −t r a s h ”></span> </ l i > </u l > </a> <a h r e f = ” . . / h o m e u s e r / s h a r e c r e a t e d r e c i p e /<?php e c h o $ o w n r e c i p e i d ; ?>”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”S h a r e on S i t e ”> <span c l a s s =”u i −i c o n u i −i c o n −l i n k ”></span> </ l i > </u l > </a> </td> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > <?php e l s e : ?> <?php e c h o ”No d a t a t o d i s p l a y . ” ; ?> <?php e n d i f ; ?> </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</ button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</ button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” <br> false ; }, t i t l e =’View R e c i p e ’> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <t a b l e > <t r > 152 <?php $a = $ q u e r y [0] − > img name ; $b = $ q u e r y [0] − > e x t ; ?> <img a l t =”” s r c =”<?= b a s e u r l ( ) . ’ u p l o a d s / ’ . $a . ’ . ’ . $b ;? >” h e i g h t =”250” w i d t h =”250”> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>R e c i p e Name: </b> <td><?php $a = $ q u e r y [0] − > r e c i p e n a m e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>S e r v i n g S i z e : </b> <td><?php $a = $ q u e r y [0] − > s e r v i n g s u g g ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>Meal Type: </b> <td><?php $a = $ q u e r y [0] − > m e a l t y p e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>H e a l t h C o n d i t i o n : </b> <td><?php $a = $ q u e r y [0] − > h e a l t h c o n d i t i o n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a l o r i e s ( Kcal ) : </b> <td><?php $a = $ q u e r y [0] − > c a l o r i e s ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a r b o h y d r a t e s ( g ) : </b> <td><?php $a = $ q u e r y [0] − > c a r b o h y d r a t e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l P r o t e i n ( g ) : </b> <td><?php $a = $ q u e r y [0] − > p r o t e i n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l Fat ( g ) : </b> <td><?php $a = $ q u e r y [0] − > f a t ; e c h o $a ; ?> </t r > <t r > <th>I n g r e d i e n t s </th> <th>Measure ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ r e c o m m e n d e d r e c i p e i d= $item−>r e c o m m e n d e d r e c i p e i d ?> <t r > <td><?= $item−>f o o d n a m e ?></td> <td><?php $b= $item−>measure ; $ c= $item−>s e r v i n g s i z e ; e c h o $b ∗ $ c ; ?> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <t d c l a s s = ” r e d b o x”><b>P r o c e d u r e : </b> <td><?php $a = $ q u e r y [0] − > p r e p a r a t i o n p r o c e d u r e ; e c h o $a ; ?> </t r > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / r e c o m m e n d e d s e l e c t b y d a t e ’” > Back</button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</ button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#viewFPBackButton , #viewFPHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { 153 $( } ); this ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; $ ( ”#v i e w F P D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 1100 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; $ ( document ) . r e a d y ( f u n c t i o n ( ) { var o p t i o n s = { chart : { r e n d e r T o : ’ weightChartBox ’ , type : ’ l i n e ’ , marginRight : 130 , marginBottom : 25 }, title : { t e x t : ’ Weight Monitor ’ , x : −20 // c e n t e r }, subtitle : { text : ’ ’ , x : −20 }, xAxis : { categories : [ ] }, yAxis : { title : { t e x t : ’ Weight ( kg ) ’ }, plotLines : [{ value : 0 , width : 1 , c o l o r : ’#808080 ’ }] }, tooltip : { /∗ f o r m a t t e r : f u n c t i o n ( ) { r e t u r n ’<b>’+ t h i s . s e r i e s . name +’</b><b r />’+ t h i s . x + ’ : ’+ t h i s . y ; }∗/ v a l u e S u f f i x : ’ kg ’ }, legend : { layout : ’ vertical ’ , align : ’ right ’ , v e r t i c a l A l i g n : ’ top ’ , x : −10 , y : 100 , borderWidth : 0 }, series : } [] $ . getJSON ( ” w e i g h t m o n i t o r g e t d a t a ” , f u n c t i o n ( j s o n ) { o p t i o n s . x A x i s . c a t e g o r i e s = j s o n [ 0 ] [ ’ data ’ ] ; options . s e r i e s [ 0 ] = json [ 1 ] ; options . s e r i e s [ 1 ] = json [ 2 ] ; // o p t i o n s . s e r i e s [ 2 ] = j s o n [ 3 ] ; c h a r t = new H i g h c h a r t s . Chart ( o p t i o n s ) ; }) ; $(”# s u c c e s s m s g ” ) . f a d e O u t ( 5 0 0 0 ) ; }) ; </ s c r i p t > </head> <body> <d i v i d =”v i e w F P D i a l o g ” t i t l e =” F i t n e s s P r o f i l e I n f o r m a t i o n ”> <br> <d i v i d =” s u c c e s s m s g ”> <c e n t e r ><f o n t c o l o r =”r e d ” s i z e =”2”><b><?php e c h o $ t h i s −>s e s s i o n −>f l a s h d a t a ( ’ s u c c e s s m s g ’ ) ; ?></b></f o n t ></c e n t e r > </d i v> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <?php i f ( ! empty ( $ q u e r y ) ) : ?> <t a b l e > <t r > <d i v i d =”w eigh tCha rtBo x ” s t y l e =”min−w i d t h : 400 px ; h e i g h t : 400 px ; margin : 0 a u t o”></d i v> </t r > <t r > <t h s t y l e =” d i s p l a y : none ;” >ID</th> <th>C u r r e n t Weight ( kg )</th> <th>Goal Weight ( kg )</th> <th>I d e a l Weight ( kg )</th> <th>H e i g h t (cm)</th> 154 <th>BMI</th> <th>BMI C l a s s i f i c a t i o n </th> <th>N u t r i t i o n a l S t a t u s </th> <th>Recommendation</th> <th>D a i l y C a l o r i e L i m i t ( Kcal )</th> <th>D a i l y C a r b o h y d r a t e L i m i t ( g )</th> <th>D a i l y P r o t e i n L i m i t ( g )</th> <th>D a i l y Fat L i m i t ( g )</th> <th>H e a l t h C o n d i t i o n </th> <th>Record Date</th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ f i t n e s s i n f o i d = $item−> f i t n e s s i n f o i d ?> <t r > <t d s t y l e =” d i s p l a y : none;”><?= $item−> f i t n e s s i n f o i d ?></td> <td><?= $item−>c u r r e n t w e i g h t ?></td> <td><?= $item−>g o a l w e i g h t ?></td> <td><?php i f ( $ g e n d e r = ” Male ” ) { i f ( ( $item−>h e i g h t ) > 1 5 2 . 4 ) { $IBW = ( ( ( ( $item−>h e i g h t ) − 1 5 2 . 4 ) ∗ ( 0 . 3 9 3 7 ) ) ∗ ( 2 . 3 ) ) + 5 0 ; e c h o round ($IBW) ; } else { $IBW = 5 0 ; e c h o round ($IBW) ; } } else { i f ( ( $item−>h e i g h t ) > 1 5 2 . 4 ) { $IBW = ( ( ( ( $item−>h e i g h t ) − 1 5 2 . 4 ) ∗ ( 0 . 3 9 3 7 ) ) ∗ ( 2 . 3 ) ) + 4 5 . 5 ; e c h o round ($IBW) ; } else { $IBW = 4 5 . 5 ; e c h o round ($IBW) ; } } ?> </td> <td><?= $item−>h e i g h t ?></td> <td><?= $BMI=round ( ( $item−>c u r r e n t w e i g h t ) / ( ( $item−>h e i g h t / 1 0 0 ) ∗ ( $item−>h e i g h t / 1 0 0 ) ) , 2 ) ?></ td> <td> <?php i f ( $BMI<=18.5) { echo ” Underweight ” ; } e l s e i f ( ( $BMI > 1 8 . 5 ) && ( $BMI <= 2 4 . 9 ) ) { e c h o ” Normal ” ; } e l s e i f ( $BMI > 2 4 . 9 && $BMI <= 2 9 . 9 ) { echo ” Overweight ” ; } e l s e i f ( $BMI > 2 9 . 9 && $BMI <= 3 9 . 9 ) { e c h o ” Obese ” ; } else { e c h o ” I n s a n e l y Obese ” ; } ?> </td> <td> <?php i f ( $BMI<=18.5) { echo ” Malnourished ” ; } e l s e i f ( ( $BMI > 1 8 . 5 ) && ( $BMI <= 2 4 . 9 ) ) { e c h o ” Normal ” ; } e l s e i f ( $BMI > 2 4 . 9 && $BMI <= 2 9 . 9 ) { echo ” Overnourished ” ; } e l s e i f ( $BMI > 2 9 . 9 && $BMI <= 3 9 . 9 ) { e c h o ” Very E x c e s s i v e l y N o u r i s h e d ” ; } else { echo ” O v e r f l o w i n g l y Nourished ” ; } ?> </td> <td> <?php i f ( $BMI<=18.5) { e c h o ” Gain Weight ” ; } e l s e i f ( ( $BMI > 1 8 . 5 ) && ( $BMI <= 2 4 . 9 ) ) { e c h o ” M a i n t a i n Weight ” ; } e l s e i f ( $BMI > 2 4 . 9 && $BMI <= 2 9 . 9 ) { e c h o ” L o s e Weight ” ; } e l s e i f ( $BMI > 2 9 . 9 && $BMI <= 3 9 . 9 ) { e c h o ” L o s e Weight ” ; } else { e c h o ” L o s e Weight ” ; } ?> </td> <td><?= $item−> c a l o r i e l i m i t ?></td> <td><?= $item−>c a r b o h y d r a t e l i m i t ?></td> <td><?= $item−>p r o t e i n l i m i t ?></td> <td><?= $item−>f a t l i m i t ?></td> <td><?= $item−>h e a l t h c o n d i t i o n ?></td> <td><?= d a t e ( ”Y−M−d ” , s t r t o t i m e ( $item−>r e c o r d d a t e ) ) ; ?></td> <td> <a h r e f = ” . . / h o m e u s e r / d e l e t e f i t n e s s p r o f i l e /<?php e c h o $ f i t n e s s i n f o i d ; ?>” o n c l i c k =” r e t u r n c o n f i r m ( ’ Are you s u r e you want t o d e l e t e ? ’ ) ”> <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> 155 < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =” D e l e t e ”> <span c l a s s =”u i −i c o n u i −i c o n −t r a s h ”></span> </ l i > </u l > </a> </td> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > <?php e l s e : ?> <?php e c h o ”No d a t a t o d i s p l a y . ” ; ?> <?php e n d i f ; ?> </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”viewFPBackButton ” t y p e=”b u t t o n ” name=”viewFPBackButton ” v a l u e =”Back ” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”viewFPHomeButton ” t y p e=”b u t t o n ” name=”viewFPHomeButton ” v a l u e =”Home” o n c l i c k =” window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” <br> false ; }, t i t l e =’View R e c i p e ’> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <t a b l e > <t r > <?php $a = $ q u e r y [0] − > img name ; $b = $ q u e r y [0] − > e x t ; ?> <img a l t =”” s r c =”<?= b a s e u r l ( ) . ’ u p l o a d s / ’ . $a . ’ . ’ . $b ;? >” h e i g h t =”250” w i d t h =”250”> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>R e c i p e Name: </b> <td><?php $a = $ q u e r y [0] − > r e c i p e n a m e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>S e r v i n g S i z e : </b> <td><?php $a = $ q u e r y [0] − > s e r v i n g s u g g ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>Meal Type: </b> <td><?php $a = $ q u e r y [0] − > m e a l t y p e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>H e a l t h C o n d i t i o n : </b> <td><?php $a = $ q u e r y [0] − > h e a l t h c o n d i t i o n ; e c h o $a ; ?> </t r > 156 <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a l o r i e s ( Kcal ) : </b> <td><?php $a = $ q u e r y [0] − > c a l o r i e s ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a r b o h y d r a t e s ( g ) : </b> <td><?php $a = $ q u e r y [0] − > c a r b o h y d r a t e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l P r o t e i n ( g ) : </b> <td><?php $a = $ q u e r y [0] − > p r o t e i n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l Fat ( g ) : </b> <td><?php $a = $ q u e r y [0] − > f a t ; e c h o $a ; ?> </t r > <t r > <th>I n g r e d i e n t s </th> <th>Measure ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ r e c o m m e n d e d r e c i p e i d= $item−>r e c o m m e n d e d r e c i p e i d ?> <t r > <td><?= $item−>f o o d n a m e ?></td> <td><?php $b= $item−>measure ; $ c= $item−>s e r v i n g s i z e ; e c h o $b ∗ $ c ; ?> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <t d c l a s s = ” r e d b o x”><b>P r o c e d u r e : </b> e c h o wordwrap ( $a , 1 5 , ”<br >\n ” , TRUE) ; ?> <td><?php $a = $ q u e r y [0] − > p r e p a r a t i o n p r o c e d u r e ; </t r > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager / s e a r c h m e a l ’” > Back</button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home </button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” <br> <?php if false ; }, t i t l e =’View R e c i p e ’> ( i s a r r a y ( $ q u e r y ) ) { ?> 157 <c e n t e r > <t a b l e > <t r > <?php $a = $ q u e r y [0] − > img name ; $b = $ q u e r y [0] − > e x t ; ?> <img a l t =”” s r c =”<?= b a s e u r l ( ) . ’ u p l o a d s / ’ . $a . ’ . ’ . $b ;? >” h e i g h t =”250” w i d t h =”250”> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>R e c i p e Name: </b> <td><?php $a = $ q u e r y [0] − > r e c i p e n a m e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>S e r v i n g S i z e : </b> <td><?php $a = $ q u e r y [0] − > s e r v i n g s u g g ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>Meal Type: </b> <td><?php $a = $ q u e r y [0] − > m e a l t y p e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>H e a l t h C o n d i t i o n : </b> <td><?php $a = $ q u e r y [0] − > h e a l t h c o n d i t i o n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a l o r i e s ( Kcal ) : </b> <td><?php $a = $ q u e r y [0] − > c a l o r i e s ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a r b o h y d r a t e s ( g ) : </b> <td><?php $a = $ q u e r y [0] − > c a r b o h y d r a t e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l P r o t e i n ( g ) : </b> <td><?php $a = $ q u e r y [0] − > p r o t e i n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l Fat ( g ) : </b> <td><?php $a = $ q u e r y [0] − > f a t ; e c h o $a ; ?> </t r > <t r > <th>I n g r e d i e n t s </th> <th>Measure ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ o w n r e c i p e i d= $item−>o w n r e c i p e i d ?> <t r > <td><?= $item−>f o o d n a m e ?></td> <td><?php $b= $item−>measure ; $ c= $item−>s e r v i n g s i z e ; e c h o $b ∗ $ c ; ?> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <t d c l a s s = ” r e d b o x”><b>P r o c e d u r e : </b> <td><?php $a = $ q u e r y [0] − > p r e p a r a t i o n p r o c e d u r e ; e c h o wordwrap ( $a , 1 5 , ”<br >\n ” , TRUE) ; ?> </t r > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s e a r c h m e a l ’” > Back</button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</ button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c $ ( ”# i c o n s l i ” ) . h o v e r ( function () { widgets 158 $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” <br> false ; }, t i t l e =’View R e c i p e ’> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <t a b l e > <t r > <?php $a = $ q u e r y [0] − > img name ; $b = $ q u e r y [0] − > e x t ; ?> <img a l t =”” s r c =”<?= b a s e u r l ( ) . ’ u p l o a d s / ’ . $a . ’ . ’ . $b ;? >” h e i g h t =”250” w i d t h =”250”> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>R e c i p e Name: </b> <td><?php $a = $ q u e r y [0] − > r e c i p e n a m e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>S e r v i n g S i z e : </b> <td><?php $a = $ q u e r y [0] − > s e r v i n g s u g g ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>Meal Type: </b> <td><?php $a = $ q u e r y [0] − > m e a l t y p e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>H e a l t h C o n d i t i o n : </b> <td><?php $a = $ q u e r y [0] − > h e a l t h c o n d i t i o n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a l o r i e s ( Kcal ) : </b> <td><?php $a = $ q u e r y [0] − > c a l o r i e s ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a r b o h y d r a t e s ( g ) : </b> <td><?php $a = $ q u e r y [0] − > c a r b o h y d r a t e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l P r o t e i n ( g ) : </b> <td><?php $a = $ q u e r y [0] − > p r o t e i n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l Fat ( g ) : </b> <td><?php $a = $ q u e r y [0] − > f a t ; e c h o $a ; ?> </t r > <t r > <th>I n g r e d i e n t s </th> <th>Measure ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ r e c o m m e n d e d r e c i p e i d= $item−>r e c o m m e n d e d r e c i p e i d ?> <t r > <td><?= $item−>f o o d n a m e ?></td> <td><?php $b= $item−>measure ; $ c= $item−>s e r v i n g s i z e ; e c h o $b ∗ $ c ; ?> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <t d c l a s s = ” r e d b o x”><b>P r o c e d u r e : </b> <td><?php $a = $ q u e r y [0] − > p r e p a r a t i o n p r o c e d u r e ; e c h o wordwrap ( $a , 1 5 , ”<br >\n ” , TRUE) ; ?> </t r > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager / s h o w c r e a t e d r e c i p e s ’” > Back</button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home </button> </d i v> </body> </html> <html l a n g =”en”> 159 <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” <br> false ; }, t i t l e =’View R e c i p e ’> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <t a b l e > <t r > <?php $a = $ q u e r y [0] − > img name ; $b = $ q u e r y [0] − > e x t ; ?> <img a l t =”” s r c =”<?= b a s e u r l ( ) . ’ u p l o a d s / ’ . $a . ’ . ’ . $b ;? >” h e i g h t =”250” w i d t h =”250”> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>R e c i p e Name: </b> <td><?php $a = $ q u e r y [0] − > r e c i p e n a m e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>S e r v i n g S i z e : </b> <td><?php $a = $ q u e r y [0] − > s e r v i n g s u g g ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>Meal Type: </b> <td><?php $a = $ q u e r y [0] − > m e a l t y p e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>H e a l t h C o n d i t i o n : </b> <td><?php $a = $ q u e r y [0] − > h e a l t h c o n d i t i o n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a l o r i e s ( Kcal ) : </b> <td><?php $a = $ q u e r y [0] − > c a l o r i e s ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a r b o h y d r a t e s ( g ) : </b> <td><?php $a = $ q u e r y [0] − > c a r b o h y d r a t e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l P r o t e i n ( g ) : </b> <td><?php $a = $ q u e r y [0] − > p r o t e i n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l Fat ( g ) : </b> <td><?php $a = $ q u e r y [0] − > f a t ; e c h o $a ; ?> </t r > <t r > <th>I n g r e d i e n t s </th> <th>Measure ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ o w n r e c i p e i d= $item−>o w n r e c i p e i d ?> <t r > <td><?= $item−>f o o d n a m e ?></td> <td><?php $b= $item−>measure ; $ c= $item−>s e r v i n g s i z e ; e c h o $b ∗ $ c ; 160 ?> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <t d c l a s s = ” r e d b o x”><b>P r o c e d u r e : </b></td> <td><?php $a = $ q u e r y [0] − > p r e p a r a t i o n p r o c e d u r e ; e c h o wordwrap ( $a , 1 5 , ”<br >\n ” , TRUE) ; ?></td > </d i v> </t r > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h o w c r e a t e d r e c i p e s ’” > Back</button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</ button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” <br> false ; }, t i t l e =’View R e c i p e ’> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <t a b l e > <t r > <?php $a = $ q u e r y [0] − > img name ; $b = $ q u e r y [0] − > e x t ; ?> <img a l t =”” s r c =”<?= b a s e u r l ( ) . ’ u p l o a d s / ’ . $a . ’ . ’ . $b ;? >” h e i g h t =”250” w i d t h =”250”> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>R e c i p e Name: </b> <td><?php $a = $ q u e r y [0] − > r e c i p e n a m e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>S e r v i n g S i z e : </b> <td><?php $a = $ q u e r y [0] − > s e r v i n g s u g g ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>Meal Type: </b> <td><?php $a = $ q u e r y [0] − > m e a l t y p e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>H e a l t h C o n d i t i o n : </b> <td><?php $a = $ q u e r y [0] − > h e a l t h c o n d i t i o n ; e c h o $a ; ?> </t r > <t r > 161 <t d c l a s s = ” r e d b o x”><b>T o t a l C a l o r i e s ( Kcal ) : </b> <td><?php $a = $ q u e r y [0] − > c a l o r i e s ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a r b o h y d r a t e s ( g ) : </b> <td><?php $a = $ q u e r y [0] − > c a r b o h y d r a t e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l P r o t e i n ( g ) : </b> <td><?php $a = $ q u e r y [0] − > p r o t e i n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l Fat ( g ) : </b> <td><?php $a = $ q u e r y [0] − > f a t ; e c h o $a ; ?> </t r > <t r > <th>I n g r e d i e n t s </th> <th>Measure ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ o w n r e c i p e i d= $item−>o w n r e c i p e i d ?> <t r > <td><?= $item−>f o o d n a m e ?></td> <td><?php $b= $item−>measure ; $ c= $item−>s e r v i n g s i z e ; e c h o $b ∗ $ c ; ?> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <t d c l a s s = ” r e d b o x”><b>P r o c e d u r e : </b> <td><?php $a = $ q u e r y [0] − > p r e p a r a t i o n p r o c e d u r e ; e c h o wordwrap ( $a , 1 5 , ”<br >\n ” , TRUE) ; ?> </t r > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s e l e c t b y d a t e ’” > Back</button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</ button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” <br> false ; }, t i t l e =’View R e c i p e ’> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > 162 <t a b l e > <t r > <?php $a = $ q u e r y [0] − > img name ; $b = $ q u e r y [0] − > e x t ; ?> <img a l t =”” s r c =”<?= b a s e u r l ( ) . ’ u p l o a d s / ’ . $a . ’ . ’ . $b ;? >” h e i g h t =”250” w i d t h =”250”> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>R e c i p e Name: </b> <td><?php $a = $ q u e r y [0] − > r e c i p e n a m e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>S e r v i n g S i z e : </b> <td><?php $a = $ q u e r y [0] − > s e r v i n g s u g g ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>Meal Type: </b> <td><?php $a = $ q u e r y [0] − > m e a l t y p e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>H e a l t h C o n d i t i o n : </b> <td><?php $a = $ q u e r y [0] − > h e a l t h c o n d i t i o n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a l o r i e s ( Kcal ) : </b> <td><?php $a = $ q u e r y [0] − > c a l o r i e s ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a r b o h y d r a t e s ( g ) : </b> <td><?php $a = $ q u e r y [0] − > c a r b o h y d r a t e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l P r o t e i n ( g ) : </b> <td><?php $a = $ q u e r y [0] − > p r o t e i n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l Fat ( g ) : </b> <td><?php $a = $ q u e r y [0] − > f a t ; e c h o $a ; ?> </t r > <t r > <th>I n g r e d i e n t s </th> <th>Measure ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ r e c o m m e n d e d r e c i p e i d= $item−>r e c o m m e n d e d r e c i p e i d ?> <t r > <td><?= $item−>f o o d n a m e ?></td> <td><?php $b= $item−>measure ; $ c= $item−>s e r v i n g s i z e ; e c h o $b ∗ $ c ; ?> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <t d c l a s s = ” r e d b o x”><b>P r o c e d u r e : </b> <td><?php $a = $ q u e r y [0] − > p r e p a r a t i o n p r o c e d u r e ; e c h o wordwrap ( $a , 1 5 , ”<br >\n ” , TRUE) ; ?> </t r > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager / s e l e c t b y d a t e ’” > Back</button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>home cmanager ’” >Home </button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; 163 }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” <br> false ; }, t i t l e =’View R e c i p e ’> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <t a b l e > <t r > <?php $a = $ q u e r y [0] − > img name ; $b = $ q u e r y [0] − > e x t ; ?> <img a l t =”” s r c =”<?= b a s e u r l ( ) . ’ u p l o a d s / ’ . $a . ’ . ’ . $b ;? >” h e i g h t =”250” w i d t h =”250”> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>R e c i p e Name: </b> <td><?php $a = $ q u e r y [0] − > r e c i p e n a m e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>S e r v i n g S i z e : </b> <td><?php $a = $ q u e r y [0] − > s e r v i n g s u g g ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>Meal Type: </b> <td><?php $a = $ q u e r y [0] − > m e a l t y p e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>H e a l t h C o n d i t i o n : </b> <td><?php $a = $ q u e r y [0] − > h e a l t h c o n d i t i o n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a l o r i e s ( Kcal ) : </b> <td><?php $a = $ q u e r y [0] − > c a l o r i e s ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a r b o h y d r a t e s ( g ) : </b> <td><?php $a = $ q u e r y [0] − > c a r b o h y d r a t e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l P r o t e i n ( g ) : </b> <td><?php $a = $ q u e r y [0] − > p r o t e i n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l Fat ( g ) : </b> <td><?php $a = $ q u e r y [0] − > f a t ; e c h o $a ; ?> </t r > <t r > <th>I n g r e d i e n t s </th> <th>Measure ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ r e c o m m e n d e d r e c i p e i d= $item−>r e c o m m e n d e d r e c i p e i d ?> <t r > <td><?= $item−>f o o d n a m e ?></td> <td><?php $b= $item−>measure ; $ c= $item−>s e r v i n g s i z e ; e c h o $b ∗ $ c ; ?> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <t d c l a s s = ” r e d b o x”><b>P r o c e d u r e : </b> <td><?php $a = $ q u e r y [0] − > p r e p a r a t i o n p r o c e d u r e ; e c h o wordwrap ( $a , 1 5 , ”<br >\n ” , TRUE) ; ?> </t r > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h o w r e c o m m e n d e d r e c i p e s ’” > Back</button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</ button> </d i v> </body> </html> <html l a n g =”en”> <head> 164 <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#userSearchRRBackButton , #userSearchRRButton , #userSearchRRHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” t i t l e =”Recommended R e c i p e s ”> <br> <?=f o r m o p e n ( ’ h o m e u s e r / s e a r c h r e c r e c ’ ) ;? > <?php $ s e a r c h r e c r e c = a r r a y ( ’ name’=>’ s e a r c h r e c r e c ’ , ’ i d ’=>’ s e a r c h r e c r e c ’ , ’ v a l u e ’ = > ’ ’ , ) ; ?> <c e n t e r >Recommended R e c i p e s : <?=f o r m i n p u t ( $ s e a r c h r e c r e c ) ;? > <b u t t o n i d =”u s e r S e a r c h R R B u t t o n ” t y p e=”s u b m i t ” v a l u e =”” t i t l e =”S e a r c h Recommended R e c i p e s ”> S e a r c h </button> <b u t t o n i d =”userSearchRRBackButton ” t y p e=”b u t t o n ” name=”userSearchRRBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”userSearchRRHomeButton ” t y p e=”b u t t o n ” name=”userSearchRRHomeButton ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </ c e n t e r > <?= f o r m c l o s e ( ) ;? > <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <?php i f ( ! empty ( $ q u e r y ) ) : ?> <t a b l e > <t r > <t h s t y l e =” d i s p l a y : none ;” >ID</th> <th>H e a l t h C o n d i t i o n </th> <th>Meal Type</th> <th>R e c i p e Name</th> <th>S e r v i n g S i z e </th> <th>T o t a l C a l o r i e s ( Kcal )</th> <th>T o t a l C a r b o h y d r a t e ( g )</th> <th>T o t a l P r o t e i n ( g )</th> <th>T o t a l Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ r e c o m m e n d e d r e c i p e i d= $item−>r e c o m m e n d e d r e c i p e i d ?> <?php $ r e c i p e n a m e= $item−>r e c i p e n a m e ?> <t r > <t d s t y l e =” d i s p l a y : none;”><?= $item−>r e c o m m e n d e d r e c i p e i d ?></td> <td><?= $item−>h e a l t h c o n d i t i o n ?></td> <td><?= $item−>m e a l t y p e ?></td> <td><?= $item−>r e c i p e n a m e ?></td> <td><?= $item−>s e r v i n g s u g g ?></td> <td><?= $item−>c a l o r i e s ?></td> <td><?= $item−>c a r b o h y d r a t e ?></td> <td><?= $item−>p r o t e i n ?></td> <td><?= $item−>f a t ?></td> <td> <a h r e f = ” . . / h o m e u s e r / v i e w r e c o m m e n d e d r e c i p e /<?php e c h o $ r e c o m m e n d e d r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −f o l d e r −open”></span> </ l i > </u l > </a> </td> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > <?php e l s e : ?> 165 <?php e c h o ”No d a t a t o <?php e n d i f ; ?> </ c e n t e r > <?php } ?> <br> </d i v> </body> </html> d i s p l a y . ” ; ?> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#v i e w C r e a t e d R e c i p e s B a c k B u t t o n , #v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” <br> false ; }, t i t l e =’View R e c i p e ’> <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <t a b l e > <t r > <?php $a = $ q u e r y [0] − > img name ; $b = $ q u e r y [0] − > e x t ; ?> <img a l t =”” s r c =”<?= b a s e u r l ( ) . ’ u p l o a d s / ’ . $a . ’ . ’ . $b ;? >” h e i g h t =”250” w i d t h =”250”> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>R e c i p e Name: </b> <td><?php $a = $ q u e r y [0] − > r e c i p e n a m e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>S e r v i n g S i z e : </b> <td><?php $a = $ q u e r y [0] − > s e r v i n g s u g g ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>Meal Type: </b> <td><?php $a = $ q u e r y [0] − > m e a l t y p e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>H e a l t h C o n d i t i o n : </b> <td><?php $a = $ q u e r y [0] − > h e a l t h c o n d i t i o n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a l o r i e s ( Kcal ) : </b> <td><?php $a = $ q u e r y [0] − > c a l o r i e s ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l C a r b o h y d r a t e s ( g ) : </b> <td><?php $a = $ q u e r y [0] − > c a r b o h y d r a t e ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l P r o t e i n ( g ) : </b> <td><?php $a = $ q u e r y [0] − > p r o t e i n ; e c h o $a ; ?> </t r > <t r > <t d c l a s s = ” r e d b o x”><b>T o t a l Fat ( g ) : </b> <td><?php $a = $ q u e r y [0] − > f a t ; e c h o $a ; ?> </t r > 166 <t r > <th>I n g r e d i e n t s </th> <th>Measure ( g )</th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ s h a r e d r e c i p e i d= $item−>s h a r e d r e c i p e i d ?> <t r > <td><?= $item−>f o o d n a m e ?></td> <td><?php $b= $item−>measure ; $ c= $item−>s e r v i n g s i z e ; e c h o $b ∗ $ c ; ?> </td> </t r > <?php e n d f o r e a c h ;? > <t r > <t d c l a s s = ” r e d b o x”><b>P r o c e d u r e : </b> e c h o wordwrap ( $a , 1 5 , ”<br >\n ” , TRUE) ; ?> <td><?php $a = $ q u e r y [0] − > p r e p a r a t i o n p r o c e d u r e ; </t r > </ t a b l e > </ c e n t e r > <?php } ?> <br> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s B a c k B u t t o n ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r / s h o w s h a r e d r e c i p e s ’” > Back</button> <b u t t o n i d =”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” t y p e=”b u t t o n ” name=”v i e w C r e a t e d R e c i p e s H o m e B u t t o n ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</ button> </d i v> </body> </html> <html l a n g =”en”> <head> <meta c h a r s e t =” u t f −8”> < t i t l e >H e a l t h y E a t i n g A l e r t System </ t i t l e > < l i n k r e l =” i c o n ” t y p e=”image / i c o ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / i m a g e s / h e a s f i m i c o n . i c o ”> < l i n k r e l =” s t y l e s h e e t ” t y p e=” t e x t / c s s ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / s t y l e . c s s ”> < l i n k r e l =” s t y l e s h e e t ” h r e f =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / c s s / b l i t z e r / j q u e r y −u i − 1 . 1 0 . 3 . custom . c s s ” /> < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y − 1 . 9 . 1 . j s ”></ script > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ;? > l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / j s / j q u e r y −u i − 1 . 1 0 . 3 . custom . j s ”></ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y −v a l i d a t i o n − 1 . 1 1 . 1 / d i s t / j q u e r y . v a l i d a t e . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> v a l i d a t i o n / j q u e r y − 1 . 1 1 . 0 . min . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / h i g h c h a r t s . j s ”</ s c r i p t > < s c r i p t s r c =”<?php e c h o b a s e u r l ( ) ; ?> c h a r t / e x p o r t i n g . j s ”</ s c r i p t > <s c r i p t > $( function () { $ ( ”#userSearchRRBackButton , #userSearchRRButton , #userSearchRRHomeButton ” ) . b u t t o n ( ) ; // Hover s t a t e s on t h e s t a t i c w i d g e t s $ ( ”# i c o n s l i ” ) . h o v e r ( function () { $ ( t h i s ) . a d d C l a s s ( ” u i −s t a t e −h o v e r ” ) ; }, function () { $ ( t h i s ) . r e m o v e C l a s s ( ” u i −s t a t e −h o v e r ” ) ; } ); $ ( ”#v i e w C r e a t e d R e c i p e s D i a l o g ” ) . d i a l o g ( { autoOpen : t r u e , width : 950 , modal : t r u e , closeOnEscape : f a l s e , b e f o r e c l o s e : f u n c t i o n ( event , u i ) { r e t u r n dialogClass : ” noclose ” false ; }, }) ; }) ; </ s c r i p t > </head> <body> <d i v i d =” v i e w C r e a t e d R e c i p e s D i a l o g ” t i t l e =”S h a r e d R e c i p e s ”> <br> <?=f o r m o p e n ( ’ h o m e u s e r / s e a r c h s h a r e d r e c ’ ) ;? > <?php $ s e a r c h s h a r e d r e c = a r r a y ( ’ name’=>’ s e a r c h s h a r e d r e c ’ , ’ i d ’=>’ s e a r c h s h a r e d r e c ’ , ’ v a l u e ’ = > ’ ’ , ) ; ?> <c e n t e r >S h a r e d R e c i p e s : <?=f o r m i n p u t ( $ s e a r c h s h a r e d r e c ) ;? > <b u t t o n i d =”u s e r S e a r c h R R B u t t o n ” t y p e=”s u b m i t ” v a l u e =”” t i t l e =”S e a r c h S h a r e d R e c i p e s ”>S e a r c h </ button> <b u t t o n i d =”userSearchRRBackButton ” t y p e=”b u t t o n ” name=”userSearchRRBackButton ” v a l u e =”Back ” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” > Back</button> <b u t t o n i d =”userSearchRRHomeButton ” t y p e=”b u t t o n ” name=”userSearchRRHomeButton ” v a l u e =”Home” o n c l i c k =”window . l o c a t i o n . h r e f =’<?php e c h o s i t e u r l ( ) ; ?>h o m e u s e r ’” >Home</button> </ c e n t e r > <?= f o r m c l o s e ( ) ;? > <?php i f ( i s a r r a y ( $ q u e r y ) ) { ?> <c e n t e r > <?php i f ( ! empty ( $ q u e r y ) ) : ?> <t a b l e > <t r > 167 <t h s t y l e =” d i s p l a y : none ;” >ID</th> <th>H e a l t h C o n d i t i o n </th> <th>Meal Type</th> <th>R e c i p e Name</th> <th>S e r v i n g S i z e </th> <th>T o t a l C a l o r i e s ( Kcal )</th> <th>T o t a l C a r b o h y d r a t e ( g )</th> <th>T o t a l P r o t e i n ( g )</th> <th>T o t a l Fat ( g )</th> <th>A c t i o n s </th> </t r > <?php f o r e a c h ( $ q u e r y a s $ i t e m ) : ?> <?php $ s h a r e d r e c i p e i d= $item−>s h a r e d r e c i p e i d ?> <?php $ r e c i p e n a m e= $item−>r e c i p e n a m e ?> <t r > <t d s t y l e =” d i s p l a y : none;”><?= $item−>s h a r e d r e c i p e i d ?></td> <td><?= $item−>h e a l t h c o n d i t i o n ?></td> <td><?= $item−>m e a l t y p e ?></td> <td><?= $item−>r e c i p e n a m e ?></td> <td><?= $item−>s e r v i n g s u g g ?></td> <td><?= $item−>c a l o r i e s ?></td> <td><?= $item−>c a r b o h y d r a t e ?></td> <td><?= $item−>p r o t e i n ?></td> <td><?= $item−>f a t ?></td> <td> <a h r e f = ” . . / h o m e u s e r / v i e w s h a r e d r e c i p e /<?php e c h o $ s h a r e d r e c i p e i d ; ?>” > <u l i d =” i c o n s ” c l a s s =”u i −w i d g e t u i −h e l p e r − c l e a r f i x ”> < l i c l a s s =”u i −s t a t e −d e f a u l t u i −c o r n e r − a l l ” t i t l e =”View R e c i p e”> <span c l a s s =”u i −i c o n u i −i c o n −f o l d e r −open”></span> </ l i > </u l > </a> </td> </t r > <?php e n d f o r e a c h ;? > </ t a b l e > <?php e l s e : ?> <?php e c h o ”No d a t a t o d i s p l a y . ” ; ?> <?php e n d i f ; ?> </ c e n t e r > <?php } ?> <br> </d i v> </body> </html> B. B..1 Source Code Configs <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; /∗ | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | AUTO−LOADER | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | T h i s f i l e s p e c i f i e s which s y s t e m s s h o u l d be l o a d e d by d e f a u l t . | | I n o r d e r t o k e e p t h e framework a s l i g h t −w e i g h t a s p o s s i b l e o n l y t h e | a b s o l u t e minimal r e s o u r c e s a r e l o a d e d by d e f a u l t . For example , | t h e d a t a b a s e i s n o t c o n n e c t e d t o a u t o m a t i c a l l y s i n c e no a s s u m p t i o n | i s made r e g a r d i n g w h e t h e r you i n t e n d t o u s e i t . This f i l e l e t s | you g l o b a l l y d e f i n e which s y s t e m s you would l i k e l o a d e d w i t h e v e r y | request . | | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Instructions | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | These a r e t h e t h i n g s you can l o a d a u t o m a t i c a l l y : | | 1 . Packages | 2. Libraries | 3 . Helper f i l e s | 4 . Custom c o n f i g f i l e s | 5 . Language f i l e s | 6 . Models | ∗/ /∗ | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Auto−l o a d P a c k g e s | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Prototype : | | $ a u t o l o a d [ ’ p a c k a g e s ’ ] = a r r a y (APPPATH. ’ t h i r d p a r t y ’ , ’ / u s r / l o c a l / s h a r e d ’ ) ; | ∗/ $autoload [ ’ packages ’ ] = array ( ) ; /∗ | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Auto−l o a d L i b r a r i e s 168 | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | These a r e t h e c l a s s e s l o c a t e d i n t h e s y s t e m / l i b r a r i e s f o l d e r | or i n your a p p l i c a t i o n / l i b r a r i e s f o l d e r . | | Prototype : | | $ a u t o l o a d [ ’ l i b r a r i e s ’ ] = a r r a y ( ’ d a t a b a s e ’ , ’ s e s s i o n ’ , ’ xmlrpc ’ ) ; ∗/ $autoload [ ’ l i b r a r i e s ’ ] = array ( ’ database ’ , ’ s e s s i o n ’ , ’ facebook ’ ) ; /∗ | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Auto−l o a d H e l p e r F i l e s | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Prototype : | | $autoload [ ’ helper ’ ] = array ( ’ url ’ , ’ f i l e ’ ) ; ∗/ $ a u t o l o a d [ ’ h e l p e r ’ ] = a r r a y ( ’ html ’ , ’ form ’ , ’ u r l ’ , ’ f i l e ’ ) ; /∗ | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Auto−l o a d C o n f i g f i l e s | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Prototype : | | $autoload [ ’ config ’ ] = array ( ’ config1 ’ , ’ config2 ’ ) ; | | NOTE: T h i s i t e m i s i n t e n d e d f o r u s e ONLY i f you have c r e a t e d custom | config f i l e s . Otherwise , l e a v e i t blank . | ∗/ $autoload [ ’ config ’ ] = array () ; /∗ | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Auto−l o a d Language f i l e s | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Prototype : | | $autoload [ ’ language ’ ] = array ( ’ lang1 ’ , ’ lang2 ’ ) ; | For example | NOTE: Do n o t i n c l u d e t h e ” l a n g ” p a r t o f y o u r f i l e . | ” c o d e i g n i t e r l a n g . php ” would be r e f e r e n c e d a s a r r a y ( ’ c o d e i g n i t e r ’ ) ; | ∗/ $autoload [ ’ language ’ ] = array ( ) ; /∗ | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Auto−l o a d Models | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Prototype : | | $ a u t o l o a d [ ’ model ’ ] = a r r a y ( ’ model1 ’ , ’ model2 ’ ) ; | ∗/ $ a u t o l o a d [ ’ model ’ ] = a r r a y ( ) ; /∗ End o f f i l e a u t o l o a d . php ∗/ /∗ L o c a t i o n : . / a p p l i c a t i o n / c o n f i g / a u t o l o a d . php ∗/ <?php if ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t script access allowed ’ ) ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Base S i t e URL |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | URL t o y o u r C o d e I g n i t e r r o o t . T y p i c a l l y t h i s w i l l be y o u r b a s e URL, | WITH a t r a i l i n g s l a s h : | | h t t p : / / example . com/ | | I f t h i s i s n o t s e t t h e n C o d e I g n i t e r w i l l g u e s s t h e p r o t o c o l , domain and | path t o y o u r i n s t a l l a t i o n . | ∗/ $config [ ’ base url ’ ] = ’ h t t p s : / / a g i l a . upm . edu . ph /˜ p j d i z o n /FIM / ’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Index F i l e |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | T y p i c a l l y t h i s w i l l be y o u r i n d e x . php f i l e , u n l e s s you ’ ve renamed i t t o | s o m e t h i n g e l s e . I f you a r e u s i n g m o d r e w r i t e t o remove t h e page s e t t h i s | v a r i a b l e so that i t i s blank . 169 | ∗/ $ co n fi g [ ’ index page ’ ] = ’ ’; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | URI PROTOCOL |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | T h i s i t e m d e t e r m i n e s which s e r v e r g l o b a l s h o u l d be u s e d t o r e t r i e v e t h e | URI s t r i n g . The d e f a u l t s e t t i n g o f ’AUTO’ works f o r most s e r v e r s . | I f y o u r l i n k s do n o t seem t o work , t r y one o f t h e o t h e r d e l i c i o u s f l a v o r s : | | ’AUTO’ D e f a u l t − auto d e t e c t s U s e s t h e PATH INFO | ’PATH INFO ’ | ’QUERY STRING’ U s e s t h e QUERY STRING U s e s t h e REQUEST URI | ’REQUEST URI ’ U s e s t h e ORIG PATH INFO | ’ ORIG PATH INFO ’ | ∗/ $ c o n f i g [ ’ u r i p r o t o c o l ’ ] = ’AUTO’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | URL s u f f i x |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | T h i s o p t i o n a l l o w s you t o add a s u f f i x t o a l l URLs g e n e r a t e d by C o d e I g n i t e r . | For more i n f o r m a t i o n p l e a s e s e e t h e u s e r g u i d e : | | h t t p : / / c o d e i g n i t e r . com/ u s e r g u i d e / g e n e r a l / u r l s . html ∗/ $config [ ’ url suffix ’ ] = ’ ’; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | D e f a u l t Language |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | T h i s d e t e r m i n e s which s e t o f l a n g u a g e f i l e s s h o u l d be u s e d . Make s u r e | t h e r e i s an a v a i l a b l e t r a n s l a t i o n i f you i n t e n d t o u s e s o m e t h i n g o t h e r | than e n g l i s h . | ∗/ $ c o n f i g [ ’ language ’ ] = ’ english ’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Default Character Set |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | T h i s d e t e r m i n e s which c h a r a c t e r s e t i s u s e d by d e f a u l t i n v a r i o u s methods | t h a t r e q u i r e a c h a r a c t e r s e t t o be p r o v i d e d . | ∗/ $ c o n f i g [ ’ c h a r s e t ’ ] = ’UTF− 8 ’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | E n a b l e / D i s a b l e System Hooks |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | I f you would l i k e t o u s e t h e ’ hooks ’ f e a t u r e you must e n a b l e i t by | s e t t i n g t h i s v a r i a b l e t o TRUE ( b o o l e a n ) . See the u s e r guide f o r d e t a i l s . | ∗/ $ c o n f i g [ ’ e n a b l e h o o k s ’ ] = FALSE ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Class Extension Prefix |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | T h i s i t e m a l l o w s you t o s e t t h e f i l e n a m e / c l a s s n a m e p r e f i x when e x t e n d i n g | native l i b r a r i e s . For more i n f o r m a t i o n p l e a s e s e e t h e u s e r g u i d e : | | h t t p : / / c o d e i g n i t e r . com/ u s e r g u i d e / g e n e r a l / c o r e c l a s s e s . html | h t t p : / / c o d e i g n i t e r . com/ u s e r g u i d e / g e n e r a l / c r e a t i n g l i b r a r i e s . html | ∗/ $ c o n f i g [ ’ s u b c l a s s p r e f i x ’ ] = ’MY ’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | A l l o w e d URL C h a r a c t e r s |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | T h i s l e t s you s p e c i f y w i t h a r e g u l a r e x p r e s s i o n which c h a r a c t e r s a r e p e r m i t t e d | w i t h i n y o u r URLs . When someone t r i e s t o s u b m i t a URL w i t h d i s a l l o w e d | c h a r a c t e r s they w i l l g e t a warning message . | | As a s e c u r i t y measure you a r e STRONGLY e n c o u r a g e d t o r e s t r i c t URLs t o | a s few c h a r a c t e r s a s p o s s i b l e . By d e f a u l t o n l y t h e s e a r e a l l o w e d : a−z 0 −9˜%.: − | | Leave b l a n k t o a l l o w a l l c h a r a c t e r s −− but o n l y i f you a r e i n s a n e . | 170 | DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS ! ! | ∗/ $ c o n f i g [ ’ p e r m i t t e d u r i c h a r s ’ ] = ’ a−z 0 −9˜%.: \ − ’; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | E n a b l e Query S t r i n g s |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | By d e f a u l t C o d e I g n i t e r u s e s s e a r c h −e n g i n e f r i e n d l y segment b a s e d URLs : | example . com/who/ what / where / | I f f o r some | By d e f a u l t C o d e I g n i t e r e n a b l e s a c c e s s t o t h e $ GET a r r a y . | r e a s o n you would l i k e t o d i s a b l e i t , s e t ’ a l l o w g e t a r r a y ’ t o FALSE . | | You can o p t i o n a l l y e n a b l e s t a n d a r d q u e r y s t r i n g b a s e d URLs : | example . com?who=me&what=s o m e t h i n g&where=h e r e | | O p t i o n s a r e : TRUE o r FALSE ( b o o l e a n ) | | The o t h e r i t e m s l e t you s e t t h e q u e r y s t r i n g ’ words ’ t h a t w i l l | i n v o k e y o u r c o n t r o l l e r s and i t s f u n c t i o n s : | example . com/ i n d e x . php ? c=c o n t r o l l e r&m=f u n c t i o n | | P l e a s e n o t e t h a t some o f t h e h e l p e r s won ’ t work a s e x p e c t e d when | t h i s f e a t u r e i s enabled , s i n c e CodeIgniter i s designed p r i m a r i l y to | u s e segment b a s e d URLs . | ∗/ = TRUE; $config [ ’ allow get array ’ ] $ c o n f i g [ ’ e n a b l e q u e r y s t r i n g s ’ ] = FALSE ; $config [ ’ controller trigger ’ ] = ’c ’ ; $config [ ’ function trigger ’ ] = ’m’ ; $config [ ’ directory trigger ’ ] = ’ d ’ ; // e x p e r i m e n t a l n o t c u r r e n t l y i n u s e /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Error Logging Threshold |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | I f you have e n a b l e d e r r o r l o g g i n g , you can s e t an e r r o r t h r e s h o l d t o | d e t e r m i n e what g e t s l o g g e d . T h r e s h o l d o p t i o n s a r e : | You can e n a b l e e r r o r l o g g i n g by s e t t i n g a t h r e s h o l d o v e r z e r o . The | t h r e s h o l d d e t e r m i n e s what g e t s l o g g e d . T h r e s h o l d o p t i o n s a r e : | | 0 = D i s a b l e s l o g g i n g , E r r o r l o g g i n g TURNED OFF | 1 = E r r o r M e s s a g e s ( i n c l u d i n g PHP e r r o r s ) | 2 = Debug M e s s a g e s | 3 = I n f o r m a t i o n a l Messages | 4 = A l l Messages | | For a l i v e s i t e you ’ l l u s u a l l y o n l y e n a b l e E r r o r s ( 1 ) t o be l o g g e d o t h e r w i s e | y o u r l o g f i l e s w i l l f i l l up v e r y f a s t . | ∗/ $config [ ’ log threshold ’ ] = 0; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | E r r o r L o g g i n g D i r e c t o r y Path |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | Leave t h i s BLANK u n l e s s you would l i k e t o s e t s o m e t h i n g o t h e r than t h e d e f a u l t | a p p l i c a t i o n / l o g s / f o l d e r . Use a f u l l s e r v e r path w i t h t r a i l i n g s l a s h . | ∗/ $config [ ’ log path ’ ] = ’ ’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Date Format f o r Logs |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | Each i t e m t h a t i s l o g g e d h a s an a s s o c i a t e d d a t e . You can u s e PHP d a t e | c o d e s t o s e t y o u r own d a t e f o r m a t t i n g | ∗/ $ c o n f i g [ ’ l o g d a t e f o r m a t ’ ] = ’Y−m−d H : i : s ’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Cache D i r e c t o r y Path |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | Leave t h i s BLANK u n l e s s you would l i k e t o s e t s o m e t h i n g o t h e r than t h e d e f a u l t | system / cache / f o l d e r . Use a f u l l s e r v e r path w i t h t r a i l i n g s l a s h . | ∗/ $ c o n f i g [ ’ cache path ’ ] = ’ ’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | E n c r y p t i o n Key |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | I f you u s e t h e E n c r y p t i o n c l a s s o r t h e S e s s i o n c l a s s you | MUST s e t an e n c r y p t i o n key . See the u s e r guide f o r i n f o . 171 | ∗/ $ c o n f i g [ ’ e n c r y p t i o n k e y ’ ] = ’REALLY LONG NUMBER’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Session Variables |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | = t h e name you want f o r t h e c o o k i e | ’ sess cookie name ’ | ’ sess expiration ’ = t h e number o f SECONDS you want t h e s e s s i o n t o l a s t . | by d e f a u l t s e s s i o n s l a s t 7200 s e c o n d s ( two h o u r s ) . S e t t o z e r o f o r no e x p i r a t i o n . = Whether t o c a u s e t h e s e s s i o n t o e x p i r e a u t o m a t i c a l l y | ’ sess expire on close ’ | when t h e b r o w s e r window i s c l o s e d | ’ sess encrypt cookie ’ = Whether t o e n c r y p t t h e c o o k i e | ’ sess use database ’ = Whether t o s a v e t h e s e s s i o n d a t a t o a d a t a b a s e = The name o f t h e s e s s i o n d a t a b a s e t a b l e | ’ sess table name ’ = Whether t o match t h e u s e r ’ s IP a d d r e s s when r e a d i n g | ’ sess match ip ’ the s e s s i o n data | ’ sess match useragent ’ = Whether t o match t h e U s e r Agent when r e a d i n g t h e s e s s i o n data = how many s e c o n d s between CI r e f r e s h i n g S e s s i o n I n f o r m a t i o n | ’ sess time to update ’ | ∗/ $config [ ’ sess cookie name ’ ] = ’ ci session ’ ; = 7200; $config [ ’ sess expiration ’ ] $ c o n f i g [ ’ s e s s e x p i r e o n c l o s e ’ ] = FALSE ; $config [ ’ sess encrypt cookie ’ ] = FALSE ; $config [ ’ sess use database ’ ] = FALSE ; = ’ ci sessions ’; $config [ ’ sess table name ’ ] $config [ ’ sess match ip ’ ] = FALSE ; $ c o n f i g [ ’ s e s s m a t c h u s e r a g e n t ’ ] = TRUE; = 300; $config [ ’ sess time to update ’ ] /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Cookie Related V a r i a b l e s |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | ’ c o o k i e p r e f i x ’ = S e t a p r e f i x i f you need t o a v o i d c o l l i s i o n s | ’ c o o k i e d o m a i n ’ = S e t t o . your−domain . com f o r s i t e −wide c o o k i e s = T y p i c a l l y w i l l be a f o r w a r d s l a s h | ’ cookie path ’ | ’ c o o k i e s e c u r e ’ = C o o k i e s w i l l o n l y be s e t i f a s e c u r e HTTPS c o n n e c t i o n e x i s t s . | ∗/ $config [ ’ cookie prefix ’ ] = ””; $ c o n f i g [ ’ cookie domain ’ ] = ””; = ”/”; $config [ ’ cookie path ’ ] $config [ ’ cookie secure ’ ] = FALSE ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | G l o b a l XSS F i l t e r i n g |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | D e t e r m i n e s w h e t h e r t h e XSS f i l t e r i s a l w a y s a c t i v e when GET, POST o r | COOKIE d a t a i s e n c o u n t e r e d | ∗/ $ c o n f i g [ ’ g l o b a l x s s f i l t e r i n g ’ ] = FALSE ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Cross S i t e Request Forgery |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | E n a b l e s a CSRF c o o k i e t o k e n t o be s e t . When s e t t o TRUE, t o k e n w i l l be | c h e c k e d on a s u b m i t t e d form . I f you a r e a c c e p t i n g u s e r data , i t i s s t r o n g l y | recommended CSRF p r o t e c t i o n be e n a b l e d . | | ’ c s r f t o k e n n a m e ’ = The t o k e n name | ’ c s r f c o o k i e n a m e ’ = The c o o k i e name | ’ c s r f e x p i r e ’ = The number i n s e c o n d s t h e t o k e n s h o u l d e x p i r e . ∗/ $ c o n f i g [ ’ c s r f p r o t e c t i o n ’ ] = FALSE ; $config [ ’ csrf token name ’ ] = ’ csrf test name ’ ; $config [ ’ csrf cookie name ’ ] = ’ csrf cookie name ’ ; $config [ ’ c s r f e x p i r e ’ ] = 7200; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | Output C o m p r e s s i o n |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | E n a b l e s Gzip o u t p u t c o m p r e s s i o n f o r f a s t e r page l o a d s . When e n a b l e d , | t h e o u t p u t c l a s s w i l l t e s t w h e t h e r y o u r s e r v e r s u p p o r t s Gzip . | Even i f i t d o e s , however , n o t a l l b r o w s e r s s u p p o r t c o m p r e s s i o n | s o e n a b l e o n l y i f you a r e r e a s o n a b l y s u r e y o u r v i s i t o r s can h a n d l e i t . | | VERY IMPORTANT: I f you a r e g e t t i n g a b l a n k page when c o m p r e s s i o n i s e n a b l e d | means you a r e p r e m a t u r e l y o u t p u t t i n g s o m e t h i n g t o y o u r b r o w s e r . I t c o u l d | e v e n be a l i n e o f w h i t e s p a c e a t t h e end o f one o f y o u r s c r i p t s . For | c o m p r e s s i o n t o work , n o t h i n g can be s e n t b e f o r e t h e o u t p u t b u f f e r i s c a l l e d | by t h e o u t p u t c l a s s . Do n o t ’ echo ’ any v a l u e s w i t h c o m p r e s s i o n e n a b l e d . | ∗/ $ c o n f i g [ ’ c o m p r e s s o u t p u t ’ ] = FALSE ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 172 it | Maste r Time R e f e r e n c e |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | O p t i o n s a r e ’ l o c a l ’ o r ’ gmt ’ . This p r e f t e l l s the system whether to use | y o u r s e r v e r ’ s l o c a l t i m e a s t h e m a s t e r ’ now ’ r e f e r e n c e , o r c o n v e r t i t t o | GMT. S e e t h e ’ d a t e h e l p e r ’ page o f t h e u s e r g u i d e f o r i n f o r m a t i o n | regarding date handling . | ∗/ $config [ ’ time reference ’ ] = ’ local ’ ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | R e w r i t e PHP S h o r t Tags |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | I f y o u r PHP i n s t a l l a t i o n d o e s n o t have s h o r t t a g s u p p o r t e n a b l e d CI | can r e w r i t e t h e t a g s on−the−f l y , e n a b l i n g you t o u t i l i z e t h a t s y n t a x | i n your view f i l e s . O p t i o n s a r e TRUE o r FALSE ( b o o l e a n ) | ∗/ $ c o n f i g [ ’ r e w r i t e s h o r t t a g s ’ ] = FALSE ; /∗ |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | R e v e r s e Proxy I P s |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | I f y o u r s e r v e r i s b e h i n d a r e v e r s e proxy , you must w h i t e l i s t t h e p r o x y IP | a d d r e s s e s from which C o d e I g n i t e r s h o u l d t r u s t t h e HTTP X FORWARDED FOR | h e a d e r i n o r d e r t o p r o p e r l y i d e n t i f y t h e v i s i t o r ’ s IP a d d r e s s . | Comma−d e l i m i t e d , e . g . ’ 1 0 . 0 . 1 . 2 0 0 , 1 0 . 0 . 1 . 2 0 1 ’ | ∗/ $config [ ’ proxy ips ’ ] = ’ ’ ; /∗ End o f f i l e c o n f i g . php ∗/ /∗ L o c a t i o n : . / a p p l i c a t i o n / c o n f i g / c o n f i g . php ∗/ <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; /∗ | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | DATABASE CONNECTIVITY SETTINGS | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | This f i l e w i l l c o n t a i n the s e t t i n g s needed to a c c e s s your database . | | For c o m p l e t e i n s t r u c t i o n s p l e a s e c o n s u l t t h e ’ D a t a b a s e C o n n e c t i o n ’ | page o f t h e U s e r Guide . | | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | EXPLANATION OF VARIABLES | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | [ ’ hostname ’ ] The hostname o f y o u r d a t a b a s e s e r v e r . | [ ’ username ’ ] The username u s e d t o c o n n e c t t o t h e d a t a b a s e | [ ’ password ’ ] The p a s s w o r d u s e d t o c o n n e c t t o t h e d a t a b a s e | [ ’ d a t a b a s e ’ ] The name o f t h e d a t a b a s e you want t o c o n n e c t t o | [ ’ d b d r i v e r ’ ] The d a t a b a s e t y p e . i e : mysql . Currently supported : mysql , m y s q l i , p o s t g r e , odbc , mssql , s q l i t e , o c i 8 | [ ’ d b p r e f i x ’ ] You can add an o p t i o n a l p r e f i x , which w i l l be added | t o t h e t a b l e name when u s i n g t h e A c t i v e Record c l a s s | [ ’ p c o n n e c t ’ ] TRUE/FALSE − Whether t o u s e a p e r s i s t e n t c o n n e c t i o n | [ ’ db debug ’ ] TRUE/FALSE − Whether d a t a b a s e e r r o r s s h o u l d be d i s p l a y e d . | [ ’ c a c h e o n ’ ] TRUE/FALSE − E n a b l e s / d i s a b l e s q u e r y c a c h i n g | [ ’ c a c h e d i r ’ ] The path t o t h e f o l d e r where c a c h e f i l e s s h o u l d be s t o r e d | [ ’ c h a r s e t ’ ] The c h a r a c t e r s e t u s e d i n communicating w i t h t h e d a t a b a s e | [ ’ d b c o l l a t ’ ] The c h a r a c t e r c o l l a t i o n u s e d i n communicating w i t h t h e d a t a b a s e | NOTE: For MySQL and MySQLi d a t a b a s e s , t h i s s e t t i n g i s o n l y used | a s a backup i f y o u r s e r v e r i s r u n n i n g PHP < 5 . 2 . 3 o r MySQL < 5.0.7 | ( and i n t a b l e c r e a t i o n q u e r i e s made w i t h DB F o r g e ) . | There i s an i n c o m p a t i b i l i t y i n PHP w i t h m y s q l r e a l e s c a p e s t r i n g ( ) which | can make y o u r s i t e v u l n e r a b l e t o SQL i n j e c t i o n i f you a r e using a | m u l t i −b y t e c h a r a c t e r s e t and a r e r u n n i n g v e r s i o n s l o w e r than these . | S i t e s u s i n g L a t i n −1 o r UTF−8 d a t a b a s e c h a r a c t e r s e t and c o l l a t i o n are unaffected . | [ ’ s w a p p r e ’ ] A d e f a u l t t a b l e p r e f i x t h a t s h o u l d be swapped w i t h t h e d b p r e f i x | [ ’ a u t o i n i t ’ ] Whether o r n o t t o a u t o m a t i c a l l y i n i t i a l i z e t h e d a t a b a s e . | [ ’ s t r i c t o n ’ ] TRUE/FALSE − f o r c e s ’ S t r i c t Mode ’ c o n n e c t i o n s | − good f o r e n s u r i n g s t r i c t SQL w h i l e developing | | The $ a c t i v e g r o u p v a r i a b l e l e t s you c h o o s e which c o n n e c t i o n g r o u p t o | make a c t i v e . By d e f a u l t t h e r e i s o n l y one g r o u p ( t h e ’ d e f a u l t ’ g r o u p ) . | | The $ a c t i v e r e c o r d v a r i a b l e s l e t s you d e t e r m i n e w h e t h e r o r n o t t o l o a d | the a c t i v e record c l a s s ∗/ $active group = ’ default ’ ; $ a c t i v e r e c o r d = TRUE; 173 $db [ $db [ $db [ $db [ $db [ $db [ $db [ $db [ $db [ $db [ $db [ $db [ $db [ $db [ $db [ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ default default default default default default default default default default default default default default default ’][ ’][ ’][ ’][ ’][ ’][ ’][ ’][ ’][ ’][ ’][ ’][ ’][ ’][ ’][ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ hostname username password database dbdriver dbprefix pconnect db debug cache on cachedir char set dbcollat swap pre autoinit stricton ’] ’] ’] ’] ’] ’] ’] ’] ’] ’] ’] ’] ’] ’] ’] = = = = = = = = = = = = = = = ’ localhost ’ ; // hostname ’ FoodIntakeMon ’ ; ’ pnUvqYprynEdNyZn ’ ; ’ FoodIntakeMon ’ ; ’ mysql ’ ; ’ ’; TRUE; TRUE; FALSE ; ’ ’; ’ utf8 ’ ; ’ utf8 general ci ’ ; ’ ’; TRUE; FALSE ; is localhost // username is // d a t a b a s e is root // no p a s s w o r d fim /∗ End o f f i l e d a t a b a s e . php ∗/ /∗ L o c a t i o n : . / a p p l i c a t i o n / c o n f i g / d a t a b a s e . php ∗/ <?php /∗ $ c o n f i g = a r r a y ( ’ appId ’ => ’ 4 1 1 6 9 4 6 6 2 3 0 0 9 6 4 ’ , ’ s e c r e t ’ => ’ 4 4 4 9 8 8 7 d c a d 9 b 5 6 c 0 e 8 d b c 6 6 b f 6 3 b 3 3 1 ’ ) ;∗/ /∗ $ c o n f i g [ ’ appId ’ ] = ’411694662300964 ’; $config [ ’ secret ’ ] = ’4449887 dcad9b56c0e8dbc66bf63b331 ’ ; ∗ / $ c o n f i g [ ’ appId ’ ] = ’593833454087083 ’; $config [ ’ secret ’ ] = ’ a9a92c6d827ae7ed0503f689141d2b05 ’ ; ?> <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; /∗ | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | URI ROUTING | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | T h i s f i l e l e t s you r e −map URI r e q u e s t s t o s p e c i f i c c o n t r o l l e r f u n c t i o n s . | | T y p i c a l l y t h e r e i s a one−to−one r e l a t i o n s h i p between a URL s t r i n g | and i t s c o r r e s p o n d i n g c o n t r o l l e r c l a s s / method . The s e g m e n t s i n a | URL n o r m a l l y f o l l o w t h i s p a t t e r n : | | example . com/ c l a s s / method / i d / | | I n some i n s t a n c e s , however , you may want t o remap t h i s r e l a t i o n s h i p | s o t h a t a d i f f e r e n t c l a s s / f u n c t i o n i s c a l l e d than t h e one | c o r r e s p o n d i n g t o t h e URL . | | Please see the user guide f o r complete d e t a i l s : | | h t t p : / / c o d e i g n i t e r . com/ u s e r g u i d e / g e n e r a l / r o u t i n g . html | | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | RESERVED ROUTES | −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− | | There a r e a two r e s e r v e d r o u t e s : | | $ r o u t e [ ’ d e f a u l t c o n t r o l l e r ’ ] = ’ welcome ’ ; | | T h i s r o u t e i n d i c a t e s which c o n t r o l l e r c l a s s s h o u l d be l o a d e d i f t h e | URI c o n t a i n s no d a t a . I n t h e above example , t h e ” welcome ” c l a s s | would be l o a d e d . | | $route [ ’404 override ’ ] = ’ e r r o r s / page missing ’ ; | | T h i s r o u t e w i l l t e l l t h e R o u t e r what URI s e g m e n t s t o u s e i f t h o s e p r o v i d e d | i n t h e URL c a n n o t be matched t o a v a l i d r o u t e . | ∗/ $ r o u t e [ ’ d e f a u l t c o n t r o l l e r ’ ] = ” l o g i n ” ; // d e f a u l t l o g i n i n d e x . php v i e w $ r o u t e [ ’ MY Pagination / ( : any ) ’ ] = ’ l o g i n / i n d e x ’ ; $route [ ’404 override ’ ] = ’ ’ ; page l o g i n . php c o n t r o l l e r linked to // $ d e f a u l t c o n t r o l l e r = ” l o g i n ” ; // $ c o n t r o l l e r e x c e p t i o n s = a r r a y ( ’ v e r i f y l o g i n ’ , ’ l o g o u t ’ , ’ home ’ , ’ h o m e u s e r ’ , ’ home admin ’ , ’ home cmanager ’ ) ; // $ r o u t e [ ’ d e f a u l t c o n t r o l l e r ’ ] = $ d e f a u l t c o n t r o l l e r ; // $ r o u t e [ ” ˆ ( ( ? ! \ b ” . i m p l o d e ( ’ \ b | \ b ’ , $ c o n t r o l l e r e x c e p t i o n s ) . ” \ b ) . ∗ ) $ ” ] = $ d e f a u l t c o n t r o l l e r . ’ / $1 ’ ; // $ r o u t e [ ’ 4 0 4 o v e r r i d e ’ ] = ’ ’ ; // $ r o u t e [ ’ s h o w f i t n e s s p r o f i l e ’ ] = ’ h o m e u s e r / s h o w f i t n e s s p r o f i l e ’ ; // $ r o u t e [ ’ w e i g h t m o n i t o r g e t d a t a ’ ] = ’ h o m e u s e r / w e i g h t m o n i t o r g e t d a t a ’ ; /∗ End o f f i l e r o u t e s . php ∗/ /∗ L o c a t i o n : . / a p p l i c a t i o n / c o n f i g / r o u t e s . php ∗/ <?php $ c o n f i g [ ’ t w e e t c o n s u m e r k e y ’ ] = ”Y9wHRf3wQOAd5KLaW5LRwqiu2 ” ; $ c o n f i g [ ’ t w e e t c o n s u m e r s e c r e t ’ ] = ” vchyOy5I2lyJUaqBmkqkFUzXSsuf4ayrMeioxkghag958LkDBI ”; 174 ?> B..2 Controllers <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; s e s s i o n s t a r t ( ) ; //we need t o c a l l PHP’ s s e s s i o n o b j e c t t o a c c e s s i t t h r o u g h CI c l a s s Home e x t e n d s function CI Controller { construct () { construct () ; parent : : } function index ( ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ home index ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } } ?> <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; s e s s i o n s t a r t ( ) ; //we need t o c a l l PHP’ s s e s s i o n o b j e c t t o a c c e s s i t t h r o u g h CI c l a s s Home Admin e x t e n d s C I C o n t r o l l e r { function construct () { parent : : construct () ; $ t h i s −>l o a d −>model ( ’ home admin model ’ ) ; } //INDEX function index ( ) { $ t h i s −>l o a d −>model ( ’ home admin model ’ ) ; $ d a t a [ ’ query ’ ] = ” ” ; // $ t h i s −>l o a d −>v a r s ( $ d a t a ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $data [ ’ u s e r i d ’ ] = $ s e s s i o n d a t a [ ’ u s e r i d ’ ] ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ h om e a dm i n i nd e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //LOGOUT function logout () { $ t h i s −>s e s s i o n −>u n s e t u s e r d a t a ( ’ l o g g e d i n ’ ) ; session destroy () ; redirect ( ’ login ’ , ’ refresh ’ ) ; } //USER SEARCH CONTROLLERS function suggestions () { $ t h i s −>l o a d −>model ( ’ home admin model ’ ) ; $term = $ t h i s −>i n p u t −>p o s t ( ’ term ’ ,TRUE) ; if ( s t r l e n ( $term ) < 1 ) b r e a k ; $ r ow s = $ t h i s −>home admin model−>Ge tA uto co mpl et e ( a r r a y ( ’ keyword ’ => $term ) ) ; $json array = array () ; f o r e a c h ( $ r ow s a s $row ) a r r a y p u s h ( $ j s o n a r r a y , $row−>u s e r i d , $row−>username , $row−>f i r s t n a m e , $row −>middle name , $row−>l a s t n a m e , $row−>u s e r t y p e , $row−>e m a i l a d d r e s s , $row −>g e n d e r , $row−>b i r t h d a y ) ; echo j s o n e n c o d e ( $ j s o n a r r a y ) ; } function search () { $ t h i s −>l o a d −>model ( ’ home admin model ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>home admin model−>g e t s e a r c h ( ) ; // $ d a t a [ ’ query ’ ] = $ t h i s −>home admin model−>g e t s e a r c h ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { 175 $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ h om e a dm i n i nd e x ’ , $ d a t a ) ; } } //ADD USER CONTROLLERS function add user () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ a d d u s e r i n d e x ’ ) ; } function save ( ) { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ username ’ , ’ Username ’ , ’ t r i m | r e q u i r e d | alpha numeric | min length [ 4 ] | x s s c l e a n | c a l l b a c k c h e c k u s e r c i ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ password ’ , ’ Password ’ , ’ t r i m | required | alpha numeric | min length [ 8 ] ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c o n f i r m p a s s w o r d ’ , ’ Confirm Password ’ , ’ t r i m | r e q u i r e d | a l p h a n u m e r i c | matches [ p a s s w o r d ] ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f i r s t n a m e ’ , ’ F i r s t Name ’ , ’ t r i m | required | alpha numeric | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ middle name ’ , ’ M i d d l e Name ’ , ’ alpha numeric | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ l a s t n a m e ’ , ’ L a s t Name ’ , ’ t r i m | required | alpha numeric | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ b i r t h d a t e ’ , ’ B i r t h d a t e ’ , ’ required | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ g e n d e r R a d i o ’ , ’ Gender ’ , ’ r e q u i r e d ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ userTypeRadio ’ , ’ U s e r Type ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ e m a i l a d d r e s s ’ , ’ Email Address ’ , ’ required | valid email | callback check email ci ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; $ t h i s −>l o a d −>v i e w ( ’ a d d u s e r i n d e x ’ ) ; } else { $ t h i s −>l o a d −>model ( ’ home admin model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home admin model−>p r o c e s s ( ) ; // $ m e s s a g e = ” R e g i s t r a t i o n S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home admin ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ R e g i s t r a t i o n Successful . ’) ; r e d i r e c t ( ’ home admin ’ , ’ r e f r e s h ’ ) ; } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } public function check user ci () { $ u s r=$ t h i s −>i n p u t −>p o s t ( ’ username ’ ) ; $ r e s u l t=$ t h i s −>home admin model−>c h e c k u s e r e x i s t ( $ u s r ) ; if ( $result ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , exists . ’) ; return f a l s e ; } else { return true ; } } public function check user () { $ u s r=$ t h i s −>i n p u t −>p o s t ( ’ name ’ ) ; $ r e s u l t=$ t h i s −>home admin model−>c h e c k u s e r e x i s t ( $ u s r ) ; if ( $result ) { echo ” f a l s e ” ; } else { echo ” t r u e ” ; 176 ’ Username a l r e a d y } } public function check email ci () { $eml=$ t h i s −>i n p u t −>p o s t ( ’ e m a i l a d d r e s s ’ ) ; $ r e s u l t=$ t h i s −>home admin model−>c h e c k e m a i l e x i s t ( $eml ) ; if ( $result ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , already registered . ’ ) ; return f a l s e ; } else { return true ; } ’E−m a i l A d d r e s s } public function check email () { $eml=$ t h i s −>i n p u t −>p o s t ( ’ e m a i l ’ ) ; $ r e s u l t=$ t h i s −>home admin model−>c h e c k e m a i l e x i s t ( $eml ) ; if ( $result ) { echo ” f a l s e ” ; } else { echo ” t r u e ” ; } } //DELETE USER CONTROLLER f u n c t i o n d e l e t e u s e r ( $username ) { $ t h i s −>home admin model−>d e l u s e r ( $username ) ; // $ m e s s a g e = ” U s e r was s u c c e s f u l l y d e l e t e d ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home admin ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ U s e r was s u c c e s s f u l l y deleted . ’) ; r e d i r e c t ( ’ home admin ’ , ’ r e f r e s h ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //EDIT USER CONTROLLER f u n c t i o n e d i t u s e r ( $username ) { $ i t e m = $ t h i s −>home admin model−>g e t u s e r ( $username ) ; $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ username ’ , ’ Username ’ , ’ t r i m | r e q u i r e d | min length [ 4 ] | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f i r s t n a m e ’ , ’ F i r s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ middle name ’ , ’ M i d d l e Name ’ , ’ x s s c l e a n ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ l a s t n a m e ’ , ’ L a s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ b i r t h d a t e ’ , ’ B i r t h d a t e ’ , ’ r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ g e n d e r R a d i o ’ , ’ Gender ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ userTypeRadio ’ , ’ U s e r Type ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ e m a i l a d d r e s s ’ , ’ Email Address ’ , ’ r e q u i r e d | valid email ’) ; ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( ’ username ’ => $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) , ’ f i r s t n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ f i r s t n a m e ’ ) , ’ middle name ’ => $ t h i s −>i n p u t −>p o s t ( ’ middle name ’ ) , ’ l a s t n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ l a s t n a m e ’ ) , ’ g e n d e r ’ => $ t h i s −>i n p u t −>p o s t ( ’ g e n d e r R a d i o ’ ) , ’ u s e r t y p e ’ => $ t h i s −>i n p u t −>p o s t ( ’ userTypeRadio ’ ) , ’ e m a i l a d d r e s s ’ => $ t h i s −>i n p u t −>p o s t ( ’ e m a i l a d d r e s s ’ ) , ’ b i r t h d a y ’ => $ t h i s −>i n p u t −>p o s t ( ’ b i r t h d a t e ’ ) , ’ s t a t u s ’ => $ t h i s −>i n p u t −>p o s t ( ’ s t a t u s R a d i o ’ ) if ); i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>l o a d −>model ( ’ home admin model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home admin model−>u p d a t e p r o f i l e ( $username , $data ) ; // $ m e s s a g e = ” Update U s e r S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home admin ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , Update U s e r S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home admin ’ , ’ r e f r e s h ’ ) ; } 177 ’ } } $ d a t a [ ’ item ’ ] = $ i t e m ; $ d a t a [ ’ username ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ username ’ , $ i t e m [ ’ username ’ ] ) ; $data [ ’ f i r s t n a m e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ f i r s t n a m e ’ , $ i t e m [ ’ first name ’ ] ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ middle name ’ , $ i t e m $ d a t a [ ’ middle name ’ ] = [ ’ middle name ’ ] ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ l a s t n a m e ’ , $ i t e m [ ’ $data [ ’ last name ’ ] = last name ’ ] ) ; $data [ ’ birthday ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ b i r t h d a t e ’ , $ i t e m [ ’ birthday ’ ] ) ; $data [ ’ gender ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ g e n d e r R a d i o ’ , $ i t e m [ ’ gender ’ ] ) ; $data [ ’ u s e r t y p e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ userTypeRadio ’ , $ i t e m [ ’ user type ’ ] ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ e m a i l a d d r e s s ’ , $data [ ’ e m a i l a d d r e s s ’ ] = $item [ ’ e m a i l a d d r e s s ’ ] ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ e d i t u s e r i n d e x ’ , $data ) ; } //EDIT PROFILE CONTROLLER function e d i t p r o f i l e u s e r () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ username ’ , ’ Username ’ , ’ t r i m | r e q u i r e d | min length [ 4 ] | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f i r s t n a m e ’ , ’ F i r s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ middle name ’ , ’ M i d d l e Name ’ , ’ x s s c l e a n ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ l a s t n a m e ’ , ’ L a s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ b i r t h d a t e ’ , ’ B i r t h d a t e ’ , ’ r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ g e n d e r R a d i o ’ , ’ Gender ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ userTypeRadio ’ , ’ U s e r Type ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ e m a i l a d d r e s s ’ , ’ Email Address ’ , ’ r e q u i r e d | valid email ’) ; ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( ’ username ’ => $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) , ’ f i r s t n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ f i r s t n a m e ’ ) , ’ middle name ’ => $ t h i s −>i n p u t −>p o s t ( ’ middle name ’ ) , ’ l a s t n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ l a s t n a m e ’ ) , ’ g e n d e r ’ => $ t h i s −>i n p u t −>p o s t ( ’ g e n d e r R a d i o ’ ) , ’ u s e r t y p e ’ => $ t h i s −>i n p u t −>p o s t ( ’ userTypeRadio ’ ) , ’ e m a i l a d d r e s s ’ => $ t h i s −>i n p u t −>p o s t ( ’ e m a i l a d d r e s s ’ ) , ’ b i r t h d a y ’ => $ t h i s −>i n p u t −>p o s t ( ’ b i r t h d a t e ’ ) if ); $username = $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>s e s s i o n −>s e t u s e r d a t a ( ’ l o g g e d i n ’ , $ d a t a ) ; $ t h i s −>l o a d −>model ( ’ home admin model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home admin model−>u p d a t e p r o f i l e ( $username , $data ) ; // $ m e s s a g e = ” P r o f i l e Update S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home admin ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , P r o f i l e Update S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home admin ’ , ’ r e f r e s h ’ ) ; } } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $ d a t a [ ’ middle name ’ ] = $ s e s s i o n d a t a [ ’ middle name ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; } else { 178 ’ // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } $ t h i s −>l o a d −>v i e w ( ’ e d i t p r o f i l e a d m i n i n d e x ’ , $data ) ; } //EDIT PASSWORD CONTROLLER function edit password user () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ o l d p a s s w o r d ’ , ’ Old Password ’ , ’ t r i m | required | min length [ 8 ] | callback check old password ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ password ’ , ’ Password ’ , ’ t r i m | r e q u i r e d | min length [ 8 ] ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c o n f i r m p a s s w o r d ’ , ’ Confirm Password ’ , t r i m | r e q u i r e d | matches [ p a s s w o r d ] ’ ) ; ’ ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( ’ password ’ => MD5( $ t h i s −>i n p u t −>p o s t ( ’ password ’ ) ) , ’ c o n f i r m p a s s w o r d ’ => MD5( $ t h i s −>i n p u t −>p o s t ( ’ c o n f i r m p a s s w o r d ’) ) if ); $username = $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>l o a d −>model ( ’ home admin model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home admin model−>u p d a t e p a s s w o r d ( $username , $data ) ; // $ m e s s a g e = ” Password Change S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home admin ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , Password Change S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home admin ’ , ’ r e f r e s h ’ ) ; } } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ e d i t p a s s w o r d a d m i n i n d e x ’ , $data ) ; } public function check old password () { $opwd=MD5( $ t h i s −>i n p u t −>p o s t ( ’ o l d p a s s w o r d ’ ) ) ; $ r e s u l t=$ t h i s −>home admin model−>c h e c k o l d p a s s w o r d e x i s t ( $opwd ) ; if ( $result ) { return true ; } else { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ I n c o r r e c t Old Password . ’ ) ; return f a l s e ; } } } ?> <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; s e s s i o n s t a r t ( ) ; //we need t o c a l l PHP’ s s e s s i o n o b j e c t t o a c c e s s i t t h r o u g h CI c l a s s Home Cmanager e x t e n d s function CI Controller { construct () { parent : : construct () ; $ t h i s −>l o a d −>h e l p e r ( a r r a y ( ’ form ’ , ’ u r l ’ ) ) ; $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; } function index ( ) { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; $data [ ’ q u e r y f e l ’ ] = ” ” ; $data [ ’ query ht ’ ] = ” ” ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $data [ ’ u s e r i d ’ ] = $ s e s s i o n d a t a [ ’ u s e r i d ’ ] ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; 179 ’ $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ h o m e c m a n a g e r i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } } //LOGOUT function logout () { $ t h i s −>s e s s i o n −>u n s e t u s e r d a t a ( ’ l o g g e d i n ’ ) ; session destroy () ; redirect ( ’ login ’ , ’ refresh ’ ) ; } public function check user () { $ u s r=$ t h i s −>i n p u t −>p o s t ( ’ name ’ ) ; $ r e s u l t=$ t h i s −>home cmanager model−>c h e c k u s e r e x i s t ( $ u s r ) ; if ( $result ) { echo ” f a l s e ” ; } else { echo ” t r u e ” ; } } public function check email () { $eml=$ t h i s −>i n p u t −>p o s t ( ’ e m a i l ’ ) ; $ r e s u l t=$ t h i s −>home cmanager model−>c h e c k e m a i l e x i s t ( $eml ) ; if ( $result ) { echo ” f a l s e ” ; } else { echo ” t r u e ” ; } } //EDIT PROFILE CONTROLLER function e d i t p r o f i l e u s e r () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ username ’ , ’ Username ’ , ’ t r i m | r e q u i r e d | min length [ 4 ] | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f i r s t n a m e ’ , ’ F i r s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ middle name ’ , ’ M i d d l e Name ’ , ’ x s s c l e a n ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ l a s t n a m e ’ , ’ L a s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ b i r t h d a t e ’ , ’ B i r t h d a t e ’ , ’ r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ g e n d e r R a d i o ’ , ’ Gender ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ userTypeRadio ’ , ’ U s e r Type ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ e m a i l a d d r e s s ’ , ’ Email Address ’ , ’ r e q u i r e d | valid email ’) ; ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( ’ username ’ => $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) , ’ f i r s t n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ f i r s t n a m e ’ ) , ’ middle name ’ => $ t h i s −>i n p u t −>p o s t ( ’ middle name ’ ) , ’ l a s t n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ l a s t n a m e ’ ) , ’ g e n d e r ’ => $ t h i s −>i n p u t −>p o s t ( ’ g e n d e r R a d i o ’ ) , ’ u s e r t y p e ’ => $ t h i s −>i n p u t −>p o s t ( ’ userTypeRadio ’ ) , ’ e m a i l a d d r e s s ’ => $ t h i s −>i n p u t −>p o s t ( ’ e m a i l a d d r e s s ’ ) , ’ b i r t h d a y ’ => $ t h i s −>i n p u t −>p o s t ( ’ b i r t h d a t e ’ ) if ); $username = $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>s e s s i o n −>s e t u s e r d a t a ( ’ l o g g e d i n ’ , $ d a t a ) ; $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home cmanager model−>u p d a t e p r o f i l e ( $username , $data ) ; // $ m e s s a g e = ” P r o f i l e Update S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ P r o f i l e Update S u c e s s f u l . ’ ) ; r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; } } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; 180 $data $data $data $data $data $data [ [ [ [ [ [ ’ middle name ’ ] = $ s e s s i o n d a t a [ ’ middle name ’ ] ; ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; ’ user type ’ ] = $session data [ ’ user type ’ ] ; ’ email address ’ ] = $session data [ ’ email address ’ ] ; ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } $ t h i s −>l o a d −>v i e w ( ’ e d i t p r o f i l e c m a n a g e r i n d e x ’ , $data ) ; } //EDIT PASSWORD CONTROLLER function edit password user () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ o l d p a s s w o r d ’ , ’ Old Password ’ , ’ t r i m | required | min length [ 8 ] | callback check old password ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ password ’ , ’ Password ’ , ’ t r i m | r e q u i r e d | min length [ 8 ] ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c o n f i r m p a s s w o r d ’ , ’ Confirm Password ’ , t r i m | r e q u i r e d | matches [ p a s s w o r d ] ’ ) ; ’ ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( ’ password ’ => MD5( $ t h i s −>i n p u t −>p o s t ( ’ password ’ ) ) , ’ c o n f i r m p a s s w o r d ’ => MD5( $ t h i s −>i n p u t −>p o s t ( ’ c o n f i r m p a s s w o r d ’) ) if ); $username = $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home cmanager model−>u p d a t e p a s s w o r d ( $username , $data ) ; // $ m e s s a g e = ” Password Change S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Password Change S u c e s s f u l . ’ ) ; r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; } } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ e d i t p a s s w o r d c m a n a g e r i n d e x ’ , $data ) ; } public function check old password () { $opwd=MD5( $ t h i s −>i n p u t −>p o s t ( ’ o l d p a s s w o r d ’ ) ) ; $ r e s u l t=$ t h i s −>home cmanager model−>c h e c k o l d p a s s w o r d e x i s t ( $opwd ) ; if ( $result ) { return true ; } else { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ I n c o r r e c t Old Password . ’ ) ; return f a l s e ; } } //ADD FOOD EXCHANGE LIST CONTROLLERS function check felitem exists () { $ f o o d n a m e = $ t h i s −>i n p u t −>p o s t ( ’ food name ’ ) ; $ r e s u l t=$ t h i s −>home cmanager model−>c h e c k f e l i t e m e x i s t ( $ f o o d n a m e ) ; i f ( $result ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ Food Item already e x i s t s . ’ ) ; return f a l s e ; } else { return true ; } } function add felitem () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; 181 $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $ d a t a [ ’ l g ’ ] = $ t h i s −>home cmanager model−>g e t l i s t g r o u p ( ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } $ t h i s −>l o a d −>v i e w ( ’ a d d f o o d e x c h a n g e l i s t i n d e x ’ , $data ) ; } p u b l i c f u n c t i o n buildDropFEL ( ) { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; // s e t s e l e c t e d l i s t g r o u p from POST $ l i g r o u p = $ t h i s −>i n p u t −>p o s t ( ’ l i s t g r o u p ’ ,TRUE) ; // run t h e q u e r y f o r t h e f o o d g r o u p we s p e c i f i e d e a r l i e r $ f g D a t a [ ’ fgDrop ’ ] = $ t h i s −>home cmanager model−>g e t f o o d g r o u p ( $ l i g r o u p ) ; $output = n u l l ; f o r e a c h ( $ f g D a t a [ ’ fgDrop ’]−> r e s u l t ( ) a s $row ) { // h e r e we b u i l d a dropdown i t e m l i n e f o r e a c h q u e r y r e s u l t $ o u t p u t .= ”< o p t i o n v a l u e = ’ ” . $row−>l i s t g r o u p . ” ’ > ” . $row−>f o o d g r o u p .” </ o p t i o n >”; } echo $output ; } f u n c t i o n buildDropFEL2 ( ) { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; // s e t s e l e c t e d l i s t g r o u p from POST $ l i g r o u p = $ t h i s −>i n p u t −>p o s t ( ’ l i s t g r o u p ’ ,TRUE) ; public // run t h e q u e r y f o r t h e f o o d g r o u p we s p e c i f i e d e a r l i e r $ f g c D a t a [ ’ f gc D r o p ’ ] = $ t h i s −>home cmanager model−>g e t f o o d g r o u p c a t e g o r y ( $ l i g r o u p ) ; $output = n u l l ; f o r e a c h ( $ f g c D a t a [ ’ fg c D r o p ’]−> r e s u l t ( ) a s $row ) { // h e r e we b u i l d a dropdown i t e m l i n e f o r e a c h q u e r y r e s u l t $ o u t p u t .= ”< o p t i o n v a l u e = ’ ” . $row−>l i s t g r o u p . ” ’ > ” . $row−>f o o d g r o u p c a t e g o r y .” </ o p t i o n >”; } echo $output ; } add felitem save () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ l i s t g r o u p ’ , ’ L i s t Group ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f o o d g r o u p ’ , ’ Food Group ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f o o d g r o u p c a t e g o r y ’ , ’ Food Group C a t e g o r y ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ food name ’ , ’ Food Name ’ , ’ r e q u i r e d | callback check felitem exists ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ measure ’ , ’ Measure ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a r b o h y d r a t e ’ , ’ C a r b o h y d r a t e ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r o t e i n ’ , ’ P r o t e i n ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f a t ’ , ’ Fat ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ e n e r g y ’ , ’ Energy ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ w e i g h t a s p u r c h a s e d ’ , ’ Weight a s Purchased ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ w e i g h t e d i b l e p o r t i o n ’ , ’ Weight E d i b l e P o r t i o n ’ , ’ r e q u i r e d | numeric ’ ) ; function // e c h o ’< o r e > ’ ; // p r i n t r ( $ POST ) ; // e c h o ’</ pre > ’ ; // d i e ( ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; $ t h i s −>l o a d −>v i e w ( ’ a d d f o o d e x c h a n g e l i s t i n d e x ’ ) ; } else { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home cmanager model−>p r o c e s s f e l i t e m ( ) ; // $ m e s s a g e = ” Adding o f Food Exchange L i s t Item S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Adding o f Food Exchange L i s t Item S u c e s s f u l . ’ ) ; r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } 182 } //DELETE FEL ITEM function delete fel item ( $food exchange list id ) { $ t h i s −>home cmanager model−>d e l f e l i t e m ( $ f o o d e x c h a n g e l i s t i d ) ; // $ m e s s a g e = ” Food Exchange L i s t Item was s u c c e s f u l l y d e l e t e d ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Food Exchange L i s t Item was s u c c e s s f u l l y d e l e t e d . ’ ) ; r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //ADD HEALTH TIP CONTROLLERS function add healthtip () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ a d d h e a l t h t i p i n d e x ’ ) ; } function add healthtip save () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ h e a l t h t i p ’ , ’ H e a l t h Tip ’ , ’ required ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; $ t h i s −>l o a d −>v i e w ( ’ a d d h e a l t h t i p i n d e x ’ ) ; } else { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home cmanager model−>p r o c e s s h e a l t h t i p ( ) ; // $ m e s s a g e = ” Adding o f H e a l t h Tip S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Adding o f Tip S u c e s s f u l . ’ ) ; r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //DELETE HEALTH TIP function delete health tip ( $health tip id ) { $ t h i s −>home cmanager model−>d e l h e a l t h t i p ( $ h e a l t h t i p i d ) ; // $ m e s s a g e = ” H e a l t h Tip was s u c c e s f u l l y d e l e t e d ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ H e a l t h Tip was successfully deleted . ’) ; r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } function search fel () { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; $ d a t a [ ’ q u e r y f e l ’ ] = $ t h i s −>home cmanager model−>g e t s e a r c h f e l ( ) ; $data [ ’ query ht ’ ] = ” ” ; 183 Health i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ h o m e c m a n a g e r i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } function search ht () { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; $ d a t a [ ’ q u e r y h t ’ ] = $ t h i s −>home cmanager model−>g e t s e a r c h h t ( ) ; $data [ ’ q u e r y f e l ’ ] = ” ” ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ h o m e c m a n a g e r i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //VIEW CREATED RECIPES function show created recipes () { $ d a t a [ ’ query ’ ] = $ t h i s −>home cmanager model−>p r o c e s s v i e w c r e a t e d r e c i p e s ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w c r e a t e d r e c i p e s c m a n a g e r i n d e x ’ , $ d a t a ) ; ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //EDIT CREATED RECIPES function e d i t c r e a t e d r e c i p e ( $recommended recipe id ) { $ i t e m = $ t h i s −>home cmanager model−>g e t c r e a t e d r e c i p e ( $ r e c o m m e n d e d r e c i p e i d ) ; $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s // $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ o w n r e c i p e i d ’ , ’ Username ’ , ’ t r i m | required | min length [ 4 ] | xss clean ’ ) ; // $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ u s e r i d ’ , ’ F i r s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ h e a l t h c o n d i t i o n ’ , ’ H e a l t h C o n d i t i o n ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ m e a l t y p e ’ , ’ Meal Type ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ r e c i p e n a m e ’ , ’ R e c i p e Name ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ s e r v i n g s u g g ’ , ’ S e r v i n g S i z e ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ i n g r e d i e n t s ’ , ’ I n g r e d i e n t s ’ , ’ callback health conditions restrictions ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r e p a r a t i o n p r o c e d u r e ’ , ’ P r o c e d u r e ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a l o r i e s ’ , ’ C a l o r i e s ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a r b o h y d r a t e ’ , ’ C a r b o h y d r a t e s ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r o t e i n ’ , ’ P r o t e i n ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f a t ’ , ’ Fat ’ , ’ r e q u i r e d | numeric ’ ) ; ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( / / ’ o w n r e c i p e i d ’ => $ t h i s −>i n p u t −>p o s t ( ’ o w n r e c i p e i d ’ ) , / / ’ u s e r i d ’ => $ t h i s −>i n p u t −>p o s t ( ’ u s e r i d ’ ) , / / ’ h e a l t h c o n d i t i o n ’ => $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h c o n d i t i o n ’ ) , ’ h e a l t h c o n d i t i o n ’ => i m p l o d e ( ” , ” , $ t h i s −>i n p u t −>p o s t ( ’ health condition ’) ) , ’ m e a l t y p e ’ => $ t h i s −>i n p u t −>p o s t ( ’ m e a l t y p e ’ ) , ’ r e c i p e n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ r e c i p e n a m e ’ ) , ’ s e r v i n g s u g g ’ => $ t h i s −>i n p u t −>p o s t ( ’ s e r v i n g s u g g ’ ) , ’ p r e p a r a t i o n p r o c e d u r e ’ => $ t h i s −>i n p u t −>p o s t ( ’ preparation procedure ’ ) , ’ c a l o r i e s ’ => $ t h i s −>i n p u t −>p o s t ( ’ c a l o r i e s ’ ) , ’ c a r b o h y d r a t e ’ => $ t h i s −>i n p u t −>p o s t ( ’ c a r b o h y d r a t e ’ ) , ’ p r o t e i n ’ => $ t h i s −>i n p u t −>p o s t ( ’ p r o t e i n ’ ) , if 184 ’ f a t ’ => $ t h i s −>i n p u t −>p o s t ( ’ f a t ’ ) ); $data2 = array ( ) ; $data2 $data2 $data2 $data2 $data2 [ [ [ [ [ ’ food name ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t s ’ ) ; ’ f o o d g r o u p ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ f o o d g r o u p ’ ) ; ’ measure ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t m e a s u r e ’ ) ; ’ s e r v i n g s i z e ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t q u a n t i t y ’ ) ; ’ i n g r e d i e n t i d ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t i d ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home cmanager model−>u p d a t e r e c i p e ( $ r e c o m m e n d e d r e c i p e i d , $data , $ d a t a 2 ) ; // $ m e s s a g e = ” E d i t R e c i p e S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Edit Recipe S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; } } } $ d a t a [ ’ item ’ ] = $ i t e m ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ o w n r e c i p e i d ’ , // $ d a t a [ ’ o w n r e c i p e i d ’ ] = $item [ ’ o w n r e c i p e i d ’ ] ) ; // $ d a t a [ ’ u s e r i d ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ u s e r i d ’ , $ i t e m [ ’ user id ’ ] ) ; // $ d a t a [ ’ h e a l t h c o n d i t i o n ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ h e a l t h c o n d i t i o n ’ , $item [ ’ h e a l t h c o n d i t i o n ’ ] ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ m e a l t y p e ’ , $ i t e m [ ’ // $ d a t a [ ’ m e a l t y p e ’ ] = meal type ’ ] ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ r e c i p e n a m e ’ , // $ d a t a [ ’ r e c i p e n a m e ’ ] = $item [ ’ recipe name ’ ] ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ s e r v i n g s u g g ’ , // $ d a t a [ ’ s e r v i n g s u g g ’ ] = $item [ ’ s e r v i n g s u g g ’ ] ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ i n g r e d i e n t s ’ , $ i t e m // $ d a t a [ ’ food name ’ ] = [ ’ food name ’ ] ) ; // $ d a t a [ ’ f o o d g r o u p ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ f o o d g r o u p ’ , $ i t e m [ ’ food group ’ ] ) ; // $ d a t a [ ’ measure ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ i n g r e d i e n t m e a s u r e ’ , $ i t e m [ ’ measure ’ ] ) ; // $ d a t a [ ’ s e r v i n g s i z e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ i n g r e d i e n t q u a n t i t y ’ , $item [ ’ s e r v i n g s i z e ’ ] ) ; // $ d a t a [ ’ p r e p a r a t i o n p r o c e d u r e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ p r e p a r a t i o n p r o c e d u r e ’ , $item [ ’ p r e p a r a t i o n p r o c e d u r e ’ ] ) ; // $ d a t a [ ’ c a l o r i e s ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ c a l o r i e s ’ , $ i t e m [ ’ calories ’ ] ) ; // $ d a t a [ ’ c a r b o h y d r a t e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ c a r b o h y d r a t e ’ , $item [ ’ carbohydrate ’ ] ) ; // $ d a t a [ ’ p r o t e i n ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ p r o t e i n ’ , $ i t e m [ ’ protein ’ ] ) ; // $ d a t a [ ’ f a t ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ f a t ’ , $ i t e m [ ’ f a t ’ ] ) ; // p r i n t r ( $ i t e m ) ; // d i e ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ e d i t r e c i p e c m a n a g e r i n d e x ’ , $ d a t a ) ; } //VIEW SELECTED RECIPE function v i e w c r e a t e d r e c i p e ( $recommended recipe id ) { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>home cmanager model−>g e t r e c i p e c o n t e n t s ( $recommended recipe id ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w r e c i p e c m a n a g e r i n d e x ’ , $ d a t a ) ; } 185 else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } } //DELETE CREATED RECIPE function d e l e t e c r e a t e d r e c i p e ( $recommended recipe id ) { $ t h i s −>home cmanager model−>d e l c r e a t e d r e c i p e ( $ r e c o m m e n d e d r e c i p e i d ) ; // $ m e s s a g e = ” R e c i p e was s u c c e s f u l l y d e l e t e d ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / s h o w c r e a t e d r e c i p e s ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ R e c i p e was s u c c e s s f u l l y deleted . ’) ; r e d i r e c t ( ’ home cmanager / s h o w c r e a t e d r e c i p e s ’ , ’ refresh ’) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } function //DELETE INGREDIENTS delete ingredient () { $ t h i s −>home cmanager model−>d e l i n g r e d i e n t ( $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t i d ’ ) ); } //CREATE RECIPE CONTROLLER function add recipe () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ a d d r e c i p e c m a n a g e r i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } function add recipe save () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ h e a l t h c o n d i t i o n ’ , ’ H e a l t h C o n d i t i o n ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ m e a l t y p e ’ , ’ Meal Type ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ r e c i p e n a m e ’ , ’ R e c i p e Name ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ s e r v i n g s u g g ’ , ’ S e r v i n g S i z e ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ i n g r e d i e n t s ’ , ’ I n g r e d i e n t s ’ , ’ callback health conditions restrictions ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r e p a r a t i o n p r o c e d u r e ’ , ’ P r o c e d u r e ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a l o r i e s ’ , ’ C a l o r i e s ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a r b o h y d r a t e ’ , ’ C a r b o h y d r a t e s ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r o t e i n ’ , ’ P r o t e i n ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f a t ’ , ’ Fat ’ , ’ r e q u i r e d | numeric ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // e c h o ’< pre > ’ . p r i n t r ( $ t h i s −>i n p u t −>p o s t ( ) ,TRUE) . ’ </ pre > ’ ; // d i e ( ) ; // $ t h i s −>i n d e x ( ) ; // i f ( $ t h i s −>i n p u t −>p o s t ( ) ) //{ // // Merge t h e s u b m i t t e d d a t a w i t h t h e c u r r e n t d a t a $ d a t a = $ t h i s −>i n p u t −>p o s t ( ) ; // e c h o ’< pre > ’ . p r i n t r ( $ d a t a ) . ’ </ pre > ’ ; // d i e ( ) ; //} // $ d a t a = $ t h i s −>i n p u t −>p o s t ( ) ; // $ i n g r e d i e n t s = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t s ’ ) ; // e c h o ’< pre > ’ . p r i n t r ( $ i n g r e d i e n t s ) . ’ </ pre > ’ ; // d i e ( ) ; // e c h o ’< pre > ’ . p r i n t r ( $ d a t a ) . ’ </ pre > ’ ; // d i e ( ) ; $ t h i s −>l o a d −>v i e w ( ’ a d d r e c i p e c m a n a g e r i n d e x ’ / ∗ , $data ∗/) ; } else { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { /∗ C r e a t e c o n f i g f o r image l i b r a r y ∗/ $ t h i s −>l o a d −>l i b r a r y ( ’ i m a g e l i b ’ ) ; 186 $ c o n f i g [ ’ i m a g e l i b r a r y ’ ] = ’ gd2 ’ ; /∗ C r e a t e c o n f i g f o r u p l o a d l i b r a r y ∗/ $ c o n f i g [ ’ upload path ’ ] = ’ . / uploads / ’ ; $ c o n f i g [ ’ a l l o w e d t y p e s ’ ] = ’ g i f | j p g | png ’ ; $ c o n f i g [ ’ max size ’ ] = ’0 ’; $ c o n f i g [ ’ max width ’ ] = ’0 ’; = ’0 ’; $ c o n f i g [ ’ max height ’ ] $ t h i s −>l o a d −>l i b r a r y ( ’ upload ’ , $ c o n f i g ) ; if ( ! $ t h i s −>upload−>d o u p l o a d ( ’ u s e r f i l e ’ ) ) { i f ( ! empty ( $ FILES [ ’ u s e r f i l e ’ ] [ ’ name ’ ] ) ) { // $ e r r o r = a r r a y ( ’ e r r o r ’ => $ t h i s −> upload−>d i s p l a y e r r o r s ( ) ) ; $ e r r o r = $ t h i s −>upload−>d i s p l a y e r r o r s () ; $data [ ’ e r r o r d i s p l a y ’ ] = $ e r r o r ; $ t h i s −>l o a d −>v i e w ( ’ ad d re cip e cm an age r in de x ’ , $data ) ; } else { $filename = ’ default ’ ; $ f i l e E x t e n s i o n = ’ png ’ ; $ d a t a 3 [ ’ raw name ’ ] = $ f i l e n a m e ; $data3 [ ’ f i l e e x t ’ ] = $ f i l e E x t e n s i o n ; $ f i l e =a r r a y ( ’ img name ’=> $ d a t a 3 [ ’ raw name ’] , ’ thumb name’=> $ d a t a 3 [ ’ raw name ’ ] . ’ thumb ’ , ’ e x t ’=> $ d a t a 3 [ ’ f i l e e x t ’ ] , ’ u p l o a d d a t e ’=> t i m e ( ) ); $ t h i s −>home cmanager model−>p r o c e s s a d d r e c i p e ( $file ) ; } } else { $ d a t a 3=$ t h i s −>upload−>d a t a ( ) ; $ p a t h i n f o = p a t h i n f o ( $ FILES [ ” u s e r f i l e ” ] [ ” name ” ] ) ; $filename = $path info [ ’ filename ’ ] ; $fileExtension = $path info [ ’ extension ’ ] ; // $ d a t a 3=$ t h i s −>upload−>d a t a ( ) ; // $ t h i s −>thumb ( $ d a t a 3 ) ; $ d a t a 3 [ ’ raw name ’ ] = $ f i l e n a m e ; $data3 [ ’ f i l e e x t ’ ] = $ f i l e E x t e n s i o n ; $ f i l e =a r r a y ( ’ img name ’=> $ d a t a 3 [ ’ raw name ’] , ’ thumb name’=> $ d a t a 3 [ ’ raw name ’ ] . ’ thumb ’ , ’ e x t ’=> $ d a t a 3 [ ’ f i l e e x t ’ ] , ’ u p l o a d d a t e ’=> t i m e ( ) ); $ t h i s −>home cmanager model−>p r o c e s s a d d r e c i p e ( $file ) ; $ d a t a 3 = a r r a y ( ’ u p l o a d d a t a ’ => $ t h i s −>upload −>d a t a ( ) ) ; } // $ m e s s a g e = ” C r e a t i n g o f R e c i p e S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager / s h o w c r e a t e d r e c i p e s ”) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Creating of Recipe S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home cmanager / s h o w c r e a t e d r e c i p e s ’ , ’ refresh ’) ; } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } /∗ f u n c t i o n thumb ( $ d a t a 3 ) { $ c o n f i g [ ’ i m a g e l i b r a r y ’ ] = ’ gd2 ’ ; $ c o n f i g [ ’ s o u r c e i m a g e ’ ] =$ d a t a 3 [ ’ f u l l p a t h ’ ] ; $ c o n f i g [ ’ c r e a t e t h u m b ’ ] = TRUE; $ c o n f i g [ ’ m a i n t a i n r a t i o ’ ] = TRUE; 187 $ c o n f i g [ ’ width ’ ] = 2 7 5 ; $config [ ’ height ’ ] = 250; $ t h i s −>l o a d −>l i b r a r y ( ’ i m a g e l i b ’ , $ t h i s −>i m a g e l i b −>r e s i z e ( ) ; $config ) ; }∗/ function health conditions restrictions ( $ingredients ) { $ h e a l t h c o n d i t i o n = $ POST [ ’ h e a l t h c o n d i t i o n ’ ] ; f o r ( $ i = 0 ; $ i < c o u n t ( $ i n g r e d i e n t s ) ; $ i ++) { i f (! is se t ( $ingredients [ $i ]) ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION Ingredient f i e l d is required . ’) ; return f a l s e ; } i f ( ! i s s e t ( $ POST [ ’ i n g r e d i e n t q u a n t i t y ’ ] [ $ i ] ) ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION Quantity f i e l d i s r e q u i r e d . ’ ) ; return f a l s e ; } , ’ The , ’ The $ f o o d g r o u p = $ POST [ ’ f o o d g r o u p ’ ] [ $ i ] ; $counts = 0; f o r ( $ j = 0 ; $ j < c o u n t ( $ i n g r e d i e n t s ) ; $ j ++) { i f ( $ POST [ ’ f o o d g r o u p ’ ] [ $ i ] == $ f o o d g r o u p ) $ c o u n t s += $ POST [ ’ i n g r e d i e n t q u a n t i t y ’ ] [ $ j ] ; } i f ( $ h e a l t h c o n d i t i o n == ’ D i a b e t e s ’ ) { i f ( ( $ f o o d g r o u p === ” V e g e t a b l e ” | | $ f o o d g r o u p === ” F r u i t ” ) && $counts > 4) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 4 s e r v i n g s o f ’ . $food group . ’ daily . ’ ) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Milk ” && $ c o u n t s > 3 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 3 s e r v i n g s o f Milk daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” R i c e ” && $ c o u n t s > 9 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 9 s e r v i n g s o f R i c e daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Meat ” && $ c o u n t s > 6 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 6 s e r v i n g s o f Meat daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Meat ” && $ c o u n t s > 5 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f Fat daily . ’) ; return f a l s e ; } } e l s e i f ( $ h e a l t h c o n d i t i o n == ’ H y p e r t e n s i o n ’ | | $ h e a l t h c o n d i t i o n == ’ Kidney S t o n e s ’ ) { i f ( ( $ f o o d g r o u p === ” V e g e t a b l e ” | | $ f o o d g r o u p === ” F r u i t ” ) && $counts > 5) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f ’ . $food group . ’ daily . ’ ) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Milk ” && $ c o u n t s > 5 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f Milk daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” R i c e ” && $ c o u n t s > 8 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 8 s e r v i n g s o f R i c e daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Meat ” && $ c o u n t s > 2 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 2 s e r v i n g s o f Meat daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Meat ” && $ c o u n t s > 3 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 3 s e r v i n g s o f Fat daily . ’) ; return f a l s e ; } } return true ; } } //AUTOCOMPLETE ADD INGREDIENTS function suggestions () { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; $term = $ t h i s −>i n p u t −>p o s t ( ’ term ’ ,TRUE) ; if ( s t r l e n ( $term ) < 1 ) b r e a k ; 188 $ r ow s = $ t h i s −>home cmanager model−>Ge tA uto co mpl et e ( a r r a y ( ’ keyword ’ => $term ) ) ; $json array = array () ; f o r e a c h ( $ r ow s a s $row ) { // a r r a y p u s h ( $ j s o n a r r a y , $row−>food name , $row−>measure ) ; $ j s o n a r r a y [ ] [ ’ food name ’ ] = $row−>f o o d n a m e ; $ j s o n a r r a y [ ] [ ’ measure ’ ] = $row−>w e i g h t e d i b l e p o r t i o n ; $ j s o n a r r a y [ ] [ ’ e n e r g y ’ ] = $row−>e n e r g y ; $ j s o n a r r a y [ ] [ ’ c a r b o h y d r a t e ’ ] = $row−>c a r b o h y d r a t e ; $ j s o n a r r a y [ ] [ ’ p r o t e i n ’ ] = $row−>p r o t e i n ; $ j s o n a r r a y [ ] [ ’ f a t ’ ] = $row−>f a t ; $ j s o n a r r a y [ ] [ ’ f o o d g r o u p ’ ] = $row−>f o o d g r o u p ; } echo j s o n e n c o d e ( $ j s o n a r r a y ) ; } function get fa () { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; $ i n g r e d i e n t = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t ’ ) ; i f ( s t r l e n ( $ i n g r e d i e n t ) < 1) break ; $ r ow s = $ t h i s −>home cmanager model−>Ge tA uto co mpl et e ( a r r a y ( ’ keyword ’ => $ingredient ) ) ; $response = ””; f o r e a c h ( $ r ow s a s $row ) $ r e s p o n s e = $row−>e n e r g y . ” , ” . $row−>c a r b o h y d r a t e . ” , ” . $row−>p r o t e i n . ” , ” . $row−> fat ; echo $ r e s p o n s e ; } //PLAN DAILY MEALS function recommend daily meals ( ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ r e c o m m e n d d a i l y m e a l s i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //VIEW SELECTED RECIPE UNDER RECOMMEND MEALS function view created recommended recipe ( $recommended recipe id ) { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>home cmanager model−>g e t r e c i p e c o n t e n t s ( $recommended recipe id ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w r e c i p e r e c o m m e n d e d i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //VIEW DAILY MEALS BY DATE public function select by date () { $ r e c o r d d a t e = $ t h i s −>i n p u t −>p o s t ( ’ r e c o r d d a t e ’ ) ; i f ( $ r e c o r d d a t e != ” ” ) { $ r e s u l t = $ t h i s −>home cmanager model−>s h o w d a t a b y d a t e ( $ r e c o r d d a t e ) ; i f ( $ r e s u l t != f a l s e ) { $data [ ’ r e s u l t d i s p l a y ’ ] = $ r e s u l t ; } else { $ d a t a [ ’ r e s u l t d i s p l a y ’ ] = ”No r e c o r d f o u n d ! ” ; } } else { $ d a t a [ ’ d a t e e r r o r m e s s a g e ’ ] = ” Date f i e l d i s r e q u i r e d ” ; } // $ d a t a [ ’ s h o w t a b l e ’ ] = $ t h i s −>v i e w t a b l e ( ) ; $ t h i s −>l o a d −>v i e w ( ’ r e c o m m e n d d a i l y m e a l s i n d e x ’ , $ d a t a ) ; // var dump ( $ r e s u l t ) ; } //SEARCH MEAL function search meal () { // $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s // $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ r e c o r d d a t e ’ , 189 ’ Date ’ , ’ required ’ ) ; // i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; // $ t h i s −>l o a d −>v i e w ( ’ p l a n d a i l y m e a l s i n d e x ’ ) ; //} // e l s e { // i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { // $ d a t a [ ’ r e c o r d d a t e ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ r e c o r d d a t e ’ ) ; //} $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; $ d a t a [ ’ q u e r y m e a l ’ ] = $ t h i s −>home cmanager model−>g e t s e a r c h m e a l ( ) ; $ t h i s −>l o a d −>v i e w ( ’ s e a r c h m e a l c m a n a g e r i n d e x ’ , $ d a t a ) ; //} i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //ADD MEAL f u n c t i o n add meal ( $ re co mme nd ed re ci pe id ) { $data [ ’ recommended recipe id ’ ] = $recommended recipe id ; $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home cmanager model−>p r o c e s s a d d m e a l ( $recommended recipe id ) ; // $ m e s s a g e = ” Adding o f Meal S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / s e a r c h m e a l ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Adding o f Meal S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home cmanager / s e a r c h m e a l ’ , ’ r e f r e s h ’) ; } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $ d a t a [ ’ middle name ’ ] = $ s e s s i o n d a t a [ ’ middle name ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ a d d m e a l c m a n a g e r i n d e x ’ , $data ) ; } //DELETE MEAL function delete meal ( $recommended daily meal id ) { $ t h i s −>home cmanager model−>d e l m e a l ( $ r e c o m m e n d e d d a i l y m e a l i d ) ; // $ m e s s a g e = ” Meal was s u c c e s f u l l y d e l e t e d ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / s e l e c t b y d a t e ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Meal was s u c c e s s f u l l y deleted . ’) ; r e d i r e c t ( ’ home cmanager / s e l e c t b y d a t e ’ , ’ refresh ’) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //VIEW SELECTED RECIPE FOR MEAL function view created recipe meal ( $recommended recipe id ) { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>home cmanager model−>g e t r e c i p e c o n t e n t s ( $recommended recipe id ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; 190 $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w r e c i p e a d d m e a l c m a n a g e r i n d e x ’ , $data ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } } //EDIT FEL CONTROLLER function e d i t f e l ( $food exchange list id ) { $ i t e m = $ t h i s −>home cmanager model−> g e t f e l e d i t ( $ f o o d e x c h a n g e l i s t i d ) ; $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ l i s t g r o u p ’ , ’ L i s t Group ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f o o d g r o u p ’ , ’ Food Group ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f o o d g r o u p c a t e g o r y ’ , ’ Food Group C a t e g o r y ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ food name ’ , ’ Food Name ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ measure ’ , ’ Measure ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a r b o h y d r a t e ’ , ’ C a r b o h y d r a t e ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r o t e i n ’ , ’ P r o t e i n ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f a t ’ , ’ Fat ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ e n e r g y ’ , ’ Energy ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ w e i g h t a s p u r c h a s e d ’ , ’ Weight a s Purchased ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ w e i g h t e d i b l e p o r t i o n ’ , ’ Weight E d i b l e P o r t i o n ’ , ’ r e q u i r e d | numeric ’ ) ; i f ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( / / ’ l i s t g r o u p ’ => $ t h i s −>i n p u t −>p o s t ( ’ l i s t g r o u p ’ ) , / / ’ f o o d g r o u p ’ => $ t h i s −>i n p u t −>p o s t ( ’ f o o d g r o u p ’ ) , / / ’ f o o d g r o u p c a t e g o r y ’ => $ t h i s −>i n p u t −>p o s t ( ’ food group category ’ ) , ’ food name ’ => $ t h i s −>i n p u t −>p o s t ( ’ food name ’ ) , ’ measure ’ => $ t h i s −>i n p u t −>p o s t ( ’ measure ’ ) , ’ c a r b o h y d r a t e ’ => $ t h i s −>i n p u t −>p o s t ( ’ c a r b o h y d r a t e ’ ) , ’ p r o t e i n ’ => $ t h i s −>i n p u t −>p o s t ( ’ p r o t e i n ’ ) , ’ f a t ’ => $ t h i s −>i n p u t −>p o s t ( ’ f a t ’ ) , ’ e n e r g y ’ => $ t h i s −>i n p u t −>p o s t ( ’ e n e r g y ’ ) , ’ w e i g h t a s p u r c h a s e d ’ => $ t h i s −>i n p u t −>p o s t ( ’ weight as purchased ’ ) , ’ w e i g h t e d i b l e p o r t i o n ’ => $ t h i s −>i n p u t −>p o s t ( ’ weight edible portion ’) ); i f ( i s s e t ( $ POST [ ’ l i s t g r o u p o t h e r ’ ] , $ POST [ ’ f o o d g r o u p o t h e r ’ ] , $ POST [ ’ food group categoryother ’ ] ) ) { $ d a t a [ ’ l i s t g r o u p ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ l i s t g r o u p o t h e r ’ ) ; $ d a t a [ ’ f o o d g r o u p ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ f o o d g r o u p o t h e r ’ ) ; $ d a t a [ ’ f o o d g r o u p c a t e g o r y ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ food group categoryother ’ ) ; } else { $ d a t a [ ’ l i s t g r o u p ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ l i s t g r o u p ’ ) ; $ d a t a [ ’ f o o d g r o u p ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ f o o d g r o u p ’ ) ; $ d a t a [ ’ f o o d g r o u p c a t e g o r y ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ food group category ’ ) ; } i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home cmanager model−>u p d a t e f e l ( $ f o o d e x c h a n g e l i s t i d , $data ) ; // $ m e s s a g e = ” Update Food Exchange L i s t Item Successful !”; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Update Food Exchange L i s t Item S u c c e s s f u l . ’) ; r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; } } } $ d a t a [ ’ item ’ ] = $ i t e m ; $data [ ’ l i s t g r o u p ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ l i s t g r o u p ’ , $ i t e m [ ’ list group ’ ] ) ; $data [ ’ food group ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ f o o d g r o u p ’ , $ i t e m [ ’ food group ’ ] ) ; $data [ ’ f o o d g r o u p c a t e g o r y ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ f o o d g r o u p c a t e g o r y ’ , $item [ ’ f o o d g r o u p c a t e g o r y ’ ] ) ; $ d a t a [ ’ food name ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ food name ’ , $ i t e m [ ’ food name ’ ] ) ; $ d a t a [ ’ measure ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ measure ’ , $ i t e m [ ’ measure ’ ] ) ; 191 $data [ ’ carbohydrate ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ c a r b o h y d r a t e ’ , $item [ ’ carbohydrate ’ ] ) ; $data [ ’ pr ot ei n ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ p r o t e i n ’ , $ i t e m [ ’ protein ’ ] ) ; $data [ ’ fat ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ f a t ’ , $ i t e m [ ’ f a t ’ ] ) ; $data [ ’ energy ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ e n e r g y ’ , $ i t e m [ ’ e n e r g y ’]) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ $data [ ’ weight as purchased ’ ] = weight as purchased ’ , $item [ ’ weight as purchased ’ ] ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ $data [ ’ w e i g h t e d i b l e p o r t i o n ’ ] = w e i g h t e d i b l e p o r t i o n ’ , $item [ ’ w e i g h t e d i b l e p o r t i o n ’ ] ) ; $ d a t a [ ’ l g ’ ] = $ t h i s −>home cmanager model−>g e t l i s t g r o u p ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ e d i t f e l i n d e x ’ , $data ) ; } //EDIT HT CONTROLLER function edit ht ( $health tip id ) { $ i t e m = $ t h i s −>home cmanager model−>g e t h t e d i t ( $ h e a l t h t i p i d ) ; $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ h e a l t h t i p ’ , ’ H e a l t h Tip ’ , if ’ required ’ ) ; ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( ’ h e a l t h t i p ’ => $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h t i p ’ ) ); i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>l o a d −>model ( ’ home cmanager model ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>home cmanager model−>u p d a t e h t ( $ h e a l t h t i p i d , $data ) ; // $ m e s s a g e = ” E d i t H e a l t h Tip S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home cmanager ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ E d i t H e a l t h Tip S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e s h ’ ) ; } } } $ d a t a [ ’ item ’ ] = $ i t e m ; $data [ ’ h e a l t h t i p ’ ] = health tip ’ ] ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ h e a l t h t i p ’ , i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ e d i t h t i n d e x ’ , $data ) ; } } ?> <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; s e s s i o n s t a r t ( ) ; //we need t o c a l l PHP’ s s e s s i o n o b j e c t t o a c c e s s i t t h r o u g h CI c l a s s Home User e x t e n d s function CI Controller { construct () { parent : : construct () ; $ t h i s −>l o a d −>h e l p e r ( a r r a y ( ’ form ’ , ’ u r l ’ ) ) ; $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; } function index ( ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $data [ ’ u s e r i d ’ ] = $ s e s s i o n d a t a [ ’ u s e r i d ’ ] ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; 192 $item [ ’ $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ h o m e u s e r i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } } function logout () { $ t h i s −>s e s s i o n −>u n s e t u s e r d a t a ( ’ l o g g e d i n ’ ) ; session destroy () ; redirect ( ’ login ’ , ’ refresh ’ ) ; } public function check user () { $ u s r=$ t h i s −>i n p u t −>p o s t ( ’ name ’ ) ; $ r e s u l t=$ t h i s −>h o m e u s e r m o d e l −>c h e c k u s e r e x i s t ( $ u s r ) ; if ( $result ) { echo ” f a l s e ” ; } else { echo ” t r u e ” ; } } public function check email () { $eml=$ t h i s −>i n p u t −>p o s t ( ’ e m a i l ’ ) ; $ r e s u l t=$ t h i s −>h o m e u s e r m o d e l −>c h e c k e m a i l e x i s t ( $eml ) ; if ( $result ) { echo ” f a l s e ” ; } else { echo ” t r u e ” ; } } //EDIT PASSWORD CONTROLLER function edit password user () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ o l d p a s s w o r d ’ , ’ Old Password ’ , ’ t r i m | required | min length [ 8 ] | callback check old password ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ password ’ , ’ Password ’ , ’ t r i m | r e q u i r e d | min length [ 8 ] ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c o n f i r m p a s s w o r d ’ , ’ Confirm Password ’ , t r i m | r e q u i r e d | matches [ p a s s w o r d ] ’ ) ; ’ ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( ’ password ’ => MD5( $ t h i s −>i n p u t −>p o s t ( ’ password ’ ) ) , ’ c o n f i r m p a s s w o r d ’ => MD5( $ t h i s −>i n p u t −>p o s t ( ’ c o n f i r m p a s s w o r d ’) ) if ); $username = $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>h o m e u s e r m o d e l −>u p d a t e p a s s w o r d ( $username , $data ) ; // $ m e s s a g e = ” Password Change S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home user ”) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Password Change Successful . ’) ; r e d i r e c t ( ’ home user ’ , ’ r e f r e s h ’ ) ; } } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ e d i t p a s s w o r d u s e r i n d e x ’ , $data ) ; } public function check old password () { $opwd=MD5( $ t h i s −>i n p u t −>p o s t ( ’ o l d p a s s w o r d ’ ) ) ; $ r e s u l t=$ t h i s −>h o m e u s e r m o d e l −>c h e c k o l d p a s s w o r d e x i s t ( $opwd ) ; if ( $result ) { return true ; } 193 else { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( Password . ’ ) ; return f a l s e ; FUNCTION , ’ I n c o r r e c t Old } } //EDIT PROFILE CONTROLLER function e d i t p r o f i l e u s e r () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ username ’ , ’ Username ’ , ’ t r i m | r e q u i r e d | min length [ 4 ] | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f i r s t n a m e ’ , ’ F i r s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ middle name ’ , ’ M i d d l e Name ’ , ’ x s s c l e a n ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ l a s t n a m e ’ , ’ L a s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ b i r t h d a t e ’ , ’ B i r t h d a t e ’ , ’ r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ g e n d e r R a d i o ’ , ’ Gender ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ userTypeRadio ’ , ’ U s e r Type ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ e m a i l a d d r e s s ’ , ’ Email Address ’ , ’ r e q u i r e d | valid email ’) ; ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( ’ u s e r i d ’ => $ t h i s −>i n p u t −>p o s t ( ’ u s e r i d ’ ) , ’ username ’ => $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) , ’ f i r s t n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ f i r s t n a m e ’ ) , ’ middle name ’ => $ t h i s −>i n p u t −>p o s t ( ’ middle name ’ ) , ’ l a s t n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ l a s t n a m e ’ ) , ’ g e n d e r ’ => $ t h i s −>i n p u t −>p o s t ( ’ g e n d e r R a d i o ’ ) , ’ u s e r t y p e ’ => $ t h i s −>i n p u t −>p o s t ( ’ userTypeRadio ’ ) , ’ e m a i l a d d r e s s ’ => $ t h i s −>i n p u t −>p o s t ( ’ e m a i l a d d r e s s ’ ) , ’ b i r t h d a y ’ => $ t h i s −>i n p u t −>p o s t ( ’ b i r t h d a t e ’ ) if ); $username = $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) ; $ u s e r i d = $ t h i s −>i n p u t −>p o s t ( ’ u s e r i d ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>s e s s i o n −>s e t u s e r d a t a ( ’ l o g g e d i n ’ , $ d a t a ) ; $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>h o m e u s e r m o d e l −>u p d a t e p r o f i l e ( $username , $data ) ; // $ m e s s a g e = ” P r o f i l e Update S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home user ”) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ P r o f i l e Update Successful . ’) ; r e d i r e c t ( ’ home user ’ , ’ r e f r e s h ’ ) ; } } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $ d a t a [ ’ middle name ’ ] = $ s e s s i o n d a t a [ ’ middle name ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ e d i t p r o f i l e u s e r i n d e x ’ , $data ) ; } //SEARCH FOOD EXCHANGE LIST function search fel () { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ q u e r y f e l ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t s e a r c h f e l ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ s e a r c h f e l u s e r i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page 194 redirect ( ’ login ’ , ’ refresh ’) ; } } //HEALTH TIPS NEWS FEED function user ht feed () { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; /∗ $ c o u n t = $ t h i s −>h o m e u s e r m o d e l −>c o u n t h t ( ) ; $ t h i s −>l o a d −>l i b r a r y ( ’ p a g i n a t i o n ’ ) ; $ c o n f i g [ ’ t o t a l r o w s ’ ] = $count ; $ c o n f i g [ ’ per page ’ ] = 2 ; $ t h i s −>p a g i n a t i o n −> i n i t i a l i z e ( $ c o n f i g ) ; $ d a t a [ ’ p a g i n a t i o n ’ ] = $ t h i s −>p a g i n a t i o n −>c r e a t e l i n k s ( ) ; $ d a t a [ ’ h t f e e d ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t s e a r c h h t r e t ( a r r a y ( ’ l i m i t ’ => $ c o n f i g [ ’ p e r p a g e ’ ] , ’ o f f s e t ’ => $ t h i s −>p a g i n a t i o n −> o f f s e t ) ) ; ∗ / $ d a t a [ ’ h t f e e d ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t s e a r c h h t ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ u s e r h t f e e d i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //ACHIEVEMENTS NEWS FEED //HEALTH TIPS NEWS FEED function user achievements feed () { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ a c h i e v e m e n t f e e d ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t s e a r c h a c h i e v e m e n t s ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ u s e r a c h i e v e m e n t f e e d i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //FITNESS PROFILE function show fitness profile () { $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s v i e w f p ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w f i t n e s s p r o f i l e i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } function weightmonitor getdata () { $ w e i g h t c h a r t d a t a = $ t h i s −>h o m e u s e r m o d e l −>g e t w e i g h t c h a r t d a t a ( ) ; $category = array () ; $ c a t e g o r y [ ’ name ’ ] = ’ C a t e g o r y ’ ; $ s e r i e s 1 = array () ; $ s e r i e s 1 [ ’ name ’ ] = ’ C u r r e n t Weight ’ ; $ s e r i e s 2 = array () ; $ s e r i e s 2 [ ’ name ’ ] = ’ Goal Weight ’ ; f o r e a c h ( $ w e i g h t c h a r t d a t a a s $row ) { $ c a t e g o r y [ ’ data ’ ] [ ] = $row−>r e c o r d d a t e ; $ s e r i e s 1 [ ’ data ’ ] [ ] = $row−>c u r r e n t w e i g h t ; $ s e r i e s 2 [ ’ data ’ ] [ ] = $row−>g o a l w e i g h t ; } $ r e s u l t = array () ; 195 array push ( $result , array push ( $result , array push ( $result , echo $category ) ; $series1 ) ; $series2 ) ; j s o n e n c o d e ( $ r e s u l t , JSON NUMERIC CHECK) ; } public function c h e c k f i t n e s s p r o f i l e () { $ r e c d a t e=$ t h i s −>i n p u t −>p o s t ( ’ r e c o r d d a t e ’ ) ; $ r e s u l t=$ t h i s −>h o m e u s e r m o d e l −>c h e c k f p e x i s t ( $ r e c d a t e ) ; if ( $result ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a l r e a d y data f o r the s e l e c t e d date . ’ ) ; return f a l s e ; } else { return true ; entered } } function add fitness profile () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ a d d f i t n e s s p r o f i l e i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } function add fitness profile save () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ g o a l w e i g h t ’ , ’ Goal Weight ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c u r r e n t w e i g h t ’ , ’ C u r r e n t Weight ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ h e i g h t ’ , ’ H e i g h t ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ r e c o r d d a t e ’ , ’ Record Date ’ , ’ r e q u i r e d | callback check fitness profile ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ h e a l t h c o n d i t i o n ’ , ’ H e a l t h C o n d i t i o n ’ , ’ required ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; $ t h i s −>l o a d −>v i e w ( ’ a d d f i t n e s s p r o f i l e i n d e x ’ ) ; } else { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s a d d f p ( ) ; // $ m e s s a g e = ” Adding o f I n f o r m a t i o n S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / h o m e u s e r / s h o w f i t n e s s p r o f i l e ”) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ I n f o r m a t i o n s u c c e s s f u l l y added . ’ ) ; r e d i r e c t ( ’ home user / s h o w f i t n e s s p r o f i l e ’ , ’ r e f r e s h ’ ) ; } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //DELETE FITNESS PROFILE CONTROLLER function d e l e t e f i t n e s s p r o f i l e ( $ f i t n e s s i n f o i d ) { $ t h i s −>h o m e u s e r m o d e l −> d e l f i t n e s s p r o f i l e ( $ f i t n e s s i n f o i d ) ; // $ m e s s a g e = ” F i t n e s s P r o f i l e was s u c c e s f u l l y d e l e t e d ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / s h o w f i t n e s s p r o f i l e ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ F i t n e s s P r o f i l e was successfully deleted . ’) ; r e d i r e c t ( ’ home user / s h o w f i t n e s s p r o f i l e ’ , ’ refresh ’) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; 196 $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } } //SHARE ACHIEVEMENT CONTROLLERS function share achievement () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ s h a r e a c h i e v e m e n t i n d e x ’ ) ; } function share achievement save () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ a c h i e v e m e n t ’ , ’ Achievement ’ , ’ required ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; $ t h i s −>l o a d −>v i e w ( ’ s h a r e a c h i e v e m e n t i n d e x ’ ) ; } else { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s a c h i e v e m e n t ( ) ; // $ m e s s a g e = ” S h a r i n g o f Achievement S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / h o m e u s e r ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ S h a r i n g Achievement S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home user ’ , ’ r e f r e s h ’ ) ; } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } of } //VIEW CREATED RECIPES function show created recipes () { $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s v i e w c r e a t e d r e c i p e s ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w c r e a t e d r e c i p e s i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //EDIT CREATED RECIPES function edit created recipe ( $own recipe id ) { $ i t e m = $ t h i s −>h o m e u s e r m o d e l −>g e t c r e a t e d r e c i p e ( $ o w n r e c i p e i d ) ; $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s // $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ o w n r e c i p e i d ’ , ’ Username ’ , ’ t r i m | required | min length [ 4 ] | xss clean ’ ) ; // $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ u s e r i d ’ , ’ F i r s t Name ’ , ’ t r i m | r e q u i r e d | xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ h e a l t h c o n d i t i o n ’ , ’ H e a l t h C o n d i t i o n ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ m e a l t y p e ’ , ’ Meal Type ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ r e c i p e n a m e ’ , ’ R e c i p e Name ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ s e r v i n g s u g g ’ , ’ S e r v i n g S i z e ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ i n g r e d i e n t s ’ , ’ I n g r e d i e n t s ’ , ’ callback health conditions restrictions ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r e p a r a t i o n p r o c e d u r e ’ , ’ P r o c e d u r e ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a l o r i e s ’ , ’ C a l o r i e s ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a r b o h y d r a t e ’ , ’ C a r b o h y d r a t e s ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r o t e i n ’ , ’ P r o t e i n ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f a t ’ , ’ Fat ’ , ’ r e q u i r e d | numeric ’ ) ; 197 ( i s s e t ( $ POST ) && ! empty ( $ POST ) ) { $data = array ( / / ’ o w n r e c i p e i d ’ => $ t h i s −>i n p u t −>p o s t ( ’ o w n r e c i p e i d ’ ) , / / ’ u s e r i d ’ => $ t h i s −>i n p u t −>p o s t ( ’ u s e r i d ’ ) , / / ’ h e a l t h c o n d i t i o n ’ => $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h c o n d i t i o n ’ ) , ’ h e a l t h c o n d i t i o n ’ => i m p l o d e ( ” , ” , $ t h i s −>i n p u t −>p o s t ( ’ health condition ’) ) , ’ m e a l t y p e ’ => $ t h i s −>i n p u t −>p o s t ( ’ m e a l t y p e ’ ) , ’ r e c i p e n a m e ’ => $ t h i s −>i n p u t −>p o s t ( ’ r e c i p e n a m e ’ ) , ’ s e r v i n g s u g g ’ => $ t h i s −>i n p u t −>p o s t ( ’ s e r v i n g s u g g ’ ) , $ t h i s −>i n p u t −>p o s t ( ’ ’ p r e p a r a t i o n p r o c e d u r e ’ => preparation procedure ’ ) , ’ c a l o r i e s ’ => $ t h i s −>i n p u t −>p o s t ( ’ c a l o r i e s ’ ) , ’ c a r b o h y d r a t e ’ => $ t h i s −>i n p u t −>p o s t ( ’ c a r b o h y d r a t e ’ ) , ’ p r o t e i n ’ => $ t h i s −>i n p u t −>p o s t ( ’ p r o t e i n ’ ) , ’ f a t ’ => $ t h i s −>i n p u t −>p o s t ( ’ f a t ’ ) if ); $data2 = array ( ) ; $data2 $data2 $data2 $data2 $data2 [ [ [ [ [ ’ food name ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t s ’ ) ; ’ f o o d g r o u p ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ f o o d g r o u p ’ ) ; ’ measure ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t m e a s u r e ’ ) ; ’ s e r v i n g s i z e ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t q u a n t i t y ’ ) ; ’ i n g r e d i e n t i d ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t i d ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>h o m e u s e r m o d e l −>u p d a t e r e c i p e ( $ o w n r e c i p e i d , $data , $ d a t a 2 ) ; // $ m e s s a g e = ” E d i t R e c i p e S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / h o m e u s e r ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ E d i t R e c i p e Successful . ’) ; r e d i r e c t ( ’ home user ’ , ’ r e f r e s h ’ ) ; } } } $ d a t a [ ’ item ’ ] = $ i t e m ; // $ d a t a [ ’ o w n r e c i p e i d ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ o w n r e c i p e i d ’ , $item [ ’ o w n r e c i p e i d ’ ] ) ; // $ d a t a [ ’ u s e r i d ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ u s e r i d ’ , $ i t e m [ ’ user id ’ ] ) ; // $ d a t a [ ’ h e a l t h c o n d i t i o n ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ h e a l t h c o n d i t i o n ’ , $item [ ’ h e a l t h c o n d i t i o n ’ ] ) ; // $ d a t a [ ’ m e a l t y p e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ m e a l t y p e ’ , $ i t e m [ ’ meal type ’ ] ) ; // $ d a t a [ ’ r e c i p e n a m e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ r e c i p e n a m e ’ , $item [ ’ recipe name ’ ] ) ; // $ d a t a [ ’ s e r v i n g s u g g ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ s e r v i n g s u g g ’ , $item [ ’ s e r v i n g s u g g ’ ] ) ; // $ d a t a [ ’ food name ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ i n g r e d i e n t s ’ , $ i t e m [ ’ food name ’ ] ) ; // $ d a t a [ ’ f o o d g r o u p ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ f o o d g r o u p ’ , $ i t e m [ ’ food group ’ ] ) ; // $ d a t a [ ’ measure ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ i n g r e d i e n t m e a s u r e ’ , $ i t e m [ ’ measure ’ ] ) ; // $ d a t a [ ’ s e r v i n g s i z e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ i n g r e d i e n t q u a n t i t y ’ , $item [ ’ s e r v i n g s i z e ’ ] ) ; // $ d a t a [ ’ p r e p a r a t i o n p r o c e d u r e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ p r e p a r a t i o n p r o c e d u r e ’ , $item [ ’ p r e p a r a t i o n p r o c e d u r e ’ ] ) ; // $ d a t a [ ’ c a l o r i e s ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ c a l o r i e s ’ , $ i t e m [ ’ calories ’ ] ) ; // $ d a t a [ ’ c a r b o h y d r a t e ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ c a r b o h y d r a t e ’ , $item [ ’ carbohydrate ’ ] ) ; // $ d a t a [ ’ p r o t e i n ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ p r o t e i n ’ , $ i t e m [ ’ protein ’ ] ) ; // $ d a t a [ ’ f a t ’ ] = $ t h i s −>f o r m v a l i d a t i o n −>s e t v a l u e ( ’ f a t ’ , $ i t e m [ ’ f a t ’ ] ) ; // p r i n t r ( $ i t e m ) ; // d i e ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ e d i t r e c i p e i n d e x ’ , $ d a t a ) ; } 198 //SHOW RECOMMENDED DAILY MEALS f un c ti o n show recommended daily meals ( ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ s h o w r e c o m m e n d e d d a i l y m e a l s i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //SELECT BY DATE RECOMMENDED MEALS public function recommended select by date () { $ r e c o r d d a t e = $ t h i s −>i n p u t −>p o s t ( ’ r e c o r d d a t e ’ ) ; i f ( $ r e c o r d d a t e != ” ” ) { $ r e s u l t = $ t h i s −>h o m e u s e r m o d e l −>r e c o m m e n d e d s h o w d a t a b y d a t e ( $record date ) ; i f ( $ r e s u l t != f a l s e ) { $data [ ’ r e s u l t d i s p l a y ’ ] = $ r e s u l t ; } else { $ d a t a [ ’ r e s u l t d i s p l a y ’ ] = ”No r e c o r d f o u n d ! ” ; } } else { $ d a t a [ ’ d a t e e r r o r m e s s a g e ’ ] = ” Date f i e l d i s r e q u i r e d ” ; } // $ d a t a [ ’ s h o w t a b l e ’ ] = $ t h i s −>v i e w t a b l e ( ) ; $ t h i s −>l o a d −>v i e w ( ’ s h o w r e c o m m e n d e d d a i l y m e a l s i n d e x ’ , $ d a t a ) ; // var dump ( $ r e s u l t ) ; } //VIEW SELECTED RECIPE UNDER RECOMMENDED MEALS function view created recommended recipe ( $recommended recipe id ) { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t r e c o m m e n d e d r e c i p e c o n t e n t s ( $recommended recipe id ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w d a i l y r e c o m m e n d e d r e c i p e i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //VIEW RECOMMENDED RECIPES f un c ti o n show recommended recipes ( ) { $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s v i e w r e c o m m e n d e d r e c i p e s ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w r e c o m m e n d e d r e c i p e s i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //SEARCH RECOMMENDED RECIPES function search recrec () { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t s e a r c h r e c r e c ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w r e c o m m e n d e d r e c i p e s i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } 199 } //VIEW SHARED RECIPES function show shared recipes () { $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s v i e w s h a r e d r e c i p e s ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w s h a r e d r e c i p e s i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //VIEW SELECTED SHARED RECIPE function view shared recipe ( $shared recipe id ) { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t s h a r e d r e c i p e c o n t e n t s ( $shared recipe id ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w s h a r e d r e c i p e i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //SEARCH SHARED RECIPES function search sharedrec () { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t s e a r c h s h a r e d r e c ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w s h a r e d r e c i p e s i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //VIEW SELECTED RECIPE function view created recipe ( $own recipe id ) { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t r e c i p e c o n t e n t s ( $ o w n r e c i p e i d ) ; // var dump ( $ d a t a [ ’ query ’ ] ) ; // d i e ( ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w r e c i p e i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //VIEW SELECTED RECIPE function view recommended recipe ( $recommended recipe id ) { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t r e c o m m e n d e d r e c i p e c o n t e n t s ( $recommended recipe id ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; 200 $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w r e c o m m e n d e d r e c i p e i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } } //DELETE CREATED RECIPE function delete created recipe ( $own recipe id ) { $ t h i s −>h o m e u s e r m o d e l −>d e l c r e a t e d r e c i p e ( $ o w n r e c i p e i d ) ; // $ m e s s a g e = ” R e c i p e was s u c c e s f u l l y d e l e t e d ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / s h o w c r e a t e d r e c i p e s ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ R e c i p e was s u c c e s s f u l l y deleted . ’) ; r e d i r e c t ( ’ home user / s h o w c r e a t e d r e c i p e s ’ , ’ r e f r e s h ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //DELETE INGREDIENTS function delete ingredient () { $ t h i s −>h o m e u s e r m o d e l −>d e l i n g r e d i e n t ( $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t i d ’ ) ) ; } //SHARE RECIPE function share created recipe ( $own recipe id ) { // $ o w n r e c i p e i d = $ t h i s −>i n p u t −>p o s t ( ’ o w n r e c i p e i d ’ ) ; // $ d a t a [ ’ o w n r e c i p e i d ’ ] = $ o w n r e c i p e i d ; // e c h o $ o w n r e c i p e i d ; $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; // i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s s h a r e r e c i p e ( $own recipe id ) ; // $ m e s s a g e = ” S h a r i n g o f R e c i p e S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / s h o w c r e a t e d r e c i p e s ” ) ; //</ s c r i p t > ’ ; //} //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ S h a r i n g o f R e c i p e Successful . ’) ; r e d i r e c t ( ’ home user / s h o w c r e a t e d r e c i p e s ’ , ’ r e f r e s h ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $ d a t a [ ’ middle name ’ ] = $ s e s s i o n d a t a [ ’ middle name ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //CREATE RECIPE CONTROLLER function add recipe () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ a d d r e c i p e i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } function add recipe save () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; 201 // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ h e a l t h c o n d i t i o n ’ , ’ H e a l t h C o n d i t i o n ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ m e a l t y p e ’ , ’ Meal Type ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ r e c i p e n a m e ’ , ’ R e c i p e Name ’ , ’ r e q u i r e d ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ s e r v i n g s u g g ’ , ’ S e r v i n g S i z e ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ i n g r e d i e n t s ’ , ’ I n g r e d i e n t s ’ , ’ callback health conditions restrictions ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r e p a r a t i o n p r o c e d u r e ’ , ’ P r o c e d u r e ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a l o r i e s ’ , ’ C a l o r i e s ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a r b o h y d r a t e ’ , ’ C a r b o h y d r a t e s ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p r o t e i n ’ , ’ P r o t e i n ’ , ’ r e q u i r e d | numeric ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f a t ’ , ’ Fat ’ , ’ r e q u i r e d | numeric ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // e c h o ’< pre > ’ . p r i n t r ( $ t h i s −>i n p u t −>p o s t ( ) ,TRUE) . ’ </ pre > ’ ; // d i e ( ) ; // $ t h i s −>i n d e x ( ) ; // i f ( $ t h i s −>i n p u t −>p o s t ( ) ) //{ // // Merge t h e s u b m i t t e d d a t a w i t h t h e c u r r e n t d a t a $ d a t a = $ t h i s −>i n p u t −>p o s t ( ) ; // e c h o ’< pre > ’ . p r i n t r ( $ d a t a ) . ’ </ pre > ’ ; // d i e ( ) ; //} // $ d a t a = $ t h i s −>i n p u t −>p o s t ( ) ; // $ i n g r e d i e n t s = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t s ’ ) ; // e c h o ’< pre > ’ . p r i n t r ( $ i n g r e d i e n t s ) . ’ </ pre > ’ ; // d i e ( ) ; // e c h o ’< pre > ’ . p r i n t r ( $ d a t a ) . ’ </ pre > ’ ; // d i e ( ) ; $ t h i s −>l o a d −>v i e w ( ’ a d d r e c i p e i n d e x ’ / ∗ , $data ∗/) ; } else { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { /∗ C r e a t e c o n f i g f o r image l i b r a r y ∗/ $ t h i s −>l o a d −>l i b r a r y ( ’ i m a g e l i b ’ ) ; $ c o n f i g [ ’ i m a g e l i b r a r y ’ ] = ’ gd2 ’ ; /∗ C r e a t e c o n f i g f o r u p l o a d l i b r a r y ∗/ $ c o n f i g [ ’ upload path ’ ] = ’ . / uploads / ’ ; $ c o n f i g [ ’ a l l o w e d t y p e s ’ ] = ’ g i f | j p g | png ’ ; $ c o n f i g [ ’ max size ’ ] = ’0 ’; $ c o n f i g [ ’ max width ’ ] = ’0 ’; = ’0 ’; $ c o n f i g [ ’ max height ’ ] $ t h i s −>l o a d −>l i b r a r y ( ’ upload ’ , $ c o n f i g ) ; if ( ! $ t h i s −>upload−>d o u p l o a d ( ’ u s e r f i l e ’ ) ) { i f ( ! empty ( $ FILES [ ’ u s e r f i l e ’ ] [ ’ name ’ ] ) ) { // $ e r r o r = a r r a y ( ’ e r r o r ’ => $ t h i s −> upload−>d i s p l a y e r r o r s ( ) ) ; $ e r r o r = $ t h i s −>upload−>d i s p l a y e r r o r s () ; $data [ ’ e r r o r d i s p l a y ’ ] = $ e r r o r ; $ t h i s −>l o a d −>v i e w ( ’ a d d r e c i p e i n d e x ’ , $data ) ; } else { $filename = ’ default ’ ; $ f i l e E x t e n s i o n = ’ png ’ ; $ d a t a 3 [ ’ raw name ’ ] = $ f i l e n a m e ; $data3 [ ’ f i l e e x t ’ ] = $ f i l e E x t e n s i o n ; $ f i l e =a r r a y ( ’ img name ’=> $ d a t a 3 [ ’ raw name ’] , ’ thumb name’=> $ d a t a 3 [ ’ raw name ’ ] . ’ thumb ’ , ’ e x t ’=> $ d a t a 3 [ ’ f i l e e x t ’ ] , ’ u p l o a d d a t e ’=> t i m e ( ) ); $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s a d d r e c i p e ( $file ) ; } } else { $ d a t a 3=$ t h i s −>upload−>d a t a ( ) ; $ p a t h i n f o = p a t h i n f o ( $ FILES [ ” u s e r f i l e ” ] [ ” name ” ] ) ; $filename = $path info [ ’ filename ’ ] ; $fileExtension = $path info [ ’ extension ’ ] ; // $ d a t a 3=$ t h i s −>upload−>d a t a ( ) ; // $ t h i s −>thumb ( $ d a t a 3 ) ; $ d a t a 3 [ ’ raw name ’ ] = $ f i l e n a m e ; $data3 [ ’ f i l e e x t ’ ] = $ f i l e E x t e n s i o n ; $ f i l e =a r r a y ( ’ img name ’=> $ d a t a 3 [ ’ raw name ’] , 202 ’ thumb name’=> $ d a t a 3 [ ’ raw name ’ ] . ’ thumb ’ , ’ e x t ’=> $ d a t a 3 [ ’ f i l e e x t ’ ] , ’ u p l o a d d a t e ’=> t i m e ( ) ); $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s a d d r e c i p e ( $file ) ; $ d a t a 3 = a r r a y ( ’ u p l o a d d a t a ’ => $ t h i s −>upload −>d a t a ( ) ) ; } // $ m e s s a g e = ” C r e a t i n g o f R e c i p e S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / home user / s h o w c r e a t e d r e c i p e s ”) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Creating of Recipe S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home user / s h o w c r e a t e d r e c i p e s ’ , ’ refresh ’) ; } } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } /∗ f u n c t i o n thumb ( $ d a t a 3 ) { $ c o n f i g [ ’ i m a g e l i b r a r y ’ ] = ’ gd2 ’ ; $ c o n f i g [ ’ s o u r c e i m a g e ’ ] =$ d a t a 3 [ ’ f u l l p a t h ’ ] ; $ c o n f i g [ ’ c r e a t e t h u m b ’ ] = TRUE; $ c o n f i g [ ’ m a i n t a i n r a t i o ’ ] = TRUE; $ c o n f i g [ ’ width ’ ] = 2 7 5 ; $config [ ’ height ’ ] = 250; $ t h i s −>l o a d −>l i b r a r y ( ’ i m a g e l i b ’ , $ c o n f i g ) ; $ t h i s −>i m a g e l i b −>r e s i z e ( ) ; }∗/ function health conditions restrictions ( $ingredients ) { $ h e a l t h c o n d i t i o n = $ POST [ ’ h e a l t h c o n d i t i o n ’ ] ; f o r ( $ i = 0 ; $ i < c o u n t ( $ i n g r e d i e n t s ) ; $ i ++) { i f (! is se t ( $ingredients [ $i ]) ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION Ingredient f i e l d is required . ’) ; return f a l s e ; } i f ( ! i s s e t ( $ POST [ ’ i n g r e d i e n t q u a n t i t y ’ ] [ $ i ] ) ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION Quantity f i e l d i s r e q u i r e d . ’ ) ; return f a l s e ; } , ’ The , ’ The $ f o o d g r o u p = $ POST [ ’ f o o d g r o u p ’ ] [ $ i ] ; $counts = 0; f o r ( $ j = 0 ; $ j < c o u n t ( $ i n g r e d i e n t s ) ; $ j ++) { i f ( $ POST [ ’ f o o d g r o u p ’ ] [ $ i ] == $ f o o d g r o u p ) $ c o u n t s += $ POST [ ’ i n g r e d i e n t q u a n t i t y ’ ] [ $ j ] ; } i f ( $ h e a l t h c o n d i t i o n == ’ D i a b e t e s ’ ) { i f ( ( $ f o o d g r o u p === ” V e g e t a b l e ” | | $ f o o d g r o u p === ” F r u i t ” ) && $counts > 4) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 4 s e r v i n g s o f ’ . $food group . ’ daily . ’ ) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Milk ” && $ c o u n t s > 3 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 3 s e r v i n g s o f Milk daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” R i c e ” && $ c o u n t s > 9 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 9 s e r v i n g s o f R i c e daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Meat ” && $ c o u n t s > 6 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 6 s e r v i n g s o f Meat daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Meat ” && $ c o u n t s > 5 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f Fat daily . ’) ; return f a l s e ; } 203 } e l s e i f ( $ h e a l t h c o n d i t i o n == ’ H y p e r t e n s i o n ’ | | $ h e a l t h c o n d i t i o n == ’ Kidney S t o n e s ’ ) { i f ( ( $ f o o d g r o u p === ” V e g e t a b l e ” | | $ f o o d g r o u p === ” F r u i t ” ) && $counts > 5) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f ’ . $food group . ’ daily . ’ ) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Milk ” && $ c o u n t s > 5 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 5 s e r v i n g s o f Milk daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” R i c e ” && $ c o u n t s > 8 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 8 s e r v i n g s o f R i c e daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Meat ” && $ c o u n t s > 2 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 2 s e r v i n g s o f Meat daily . ’) ; return f a l s e ; } e l s e i f ( $ f o o d g r o u p === ” Meat ” && $ c o u n t s > 3 ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION , ’ You a r e o n l y a l l o w e d a maximum o f 3 s e r v i n g s o f Fat daily . ’) ; return f a l s e ; } } return true ; } } //AUTOCOMPLETE ADD INGREDIENTS //USER SEARCH CONTROLLERS function suggestions () { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $term = $ t h i s −>i n p u t −>p o s t ( ’ term ’ ,TRUE) ; if ( s t r l e n ( $term ) < 1 ) b r e a k ; $ r ow s = $ t h i s −>h o m e u s e r m o d e l −>Ge tA uto co mpl et e ( a r r a y ( ’ keyword ’ => $term ) ) ; $json array = array () ; f o r e a c h ( $ r ow s a s $row ) { // a r r a y p u s h ( $ j s o n a r r a y , $row−>food name , $row−>measure ) ; $ j s o n a r r a y [ ] [ ’ food name ’ ] = $row−>f o o d n a m e ; $ j s o n a r r a y [ ] [ ’ measure ’ ] = $row−>w e i g h t e d i b l e p o r t i o n ; $ j s o n a r r a y [ ] [ ’ e n e r g y ’ ] = $row−>e n e r g y ; $ j s o n a r r a y [ ] [ ’ c a r b o h y d r a t e ’ ] = $row−>c a r b o h y d r a t e ; $ j s o n a r r a y [ ] [ ’ p r o t e i n ’ ] = $row−>p r o t e i n ; $ j s o n a r r a y [ ] [ ’ f a t ’ ] = $row−>f a t ; $ j s o n a r r a y [ ] [ ’ f o o d g r o u p ’ ] = $row−>f o o d g r o u p ; } echo j s o n e n c o d e ( $ j s o n a r r a y ) ; } function get fa () { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ i n g r e d i e n t = $ t h i s −>i n p u t −>p o s t ( ’ i n g r e d i e n t ’ ) ; i f ( s t r l e n ( $ i n g r e d i e n t ) < 1) break ; $ r ow s = $ t h i s −>h o m e u s e r m o d e l −>Ge tA uto co mpl et e ( a r r a y ( ’ keyword ’ => $ i n g r e d i e n t )); $response = ””; f o r e a c h ( $ r ow s a s $row ) $ r e s p o n s e = $row−>e n e r g y . ” , ” . $row−>c a r b o h y d r a t e . ” , ” . $row−>p r o t e i n . ” , ” . $row−> fat ; echo $ r e s p o n s e ; } //PLAN DAILY MEALS function plan daily meals () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ p l a n d a i l y m e a l s i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //VIEW SELECTED RECIPE UNDER PLAN MEALS function view created plan recipe ( $own recipe id ) { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t r e c i p e c o n t e n t s ( $ o w n r e c i p e i d ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { 204 $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w r e c i p e p l a n i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } } //VIEW DAILY MEALS BY DATE public function select by date () { $ r e c o r d d a t e = $ t h i s −>i n p u t −>p o s t ( ’ r e c o r d d a t e ’ ) ; i f ( $ r e c o r d d a t e != ” ” ) { $ r e s u l t = $ t h i s −>h o m e u s e r m o d e l −>s h o w d a t a b y d a t e ( $ r e c o r d d a t e ) ; i f ( $ r e s u l t != f a l s e ) { $data [ ’ r e s u l t d i s p l a y ’ ] = $ r e s u l t ; } else { $ d a t a [ ’ r e s u l t d i s p l a y ’ ] = ”No r e c o r d f o u n d ! ” ; } } else { $ d a t a [ ’ d a t e e r r o r m e s s a g e ’ ] = ” Date f i e l d i s r e q u i r e d ” ; } // $ d a t a [ ’ s h o w t a b l e ’ ] = $ t h i s −>v i e w t a b l e ( ) ; $ t h i s −>l o a d −>v i e w ( ’ p l a n d a i l y m e a l s i n d e x ’ , $ d a t a ) ; // var dump ( $ r e s u l t ) ; } //SEARCH MEAL function search meal () { // $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s // $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ r e c o r d d a t e ’ , ’ Date ’ , ’ required ’ ) ; // i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; // $ t h i s −>l o a d −>v i e w ( ’ p l a n d a i l y m e a l s i n d e x ’ ) ; //} // e l s e { // i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { // $ d a t a [ ’ r e c o r d d a t e ’ ] = $ t h i s −>i n p u t −>p o s t ( ’ r e c o r d d a t e ’ ) ; //} $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ q u e r y m e a l ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t s e a r c h m e a l ( ) ; $ t h i s −>l o a d −>v i e w ( ’ s e a r c h m e a l i n d e x ’ , $ d a t a ) ; //} i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //ADD MEAL f u n c t i o n add meal ( $ o w n r e c i p e i d ) { // $ o w n r e c i p e i d = $ t h i s −>i n p u t −>p o s t ( ’ o w n r e c i p e i d ’ ) ; $data [ ’ o w n r e c i p e i d ’ ] = $ o w n r e c i p e i d ; // e c h o $ o w n r e c i p e i d ; $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { $ t h i s −>h o m e u s e r m o d e l −>p r o c e s s a d d m e a l ( $ o w n r e c i p e i d ); // $ m e s s a g e = ” Adding o f Meal S u c c e s s f u l ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / s e a r c h m e a l ” ) ; //</ s c r i p t > ’ ; //} $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , ’ Adding o f Meal S u c c e s s f u l . ’ ) ; r e d i r e c t ( ’ home user / search meal ’ , ’ r e f r e s h ’ ) ; } i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $ d a t a [ ’ middle name ’ ] = $ s e s s i o n d a t a [ ’ middle name ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; 205 $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n redirect ( ’ login ’ , ’ refresh ’ ) ; page } $ t h i s −>l o a d −>v i e w ( ’ a d d m e a l i n d e x ’ , $data ) ; } //DELETE MEAL function delete meal ( $plan daily meal id ) { $ t h i s −>h o m e u s e r m o d e l −>d e l m e a l ( $ p l a n d a i l y m e a l i d ) ; // $ m e s s a g e = ” Meal was s u c c e s f u l l y d e l e t e d ! ” ; // i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { // e c h o ’< s c r i p t > // l o c a t i o n . r e p l a c e ( ” . . / s e l e c t b y d a t e //</ s c r i p t > ’ ; $ t h i s −>s e s s i o n −>s e t f l a s h d a t a ( ’ s u c c e s s m s g ’ , successfully deleted . ’) ; r e d i r e c t ( ’ home user / s e l e c t b y ; //} i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } ”) ; ’ Meal was date ’ , ’ refresh ’) ; //VIEW SELECTED RECIPE FOR MEAL function view created recipe meal ( $own recipe id ) { $ t h i s −>l o a d −>model ( ’ h o m e u s e r m o d e l ’ ) ; $ d a t a [ ’ query ’ ] = $ t h i s −>h o m e u s e r m o d e l −>g e t r e c i p e c o n t e n t s ( $ o w n r e c i p e i d ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; $data [ ’ f i r s t n a m e ’ ] = $ s e s s i o n d a t a [ ’ f i r s t n a m e ’ ] ; $data [ ’ last name ’ ] = $ s e s s i o n d a t a [ ’ last name ’ ] ; $data [ ’ u s e r t y p e ’ ] = $ s e s s i o n d a t a [ ’ u s e r t y p e ’ ] ; $data [ ’ e m a i l a d d r e s s ’ ] = $ s e s s i o n d a t a [ ’ e m a i l a d d r e s s ’ ] ; $data [ ’ gender ’ ] = $ s e s s i o n d a t a [ ’ gender ’ ] ; $data [ ’ birthday ’ ] = $ s e s s i o n d a t a [ ’ birthday ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ v i e w r e c i p e a d d m e a l i n d e x ’ , $ d a t a ) ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } } //FACEBOOK function share achievement fb () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ d a t a [ ’ username ’ ] = $ s e s s i o n d a t a [ ’ username ’ ] ; } else { // I f no s e s s i o n , r e d i r e c t t o l o g i n page redirect ( ’ login ’ , ’ refresh ’ ) ; } $ t h i s −>l o a d −>v i e w ( ’ s h a r e a c h i e v e m e n t f b i n d e x ’ ) ; } function post facebook () { p a r s e s t r ( $ SERVER [ ’ QUERY STRING ’ ] , $ REQUEST ) ; $CI = & g e t i n s t a n c e ( ) ; $CI−>c o n f i g −>l o a d ( ” f a c e b o o k ” ,TRUE) ; $ c o n f i g = $CI−>c o n f i g −>i t e m ( ’ f a c e b o o k ’ ) ; $ t h i s −>l o a d −>l i b r a r y ( ’ Facebook ’ , $ c o n f i g ) ; // Try t o g e t t h e u s e r ’ s i d on Facebook $ u s e r I d = $ t h i s −>f a c e b o o k −>g e t U s e r ( ) ; // I f u s e r i s n o t y e t a u t h e n t i c a t e d , t h e i d w i l l be z e r o i f ( $ u s e r I d == 0 ) { // G e n e r a t e a l o g i n u r l $ d a t a [ ’ u r l ’ ] = $ t h i s −>f a c e b o o k −>g e t L o g i n U r l ( a r r a y ( ’ s c o p e ’=>’ e m a i l , p u b l i s h a c t i o n s ’ / ∗ , ’ r e d i r e c t u r i ’ => ’ h t t p s : / / a g i l a . upm . edu . ph /˜ p j d i z o n /FIM/ h o m e u s e r / share achievement fb ’∗/) ) ; $ u r l = $data [ ’ url ’ ] ; e c h o ”<a h r e f =’ $ u r l ’> Login </a >”; // $ t h i s −>l o a d −>v i e w ( ’ s h a r e a c h i e v e m e n t f b i n d e x ’ , $ d a t a ) ; } else { // Get u s e r ’ s d a t a and p r i n t i t // $ u s e r = $ t h i s −>f a c e b o o k −>a p i ( ’ / me ’ ) ; // p r i n t r ( $ u s e r ) ; // $ d a t a [ ’ u s e r p r o f i l e ’ ] = $ t h i s −>f a c e b o o k −>a p i ( ’ / me ’ ) ; $ t h i s −>f a c e b o o k −>a p i ( ’ / me/ f e e d / ’ , ’POST’ , a r r a y ( ’ message ’ => $ t h i s −>i n p u t −>p o s t ( ’ a c h i e v e m e n t ’ ) , ’ r e d i r e c t u r i ’ => ’ h t t p s : / / a g i l a . upm . edu . ph /˜ p j d i z o n / FIM/ h o m e u s e r ’ ) ) ; 206 $message = ” Posting Successful !”; if o f Achievement t o Facebook ( ( i s s e t ( $ m e s s a g e ) ) && e c h o ’< s c r i p t > alert (” ’. ’’, location . </ s c r i p t > ’ ; ( $ m e s s a g e != ’ ’) ) { s t r r e p l a c e ( array (”\ r ” ,”\n ”) , $message ) . ’ ” ) ; r e p l a c e ( ” . . / home user ”) ; } } } /∗ f u n c t i o n post twitter () { // I t r e a l l y i s b e s t t o auto−l o a d $ t h i s −>l o a d −>l i b r a r y ( ’ t w e e t ’ ) ; this library ! // E n a b l i n g debug w i l l show you any e r r o r s e.g: $ t h i s −>t w e e t−>e n a b l e d e b u g (TRUE) ; in the calls you ’ r e making , // I f you a l r e a d y have a t o k e n s a v e d f o r y o u r u s e r // ( I n a db f o r example ) − S e e l i n e #37 // // You can s e t t h e s e t o k e n s b e f o r e c a l l i n g l o g g e d i n t o t r y u s i n g t h e e x i s t i n g tokens . // $ t o k e n s = a r r a y ( ’ o a u t h t o k e n ’ => ’ f o o ’ , ’ o a u t h t o k e n s e c r e t ’ => ’ bar ’ ) ; $ t o k e n s = a r r a y ( ’ o a u t h t o k e n ’ => ’787163882 −5 XZQdNXKxKfxs7CMpnK8KOQfGG96p9obqSINTcab ’ , ’ o a u t h t o k e n s e c r e t ’ => ’ lUqdGhuXJMbp2qLzhAsxFPxBOwPf7B5jek85ZugKHJ9qA ’ ) ; $ t h i s −>t w e e t−>s e t t o k e n s ( $ t o k e n s ) ; if ( ! $ t h i s −>t w e e t−>l o g g e d i n ( ) ) { // T h i s i s where t h e u r l w i l l go t o a f t e r auth . // ( C a l l b a c k u r l ) $ t h i s −>t w e e t−>s e t c a l l b a c k ( s i t e u r l ( ’ h o m e u s e r / auth ’ ) ) ; // Send t h e u s e r o f f f o r l o g i n ! $ t h i s −>t w e e t−>l o g i n ( ) ; } else { // You can g e t t h e t o k e n s f o r t h e a c t i v e // $ t o k e n s = $ t h i s −>t w e e t−>g e t t o k e n s ( ) ; logged // // These can be s a v e d i n a db a l o n g s i d e a u s e r // i f you a l r e a d y have y o u r own auth s y s t e m . } /∗ $ m e s s a g e = ” P o s t i n g if o f Achievement t o T w i t t e r ( ( i s s e t ( $ m e s s a g e ) ) && e c h o ’< s c r i p t > alert (” ’. ’’, location . </ s c r i p t > ’ ; in user : record Successful !”; ( $ m e s s a g e != ’ ’) ) { s t r r e p l a c e ( array (”\ r ” ,”\n ”) , $message ) . ’ ” ) ; r e p l a c e ( ” . . / home user ”) ; }∗/ // $ t o k e n s = $ t h i s −>t w e e t−>g e t t o k e n s ( ) ; // $ u s e r = $ t h i s −>t w e e t−>c a l l ( ’ g e t ’ , ’ a c c o u n t / verify credentiaaaaaaaaals ’) ; // // W i l l throw an e r r o r w i t h a s t a c k t r a c e . /∗ $ u s e r = $ t h i s −>t w e e t−>c a l l ( ’ g e t ’ , var dump ( $ u s e r ) ; ’ account / v e r i f y c r e d e n t i a l s ’ ) ; $friendship = $ t h i s −>t w e e t−>c a l l ( ’ g e t ’ , ’ f r i e n d s h i p s / show ’ , a r r a y ( ’ s o u r c e s c r e e n n a m e ’ => $ u s e r −>s c r e e n n a m e , ’ t a r g e t s c r e e n n a m e ’ => ’ pjud31 ’ ) ) ; var dump ( $ f r i e n d s h i p ) ; if { ( $ f r i e n d s h i p −>r e l a t i o n s h i p −>t a r g e t −>f o l l o w i n g === FALSE ) $ t h i s −>t w e e t−>c a l l ( ’ p o s t ’ , ’ f r i e n d s h i p s / c r e a t e ’ , a r r a y ( ’ s c r e e n n a m e ’ => $ u s e r −>s c r e e n n a m e , ’ f o l l o w ’ => TRUE) ) ; } $ t h i s −>t w e e t−>c a l l ( ’ p o s t ’ , ’ s t a t u s e s / update ’ , −>i n p u t −>p o s t ( ’ a c h i e v e m e n t ’ ) ) ) ; a r r a y ( ’ s t a t u s ’ => $ t h i s $options = array ( ’ count ’ => 1 0 , ’ page ’ => 2 , ’ i n c l u d e e n t i t i e s ’ => 1 ); $ t i m e l i n e = $ t h i s −>t w e e t−>c a l l ( ’ g e t ’ , var dump ( $ t i m e l i n e ) ; }∗/ /∗ f u n c t i o n auth ( ) { $ t o k e n s = $ t h i s −>t w e e t−>g e t t o k e n s ( ) ; 207 ’ s t a t u s e s / home timeline ’ ) ; // $ u s e r = $ t h i s −>t w e e t−>c a l l ( ’ g e t ’ , ’ a c c o u n t / verify credentiaaaaaaaaals ’) ; // // W i l l throw an e r r o r w i t h a s t a c k t r a c e . $ u s e r = $ t h i s −>t w e e t−>c a l l ( ’ g e t ’ , var dump ( $ u s e r ) ; ’ account / v e r i f y c r e d e n t i a l s ’ ) ; $friendship = $ t h i s −>t w e e t−>c a l l ( ’ g e t ’ , ’ f r i e n d s h i p s / show ’ , a r r a y ( ’ s o u r c e s c r e e n n a m e ’ => $ u s e r −>s c r e e n n a m e , ’ t a r g e t s c r e e n n a m e ’ => ’ pjud31 ’ ) ) ; var dump ( $ f r i e n d s h i p ) ; if { ( $ f r i e n d s h i p −>r e l a t i o n s h i p −>t a r g e t −>f o l l o w i n g === FALSE ) $ t h i s −>t w e e t−>c a l l ( ’ p o s t ’ , ’ f r i e n d s h i p s / c r e a t e ’ , a r r a y ( ’ s c r e e n n a m e ’ => $ u s e r −>s c r e e n n a m e , ’ f o l l o w ’ => TRUE) ) ; } $ t h i s −>t w e e t−>c a l l ( ’ p o s t ’ , ’ s t a t u s e s / update ’ , −>i n p u t −>p o s t ( ’ a c h i e v e m e n t ’ ) ) ) ; a r r a y ( ’ s t a t u s ’ => $ t h i s $options = array ( ’ count ’ => 1 0 , ’ page ’ => 2 , ’ i n c l u d e e n t i t i e s ’ => 1 ); $ t i m e l i n e = $ t h i s −>t w e e t−>c a l l ( ’ g e t ’ , ’ s t a t u s e s / home timeline ’ ) ; var dump ( $ t i m e l i n e ) ; }∗/ } ?> <?php if ( ! d e f i n e d ( ’BASEPATH’ ) ) class Login extends function e x i t ( ’ No d i r e c t script access allowed ’ ) ; CI Controller { construct () { parent : : construct () ; $ t h i s −>l o a d −>model ( ’ l o g i n m o d e l ’ ) ; } function index ( ) { $ t h i s −>l o a d −>h e l p e r ( a r r a y ( ’ form ’ ) ) ; $ t h i s −>l o a d −>h e l p e r ( ’ c a p t c h a ’ ) ; $vals = array ( ’ i m g p a t h ’ => ’ . / c a p t c h a / ’ , ’ i m g u r l ’ => ’ h t t p s : / / a g i l a . upm . edu . ph /˜ p j d i z o n /FIM/ c a p t c h a / ’ ); $cap = c r e a t e c a p t c h a ( $ v a l s ) ; $data = array ( ’ c a p t c h a t i m e ’ => $cap [ ’ time ’ ] , ’ i p a d d r e s s ’ => $ t h i s −>i n p u t −>i p a d d r e s s ( ) , ’ word ’ => $cap [ ’ word ’ ] ); $ t h i s −>s e s s i o n −>s e t u s e r d a t a ( $ d a t a ) ; $ d a t a [ ’ cap img ’ ] = $cap [ ’ image ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ l o g i n i n d e x ’ , $ d a t a ) ; } function save ( ) { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; // f i e l d name , e r r o r message , v a l i d a t i o n r u l e s $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ u s e r n a m e r e g ’ , ’ Username ’ , ’ t r i m | required | alpha numeric | min length [ 4 ] | x s s c l e a n | callback check user ci ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ p a s s w o r d r e g ’ , ’ Password ’ , ’ t r i m | required | alpha numeric | min length [ 8 ] ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c o n f i r m p a s s w o r d r e g ’ , ’ Confirm Password ’ , ’ t r i m | r e q u i r e d | a l p h a n u m e r i c | matches [ p a s s w o r d r e g ] ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ f i r s t n a m e ’ , ’ F i r s t Name ’ , ’ t r i m | required | alpha numeric | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ middle name ’ , ’ M i d d l e Name ’ , ’ alpha numeric | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ l a s t n a m e ’ , ’ L a s t Name ’ , ’ t r i m | required | alpha numeric | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ b i r t h d a t e ’ , ’ B i r t h d a t e ’ , ’ required | xss clean ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ g e n d e r R a d i o ’ , ’ Gender ’ , ’ r e q u i r e d ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ userTypeRadio ’ , ’ U s e r Type ’ , ’ required ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ e m a i l a d d r e s s ’ , ’ Email Address ’ , ’ required | valid email | callback check email ci ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ c a p t c h a ’ , ’ S e c u r i t y Code ’ , ’ t r i m | required | callback check captcha ’ ) ; i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { $ t h i s −>i n d e x ( ) ; } else { $ t h i s −>l o a d −>model ( ’ l o g i n m o d e l ’ ) ; i f ( $ t h i s −>i n p u t −>p o s t ( ’ submit ’ ) ) { 208 $ t h i s −>l o g i n m o d e l −>p r o c e s s ( ) ; } $message = ” R e g i s t r a t i o n S u c c e s s f u l ! ” ; i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { e c h o ’< s c r i p t > a l e r t ( ” ’ . s t r r e p l a c e ( array (”\ r ” ,”\n ”) , $message ) . ’ ” ) ; l o c a t i o n . r e p l a c e ( ” . . / l o g i n ”) ; </ s c r i p t > ’ ; } ’’, } } public function check captcha () { $ e x p i r a t i o n = t i m e ( ) −7200; // Two hour l i m i t $cap=$ t h i s −>i n p u t −>p o s t ( ’ c a p t c h a ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ word ’ )== $cap AND $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ i p a d d r e s s ’ )== $ t h i s −>i n p u t −> ip address () AND $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ c a p t c h a t i m e ’ )> $ e x p i r a t i o n ) { return true ; } else { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( ’ c h e c k c a p t c h a ’ , ’ S e c u r i t y number d o e s n o t match . ’ ) ; return f a l s e ; } } public } public function check user ci () { $ u s r=$ t h i s −>i n p u t −>p o s t ( ’ u s e r n a m e r e g ’ ) ; $ r e s u l t=$ t h i s −>l o g i n m o d e l −>c h e c k u s e r e x i s t ( $ u s r ) ; i f ( $result ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION already e x i s t s . ’ ) ; return f a l s e ; } else { return true ; } , ’ Username function check user () { $ u s r=$ t h i s −>i n p u t −>p o s t ( ’ name ’ ) ; $ r e s u l t=$ t h i s −>l o g i n m o d e l −>c h e c k u s e r e x i s t ( $ u s r ) ; i f ( $result ) { echo ” f a l s e ” ; } else { echo ” t r u e ” ; } } public function check email ci () { $eml=$ t h i s −>i n p u t −>p o s t ( ’ e m a i l a d d r e s s ’ ) ; $ r e s u l t=$ t h i s −>l o g i n m o d e l −>c h e c k e m a i l e x i s t ( $eml ) ; if ( $result ) { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION already registered . ’ ) ; return f a l s e ; } else { return true ; } , ’E−m a i l A d d r e s s } public function check email () { $eml=$ t h i s −>i n p u t −>p o s t ( ’ e m a i l ’ ) ; $ r e s u l t=$ t h i s −>l o g i n m o d e l −>c h e c k e m a i l e x i s t ( $eml ) ; if ( $result ) { echo ” f a l s e ” ; } else { echo ” t r u e ” ; } } //FORGOT PASSWORD CONTROLLERS public function forget password () { $ t h i s −>l o a d −>v i e w ( ’ l o g i n f o r g e t i n d e x ’ ) ; } public function doforget () { $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ e m a i l a d d r e s s ’ , valid email | callback check email ci exists ’) ; ’ Email Address ’ , ’ required | i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // $ t h i s −>i n d e x ( ) ; $ t h i s −>l o a d −>v i e w ( ’ l o g i n f o r g e t i n d e x ’ ) ; } else { $ t h i s −>l o a d −>h e l p e r ( ’ u r l ’ ) ; $ e m a i l a d d r e s s= $ POST [ ’ e m a i l a d d r e s s ’ ] ; $q = $ t h i s −>db−>q u e r y ( ” s e l e c t ∗ from u s e r s where e m a i l a d d r e s s = ’” . $email address . ” ’”) ; 209 if ( $q−>num rows > 0 ) { $ r = $q−>r e s u l t ( ) ; $ u s e r=$ r [ 0 ] ; $ t h i s −>r e s e t p a s s w o r d ( $ u s e r ) ; } $ m e s s a g e = ” Email S e n t . P l e a s e c h e c k y o u r e m a i l f o r d e t a i l s . ” ; i f ( ( i s s e t ( $ m e s s a g e ) ) && ( $ m e s s a g e != ’ ’ ) ) { e c h o ’< s c r i p t > a l e r t ( ” ’ . s t r r e p l a c e ( array (”\ r ” ,”\n ”) , $message ) . ’ ” ) ; l o c a t i o n . r e p l a c e ( ” . . / l o g i n ”) ; </ s c r i p t > ’ ; } ’’, } } function resetpassword ( $user ) { d a t e d e f a u l t t i m e z o n e s e t ( ’GMT’ ) ; $ t h i s −>l o a d −>h e l p e r ( ’ s t r i n g ’ ) ; $ p a s s w o r d= r a n d o m s t r i n g ( ’ alnum ’ , 1 6 ) ; $ t h i s −>db−>where ( ’ username ’ , $ u s e r −>username ) ; $ t h i s −>db−>u p d a t e ( ’ u s e r s ’ , a r r a y ( ’ password ’=>MD5( $ p a s s w o r d ) , ’=>MD5( $ p a s s w o r d ) ) ) ; $ci = get instance () ; $ c i −>l o a d −>l i b r a r y ( ’ e m a i l ’ ) ; $ c o n f i g [ ’ p r o t o c o l ’ ] = ” smtp ” ; $ c o n f i g [ ’ s m t p h o s t ’ ] = ” s s l : / / smtp . g m a i l . com ” ; $ c o n f i g [ ’ smtp port ’ ] = ”465”; $ c o n f i g [ ’ s m t p u s e r ’ ] = ” h e a s f i m . n o r e p l y @ g m a i l . com ” ; $ c o n f i g [ ’ smtp pass ’ ] = ” sasablayakothissem2015 ” ; $ c o n f i g [ ’ c h a r s e t ’ ] = ” u t f −8”; $ c o n f i g [ ’ m a i l t y p e ’ ] = ” html ” ; $ c o n f i g [ ’ n e w l i n e ’ ] = ”\ r \n ” ; private ’ confirm password $ c i −>e m a i l −> i n i t i a l i z e ( $ c o n f i g ) ; $ c i −>e m a i l −>from ( ’ h e a s f i m . n o r e p l y @ g m a i l . com ’ , ’HEAS : FIM ’ ) ; // $ l i s t = a r r a y ( ’ xxx@gmail . com ’ ) ; $ c i −>e m a i l −>t o ( $ u s e r −>e m a i l a d d r e s s ) ; // $ t h i s −>e m a i l −>r e p l y t o ( ’ my−e m a i l @ g m a i l . com ’ , ’My Email ’ ) ; $ c i −>e m a i l −>s u b j e c t ( ’ Password R e s e t ’ ) ; $ c i −>e m a i l −>m e s s a g e ( ’ You have r e q u e s t e d a new p a s s w o r d . Here i s y o u r new p a s s w o r d : ’ . $password ) ; $ c i −>e m a i l −>s e n d ( ) ; } public function check email ci exists () { $eml=$ t h i s −>i n p u t −>p o s t ( ’ e m a i l a d d r e s s ’ ) ; $ r e s u l t=$ t h i s −>l o g i n m o d e l −>c h e c k e m a i l e x i s t ( $eml ) ; if ( $result ) { return true ; } else { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( FUNCTION not e x i s t . ’ ) ; return f a l s e ; } , ’E−m a i l A d d r e s s d o e s } } ?> <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; s e s s i o n s t a r t ( ) ; //we need t o c a l l PHP’ s s e s s i o n o b j e c t t o a c c e s s i t t h r o u g h CI class Logout e x t e n d s function CI Controller { construct () { parent : : construct () ; } //LOGOUT function logout () { $ t h i s −>s e s s i o n −>u n s e t u s e r d a t a ( ’ l o g g e d i n ’ ) ; session destroy () ; redirect ( ’ login ’ , ’ refresh ’ ) ; } } ?> <?php if ( ! d e f i n e d ( ’BASEPATH’ ) ) class VerifyLogin function extends e x i t ( ’ No d i r e c t script access allowed ’ ) ; CI Controller { construct () { parent : : construct () ; $ t h i s −>l o a d −>model ( ’ l o g i n m o d e l ’ , ’ ’ ,TRUE) ; } function index ( ) { // T h i s method w i l l have t h e c r e d e n t i a l s v a l i d a t i o n $ t h i s −>l o a d −>l i b r a r y ( ’ f o r m v a l i d a t i o n ’ ) ; 210 $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ username ’ , xss clean ’) ; $ t h i s −>f o r m v a l i d a t i o n −>s e t r u l e s ( ’ password ’ , xss clean | callback check database ’ ) ; ’ Username ’ , ’ trim | r e q u i r e d | ’ Password ’ , ’ trim | r e q u i r e d | i f ( $ t h i s −>f o r m v a l i d a t i o n −>run ( ) == FALSE) { // F i e l d v a l i d a t i o n f a i l e d . U s e r r e d i r e c t e d t o l o g i n page // $ t h i s −>l o a d −>v i e w ( ’ l o g i n i n d e x ’ ) ; $ t h i s −>l o a d −>h e l p e r ( a r r a y ( ’ form ’ ) ) ; $ t h i s −>l o a d −>h e l p e r ( ’ c a p t c h a ’ ) ; $vals = array ( ’ i m g p a t h ’ => ’ . / c a p t c h a / ’ , ’ i m g u r l ’ => ’ h t t p s : / / a g i l a . upm . edu . ph /˜ p j d i z o n /FIM/ c a p t c h a / ’ ); $cap = c r e a t e c a p t c h a ( $ v a l s ) ; $data = array ( ’ c a p t c h a t i m e ’ => $cap [ ’ time ’ ] , ’ i p a d d r e s s ’ => $ t h i s −>i n p u t −>i p a d d r e s s ( ) , ’ word ’ => $cap [ ’ word ’ ] ); $ t h i s −>s e s s i o n −>s e t u s e r d a t a ( $ d a t a ) ; $ d a t a [ ’ cap img ’ ] = $cap [ ’ image ’ ] ; $ t h i s −>l o a d −>v i e w ( ’ l o g i n i n d e x ’ , $ d a t a ) ; } else { //Go t o p r i v a t e a r e a r e d i r e c t ( ’ home ’ , ’ r e f r e s h ’ ) ; } } function c h e c k d a t a b a s e ( $password ) { // F i e l d v a l i d a t i o n s u c c e e d e d . Validate against $username = $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) ; $ f i r s t n a m e = $ t h i s −>i n p u t −>p o s t ( ’ f i r s t n a m e ’ ) ; $ u s e r t y p e = $ t h i s −>i n p u t −>p o s t ( ’ u s e r t y p e ’ ) ; // q u e r y t h e d a t a b a s e $ r e s u l t = $ t h i s −>l o g i n m o d e l −>l o g i n ( $username , database $password ) ; if ( $result ) { $ s e s s a r r a y = array () ; f o r e a c h ( $ r e s u l t a s $row ) { $ s e s s a r r a y = array ( ’ u s e r i d ’ => $row−>u s e r i d , ’ username ’ => $row−>username , ’ f i r s t n a m e ’ => $row−>f i r s t n a m e , ’ middle name ’ => $row−>middle name , ’ l a s t n a m e ’ => $row−>l a s t n a m e , ’ u s e r t y p e ’ => $row−>u s e r t y p e , ’ e m a i l a d d r e s s ’ => $row−>e m a i l a d d r e s s , ’ g e n d e r ’ => $row−>g e n d e r , ’ b i r t h d a y ’ => $row−>b i r t h d a y , ’ s t a t u s ’ => $row−>s t a t u s ); } i f ( $row−>s t a t u s !=” D e a c t i v a t e d ” ) { $ t h i s −>s e s s i o n −>s e t u s e r d a t a ( ’ l o g g e d i n ’ , r e t u r n TRUE; } $sess array ) ; else { $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( ’ c h e c k d a t a b a s e ’ , might be d e a c t i v a t e d a t t h e moment . ’ ) ; return f a l s e ; ’ Your a c c o u n t $ t h i s −>f o r m v a l i d a t i o n −>s e t m e s s a g e ( ’ c h e c k d a t a b a s e ’ , Username o r Password . ’ ) ; return f a l s e ; ’ Invalid } } else { } } } ?> B..3 Models <?php c l a s s Home Admin Model e x t e n d s CI Model { //USER SEARCH MODEL/S f u n c t i o n Ge tA uto co mpl et e ( $ o p t i o n s = a r r a y ( ) ) { $ t h i s −>db−>s e l e c t ( ’ u s e r i d , username , f i r s t n a m e , middle name , u s e r t y p e , e m a i l a d d r e s s , gender , birthday ’ ) ; $ t h i s −>db−>l i k e ( ’ username ’ , $ o p t i o n s [ ’ keyword ’ ] , ’ a f t e r ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ u s e r s ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } function get search () { $match = $ t h i s −>i n p u t −>p o s t ( ’ s e a r c h ’ ) ; $ t h i s −>db−>l i k e ( ’ u s e r i d ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ username ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f i r s t n a m e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ middle name ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ l a s t n a m e ’ , $match ) ; 211 last name , $ t h i s −>db−>o r l i k e ( ’ u s e r t y p e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ e m a i l a d d r e s s ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ g e n d e r ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ b i r t h d a y ’ , $match ) ; $ t h i s −>db−>o r d e r b y ( ’ u s e r i d ’ , ’ d e s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ u s e r s ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } //ADD USER MODEL/S function process () { $username = $ t h i s −>i n p u t −>p o s t ( ’ username ’ ) ; $ p a s s w o r d = $ t h i s −>i n p u t −>p o s t ( ’ password ’ ) ; $ c o n f i r m p a s s w o r d = $ t h i s −>i n p u t −>p o s t ( ’ c o n f i r m p a s s w o r d ’ ) ; $ f i r s t n a m e = $ t h i s −>i n p u t −>p o s t ( ’ f i r s t n a m e ’ ) ; $ m i d d l e n a m e = $ t h i s −>i n p u t −>p o s t ( ’ middle name ’ ) ; $ l a s t n a m e = $ t h i s −>i n p u t −>p o s t ( ’ l a s t n a m e ’ ) ; $ g e n d e r = $ t h i s −>i n p u t −>p o s t ( ’ g e n d e r R a d i o ’ ) ; $ u s e r t y p e = $ t h i s −>i n p u t −>p o s t ( ’ userTypeRadio ’ ) ; $ e m a i l a d d r e s s = $ t h i s −>i n p u t −>p o s t ( ’ e m a i l a d d r e s s ’ ) ; $ b i r t h d a y = $ t h i s −>i n p u t −>p o s t ( ’ b i r t h d a t e ’ ) ; $data = array ( ’ username ’ => $username , ’ password ’ => MD5( $ p a s s w o r d ) , ’ c o n f i r m p a s s w o r d ’ => MD5( $ c o n f i r m p a s s w o r d ) , ’ f i r s t n a m e ’ => $ f i r s t n a m e , ’ middle name ’ => $middle name , ’ l a s t n a m e ’ => $ l a s t n a m e , ’ g e n d e r ’ => $ g e n d e r , ’ u s e r t y p e ’ => $ u s e r t y p e , ’ e m a i l a d d r e s s ’ => $ e m a i l a d d r e s s , ’ b i r t h d a y ’ => $ b i r t h d a y ); $ t h i s −>db−>i n s e r t ( ’ u s e r s ’ , $ d a t a ) ; } public function c h e c k u s e r e x i s t ( $usr ) { $ t h i s −>db−>where ( ” username ” , $ u s r ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } public f u n c t i o n c h e c k e m a i l e x i s t ( $eml ) { $ t h i s −>db−>where ( ” e m a i l a d d r e s s ” , $eml ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } //DELETE USER MODEL p u b l i c f u n c t i o n d e l u s e r ( $username ) { $ t h i s −>db−>where ( ’ username ’ , $username ) ; $ t h i s −>db−>d e l e t e ( ’ u s e r s ’ ) ; } //EDIT USER MODEL p u b l i c f u n c t i o n u p d a t e u s e r ( $username , $ d a t a ) { $ t h i s −>db−>where ( ’ username ’ , $username ) ; $ t h i s −>db−>u p d a t e ( ’ u s e r s ’ , $ d a t a ) ; } function g e t u s e r ( $username ) { $ t h i s −>db−>s e l e c t ( ’ username , f i r s t n a m e , middle name , e m a i l a d d r e s s , gender , birthday , s t a t u s ’ ) ; $ t h i s −>db−>where ( ’ username ’ , $username ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ u s e r s ’ ) ; r e t u r n $query−>r o w a r r a y ( ) ; // r e t u r n $query−>r e s u l t ( ) ; } public //EDIT PROFILE MODEL f u n c t i o n u p d a t e p r o f i l e ( $username , $ d a t a ) { $ t h i s −>db−>where ( ’ username ’ , $username ) ; $ t h i s −>db−>u p d a t e ( ’ u s e r s ’ , $ d a t a ) ; } //EDIT PASSWORD MODEL p u b l i c f u n c t i o n u p d a t e p a s s w o r d ( $username , $ d a t a ) { $ t h i s −>db−>where ( ’ username ’ , $username ) ; $ t h i s −>db−>u p d a t e ( ’ u s e r s ’ , $ d a t a ) ; } public f u n c t i o n c h e c k o l d p a s s w o r d e x i s t ( $opwd ) { $ t h i s −>db−>where ( ” p a s s w o r d ” , $opwd ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } 212 last name , user type , else { return false ; } } } ?> <?php c l a s s Home Cmanager Model e x t e n d s CI Model { public function c h e c k u s e r e x i s t ( $usr ) { $ t h i s −>db−>where ( ” username ” , $ u s r ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } public f u n c t i o n c h e c k e m a i l e x i s t ( $eml ) { $ t h i s −>db−>where ( ” e m a i l a d d r e s s ” , $eml ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } //EDIT PROFILE MODEL p u b l i c f u n c t i o n u p d a t e p r o f i l e ( $username , $ d a t a ) { $ t h i s −>db−>where ( ’ username ’ , $username ) ; $ t h i s −>db−>u p d a t e ( ’ u s e r s ’ , $ d a t a ) ; } //EDIT PASSWORD MODEL p u b l i c f u n c t i o n u p d a t e p a s s w o r d ( $username , $ d a t a ) { $ t h i s −>db−>where ( ’ username ’ , $username ) ; $ t h i s −>db−>u p d a t e ( ’ u s e r s ’ , $ d a t a ) ; } public f u n c t i o n c h e c k o l d p a s s w o r d e x i s t ( $opwd ) { $ t h i s −>db−>where ( ” p a s s w o r d ” , $opwd ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } //ADD HEALTH TIP MODEL function process healthtip () { $ h e a l t h t i p = $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h t i p ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; $data [ ’ h e a l t h t i p ’ ] = $ h e a l t h t i p ; $ d a t a [ ’ p o s t d a t e ’ ] = d a t e ( ’ y−m−d ’ ) ; $ t h i s −>db−>i n s e r t ( ’ h e a l t h t i p s ’ , $ d a t a ) ; } else e c h o ( ’ S e s s i o n Timeout . ’ ) ; } //DELETE HEALTH TIP MODEL public function del health tip ( $health tip id ) { // $ t h i s −>db−>where ( ’ f i t n e s s i n f o i d ’ , $ f i t n e s s i n f o i d ) ; $ t h i s −>db−>d e l e t e ( ’ h e a l t h t i p s ’ , a r r a y ( ’ h e a l t h t i p i d ’ => $ h e a l t h t i p i d ) ) ; } //ADD FOOD EXCHANGE LIST ITEM p u b l i c f u n c t i o n c h e c k f e l i t e m e x i s t ( $food name ) { $ t h i s −>db−>where ( ” f o o d n a m e ” , $ f o o d n a m e ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” f o o d e x c h a n g e l i s t ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } function process felitem (){ i f ( i s s e t ( $ POST [ ’ l i s t g r o u p o t h e r ’ ] , $ POST [ ’ f o o d g r o u p o t h e r ’ ] , $ POST [ ’ food group categoryother ’ ] ) ) { $ l i s t g r o u p = $ t h i s −>i n p u t −>p o s t ( ’ l i s t g r o u p o t h e r ’ ) ; $ f o o d g r o u p = $ t h i s −>i n p u t −>p o s t ( ’ f o o d g r o u p o t h e r ’ ) ; $ f o o d g r o u p c a t e g o r y = $ t h i s −>i n p u t −>p o s t ( ’ f o o d g r o u p c a t e g o r y o t h e r ’ ) ; } else { 213 $ l i s t g r o u p = $ t h i s −>i n p u t −>p o s t ( ’ l i s t g r o u p ’ ) ; $ f o o d g r o u p = $ t h i s −>i n p u t −>p o s t ( ’ f o o d g r o u p ’ ) ; $ f o o d g r o u p c a t e g o r y = $ t h i s −>i n p u t −>p o s t ( ’ f o o d g r o u p c a t e g o r y ’ ) ; } $ f o o d n a m e = $ t h i s −>i n p u t −>p o s t ( ’ food name ’ ) ; $ me a su r e = $ t h i s −>i n p u t −>p o s t ( ’ measure ’ ) ; $ c a r b o h y d r a t e = $ t h i s −>i n p u t −>p o s t ( ’ c a r b o h y d r a t e ’ ) ; $ p r o t e i n = $ t h i s −>i n p u t −>p o s t ( ’ p r o t e i n ’ ) ; $ f a t = $ t h i s −>i n p u t −>p o s t ( ’ f a t ’ ) ; $ e n e r g y = $ t h i s −>i n p u t −>p o s t ( ’ e n e r g y ’ ) ; $ w e i g h t a s p u r c h a s e d = $ t h i s −>i n p u t −>p o s t ( ’ w e i g h t a s p u r c h a s e d ’ ) ; $ w e i g h t e d i b l e p o r t i o n = $ t h i s −>i n p u t −>p o s t ( ’ w e i g h t e d i b l e p o r t i o n ’ ) ; $data = array ( ’ l i s t g r o u p ’ => $ l i s t g r o u p , ’ f o o d g r o u p ’ => $ f o o d g r o u p , ’ f o o d g r o u p c a t e g o r y ’ => $ f o o d g r o u p c a t e g o r y , ’ food name ’ => $food name , ’ measure ’ => $measure , ’ c a r b o h y d r a t e ’ => $ c a r b o h y d r a t e , ’ p r o t e i n ’ => $ p r o t e i n , ’ f a t ’ => $ f a t , ’ e n e r g y ’ => $ e n e r g y , ’ w e i g h t a s p u r c h a s e d ’ => $ w e i g h t a s p u r c h a s e d , ’ w e i g h t e d i b l e p o r t i o n ’ => $ w e i g h t e d i b l e p o r t i o n ); $ t h i s −>db−>i n s e r t ( ’ f o o d e x c h a n g e l i s t ’ , $ d a t a ) ; } //DELETE FEL ITEM public function del fel item ( $food exchange list id ) { // $ t h i s −>db−>where ( ’ f i t n e s s i n f o i d ’ , $ f i t n e s s i n f o i d ) ; $ t h i s −>db−>d e l e t e ( ’ f o o d e x c h a n g e l i s t ’ , a r r a y ( ’ f o o d e x c h a n g e l i s t i d ’ => $food exchange list id ) ) ; } function get search fel () { $match = $ t h i s −>i n p u t −>p o s t ( ’ s e a r c h f e l ’ ) ; $ t h i s −>db−>l i k e ( ’ l i s t g r o u p ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f o o d g r o u p ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f o o d g r o u p c a t e g o r y ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ food name ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ measure ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a r b o h y d r a t e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ p r o t e i n ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f a t ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ e n e r g y ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ w e i g h t a s p u r c h a s e d ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ w e i g h t e d i b l e p o r t i o n ’ , $match ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ f o o d e x c h a n g e l i s t ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } function get search ht () { $match = $ t h i s −>i n p u t −>p o s t ( ’ s e a r c h h t ’ ) ; $ t h i s −>db−>l i k e ( ’ h e a l t h t i p ’ , $match ) ; $ t h i s −>db−>o r d e r b y ( ’ h e a l t h t i p i d ’ , ’ d e s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ h e a l t h t i p s ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } //VIEW CREATED RECIPES MODEL function process view created recipes () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; /∗ $ t h i s −>db−>s e l e c t ( ’ o . ∗ , i . ∗ ’ ) ; $ t h i s −>db−>from ( ’ o w n r e c i p e s o , i n g r e d i e n t s i ’ ) ; $ t h i s −>db−>where ( ’ o . u s e r i d ’ , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d = i . o w n r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>from ( ’ r e c o m m e n d e d r e c i p e s ’ ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ t h i s −>db−>o r d e r b y ( ’ r e c o m m e n d e d r e c i p e i d ’ , $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ’ desc ’ ) ; } } //EDIT CREATED RECIPE function g e t c r e a t e d r e c i p e ( $recommended recipe id ) { $ t h i s −>db−>s e l e c t ( ’ o . ∗ , i . ∗ , r . ∗ ’ ) ; $ t h i s −>db−>from ( ’ r e c o m m e n d e d r e c i p e s o , i n g r e d i e n t s r e c o m m e n d e d i , recipe images recommended r ’ ) ; $ t h i s −>db−>where ( ’ o . r e c o m m e n d e d r e c i p e i d ’ , $ r e c o m m e n d e d r e c i p e i d ) ; $ t h i s −>db−>where ( ’ o . r e c o m m e n d e d r e c i p e i d = i . r e c o m m e n d e d r e c i p e i d ’ ) ; $ t h i s −>db−>where ( ’ o . r e c o m m e n d e d r e c i p e i d = r . r e c o m m e n d e d r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; // r e t u r n $query−>r o w a r r a y ( ) ; r e t u r n $query−>r e s u l t ( ) ; 214 } //UPDATE RECIPE MODEL p u b l i c f u n c t i o n u p d a t e r e c i p e ( $ r e c o m m e n d e d r e c i p e i d , $data , $ d a t a 2 ) { $ t h i s −>db−>where ( ’ r e c o m m e n d e d r e c i p e i d ’ , $ r e c o m m e n d e d r e c i p e i d ) ; $ t h i s −>db−>u p d a t e ( ’ r e c o m m e n d e d r e c i p e s ’ , $ d a t a ) ; // $ o w n r e c i p e i d = $ t h i s −>db−>i n s e r t i d ( ) ; // t h i s −>db−>u p d a t e ( ’ i n g r e d i e n t s ’ , $ d a t a 2 ) ; f o r ( $ i = 0 ; $ i < c o u n t ( $ d a t a 2 [ ’ food name ’ ] ) ; $ i ++) { $data3 = array ( ’ food name ’=> $ d a t a 2 [ ’ food name ’ ] [ $ i ] , ’ f o o d g r o u p ’=> $ d a t a 2 [ ’ f o o d g r o u p ’ ] [ $ i ] , ’ measure ’=> $ d a t a 2 [ ’ measure ’ ] [ $ i ] , ’ s e r v i n g s i z e ’=> $ d a t a 2 [ ’ s e r v i n g s i z e ’ ] [ $ i ] , ); i f ( $ d a t a 2 [ ’ i n g r e d i e n t i d ’ ] [ $ i ] == n u l l | | $ d a t a 2 [ ’ i n g r e d i e n t i d ’ ] [ $ i ] == ” ” ) { $data3 [ ’ recommended recipe id ’ ] = $recommended recipe id ; $ t h i s −>db−>i n s e r t ( ’ i n g r e d i e n t s r e c o m m e n d e d ’ , $ d a t a 3 ) ; } else { $ t h i s −>db−>where ( ’ i n g r e d i e n t i d ’ , $ d a t a 2 [ ’ i n g r e d i e n t i d ’ ] [ $ i ] ) ; $ t h i s −>db−>u p d a t e ( ’ i n g r e d i e n t s r e c o m m e n d e d ’ , $ d a t a 3 ) ; } } } //VIEW RECIPE function g e t r e c i p e c o n t e n t s ( $recommended recipe id ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $session data [ ’ user id ’ ] ; $ u s e r i d= $data [ ’ u s e r i d ’ ] = $ u s e r i d ; /∗ $ t h i s −>db−>s e l e c t ( ’ o . ∗ , i . ∗ ’ ) ; $ t h i s −>db−>from ( ’ o w n r e c i p e s o , i n g r e d i e n t s i ’ ) ; $ t h i s −>db−>where ( ’ o . u s e r i d ’ , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d = i . o w n r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / /∗ $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>from ( ’ i n g r e d i e n t s ’ ) ; $ t h i s −>db−>where ( ” o w n r e c i p e i d ” , $ o w n r e c i p e i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / $ t h i s −>db−>s e l e c t ( ’ r . ∗ , i . ∗ , c . ∗ ’ ) ; $ t h i s −>db−>from ( ’ r e c o m m e n d e d r e c i p e s r , i n g r e d i e n t s r e c o m m e n d e d i , recipe images recommended c ’ ) ; $ t h i s −>db−>where ( ’ i . r e c o m m e n d e d r e c i p e i d ’ , $ r e c o m m e n d e d r e c i p e i d ) ; $ t h i s −>db−>where ( ’ i . r e c o m m e n d e d r e c i p e i d = r . r e c o m m e n d e d r e c i p e i d ’ ) ; $ t h i s −>db−>where ( ’ c . r e c o m m e n d e d r e c i p e i d = r . r e c o m m e n d e d r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; } } //DELETE CREATED RECIPE public function d e l c r e a t e d r e c i p e ( $recommended recipe id ) { // $ t h i s −>db−>where ( ’ f i t n e s s i n f o i d ’ , $ f i t n e s s i n f o i d ) ; $ t h i s −>db−>d e l e t e ( ’ r e c o m m e n d e d r e c i p e s ’ , a r r a y ( ’ r e c o m m e n d e d r e c i p e i d ’ => $recommended recipe id ) ) ; $ t h i s −>db−>d e l e t e ( ’ i n g r e d i e n t s r e c o m m e n d e d ’ , a r r a y ( ’ r e c o m m e n d e d r e c i p e i d ’ => $recommended recipe id ) ) ; $ t h i s −>db−>d e l e t e ( ’ r e c i p e i m a g e s r e c o m m e n d e d ’ , a r r a y ( ’ r e c o m m e n d e d r e c i p e i d ’ => $ r e c o m m e n d e d r e c i p e i d ) ) ; } //DELETE INGREDIENTS public function del ingredient ( $ingredient id ) { $ t h i s −>db−>d e l e t e ( ’ i n g r e d i e n t s r e c o m m e n d e d ’ , $ingredient id ) ) ; } a r r a y ( ’ i n g r e d i e n t i d ’ => //ADD RECIPE MODEL f u n c t i o n p r o c e s s a d d r e c i p e ( $data3 ) { // $ h e a l t h c o n d i t i o n = $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h c o n d i t i o n ’ ) ; $ h e a l t h c o n d i t i o n = i m p l o d e ( ” , ” , $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h c o n d i t i o n ’ ) ) ; $ m e a l t y p e = $ t h i s −>i n p u t −>p o s t ( ’ m e a l t y p e ’ ) ; $ r e c i p e n a m e = $ t h i s −>i n p u t −>p o s t ( ’ r e c i p e n a m e ’ ) ; $ s e r v i n g s u g g = $ t h i s −>i n p u t −>p o s t ( ’ s e r v i n g s u g g ’ ) ; $ p r e p a r a t i o n p r o c e d u r e = $ t h i s −>i n p u t −>p o s t ( ’ p r e p a r a t i o n p r o c e d u r e ’ ) ; $ c a l o r i e s = $ t h i s −>i n p u t −>p o s t ( ’ c a l o r i e s ’ ) ; $ c a r b o h y d r a t e = $ t h i s −>i n p u t −>p o s t ( ’ c a r b o h y d r a t e ’ ) ; $ p r o t e i n = $ t h i s −>i n p u t −>p o s t ( ’ p r o t e i n ’ ) ; $ f a t = $ t h i s −>i n p u t −>p o s t ( ’ f a t ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data $data $data $data $data $data [ [ [ [ [ [ ’ ’ ’ ’ ’ ’ user id ’ ] = $user id ; health condition ’ ] = $health condition ; meal type ’ ] = $meal type ; recipe name ’ ] = $recipe name ; serving sugg ’]= $serving sugg ; preparation procedure ’ ] = $preparation procedure ; 215 $data $data $data $data [ [ [ [ ’ ’ ’ ’ calories ’ ] = $calories ; carbohydrate ’ ] = $carbohydrate ; protein ’ ] = $protein ; fat ’ ] = $fat ; $ t h i s −>db−>i n s e r t ( ’ r e c o m m e n d e d r e c i p e s ’ , $ d a t a ) ; $ r e c o m m e n d e d r e c i p e i d = $ t h i s −>db−>i n s e r t i d ( ) ; if ( i s s e t ( $ POST [ ’ i n g r e d i e n t s ’ ] , $ POST [ ’ f o o d g r o u p ’ ] , $ POST [ ’ i n g r e d i e n t m e a s u r e ’ ] , $ POST [ ’ i n g r e d i e n t q u a n t i t y ’ ] ) ) { f o r ( $ i =0; $ i <c o u n t ( $ POST [ ’ i n g r e d i e n t s ’ ] ) ; $ i ++) { $ i n g r e d i e n t s = $ POST [ ’ i n g r e d i e n t s ’ ] [ $ i ] ; $ f o o d g r o u p = $ POST [ ’ f o o d g r o u p ’ ] [ $ i ] ; $ i n g r e d i e n t m e a s u r e =$ POST [ ’ i n g r e d i e n t m e a s u r e ’ ] [ $ i ] ; $ i n g r e d i e n t q u a n t i t y = $ POST [ ’ i n g r e d i e n t q u a n t i t y ’ ] [ $i ] ; $data2 [ ’ recommended recipe id ’ ] = $recommended recipe id ; $ d a t a 2 [ ’ food name ’ ] = $ i n g r e d i e n t s ; $data2 [ ’ food group ’ ] = $food group ; $ d a t a 2 [ ’ measure ’ ] = $ i n g r e d i e n t m e a s u r e ; $data2 [ ’ s e r v i n g s i z e ’ ] = $ i n g r e d i e n t q u a n t i t y ; /∗ $counts = array count values ( $food group ) ; echo $counts [ ’ Vegetable ’ ] ; ∗/ $ t h i s −>db−>i n s e r t ( ’ i n g r e d i e n t s r e c o m m e n d e d ’ , $ d a t a 2 ) ; } } $data3 [ ’ recommended recipe id ’ ] = $recommended recipe id ; $ t h i s −>db−>i n s e r t ( ’ r e c i p e i m a g e s r e c o m m e n d e d ’ , $data3 ) ; } else e c h o ” S e s s i o n Timeout ” ; } //ADD INGREDIENT AUTOCOMPLETE f u n c t i o n Ge tAu to co mpl et e ( $ o p t i o n s = a r r a y ( ) ) { $ t h i s −>db−>s e l e c t ( ’ f o o d g r o u p , food name , w e i g h t e d i b l e p o r t i o n , carbohydrate , protein , fat ’ ) ; $ t h i s −>db−>l i k e ( ’ food name ’ , $ o p t i o n s [ ’ keyword ’ ] , ’ a f t e r ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ f o o d e x c h a n g e l i s t ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } energy , //SEARCH FOR MEAL MODEL function get search meal () { $match = $ t h i s −>i n p u t −>p o s t ( ’ s e a r c h m e a l ’ ) ; $ t h i s −>db−>l i k e ( ’ r e c o m m e n d e d r e c i p e i d ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ u s e r i d ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ h e a l t h c o n d i t i o n ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ m e a l t y p e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ r e c i p e n a m e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ s e r v i n g s u g g ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ p r e p a r a t i o n p r o c e d u r e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a l o r i e s ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a r b o h y d r a t e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ p r o t e i n ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f a t ’ , $match ) ; $ t h i s −>db−>o r d e r b y ( ’ r e c o m m e n d e d r e c i p e i d ’ , ’ d e s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ r e c o m m e n d e d r e c i p e s ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } //ADD MEAL function process addmeal ( $recommended recipe id ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $session data [ ’ user id ’ ] ; $user id = $ m e a l g r o u p = $ t h i s −>i n p u t −>p o s t ( ’ m e a l g r o u p ’ ) ; $ r e c o r d d a t e = $ t h i s −>i n p u t −>p o s t ( ’ r e c o r d d a t e ’ ) ; $data $data $data $data $data [ [ [ [ [ ’ ’ ’ ’ ’ user id ’ ] = $user id ; recommended recipe id ’ ] = $recommended recipe id ; meal group ’ ] = $meal group ; meal group ’ ] = $meal group ; record date ’ ] = $record date ; $ t h i s −>db−>i n s e r t ( ’ r e c o m m e n d e d d a i l y m e a l s ’ , $ d a t a ) ; } else e c h o ” S e s s i o n Timeout ” ; } //DELETE MEAL public function del meal ( $recommended daily meal id ) { // $ t h i s −>db−>where ( ’ f i t n e s s i n f o i d ’ , $ f i t n e s s i n f o i d ) ; $ t h i s −>db−>d e l e t e ( ’ r e c o m m e n d e d d a i l y m e a l s ’ , a r r a y ( ’ r e c o m m e n d e d d a i l y m e a l i d ’ => $ r e c o m m e n d e d d a i l y m e a l i d ) ) ; } //VIEW DAILY MEALS BY DATE MODEL public function show data by date ( $record date ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; 216 $ u s e r i d= $session data [ ’ user id ’ ] ; // $ d a t a [ ’ u s e r i d ’ ] = $ u s e r i d ; // $ c o n d i t i o n = ” r e c o r d d a t e =” . ” ’ ” . $record date . ” ’”; $ t h i s −>db−>s e l e c t ( ’ d . ∗ , r . ∗ ’ ) ; $ t h i s −>db−>from ( ’ r e c o m m e n d e d d a i l y m e a l s d , r e c o m m e n d e d r e c i p e s r ’ ) ; $ t h i s −>db−>where ( ” d . u s e r i d ” , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ d . r e c o r d d a t e ’ , $ r e c o r d d a t e ) ; $ t h i s −>db−>where ( ’ d . r e c o m m e n d e d r e c i p e i d = r . r e c o m m e n d e d r e c i p e i d ’ ) ; $ t h i s −>db−>o r d e r b y ( ’ m e a l g r o u p ’ , ’ a s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; ( $query−>num rows ( ) > 0 ) { r e t u r n $query−>r e s u l t ( ) ; } else { return f a l s e ; } if } } //EDIT FEL MODEL p u b l i c f u n c t i o n u p d a t e f e l ( $ f o o d e x c h a n g e l i s t i d , $data ) { $ t h i s −>db−>where ( ’ f o o d e x c h a n g e l i s t i d ’ , $ f o o d e x c h a n g e l i s t i d ) ; $ t h i s −>db−>u p d a t e ( ’ f o o d e x c h a n g e l i s t ’ , $ d a t a ) ; } function g e t f e l e d i t ( $food exchange list id ) { $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>where ( ’ f o o d e x c h a n g e l i s t i d ’ , $ f o o d e x c h a n g e l i s t i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ f o o d e x c h a n g e l i s t ’ ) ; r e t u r n $query−>r o w a r r a y ( ) ; // r e t u r n $query−>r e s u l t ( ) ; } //EDIT HT MODEL p u b l i c f u n c t i o n update ht ( $ h e a l t h t i p i d , $data ) { $ t h i s −>db−>where ( ’ h e a l t h t i p i d ’ , $ h e a l t h t i p i d ) ; $ t h i s −>db−>u p d a t e ( ’ h e a l t h t i p s ’ , $ d a t a ) ; } function get ht edit ( $health tip id ) { $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>where ( ’ h e a l t h t i p i d ’ , $ h e a l t h t i p i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ h e a l t h t i p s ’ ) ; r e t u r n $query−>r o w a r r a y ( ) ; // r e t u r n $query−>r e s u l t ( ) ; } //GET FEL LIST GROUP public function get list group () { $ t h i s −>db−>s e l e c t ( ’ l i s t g r o u p ’ ) ; // $ t h i s −>db−>d i s t i n c t ( ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ f o o d e x c h a n g e l i s t ’ ) ; f o r e a c h ( $query−>r e s u l t a r r a y ( ) a s $row ) { $ d a t a [ $row [ ’ l i s t g r o u p ’ ] ] = $row [ ’ l i s t g r o u p ’ ] ; } // $ d a t a [ ’ Other ’ ] = ’ Other ’ ; r e t u r n $data ; } //GET FEL FOOD GROUP BY LIST GROUP p u b l i c f u n c t i o n g e t f o o d g r o u p ( $ l i g r o u p=s t r i n g ) { $ t h i s −>db−>s e l e c t ( ’ l i s t g r o u p , f o o d g r o u p ’ ) ; $ t h i s −>db−>where ( ’ l i s t g r o u p ’ , $ l i g r o u p ) ; $ t h i s −>db−>d i s t i n c t ( ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ f o o d e x c h a n g e l i s t ’ ) ; r e t u r n $query ; } //GET FEL FOOD GROUP CATEGORY BY LIST GROUP p u b l i c f u n c t i o n g e t f o o d g r o u p c a t e g o r y ( $ l i g r o u p=s t r i n g ) { $ t h i s −>db−>s e l e c t ( ’ l i s t g r o u p , f o o d g r o u p c a t e g o r y ’ ) ; $ t h i s −>db−>where ( ’ l i s t g r o u p ’ , $ l i g r o u p ) ; $ t h i s −>db−>d i s t i n c t ( ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ f o o d e x c h a n g e l i s t ’ ) ; r e t u r n $query ; } } ?> <?php c l a s s Home User Model e x t e n d s CI Model { function construct () { // C a l l t h e Model c o n s t r u c t o r parent : : construct () ; } public function c h e c k u s e r e x i s t ( $usr ) { $ t h i s −>db−>where ( ” username ” , $ u s r ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; 217 } else { return false ; } } public f u n c t i o n c h e c k e m a i l e x i s t ( $eml ) { $ t h i s −>db−>where ( ” e m a i l a d d r e s s ” , $eml ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } //EDIT PROFILE MODEL p u b l i c f u n c t i o n u p d a t e p r o f i l e ( $username , $ d a t a ) { $ t h i s −>db−>where ( ’ username ’ , $username ) ; $ t h i s −>db−>u p d a t e ( ’ u s e r s ’ , $ d a t a ) ; } //EDIT PASSWORD MODEL p u b l i c f u n c t i o n u p d a t e p a s s w o r d ( $username , $ d a t a ) { $ t h i s −>db−>where ( ’ username ’ , $username ) ; $ t h i s −>db−>u p d a t e ( ’ u s e r s ’ , $ d a t a ) ; } public f u n c t i o n c h e c k o l d p a s s w o r d e x i s t ( $opwd ) { $ t h i s −>db−>where ( ” p a s s w o r d ” , $opwd ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } //SEARCH FOOD EXCHANGE LIST MODEL function get search fel () { $match = $ t h i s −>i n p u t −>p o s t ( ’ s e a r c h f e l ’ ) ; $ t h i s −>db−>l i k e ( ’ l i s t g r o u p ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f o o d g r o u p ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f o o d g r o u p c a t e g o r y ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ food name ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ measure ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a r b o h y d r a t e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ p r o t e i n ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f a t ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ e n e r g y ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ w e i g h t a s p u r c h a s e d ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ w e i g h t e d i b l e p o r t i o n ’ , $match ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ f o o d e x c h a n g e l i s t ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } //HEALTHTIPS FEED MODEL /∗ p u b l i c f u n c t i o n c o u n t h t ( ) { r e t u r n c o u n t ( $ t h i s −>g e t s e a r c h h t ( ) ) ; } public function get search ht ret () { $params = f u n c g e t a r g s ( ) ; $ l i m i t = $params [ 0 ] [ ’ l i m i t ’ ] ? $params [ 0 ] [ ’ l i m i t ’ ] : 0 ; $ o f f s e t = $params [ 0 ] [ ’ o f f s e t ’ ] ? $params [ 0 ] [ ’ o f f s e t ’ ] : 0; $ q u e r y = $ t h i s −>g e t s e a r c h h t ( ) ; $ret array = array () ; for ( $ i = 0 ; $ i < $ l i m i t ; $ i ++) { i f ( $ o f f s e t < count ( $query ) ) { $ r e t a r r a y [ ] = $query [ $ o f f s e t ] ; $ o f f s e t ++; } } return $ret array ; }∗/ function get search ht () { $ t h i s −>db−>o r d e r b y ( ” p o s t d a t e ” , ” d e s c ” ) ; // $ t h i s −>db−>l i m i t ( 5 ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ h e a l t h t i p s ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } //ACHIEVEMENTS FEED MODEL function get search achievements () { $ t h i s −>db−>o r d e r b y ( ” s h a r e d a c h i e v e m e n t i d ” , ” d e s c ” ) ; $ t h i s −>db−>l i m i t ( 5 ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ s h a r e d a c h i e v e m e n t s ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } //ADD FP INFO MODEL function process addfp () { 218 $ g o a l w e i g h t = $ t h i s −>i n p u t −>p o s t ( ’ g o a l w e i g h t ’ ) ; $ c u r r e n t w e i g h t = $ t h i s −>i n p u t −>p o s t ( ’ c u r r e n t w e i g h t ’ ) ; $ h e i g h t = $ t h i s −>i n p u t −>p o s t ( ’ h e i g h t ’ ) ; // $ h e a l t h c o n d i t i o n = $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h c o n d i t i o n ’ ) ; $ h e a l t h c o n d i t i o n = i m p l o d e ( ” , ” , $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h c o n d i t i o n ’ ) ) ; // p r i n t r ( $ h e a l t h c o n d i t i o n ) ; // d i e ( ) ; $ r e c o r d d a t e = $ t h i s −>i n p u t −>p o s t ( ’ r e c o r d d a t e ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $ t h i s −>db−>s e l e c t ( ’ b i r t h d a y ’ ) ; $ t h i s −>db−>from ( ’ u s e r s ’ ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ q u e r y b i r t h d a y = $ t h i s −>db−>g e t ( ) ; $ q u e r y b i r t h d a y −>r e s u l t ( ) ; f o r e a c h ( $ q u e r y b i r t h d a y −>r e s u l t ( ) a s $row ) { // e c h o $row−>b i r t h d a y ; $ b i r t h d a y = $row−>b i r t h d a y ; // e c h o $ b i r t h d a y ; } $ t h i s −>db−>s e l e c t ( ’ g e n d e r ’ ) ; $ t h i s −>db−>from ( ’ u s e r s ’ ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ q u e r y g e n d e r = $ t h i s −>db−>g e t ( ) ; $ q u e r y g e n d e r −>r e s u l t ( ) ; f o r e a c h ( $ q u e r y g e n d e r −>r e s u l t ( ) a s $row ) { // e c h o $row−>b i r t h d a y ; $ g e n d e r = $row−>g e n d e r ; // e c h o $ g e n d e r ; } i f ( $ g e n d e r ==”Male ” ) { $age = $ r e c o r d d a t e − $birthday ; $ c a l o r i e l i m i t = 66 + ( 1 3 . 7 ∗ $ c u r r e n t w e i g h t ) + ( 5 ∗ $ h e i g h t ) − ( 6 . 8 ∗ $age ) ; $carbohydrate limit = 0.65 ∗ $ c a l o r i e l i m i t ; $protein limit = 0.25 ∗ $ c a l o r i e l i m i t ; $ f a t l i m i t = 0.70 ∗ $ c a l o r i e l i m i t ; } else { $age = $ r e c o r d d a t e − $birthday ; $ c a l o r i e l i m i t = 655 + ( 9 . 6 ∗ $ c u r r e n t w e i g h t ) + ( 1 . 7 ∗ $ h e i g h t ) − ( 4 . 7 ∗ $age ) ; $carbohydrate limit = (0.65 ∗ $calorie limit ) / 4; $protein limit = (0.25 ∗ $calorie limit ) / 4; $fat limit = (0.70 ∗ $calorie limit ) / 9; } $data [ ’ u s e r i d ’ ] = $ u s e r i d ; $data [ ’ g o a l w e i g h t ’ ] = $ g o a l w e i g h t ; $data [ ’ c u r r e n t w e i g h t ’ ] = $ c u r r e n t w e i g h t ; $data [ ’ height ’ ] = $ h e i g h t ; $data [ ’ c a l o r i e l i m i t ’ ] = $ c a l o r i e l i m i t ; $data [ ’ c a r b o h y d r a t e l i m i t ’ ] = $ c a r b o h y d r a t e l i m i t ; $data [ ’ p r o t e i n l i m i t ’ ] = $ p r o t e i n l i m i t ; $data [ ’ f a t l i m i t ’ ] = $ f a t l i m i t ; $data [ ’ r e c o r d d a t e ’ ] = $ r e c o r d d a t e ; $ t h i s −>db−>i n s e r t ( ’ f i t n e s s p r o f i l e ’ , $ d a t a ) ; $ f i t n e s s i n f o i d = $ t h i s −>db−>i n s e r t i d ( ) ; $data2 [ ’ h e a l t h c o n d i t i o n ’ ] = $ h e a l t h c o n d i t i o n ; $data2 [ ’ u s e r i d ’ ] = $ u s e r i d ; $data2 [ ’ f i t n e s s i n f o i d ’ ] = $ f i t n e s s i n f o i d ; $data2 [ ’ r e c o r d d a t e ’ ] = $ r e c o r d d a t e ; /∗ i f ( i s s e t ( $ POST [ ’ h e a l t h c o n d i t i o n ’ ] ) ) { f o r ( $ i =0; $ i <c o u n t ( $ POST [ ’ h e a l t h c o n d i t i o n ’ ] ) ; $ i ++) { $ h e a l t h c o n d i t i o n = $ POST [ ’ h e a l t h c o n d i t i o n ’ ] [ $ i ] ; $data2 [ ’ u s e r i d ’ ] = $ u s e r i d ; $data2 [ ’ f i t n e s s i n f o i d ’ ] = $ f i t n e s s i n f o i d ; $data2 [ ’ h e a l t h c o n d i t i o n ’ ] = $ h e a l t h c o n d i t i o n ; $data2 [ ’ r e c o r d d a t e ’ ] = $ r e c o r d d a t e ; ∗ / $ t h i s −>db−>i n s e r t ( ’ h e a l t h c o n d i t i o n s ’ , $ d a t a 2 ) ; /∗} }∗/ } else e c h o ” S e s s i o n Timeout ” ; } public function check fp exist ( $rec date ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; // $ d a t a [ ’ u s e r i d ’ ] = $ u s e r i d ; } $ t h i s −>db−>where ( ” r e c o r d d a t e ” , $ r e c d a t e ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” f i t n e s s p r o f i l e ” ) ; i f ( $query−>num rows ( ) >0) { return true ; 219 } else { return false ; } } //VIEW FP INFO MODEL function process viewfp () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; /∗ $ t h i s −>db−>o r d e r b y ( ” r e c o r d d a t e ” , ” d e s c ” ) ; // $ t h i s −>db−>l i m i t ( 1 ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ f i t n e s s p r o f i l e ’ ) ; r e t u r n $query−>r e s u l t ( ) ; $ t h i s −>db−>s e l e c t ( ’ h e a l t h c o n d i t i o n s ’ ) ; $ t h i s −>db−>from ( ’ h e a l t h c o n d i t i o n s ’ ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / /∗ SELECT ∗ FROM f i t n e s s p r o f i l e f INNER JOIN h e a l t h c o n d i t i o n s h ON f . u s e r i d = h . u s e r i d WHERE f . f i t n e s s i n f o i d = h . f i t n e s s i n f o i d ∗/ $ t h i s −>db−>s e l e c t ( ’ f . ∗ , h . ∗ ’ ) ; $ t h i s −>db−>from ( ’ f i t n e s s p r o f i l e f , h e a l t h c o n d i t i o n s h ’ ) ; $ t h i s −>db−>where ( ” f . u s e r i d ” , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ f . u s e r i d = h . u s e r i d ’ ) ; $ t h i s −>db−>where ( ’ f . f i t n e s s i n f o i d = h . f i t n e s s i n f o i d ’ ) ; $ t h i s −>db−>o r d e r b y ( ’ f . r e c o r d d a t e ’ , ’ d e s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; } } //DELETE FITNESS PROFILE MODEL public function d e l f i t n e s s p r o f i l e ( $ f i t n e s s i n f o i d ) { // $ t h i s −>db−>where ( ’ f i t n e s s i n f o i d ’ , $ f i t n e s s i n f o i d ) ; $ t h i s −>db−>d e l e t e ( ’ f i t n e s s p r o f i l e ’ , a r r a y ( ’ f i t n e s s i n f o i d ’ => $fitness info id )) ; $ t h i s −>db−>d e l e t e ( ’ h e a l t h c o n d i t i o n s ’ , a r r a y ( ’ f i t n e s s i n f o i d ’ => $fitness info id )) ; } //WEIGHT GRAPH CHART MODEL function get weightchart data () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $session data [ ’ user id ’ ] ; $ u s e r i d= $data [ ’ u s e r i d ’ ] = $ u s e r i d ; $ t h i s −>db−>s e l e c t ( ’ r e c o r d d a t e , c u r r e n t w e i g h t , $ t h i s −>db−>from ( ’ f i t n e s s p r o f i l e ’ ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ t h i s −>db−>o r d e r b y ( ” r e c o r d d a t e ” , ’ a s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; goal weight ’ ) ; } } //SHARE ACHIEVEMENT MODEL //ADD HEALTH TIP MODEL function process achievement () { $ a c h i e v e m e n t = $ t h i s −>i n p u t −>p o s t ( ’ a c h i e v e m e n t ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $session data [ ’ user id ’ ] ; $ u s e r i d= $data [ ’ u s e r i d ’ ] = $ u s e r i d ; $data [ ’ achievement ’ ] = $achievement ; $ t h i s −>db−>i n s e r t ( ’ s h a r e d a c h i e v e m e n t s ’ , $ d a t a ) ; } else e c h o ( ’ S e s s i o n Timeout . ’ ) ; } //VIEW CREATED RECIPES MODEL function process view created recipes () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; /∗ $ t h i s −>db−>s e l e c t ( ’ o . ∗ , i . ∗ ’ ) ; $ t h i s −>db−>from ( ’ o w n r e c i p e s o , i n g r e d i e n t s i ’ ) ; $ t h i s −>db−>where ( ’ o . u s e r i d ’ , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d = i . o w n r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>from ( ’ o w n r e c i p e s ’ ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; 220 $ t h i s −>db−>o r d e r b y ( ’ o w n r e c i p e i d ’ , $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ’ desc ’ ) ; } } //EDIT CREATED RECIPE function get created recipe ( $own recipe id ) { $ t h i s −>db−>s e l e c t ( ’ o . ∗ , i . ∗ , r . ∗ ’ ) ; $ t h i s −>db−>from ( ’ o w n r e c i p e s o , i n g r e d i e n t s i , r e c i p e i m a g e s r ’ ) ; $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d ’ , $ o w n r e c i p e i d ) ; $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d = i . o w n r e c i p e i d ’ ) ; $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d = r . o w n r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; // r e t u r n $query−>r o w a r r a y ( ) ; r e t u r n $query−>r e s u l t ( ) ; } //UPDATE RECIPE MODEL p u b l i c f u n c t i o n u p d a t e r e c i p e ( $ o w n r e c i p e i d , $data , $ d a t a 2 ) { $ t h i s −>db−>where ( ’ o w n r e c i p e i d ’ , $ o w n r e c i p e i d ) ; $ t h i s −>db−>u p d a t e ( ’ o w n r e c i p e s ’ , $ d a t a ) ; // $ o w n r e c i p e i d = $ t h i s −>db−>i n s e r t i d ( ) ; // t h i s −>db−>u p d a t e ( ’ i n g r e d i e n t s ’ , $ d a t a 2 ) ; f o r ( $ i = 0 ; $ i < c o u n t ( $ d a t a 2 [ ’ food name ’ ] ) ; $ i ++) { $data3 = array ( ’ food name ’=> $ d a t a 2 [ ’ food name ’ ] [ $ i ] , ’ f o o d g r o u p ’=> $ d a t a 2 [ ’ f o o d g r o u p ’ ] [ $ i ] , ’ measure ’=> $ d a t a 2 [ ’ measure ’ ] [ $ i ] , ’ s e r v i n g s i z e ’=> $ d a t a 2 [ ’ s e r v i n g s i z e ’ ] [ $ i ] , ); i f ( $ d a t a 2 [ ’ i n g r e d i e n t i d ’ ] [ $ i ] == n u l l | | $ d a t a 2 [ ’ i n g r e d i e n t i d ’ ] [ $ i ] == ” ” ) { $data3 [ ’ o w n r e c i p e i d ’ ] = $ o w n r e c i p e i d ; $ t h i s −>db−>i n s e r t ( ’ i n g r e d i e n t s ’ , $ d a t a 3 ) ; } else { $ t h i s −>db−>where ( ’ i n g r e d i e n t i d ’ , $ d a t a 2 [ ’ i n g r e d i e n t i d ’ ] [ $ i ] ) ; $ t h i s −>db−>u p d a t e ( ’ i n g r e d i e n t s ’ , $ d a t a 3 ) ; } } } //VIEW RECOMMENDED RECIPES function process view recommended recipes () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; /∗ $ t h i s −>db−>s e l e c t ( ’ h e a l t h c o n d i t i o n ’ ) ; $ t h i s −>db−>from ( ’ h e a l t h c o n d i t i o n s ’ ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ t h i s −>db−>o r d e r b y ( ” r e c o r d d a t e ” , ” d e s c ” ) ; $ t h i s −>db−>l i m i t ( 1 ) ; $ q u e r y h e a l t h c o n d i t i o n = $ t h i s −>db−>g e t ( ) ; $ q u e r y h e a l t h c o n d i t i o n −>r e s u l t ( ) ; f o r e a c h ( $ q u e r y h e a l t h c o n d i t i o n −>r e s u l t ( ) a s $row ) { $ h e a l t h c o n d i t i o n = $row−>h e a l t h c o n d i t i o n ; }∗/ $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>from ( ’ r e c o m m e n d e d r e c i p e s ’ ) ; // $ t h i s −>db−>where ( ’ h e a l t h c o n d i t i o n ’ , $ h e a l t h c o n d i t i o n ) ; $ t h i s −>db−>o r d e r b y ( ’ r e c o m m e n d e d r e c i p e i d ’ , ’ d e s c ’ ) ; // $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; } } //SEARCH RECOMMENDED RECIPES function get search recrec () { $match = $ t h i s −>i n p u t −>p o s t ( ’ s e a r c h r e c r e c ’ ) ; $ t h i s −>db−>l i k e ( ’ r e c o m m e n d e d r e c i p e i d ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ h e a l t h c o n d i t i o n ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ m e a l t y p e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ r e c i p e n a m e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ s e r v i n g s u g g ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a l o r i e s ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a r b o h y d r a t e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ p r o t e i n ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f a t ’ , $match ) ; $ t h i s −>db−>o r d e r b y ( ’ r e c o m m e n d e d r e c i p e i d ’ , ’ d e s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ r e c o m m e n d e d r e c i p e s ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } //VIEW SHARED RECIPES function process view shared recipes () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; $ t h i s −>db−>s e l e c t ( ’ s . ∗ , o . ∗ ’ ) ; 221 $ t h i s −>db−>from ( ’ s h a r e d r e c i p e s s , o w n r e c i p e s o ’ ) ; $ t h i s −>db−>where ( ’ s . o w n r e c i p e i d = o . o w n r e c i p e i d ’ ) ; $ t h i s −>db−>o r d e r b y ( ’ s h a r e d r e c i p e i d ’ , ’ d e s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; } } //SEARCH SHARED RECIPES function get search sharedrec () { $match = $ t h i s −>i n p u t −>p o s t ( ’ s e a r c h s h a r e d r e c ’ ) ; $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>from ( ’ s h a r e d r e c i p e s ’ ) ; $ t h i s −>db−>j o i n ( ’ o w n r e c i p e s ’ , ’ s h a r e d r e c i p e s . o w n r e c i p e i d = o w n r e c i p e s . own recipe id ’ ) ; $ t h i s −>db−>l i k e ( ’ s h a r e d r e c i p e i d ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ h e a l t h c o n d i t i o n ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ m e a l t y p e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ r e c i p e n a m e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ s e r v i n g s u g g ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a l o r i e s ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a r b o h y d r a t e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ p r o t e i n ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f a t ’ , $match ) ; $ t h i s −>db−>o r d e r b y ( ’ s h a r e d r e c i p e i d ’ , ’ d e s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; } //VIEW DAILY MEALS BY DATE MODEL p u b l i c f u n c t i o n recommended show data by date ( $ r e c o r d d a t e ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; // $ c o n d i t i o n = ” r e c o r d d a t e =” . ” ’ ” . $ r e c o r d d a t e . ” ’ ” ; $ t h i s −>db−>s e l e c t ( ’ h e a l t h c o n d i t i o n ’ ) ; $ t h i s −>db−>from ( ’ h e a l t h c o n d i t i o n s ’ ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ t h i s −>db−>o r d e r b y ( ” r e c o r d d a t e ” , ” d e s c ” ) ; $ t h i s −>db−>l i m i t ( 1 ) ; $ q u e r y h e a l t h c o n d i t i o n = $ t h i s −>db−>g e t ( ) ; $ q u e r y h e a l t h c o n d i t i o n −>r e s u l t ( ) ; f o r e a c h ( $ q u e r y h e a l t h c o n d i t i o n −>r e s u l t ( ) a s $row ) { $ h e a l t h c o n d i t i o n = $row−>h e a l t h c o n d i t i o n ; } $ t h i s −>db−>s e l e c t ( ’ d . ∗ , r . ∗ ’ ) ; $ t h i s −>db−>from ( ’ r e c o m m e n d e d d a i l y m e a l s d , r e c o m m e n d e d r e c i p e s r ’ ) ; $ t h i s −>db−>where ( ’ d . r e c o r d d a t e ’ , $ r e c o r d d a t e ) ; $ t h i s −>db−>where ( ’ d . r e c o m m e n d e d r e c i p e i d = r . r e c o m m e n d e d r e c i p e i d ’ ) ; $ t h i s −>db−>where ( ’ r . h e a l t h c o n d i t i o n ’ , $ h e a l t h c o n d i t i o n ) ; $ t h i s −>db−>o r d e r b y ( ’ m e a l g r o u p ’ , ’ a s c ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; i f ( $query−>num rows ( ) > 0 ) { r e t u r n $query−>r e s u l t ( ) ; } else { return false ; } } } //VIEW RECIPE function get recipe contents ( $own recipe id ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; /∗ $ t h i s −>db−>s e l e c t ( ’ o . ∗ , i . ∗ ’ ) ; $ t h i s −>db−>from ( ’ o w n r e c i p e s o , i n g r e d i e n t s i ’ ) ; $ t h i s −>db−>where ( ’ o . u s e r i d ’ , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d = i . o w n r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / /∗ $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>from ( ’ i n g r e d i e n t s ’ ) ; $ t h i s −>db−>where ( ” o w n r e c i p e i d ” , $ o w n r e c i p e i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / $ t h i s −>db−>s e l e c t ( ’ o . ∗ , i . ∗ , r . ∗ ’ ) ; $ t h i s −>db−>from ( ’ o w n r e c i p e s o , i n g r e d i e n t s i , r e c i p e i m a g e s r ’ ) ; $ t h i s −>db−>where ( ’ i . o w n r e c i p e i d ’ , $ o w n r e c i p e i d ) ; $ t h i s −>db−>where ( ’ i . o w n r e c i p e i d = o . o w n r e c i p e i d ’ ) ; $ t h i s −>db−>where ( ’ r . o w n r e c i p e i d = o . o w n r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; } } 222 //VIEW RECOMMENDED RECIPE function get recommended recipe contents ( $recommended recipe id ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; /∗ $ t h i s −>db−>s e l e c t ( ’ o . ∗ , i . ∗ ’ ) ; $ t h i s −>db−>from ( ’ o w n r e c i p e s o , i n g r e d i e n t s i ’ ) ; $ t h i s −>db−>where ( ’ o . u s e r i d ’ , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d = i . o w n r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / /∗ $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>from ( ’ i n g r e d i e n t s ’ ) ; $ t h i s −>db−>where ( ” o w n r e c i p e i d ” , $ o w n r e c i p e i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / $ t h i s −>db−>s e l e c t ( ’ r . ∗ , i . ∗ , c . ∗ ’ ) ; $ t h i s −>db−>from ( ’ r e c o m m e n d e d r e c i p e s r , i n g r e d i e n t s r e c o m m e n d e d i , recipe images recommended c ’ ) ; $ t h i s −>db−>where ( ’ i . r e c o m m e n d e d r e c i p e i d ’ , $ r e c o m m e n d e d r e c i p e i d ) ; $ t h i s −>db−>where ( ’ i . r e c o m m e n d e d r e c i p e i d = r . r e c o m m e n d e d r e c i p e i d ’ ) ; $ t h i s −>db−>where ( ’ c . r e c o m m e n d e d r e c i p e i d = r . r e c o m m e n d e d r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; } } //VIEW SHARED RECIPE function get shared recipe contents ( $shared recipe id ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; /∗ $ t h i s −>db−>s e l e c t ( ’ o . ∗ , i . ∗ ’ ) ; $ t h i s −>db−>from ( ’ o w n r e c i p e s o , i n g r e d i e n t s i ’ ) ; $ t h i s −>db−>where ( ’ o . u s e r i d ’ , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d = i . o w n r e c i p e i d ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / /∗ $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>from ( ’ i n g r e d i e n t s ’ ) ; $ t h i s −>db−>where ( ” o w n r e c i p e i d ” , $ o w n r e c i p e i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; ∗ / $ t h i s −>db−>s e l e c t ( ’ s . ∗ , o . ∗ , i . ∗ , $ t h i s −>db−>from ( ’ s h a r e d r e c i p e s s recipe images r ’) ; $ t h i s −>db−>where ( ’ s . s h a r e d r e c i p e $ t h i s −>db−>where ( ’ s . o w n r e c i p e i d $ t h i s −>db−>where ( ’ o . o w n r e c i p e i d $ t h i s −>db−>where ( ’ r . o w n r e c i p e i d $ q u e r y = $ t h i s −>db−>g e t ( ) ; r e t u r n $query−>r e s u l t ( ) ; , r .∗ ’) ; own recipes o , id = = = ingredients i , ’ , $shared recipe id ) ; o . own recipe id ’ ) ; i . own recipe id ’ ) ; o . own recipe id ’ ) ; } } //DELETE CREATED RECIPE public function del created recipe ( $own recipe id ) { // $ t h i s −>db−>where ( ’ f i t n e s s i n f o i d ’ , $ f i t n e s s i n f o i d ) ; $ t h i s −>db−>d e l e t e ( ’ o w n r e c i p e s ’ , a r r a y ( ’ o w n r e c i p e i d ’ => $ o w n r e c i p e i d ) ) ; $ t h i s −>db−>d e l e t e ( ’ i n g r e d i e n t s ’ , a r r a y ( ’ o w n r e c i p e i d ’ => $ o w n r e c i p e i d ) ) ; $ t h i s −>db−>d e l e t e ( ’ r e c i p e i m a g e s ’ , a r r a y ( ’ o w n r e c i p e i d ’ => $ o w n r e c i p e i d ) ) ; } //DELETE INGREDIENTS public function del ingredient ( $ingredient id ) { $ t h i s −>db−>d e l e t e ( ’ i n g r e d i e n t s ’ , a r r a y ( ’ i n g r e d i e n t i d ’ => $ i n g r e d i e n t i d ) ) ; } //SHARE CREATED RECIPE function process sharerecipe ( $own recipe id ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $user id = $session data [ ’ user id ’ ] ; $data [ ’ u s e r i d ’ ] = $ u s e r i d ; $data [ ’ o w n r e c i p e i d ’ ] = $ o w n r e c i p e i d ; $ t h i s −>db−>i n s e r t ( ’ s h a r e d r e c i p e s ’ , $ d a t a ) ; } else e c h o ” S e s s i o n Timeout ” ; } //ADD RECIPE MODEL f u n c t i o n p r o c e s s a d d r e c i p e ( $data3 ) { // $ h e a l t h c o n d i t i o n = $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h c o n d i t i o n ’ ) ; $ h e a l t h c o n d i t i o n = i m p l o d e ( ” , ” , $ t h i s −>i n p u t −>p o s t ( ’ h e a l t h c o n d i t i o n ’ ) ) ; $ m e a l t y p e = $ t h i s −>i n p u t −>p o s t ( ’ m e a l t y p e ’ ) ; $ r e c i p e n a m e = $ t h i s −>i n p u t −>p o s t ( ’ r e c i p e n a m e ’ ) ; $ s e r v i n g s u g g = $ t h i s −>i n p u t −>p o s t ( ’ s e r v i n g s u g g ’ ) ; $ p r e p a r a t i o n p r o c e d u r e = $ t h i s −>i n p u t −>p o s t ( ’ p r e p a r a t i o n p r o c e d u r e ’ ) ; 223 $ c a l o r i e s = $ t h i s −>i n p u t −>p o s t ( ’ c a l o r i e s ’ ) ; $ c a r b o h y d r a t e = $ t h i s −>i n p u t −>p o s t ( ’ c a r b o h y d r a t e ’ ) ; $ p r o t e i n = $ t h i s −>i n p u t −>p o s t ( ’ p r o t e i n ’ ) ; $ f a t = $ t h i s −>i n p u t −>p o s t ( ’ f a t ’ ) ; i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $session data [ ’ user id ’ ] ; $ u s e r i d= $data $data $data $data $data $data $data $data $data $data [ [ [ [ [ [ [ [ [ [ ’ ’ ’ ’ ’ ’ ’ ’ ’ ’ user id ’ ] = $user id ; health condition ’ ] = $health condition ; meal type ’ ] = $meal type ; recipe name ’ ] = $recipe name ; serving sugg ’]= $serving sugg ; preparation procedure ’ ] = $preparation procedure ; calories ’ ] = $calories ; carbohydrate ’ ] = $carbohydrate ; protein ’ ] = $protein ; fat ’ ] = $fat ; $ t h i s −>db−>i n s e r t ( ’ o w n r e c i p e s ’ , $ d a t a ) ; $ o w n r e c i p e i d = $ t h i s −>db−>i n s e r t i d ( ) ; if ( i s s e t ( $ POST [ ’ i n g r e d i e n t s ’ ] , $ POST [ ’ f o o d g r o u p ’ ] , $ POST [ ’ i n g r e d i e n t m e a s u r e ’ ] , $ POST [ ’ i n g r e d i e n t q u a n t i t y ’ ] ) ) { f o r ( $ i =0; $ i <c o u n t ( $ POST [ ’ i n g r e d i e n t s ’ ] ) ; $ i ++) { $ i n g r e d i e n t s = $ POST [ ’ i n g r e d i e n t s ’ ] [ $ i ] ; $ f o o d g r o u p = $ POST [ ’ f o o d g r o u p ’ ] [ $ i ] ; $ i n g r e d i e n t m e a s u r e =$ POST [ ’ i n g r e d i e n t m e a s u r e ’ ] [ $ i ] ; $ i n g r e d i e n t q u a n t i t y = $ POST [ ’ i n g r e d i e n t q u a n t i t y ’ ] [ $i ] ; $data2 [ ’ o w n r e c i p e i d ’ ] = $ o w n r e c i p e i d ; $ d a t a 2 [ ’ food name ’ ] = $ i n g r e d i e n t s ; $data2 [ ’ food group ’ ] = $food group ; $ d a t a 2 [ ’ measure ’ ] = $ i n g r e d i e n t m e a s u r e ; $data2 [ ’ s e r v i n g s i z e ’ ] = $ i n g r e d i e n t q u a n t i t y ; /∗ $counts = array count values ( $food group ) ; echo $counts [ ’ Vegetable ’ ] ; ∗/ $ t h i s −>db−>i n s e r t ( ’ i n g r e d i e n t s ’ , $ d a t a 2 ) ; } } /∗ $ f i l e =a r r a y ( ’ img name ’=> $ d a t a [ ’ raw name ’ ] , ’ thumb name’=> $ d a t a [ ’ raw name ’ ] . ’ thumb ’ , ’ e x t ’=> $ d a t a [ ’ f i l e e x t ’ ] , ’ u p l o a d d a t e ’=> t i m e ( ) ) ;∗/ /∗ $ d a t a 3 [ ’ raw name ’ ] ; $ d a t a 3 [ ’ raw name ’ ] . ’ thumb ’ ; $data3 [ ’ f i l e e x t ’ ] ; $data3 [ ’ upload date ’ ] = time ( ) ; ∗ / $data3 [ ’ o w n r e c i p e i d ’ ] = $ o w n r e c i p e i d ; $ t h i s −>db−>i n s e r t ( ’ r e c i p e i m a g e s ’ , $data3 ) ; } else e c h o ” S e s s i o n Timeout ” ; } //ADD INGREDIENT AUTOCOMPLETE //USER SEARCH MODEL/S f u n c t i o n Ge tAu to co mpl et e ( $ o p t i o n s = a r r a y ( ) ) { $ t h i s −>db−>s e l e c t ( ’ f o o d g r o u p , food name , w e i g h t e d i b l e p o r t i o n , carbohydrate , protein , fat ’ ) ; $ t h i s −>db−>l i k e ( ’ food name ’ , $ o p t i o n s [ ’ keyword ’ ] , ’ a f t e r ’ ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ f o o d e x c h a n g e l i s t ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } energy , //SEARCH FOR MEAL MODEL function get search meal () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $user id = $session data [ ’ user id ’ ] ; } else e c h o ” S e s s i o n Timeout ” ; /∗ $ t h i s −>db−>s e l e c t ( ’ h e a l t h c o n d i t i o n ’ ) ; $ t h i s −>db−>from ( ’ h e a l t h c o n d i t i o n s ’ ) ; $ t h i s −>db−>where ( ” u s e r i d ” , $ u s e r i d ) ; $ t h i s −>db−>o r d e r b y ( ” r e c o r d d a t e ” , ” d e s c ” ) ; $ t h i s −>db−>l i m i t ( 1 ) ; $ q u e r y h e a l t h c o n d i t i o n = $ t h i s −>db−>g e t ( ) ; $ q u e r y h e a l t h c o n d i t i o n −>r e s u l t ( ) ; f o r e a c h ( $ q u e r y h e a l t h c o n d i t i o n −>r e s u l t ( ) a s $row ) { $ h e a l t h c o n d i t i o n = $row−>h e a l t h c o n d i t i o n ; }∗/ $match = $ t h i s −>i n p u t −>p o s t ( ’ s e a r c h m e a l ’ ) ; /∗ $ q u e r y = ” ( o w n r e c i p e i d LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) . ” % ’ OR u s e r i d LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) . ” % ’ OR m e a l t y p e LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) 224 . ” % ’ OR r e c i p e n a m e LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) . ” % ’ OR s e r v i n g s u g g LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) . ” % ’ OR p r e p a r a t i o n p r o c e d u r e LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) . ” % ’ OR c a l o r i e s LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) . ” % ’ OR c a r b o h y d r a t e LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) . ” % ’ OR p r o t e i n LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) . ” % ’ OR f a t LIKE ’ % ” . $ t h i s −>db−>e s c a p e l i k e s t r ( $match ) . ” % ’ ) AND health condition = ”;∗/ $ t h i s −>db−>l i k e ( ’ o w n r e c i p e i d ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ u s e r i d ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ m e a l t y p e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ r e c i p e n a m e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ s e r v i n g s u g g ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ p r e p a r a t i o n p r o c e d u r e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a l o r i e s ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ c a r b o h y d r a t e ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ p r o t e i n ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ f a t ’ , $match ) ; $ t h i s −>db−>o r l i k e ( ’ h e a l t h c o n d i t i o n ’ , $match ) ; // $ t h i s −>db−>where ( $query , $ h e a l t h c o n d i t i o n ) ; $ t h i s −>db−>o r d e r b y ( ’ o w n r e c i p e i d ’ , ’ d e s c ’ ) ; $ t h i s −>db−>where ( ’ u s e r i d ’ , $ u s e r i d ) ; $ q u e r y = $ t h i s −>db−>g e t ( ’ o w n r e c i p e s ’ ) ; r e t u r n $query−>r e s u l t ( ) ; } //ADD MEAL function process addmeal ( $own recipe id ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $user id = $session data [ ’ user id ’ ] ; $ m e a l g r o u p = $ t h i s −>i n p u t −>p o s t ( ’ m e a l g r o u p ’ ) ; $ r e c o r d d a t e = $ t h i s −>i n p u t −>p o s t ( ’ r e c o r d d a t e ’ ) ; $data $data $data $data [ [ [ [ ’ ’ ’ ’ user id ’ ] = $user id ; own recipe id ’ ] = $own recipe id ; meal group ’ ] = $meal group ; record date ’ ] = $record date ; $ t h i s −>db−>i n s e r t ( ’ p l a n d a i l y m e a l s ’ , $ d a t a ) ; } else e c h o ” S e s s i o n Timeout ” ; } //DELETE MEAL public function del meal ( $plan daily meal id ) { // $ t h i s −>db−>where ( ’ f i t n e s s i n f o i d ’ , $ f i t n e s s i n f o i d ) ; $ t h i s −>db−>d e l e t e ( ’ p l a n d a i l y m e a l s ’ , a r r a y ( ’ p l a n d a i l y m e a l i d ’ => $plan daily meal id ) ) ; } //VIEW DAILY MEALS BY DATE MODEL public function show data by date ( $record date ) { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; // $ d a t a [ ’ u s e r i d ’ ] = $ u s e r i d ; // $ c o n d i t i o n = ” r e c o r d d a t e =” . ” ’ ” . $ r e c o r d d a t e . ” ’ ” ; $ t h i s −>db−>s e l e c t ( ’ p . ∗ , o . ∗ ’ ) ; $ t h i s −>db−>from ( ’ p l a n d a i l y m e a l s p , o w n r e c i p e s o ’ ) ; $ t h i s −>db−>where ( ” p . u s e r i d ” , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ p . r e c o r d d a t e ’ , $ r e c o r d d a t e ) ; $ t h i s −>db−>where ( ’ p . o w n r e c i p e i d = o . o w n r e c i p e i d ’ ) ; $ t h i s −>db−>o r d e r b y ( ’ m e a l g r o u p ’ , ’ a s c ’ ) ; $ q u e r y 1 = $ t h i s −>db−>g e t ( ) ; $ t h i s −>db−>s e l e c t ( ’ f . ∗ , h . ∗ ’ ) ; $ t h i s −>db−>from ( ’ f i t n e s s p r o f i l e f , h e a l t h c o n d i t i o n s h ’ ) ; $ t h i s −>db−>where ( ’ f . u s e r i d ’ , $ u s e r i d ) ; $ t h i s −>db−>where ( ’ f . f i t n e s s i n f o i d = h . f i t n e s s i n f o i d ’ ) ; // $ t h i s −>db−>where ( ’ f . r e c o r d d a t e = h . r e c o r d d a t e ’ ) ; $ t h i s −>db−>o r d e r b y ( ” f . r e c o r d d a t e ” , ” d e s c ” ) ; $ t h i s −>db−>l i m i t ( 1 ) ; $ q u e r y 2 = $ t h i s −>db−>g e t ( ) ; $ r e s u l t 1 = $ q u e r y 1−>r e s u l t ( ) ; $ r e s u l t 2 = $ q u e r y 2−>r e s u l t ( ) ; i f ( $ q u e r y 1−>num rows ( ) > 0 && $ q u e r y 2−>num rows ( ) > 0 ) { return array merge ( $result1 , $ r e s u l t 2 ) ; } else { return false ; } ( $query−>num rows ( ) > 0 ) { r e t u r n $query−>r e s u l t ( ) ; } else { return f a l s e ; }∗/ /∗ i f } } public function show calorie limit () { i f ( $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ) { $ s e s s i o n d a t a = $ t h i s −>s e s s i o n −>u s e r d a t a ( ’ l o g g e d i n ’ ) ; $ u s e r i d= $session data [ ’ user id ’ ] ; 225 $data [ ’ u s e r i d ’ ] = $ u s e r i d ; $ t h i s −>db−>s e l e c t ( ’ ∗ ’ ) ; $ t h i s −>db−>from ( ’ f i t n e s s p r o f i l e ’ ) ; $ t h i s −>db−>where ( ’ u s e r i d ’ , $ u s e r i d ) ; $ t h i s −>db−>o r d e r b y ( ” r e c o r d d a t e ” , ” d e s c ” ) ; $ t h i s −>db−>l i m i t ( 1 ) ; $ q u e r y = $ t h i s −>db−>g e t ( ) ; i f ( $query−>num rows ( ) > 0 ) { r e t u r n $query−>r e s u l t ( ) ; } else { return f a l s e ; } } } } ?> <?php C l a s s L o g i n M o d e l e x t e n d s CI Model { f u n c t i o n l o g i n ( $username , $ p a s s w o r d ) { $ q u e r y = $ t h i s −> db −> g e t w h e r e ( ’ u s e r s ’ , password ’=>MD5( $ p a s s w o r d ) ) ) ; a r r a y ( ’ username ’=>$username , ’ i f ( $ q u e r y −> num rows ( ) == 1 ) { r e t u r n $query−>r e s u l t ( ) ; } else { return false ; } } function process () { $username = $ t h i s −>i n p u t −>p o s t ( ’ u s e r n a m e r e g ’ ) ; $ p a s s w o r d = $ t h i s −>i n p u t −>p o s t ( ’ p a s s w o r d r e g ’ ) ; $ c o n f i r m p a s s w o r d = $ t h i s −>i n p u t −>p o s t ( ’ confirm password reg ’ ) ; $ f i r s t n a m e = $ t h i s −>i n p u t −>p o s t ( ’ f i r s t n a m e ’ ) ; $ m i d d l e n a m e = $ t h i s −>i n p u t −>p o s t ( ’ middle name ’ ) ; $ l a s t n a m e = $ t h i s −>i n p u t −>p o s t ( ’ l a s t n a m e ’ ) ; $ g e n d e r = $ t h i s −>i n p u t −>p o s t ( ’ g e n d e r R a d i o ’ ) ; $ u s e r t y p e = $ t h i s −>i n p u t −>p o s t ( ’ userTypeRadio ’ ) ; $ e m a i l a d d r e s s = $ t h i s −>i n p u t −>p o s t ( ’ e m a i l a d d r e s s ’ ) ; $ b i r t h d a y = $ t h i s −>i n p u t −>p o s t ( ’ b i r t h d a t e ’ ) ; $data = array ( ’ username ’ => $username , ’ password ’ => MD5( $ p a s s w o r d ) , ’ c o n f i r m p a s s w o r d ’ => MD5( $ c o n f i r m p a s s w o r d ) , ’ f i r s t n a m e ’ => $ f i r s t n a m e , ’ middle name ’ => $middle name , ’ l a s t n a m e ’ => $ l a s t n a m e , ’ g e n d e r ’ => $ g e n d e r , ’ u s e r t y p e ’ => $ u s e r t y p e , ’ e m a i l a d d r e s s ’ => $ e m a i l a d d r e s s , ’ b i r t h d a y ’ => $ b i r t h d a y ); $ t h i s −>db−>i n s e r t ( ’ u s e r s ’ , $ d a t a ) ; } public function c h e c k u s e r e x i s t ( $usr ) { $ t h i s −>db−>where ( ” username ” , $ u s r ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } p u b l i c f u n c t i o n c h e c k e m a i l e x i s t ( $eml ) { $ t h i s −>db−>where ( ” e m a i l a d d r e s s ” , $eml ) ; $ q u e r y=$ t h i s −>db−>g e t ( ” u s e r s ” ) ; i f ( $query−>num rows ( ) >0) { return true ; } else { return f a l s e ; } } } ?> B..4 Libraries <?php /∗∗ ∗ C o p y r i g h t 2011 Facebook , I n c . ∗ ∗ L i c e n s e d u n d e r t h e Apache L i c e n s e , V e r s i o n 2 . 0 ( t h e ” L i c e n s e ” ) ; you may ∗ n o t u s e t h i s f i l e e x c e p t i n c o m p l i a n c e w i t h t h e L i c e n s e . You may o b t a i n ∗ a copy o f t h e L i c e n s e a t 226 ∗ ∗ h t t p : / /www. a p a c h e . o r g / l i c e n s e s /LICENSE−2.0 ∗ ∗ U n l e s s r e q u i r e d by a p p l i c a b l e law o r a g r e e d t o i n w r i t i n g , s o f t w a r e ∗ d i s t r i b u t e d u n d e r t h e L i c e n s e i s d i s t r i b u t e d on an ”AS I S ” BASIS , WITHOUT ∗ WARRANTIES OR CONDITIONS OF ANY KIND , e i t h e r e x p r e s s o r i m p l i e d . S e e t h e ∗ L i c e n s e f o r t h e s p e c i f i c l a n g u a g e g o v e r n i n g p e r m i s s i o n s and l i m i t a t i o n s ∗ under the L i c e n s e . ∗/ if } if (! function exists ( ’ curl init ’) ) { throw new E x c e p t i o n ( ’ Facebook n e e d s t h e CURL PHP e x t e n s i o n . ’ ) ; ( ! f u n c t i o n e x i s t s ( ’ json decode ’ ) ) { throw new E x c e p t i o n ( ’ Facebook n e e d s t h e JSON PHP e x t e n s i o n . ’ ) ; } /∗∗ ∗ Thrown when an API c a l l r e t u r n s an e x c e p t i o n . ∗ ∗ @author N a i t i k Shah <n a i t i k @ f a c e b o o k . com> ∗/ c l a s s FacebookApiException extends Exception { /∗∗ ∗ The r e s u l t from t h e API s e r v e r t h a t r e p r e s e n t s ∗ ∗ @var mixed ∗/ protected $result ; the exception information . /∗∗ ∗ Make a new API E x c e p t i o n w i t h t h e g i v e n r e s u l t . ∗ ∗ @param a r r a y $ r e s u l t The r e s u l t from t h e API s e r v e r ∗/ construct ( $result ) { public function $ t h i s −>r e s u l t = $ r e s u l t ; $code = 0 ; i f ( i s s e t ( $ r e s u l t [ ’ e r r o r c o d e ’ ] ) && i s i n t ( $ r e s u l t [ ’ e r r o r c o d e ’ ] ) ) { $code = $ r e s u l t [ ’ e r r o r c o d e ’ ] ; } ( isset ( $result [ ’ error description ’ ] ) ) { // OAuth 2 . 0 D r a f t 10 s t y l e $msg = $ r e s u l t [ ’ e r r o r d e s c r i p t i o n ’ ] ; } e l s e i f ( i s s e t ( $ r e s u l t [ ’ e r r o r ’ ] ) && i s a r r a y ( $ r e s u l t [ ’ e r r o r ’ ] ) ) { // OAuth 2 . 0 D r a f t 00 s t y l e $msg = $ r e s u l t [ ’ e r r o r ’ ] [ ’ message ’ ] ; } e l s e i f ( i s s e t ( $ r e s u l t [ ’ error msg ’ ] ) ) { // R e s t s e r v e r s t y l e $msg = $ r e s u l t [ ’ e r r o r m s g ’ ] ; } else { $msg = ’ Unknown E r r o r . Check g e t R e s u l t ( ) ’ ; } if parent : : c o n s t r u c t ( $msg , $code ) ; } /∗∗ ∗ Return t h e a s s o c i a t e d r e s u l t o b j e c t r e t u r n e d by t h e API s e r v e r . ∗ ∗ @ r e t u r n a r r a y The r e s u l t from t h e API s e r v e r ∗/ public function getResult () { r e t u r n $ t h i s −>r e s u l t ; } /∗∗ ∗ Returns the a s s o c i a t e d type f o r the e r r o r . ∗ ’ E x c e p t i o n ’ when a t y p e i s n o t a v a i l a b l e . ∗ ∗ @return s t r i n g ∗/ p u b l i c f u n c t i o n getType ( ) { i f ( i s s e t ( $ t h i s −>r e s u l t [ ’ e r r o r ’ ] ) ) { $ e r r o r = $ t h i s −>r e s u l t [ ’ e r r o r ’ ] ; i f ( i s s t r i n g ( $error ) ) { // OAuth 2 . 0 D r a f t 10 s t y l e return $error ; } else i f ( is array ( $error ) ) { // OAuth 2 . 0 D r a f t 00 s t y l e i f ( i s s e t ( $ e r r o r [ ’ type ’ ] ) ) { r e t u r n $ e r r o r [ ’ type ’ ] ; } } } return This will ’ Exception ’ ; } /∗∗ ∗ To make d e b u g g i n g e a s i e r . ∗ ∗ @ r e t u r n s t r i n g The s t r i n g r e p r e s e n t a t i o n ∗/ public function toString () { $ s t r = $ t h i s −>getType ( ) . ’ : ’ ; of the 227 error default to if ( $ t h i s −>c o d e != 0 ) { $ s t r .= $ t h i s −>c o d e . } return $str . ’: ’; $ t h i s −>m e s s a g e ; } } /∗∗ ∗ P r o v i d e s a c c e s s t o t h e Facebook P l a t f o r m . This c l a s s p r o v i d e s ∗ a m a j o r i t y o f t h e f u n c t i o n a l i t y needed , but t h e c l a s s i s a b s t r a c t ∗ b e c a u s e i t i s d e s i g n e d t o be sub−c l a s s e d . The s u b c l a s s must ∗ implement t h e f o u r a b s t r a c t methods l i s t e d a t t h e bottom o f ∗ the f i l e . ∗ ∗ @author N a i t i k Shah <n a i t i k @ f a c e b o o k . com> ∗/ a b s t r a c t c l a s s BaseFacebook { /∗∗ ∗ Version . ∗/ c o n s t VERSION = ’ 3 . 2 . 3 ’ ; /∗∗ ∗ Signed Request Algorithm . ∗/ c o n s t SIGNED REQUEST ALGORITHM = ’HMAC−SHA256 ’ ; /∗∗ ∗ Default options for curl . ∗ ∗ @var a r r a y ∗/ p u b l i c s t a t i c $CURL OPTS = a r r a y ( CURLOPT CONNECTTIMEOUT => 1 0 , CURLOPT RETURNTRANSFER => t r u e , => 6 0 , CURLOPT TIMEOUT CURLOPT USERAGENT => ’ f a c e b o o k −php − 3 . 2 ’ , ); /∗∗ ∗ L i s t o f q u e r y p a r a m e t e r s t h a t g e t a u t o m a t i c a l l y dropped when r e b u i l d i n g ∗ t h e c u r r e n t URL . ∗ ∗ @var a r r a y ∗/ p r o t e c t e d s t a t i c $DROP QUERY PARAMS = a r r a y ( ’ code ’ , ’ state ’ , ’ signed request ’ , ); /∗∗ ∗ Maps a l i a s e s t o Facebook domains . ∗ ∗ @var a r r a y ∗/ p u b l i c s t a t i c $DOMAIN MAP = a r r a y ( ’ api ’ => ’ h t t p s : / / a p i . f a c e b o o k . com / ’ , ’ api video ’ => ’ h t t p s : / / a p i −v i d e o . f a c e b o o k . com / ’ , => ’ h t t p s : / / a p i −r e a d . f a c e b o o k . com / ’ , ’ api read ’ ’ graph ’ => ’ h t t p s : / / g r a p h . f a c e b o o k . com / ’ , ’ g r a p h v i d e o ’ => ’ h t t p s : / / graph−v i d e o . f a c e b o o k . com / ’ , ’www’ => ’ h t t p s : / /www. f a c e b o o k . com / ’ , ); /∗∗ ∗ The A p p l i c a t i o n ID . ∗ ∗ @var s t r i n g ∗/ p r o t e c t e d $appId ; /∗∗ ∗ The A p p l i c a t i o n App S e c r e t . ∗ ∗ @var s t r i n g ∗/ protected $appSecret ; /∗∗ ∗ The ID o f t h e Facebook u s e r , ∗ ∗ @var i n t e g e r ∗/ protected $user ; or 0 /∗∗ ∗ The d a t a from t h e s i g n e d r e q u e s t ∗ ∗ @var s t r i n g ∗/ protected $signedRequest ; /∗∗ ∗ A CSRF s t a t e ∗ ∗ @var s t r i n g ∗/ variable to assist if the user is l o g g e d out . token . in the defense 228 a g a i n s t CSRF a t t a c k s . protected $state ; /∗∗ ∗ The OAuth a c c e s s t o k e n r e c e i v e d i n e x c h a n g e f o r a v a l i d a u t h o r i z a t i o n ∗ code . n u l l means t h e a c c e s s t o k e n h a s y e t t o be d e t e r m i n e d . ∗ ∗ @var s t r i n g ∗/ protected $accessToken = n u l l ; /∗∗ ∗ I n d i c a t e s i f t h e CURL b a s e d @ s y n t a x ∗ ∗ @var b o o l e a n ∗/ protected $fileUploadSupport = f a l s e ; for file uploads is enabled . /∗∗ ∗ I n d i c a t e s i f we t r u s t HTTP X FORWARDED ∗ h e a d e r s . ∗ ∗ @var b o o l e a n ∗/ protected $trustForwarded = f a l s e ; /∗∗ ∗ Indicates i f signed request i s allowed ∗ ∗ @var b o o l e a n ∗/ protected $allowSignedRequest = true ; i n query parameters . /∗∗ ∗ I n i t i a l i z e a Facebook A p p l i c a t i o n . ∗ ∗ The c o n f i g u r a t i o n : ∗ − appId : t h e a p p l i c a t i o n ID ∗ − s e c r e t : the a p p l i c a t i o n s e c r e t ∗ − f i l e U p l o a d : ( optional ) boolean i n d i c a t i n g i f f i l e uploads are enabled ∗ − allowSignedRequest : ( optional ) boolean i n d i c a t i n g i f s i g n e d r e q u e s t i s ∗ a l l o w e d i n q u e r y p a r a m e t e r s o r POST body . S h o u l d be ∗ f a l s e f o r non−c a n v a s apps . Defaults to true . ∗ ∗ @param a r r a y $ c o n f i g The a p p l i c a t i o n c o n f i g u r a t i o n ∗/ public function construct ( $config ) { $ t h i s −>s e t A p p I d ( $ c o n f i g [ ’ appId ’ ] ) ; $ t h i s −>s e t A p p S e c r e t ( $ c o n f i g [ ’ s e c r e t ’ ] ) ; i f ( i s s e t ( $config [ ’ fileUpload ’ ] ) ) { $ t h i s −>s e t F i l e U p l o a d S u p p o r t ( $ c o n f i g [ ’ f i l e U p l o a d ’ ] ) ; } i f ( i s s e t ( $ c o n f i g [ ’ t r u s t F o r w a r d e d ’ ] ) && $ c o n f i g [ ’ t r u s t F o r w a r d e d ’ ] ) { $ t h i s −>t r u s t F o r w a r d e d = t r u e ; } i f ( i s s e t ( $config [ ’ allowSignedRequest ’ ] ) && ! $ c o n f i g [ ’ a l l o w S i g n e d R e q u e s t ’ ] ) { $ t h i s −>a l l o w S i g n e d R e q u e s t = f a l s e ; } $ s t a t e = $ t h i s −>g e t P e r s i s t e n t D a t a ( ’ s t a t e ’ ) ; i f ( ! empty ( $ s t a t e ) ) { $ t h i s −>s t a t e = $ s t a t e ; } } /∗∗ ∗ S e t t h e A p p l i c a t i o n ID . ∗ ∗ @param s t r i n g $ a p p I d The A p p l i c a t i o n ID ∗ ∗ @ r e t u r n BaseFacebook ∗/ p u b l i c f u n c t i o n setAppId ( $appId ) { $ t h i s −>appId = $ a p p I d ; return $this ; } /∗∗ ∗ Get t h e A p p l i c a t i o n ID . ∗ ∗ @ r e t u r n s t r i n g t h e A p p l i c a t i o n ID ∗/ p u b l i c f u n c t i o n getAppId ( ) { r e t u r n $ t h i s −>appId ; } /∗∗ ∗ S e t t h e App S e c r e t . ∗ ∗ @param s t r i n g $ a p i S e c r e t The App S e c r e t ∗ ∗ @ r e t u r n BaseFacebook ∗ @ d e p r e c a t e d Use s e t A p p S e c r e t i n s t e a d . ∗ @see s e t A p p S e c r e t ( ) ∗/ public function setApiSecret ( $apiSecret ) { $ t h i s −>s e t A p p S e c r e t ( $ a p i S e c r e t ) ; return $this ; } /∗∗ 229 ∗ S e t t h e App S e c r e t . ∗ ∗ @param s t r i n g $ a p p S e c r e t The App S e c r e t ∗ ∗ @ r e t u r n BaseFacebook ∗/ public function setAppSecret ( $appSecret ) { $ t h i s −>a p p S e c r e t = $ a p p S e c r e t ; return $this ; } /∗∗ ∗ Get t h e App S e c r e t . ∗ ∗ @ r e t u r n s t r i n g t h e App S e c r e t ∗ ∗ @ d e p r e c a t e d Use g e t A p p S e c r e t i n s t e a d . ∗ @see g e t A p p S e c r e t ( ) ∗/ public function getApiSecret () { r e t u r n $ t h i s −>g e t A p p S e c r e t ( ) ; } /∗∗ ∗ Get t h e App S e c r e t . ∗ ∗ @ r e t u r n s t r i n g t h e App S e c r e t ∗/ public f un c ti o n getAppSecret ( ) { r e t u r n $ t h i s −>a p p S e c r e t ; } /∗∗ ∗ Set the f i l e upload support s t a t u s . ∗ ∗ @param b o o l e a n $ f i l e U p l o a d S u p p o r t The f i l e u p l o a d s u p p o r t ∗ ∗ @ r e t u r n BaseFacebook ∗/ public function setFileUploadSupport ( $fileUploadSupport ) { $ t h i s −>f i l e U p l o a d S u p p o r t = $ f i l e U p l o a d S u p p o r t ; return $this ; } /∗∗ ∗ Get t h e f i l e u p l o a d s u p p o r t s t a t u s . ∗ ∗ @ r e t u r n b o o l e a n t r u e i f and o n l y i f t h e ∗/ public function getFileUploadSupport () { r e t u r n $ t h i s −>f i l e U p l o a d S u p p o r t ; } server /∗∗ ∗ Get t h e f i l e u p l o a d s u p p o r t s t a t u s . ∗ ∗ @ r e t u r n b o o l e a n t r u e i f and o n l y i f t h e s e r v e r ∗ ∗ @ d e p r e c a t e d Use g e t F i l e U p l o a d S u p p o r t i n s t e a d . ∗ @see g e t F i l e U p l o a d S u p p o r t ( ) ∗/ public function useFileUploadSupport () { r e t u r n $ t h i s −>g e t F i l e U p l o a d S u p p o r t ( ) ; } status . supports file upload . supports file upload . /∗∗ ∗ Sets the a c c e s s token f o r api c a l l s . Use t h i s i f you g e t ∗ y o u r a c c e s s t o k e n by o t h e r means and j u s t want t h e SDK ∗ to use i t . ∗ ∗ @param s t r i n g $ a c c e s s t o k e n an a c c e s s t o k e n . ∗ ∗ @ r e t u r n BaseFacebook ∗/ public function setAccessToken ( $ a c c e s s t o k e n ) { $ t h i s −>a c c e s s T o k e n = $ a c c e s s t o k e n ; return $this ; } /∗∗ ∗ Extend an a c c e s s t o k e n , w h i l e r e m o v i n g t h e s h o r t −l i v e d t o k e n t h a t might ∗ have been g e n e r a t e d v i a c l i e n t −s i d e f l o w . Thanks t o h t t p : / / b i t . l y / b0Pt0H ∗ f o r t h e workaround . ∗/ p u b l i c f u n c t i o n setExtendedAccessToken ( ) { try { // need t o c i r c u m v e n t j s o n d e c o d e by c a l l i n g oauthRequest // d i r e c t l y , s i n c e r e s p o n s e i s n ’ t JSON f o r m a t . $ a c c e s s t o k e n r e s p o n s e = $ t h i s −> o a u t h R e q u e s t ( $ t h i s −>g e t U r l ( ’ graph ’ , ’ / o a u t h / a c c e s s t o k e n ’ ) , $params = a r r a y ( ’ c l i e n t i d ’ => $ t h i s −>getAppId ( ) , ’ c l i e n t s e c r e t ’ => $ t h i s −>g e t A p p S e c r e t ( ) , ’ g r a n t t y p e ’ => ’ f b e x c h a n g e t o k e n ’ , ’ f b e x c h a n g e t o k e n ’ => $ t h i s −>g e t A c c e s s T o k e n ( ) , ) ); } c a t c h ( FacebookApiException $e ) { 230 // most l i k e l y t h a t u s e r v e r y r e c e n t l y r e v o k e d a u t h o r i z a t i o n . // I n any e v e n t , we don ’ t have an a c c e s s t o k e n , s o s a y s o . return f a l s e ; } if ( empty ( $ a c c e s s t o k e n r e s p o n s e ) ) { return f a l s e ; } $response params = array () ; parse str ( $access token response , if $response params ) ; ( ! i s s e t ( $response params [ ’ access token ’ ] ) ) { return f a l s e ; } $ t h i s −>d e s t r o y S e s s i o n ( ) ; $ t h i s −>s e t P e r s i s t e n t D a t a ( ’ access token ’ , $response params [ ’ access token ’ ] ); } /∗∗ ∗ D e t e r m i n e s t h e a c c e s s t o k e n t h a t s h o u l d be u s e d f o r API c a l l s . ∗ The f i r s t t i m e t h i s i s c a l l e d , $ t h i s −>a c c e s s T o k e n i s s e t e q u a l ∗ to e i t h e r a v a l i d u s e r a c c e s s token , or i t ’ s s e t to the a p p l i c a t i o n ∗ a c c e s s t o k e n i f a v a l i d u s e r a c c e s s t o k e n wasn ’ t a v a i l a b l e . Subsequent ∗ c a l l s r e t u r n whatever the f i r s t c a l l returned . ∗ ∗ @ r e t u r n s t r i n g The a c c e s s t o k e n ∗/ p u b l i c f u n c t i o n getAccessToken ( ) { i f ( $ t h i s −>a c c e s s T o k e n !== n u l l ) { // we ’ ve done t h i s a l r e a d y and c a c h e d i t . Just return . r e t u r n $ t h i s −>a c c e s s T o k e n ; } // f i r s t e s t a b l i s h a c c e s s t o k e n t o be t h e a p p l i c a t i o n // a c c e s s t o k e n , i n c a s e we n a v i g a t e t o t h e / o a u t h / a c c e s s t o k e n // e n d p o i n t , where SOME a c c e s s t o k e n i s r e q u i r e d . $ t h i s −>s e t A c c e s s T o k e n ( $ t h i s −>g e t A p p l i c a t i o n A c c e s s T o k e n ( ) ) ; $ u s e r a c c e s s t o k e n = $ t h i s −>g e t U s e r A c c e s s T o k e n ( ) ; i f ( $user access token ) { $ t h i s −>s e t A c c e s s T o k e n ( $ u s e r a c c e s s t o k e n ) ; } return $ t h i s −>a c c e s s T o k e n ; } /∗∗ ∗ D e t e r m i n e s and r e t u r n s t h e u s e r a c c e s s t o k e n , f i r s t u s i n g ∗ t h e s i g n e d r e q u e s t i f p r e s e n t , and t h e n f a l l i n g back on ∗ the a u t h o r i z a t i o n code i f p r e s e n t . The i n t e n t i s t o ∗ r e t u r n a v a l i d u s e r a c c e s s t o k e n , o r f a l s e i f one i s d e t e r m i n e d ∗ t o n o t be a v a i l a b l e . ∗ ∗ @ r e t u r n s t r i n g A v a l i d u s e r a c c e s s t o k e n , o r f a l s e i f one ∗ c o u l d n o t be d e t e r m i n e d . ∗/ pr ote ct ed f u n c t i o n getUserAccessToken ( ) { // f i r s t , c o n s i d e r a s i g n e d r e q u e s t i f i t ’ s s u p p l i e d . // i f t h e r e i s a s i g n e d r e q u e s t , t h e n i t a l o n e d e t e r m i n e s // t h e a c c e s s t o k e n . $ s i g n e d r e q u e s t = $ t h i s −>g e t S i g n e d R e q u e s t ( ) ; i f ( $signed request ) { // apps . f a c e b o o k . com hands t h e a c c e s s t o k e n i n t h e s i g n e d r e q u e s t i f ( a r r a y k e y e x i s t s ( ’ oauth token ’ , $ s i g n e d r e q u e s t ) ) { $ a c c e s s t o k e n = $ s i g n e d r e q u e s t [ ’ oauth token ’ ] ; $ t h i s −>s e t P e r s i s t e n t D a t a ( ’ a c c e s s t o k e n ’ , $ a c c e s s t o k e n ) ; return $access token ; } // t h e JS SDK p u t s a c o d e i n w i t h t h e r e d i r e c t u r i o f ’ ’ i f ( a r r a y k e y e x i s t s ( ’ code ’ , $ s i g n e d r e q u e s t ) ) { $ c o d e = $ s i g n e d r e q u e s t [ ’ code ’ ] ; i f ( $ c o d e && $ c o d e == $ t h i s −>g e t P e r s i s t e n t D a t a ( ’ code ’ ) ) { // s h o r t −c i r c u i t i f t h e c o d e we have i s t h e same a s t h e one p r e s e n t e d r e t u r n $ t h i s −>g e t P e r s i s t e n t D a t a ( ’ a c c e s s t o k e n ’ ) ; } $ a c c e s s t o k e n = $ t h i s −>getAccessTokenFromCode ( $code , ’ ’ ) ; i f ( $access token ) { $ t h i s −>s e t P e r s i s t e n t D a t a ( ’ code ’ , $ c o d e ) ; $ t h i s −>s e t P e r s i s t e n t D a t a ( ’ a c c e s s t o k e n ’ , $ a c c e s s t o k e n ) ; return $access token ; } } // s i g n e d r e q u e s t s t a t e s t h e r e ’ s no a c c e s s t o k e n , s o a n y t h i n g // s t o r e d s h o u l d be c l e a r e d . $ t h i s −>c l e a r A l l P e r s i s t e n t D a t a ( ) ; r e t u r n f a l s e ; // r e s p e c t t h e s i g n e d r e q u e s t ’ s data , e v e n // i f t h e r e ’ s an a u t h o r i z a t i o n c o d e o r s o m e t h i n g } $ c o d e = $ t h i s −>getCode ( ) ; i f ( $ c o d e && $ c o d e != $ t h i s −>g e t P e r s i s t e n t D a t a ( ’ code ’ ) ) { $ a c c e s s t o k e n = $ t h i s −>getAccessTokenFromCode ( $ c o d e ) ; 231 else if ( $access token ) { $ t h i s −>s e t P e r s i s t e n t D a t a ( ’ code ’ , $ c o d e ) ; $ t h i s −>s e t P e r s i s t e n t D a t a ( ’ a c c e s s t o k e n ’ , return $access token ; $access token ) ; } // c o d e was bogus , s o e v e r y t h i n g b a s e d on $ t h i s −>c l e a r A l l P e r s i s t e n t D a t a ( ) ; return f a l s e ; it s h o u l d be i n v a l i d a t e d . } // a s a f a l l b a c k , j u s t r e t u r n w h a t e v e r i s i n t h e p e r s i s t e n t // s t o r e , knowing n o t h i n g e x p l i c i t ( s i g n e d r e q u e s t , a u t h o r i z a t i o n // code , e t c . ) was p r e s e n t t o shadow i t ( o r we saw a c o d e i n $ REQUEST , // but i t ’ s t h e same a s what ’ s i n t h e p e r s i s t e n t s t o r e ) r e t u r n $ t h i s −>g e t P e r s i s t e n t D a t a ( ’ a c c e s s t o k e n ’ ) ; } /∗∗ ∗ R e t r i e v e t h e s i g n e d r e q u e s t , e i t h e r from a r e q u e s t p a r a m e t e r or , ∗ i f n o t p r e s e n t , from a c o o k i e . ∗ ∗ @return s t r i n g the s i g n e d r e q u e s t , i f a v a i l a b l e , or n u l l o t h e r w i s e . ∗/ public function getSignedRequest () { i f ( ! $ t h i s −>s i g n e d R e q u e s t ) { i f ( $ t h i s −>a l l o w S i g n e d R e q u e s t && ! empty ($ REQUEST [ ’ s i g n e d r e q u e s t ’ ] ) ) { $ t h i s −>s i g n e d R e q u e s t = $ t h i s −>p a r s e S i g n e d R e q u e s t ( $ REQUEST [ ’ s i g n e d r e q u e s t ’ ] ); } e l s e i f ( ! empty ( $ COOKIE [ $ t h i s −>g e t S i g n e d R e q u e s t C o o k i e N a m e ( ) ] ) ) { $ t h i s −>s i g n e d R e q u e s t = $ t h i s −>p a r s e S i g n e d R e q u e s t ( $ COOKIE [ $ t h i s −>g e t S i g n e d R e q u e s t C o o k i e N a m e ( ) ] ) ; } } r e t u r n $ t h i s −>s i g n e d R e q u e s t ; } /∗∗ ∗ Get t h e UID o f t h e c o n n e c t e d u s e r , o r 0 ∗ i f t h e Facebook u s e r i s n o t c o n n e c t e d . ∗ ∗ @ r e t u r n s t r i n g t h e UID i f a v a i l a b l e . ∗/ public function getUser () { i f ( $ t h i s −>u s e r !== n u l l ) { // we ’ ve a l r e a d y d e t e r m i n e d t h i s and c a c h e d t h e v a l u e . r e t u r n $ t h i s −>u s e r ; } return $ t h i s −>u s e r = $ t h i s −>g e t U s e r F r o m A v a i l a b l e D a t a ( ) ; } /∗∗ ∗ D e t e r m i n e s t h e c o n n e c t e d u s e r by f i r s t e x a m i n i n g any s i g n e d ∗ r e q u e s t s , t h e n c o n s i d e r i n g an a u t h o r i z a t i o n code , and t h e n ∗ f a l l i n g back t o any p e r s i s t e n t s t o r e s t o r i n g t h e u s e r . ∗ ∗ @ r e t u r n i n t e g e r The i d o f t h e c o n n e c t e d Facebook u s e r , ∗ o r 0 i f no s u c h u s e r e x i s t s . ∗/ pr ote ct ed f u n c t i o n getUserFromAvailableData ( ) { // i f a s i g n e d r e q u e s t i s s u p p l i e d , t h e n i t s o l e l y d e t e r m i n e s // who t h e u s e r i s . $ s i g n e d r e q u e s t = $ t h i s −>g e t S i g n e d R e q u e s t ( ) ; i f ( $signed request ) { i f ( array key exists ( ’ user id ’ , $signed request ) ) { $user = $signed request [ ’ user id ’ ] ; i f ( $ u s e r != $ t h i s −>g e t P e r s i s t e n t D a t a ( ’ u s e r i d ’ ) ) { $ t h i s −>c l e a r A l l P e r s i s t e n t D a t a ( ) ; } $ t h i s −>s e t P e r s i s t e n t D a t a ( ’ u s e r i d ’ , return $user ; $signed request [ ’ user id ’ ] ) ; } // i f t h e s i g n e d r e q u e s t didn ’ t p r e s e n t a u s e r i d , // a l l e n t r i e s i n any p e r s i s t e n t s t o r e . $ t h i s −>c l e a r A l l P e r s i s t e n t D a t a ( ) ; return 0; then invalidate } $ u s e r = $ t h i s −>g e t P e r s i s t e n t D a t a ( ’ u s e r i d ’ , $ d e f a u l t = 0 ) ; $ p e r s i s t e d a c c e s s t o k e n = $ t h i s −>g e t P e r s i s t e n t D a t a ( ’ a c c e s s t o k e n ’ ) ; // u s e a c c e s s t o k e n t o f e t c h u s e r i d i f we have a u s e r a c c e s s t o k e n , // t h e c a c h e d a c c e s s t o k e n h a s changed . $ a c c e s s t o k e n = $ t h i s −>g e t A c c e s s T o k e n ( ) ; i f ( $ a c c e s s t o k e n && $ a c c e s s t o k e n != $ t h i s −>g e t A p p l i c a t i o n A c c e s s T o k e n ( ) && ! ( $ u s e r && $ p e r s i s t e d a c c e s s t o k e n == $ a c c e s s t o k e n ) ) { $ u s e r = $ t h i s −>g e t U s e r F r o m A c c e s s T o k e n ( ) ; i f ( $user ) { $ t h i s −>s e t P e r s i s t e n t D a t a ( ’ u s e r i d ’ , $ u s e r ) ; } else { $ t h i s −>c l e a r A l l P e r s i s t e n t D a t a ( ) ; } } 232 or if return $user ; } /∗∗ ∗ Get a L o g i n URL f o r u s e w i t h r e d i r e c t s . By d e f a u l t , f u l l page r e d i r e c t i s ∗ assumed . I f you a r e u s i n g t h e g e n e r a t e d URL w i t h a window . open ( ) c a l l i n ∗ J a v a S c r i p t , you can p a s s i n d i s p l a y=popup a s p a r t o f t h e $params . ∗ ∗ The p a r a m e t e r s : ∗ − r e d i r e c t u r i : t h e u r l t o go t o a f t e r a s u c c e s s f u l l o g i n ∗ − s c o p e : comma s e p a r a t e d l i s t o f r e q u e s t e d e x t e n d e d perms ∗ ∗ @param a r r a y $params P r o v i d e custom p a r a m e t e r s ∗ @ r e t u r n s t r i n g The URL f o r t h e l o g i n f l o w ∗/ p u b l i c f u n c t i o n g e t L o g i n U r l ( $params=a r r a y ( ) ) { $ t h i s −>e s t a b l i s h C S R F T o k e n S t a t e ( ) ; $ c u r r e n t U r l = $ t h i s −>g e t C u r r e n t U r l ( ) ; // i f ’ s c o p e ’ i s p a s s e d a s an a r r a y , c o n v e r t t o comma s e p a r a t e d l i s t $ s c op e P a r a ms = i s s e t ( $params [ ’ s c o p e ’ ] ) ? $params [ ’ s c o p e ’ ] : n u l l ; i f ( $ s c op e P a r a ms && i s a r r a y ( $ s c o p e Pa r a m s ) ) { $params [ ’ s c o p e ’ ] = i m p l o d e ( ’ , ’ , $ s c o p eP a r a m s ) ; } r e t u r n $ t h i s −>g e t U r l ( ’www’ , ’ d i a l o g / oauth ’ , array merge ( array ( ’ c l i e n t i d ’ => $ t h i s −>getAppId ( ) , ’ r e d i r e c t u r i ’ => $ c u r r e n t U r l , // p o s s i b l y ’ s t a t e ’ => $ t h i s −>s t a t e , ’ sdk ’ => ’ php−sdk − ’ . s e l f : : VERSION ), $params )); overwritten } /∗∗ ∗ Get a Logout URL s u i t a b l e f o r u s e w i t h r e d i r e c t s . ∗ ∗ The p a r a m e t e r s : ∗ − n e x t : t h e u r l t o go t o a f t e r a s u c c e s s f u l l o g o u t ∗ ∗ @param a r r a y $params P r o v i d e custom p a r a m e t e r s ∗ @ r e t u r n s t r i n g The URL f o r t h e l o g o u t f l o w ∗/ p u b l i c f u n c t i o n g e t L o g o u t U r l ( $params=a r r a y ( ) ) { r e t u r n $ t h i s −>g e t U r l ( ’www’ , ’ l o g o u t . php ’ , array merge ( array ( ’ next ’ => $ t h i s −>g e t C u r r e n t U r l ( ) , ’ a c c e s s t o k e n ’ => $ t h i s −>g e t U s e r A c c e s s T o k e n ( ) , ) , $params ) ); } /∗∗ ∗ Get a l o g i n s t a t u s URL t o f e t c h t h e s t a t u s from Facebook . ∗ ∗ @param a r r a y $params P r o v i d e custom p a r a m e t e r s ∗ @ r e t u r n s t r i n g The URL f o r t h e l o g o u t f l o w ∗/ p u b l i c f u n c t i o n g e t L o g i n S t a t u s U r l ( $params=a r r a y ( ) ) { r e t u r n $ t h i s −>g e t L o g i n U r l ( array merge ( array ( ’ r e s p o n s e t y p e ’ => ’ code ’ , ’ d i s p l a y ’ => ’ none ’ , ) , $params ) ); } /∗∗ ∗ Make an API c a l l . ∗ ∗ @ r e t u r n mixed The d e c o d e d r e s p o n s e ∗/ p u b l i c f u n c t i o n api (/∗ polymorphic ∗/) { $args = func get args () ; i f ( i s a r r a y ( $args [ 0 ] ) ) { r e t u r n $ t h i s −> r e s t s e r v e r ( $ a r g s [ 0 ] ) ; } else { return c a l l u s e r f u n c a r r a y ( array ( $this , } } ’ graph ’ ) , $args ) ; /∗∗ ∗ C o n s t r u c t s and r e t u r n s t h e name o f t h e c o o k i e t h a t ∗ p o t e n t i a l l y h o u s e s t h e s i g n e d r e q u e s t f o r t h e app u s e r . ∗ The c o o k i e i s n o t s e t by t h e BaseFacebook c l a s s , but ∗ i t may be s e t by t h e J a v a S c r i p t SDK . ∗ ∗ @ r e t u r n s t r i n g t h e name o f t h e c o o k i e t h a t would h o u s e ∗ the signed request value . ∗/ p r o t e c t e d f u n c t i o n getSignedRequestCookieName ( ) { 233 return ’ fbsr ’ . $ t h i s −>getAppId ( ) ; } /∗∗ ∗ C o n s t r u c t s and r e t u r n s t h e name o f t h e c o o k i e t h a t p o t e n t i a l l y c o n t a i n ∗ metadata . The c o o k i e i s n o t s e t by t h e BaseFacebook c l a s s , but i t may be ∗ s e t by t h e J a v a S c r i p t SDK . ∗ ∗ @ r e t u r n s t r i n g t h e name o f t h e c o o k i e t h a t would h o u s e metadata . ∗/ p r o t e c t e d f u n c t i o n getMetadataCookieName ( ) { r e t u r n ’ fbm ’ . $ t h i s −>getAppId ( ) ; } /∗∗ ∗ Get t h e a u t h o r i z a t i o n c o d e from t h e q u e r y p a r a m e t e r s , i f i t e x i s t s , ∗ and o t h e r w i s e r e t u r n f a l s e t o s i g n a l no a u t h o r i z a t i o n c o d e was ∗ discoverable . ∗ ∗ @ r e t u r n mixed The a u t h o r i z a t i o n code , o r f a l s e i f t h e a u t h o r i z a t i o n ∗ c o d e c o u l d n o t be d e t e r m i n e d . ∗/ p r o t e c t e d f u n c t i o n getCode ( ) { i f ( ! i s s e t ($ REQUEST [ ’ code ’ ] ) | | ! i s s e t ($ REQUEST [ ’ s t a t e ’ ] ) ) { return f a l s e ; } i f ( $ t h i s −>s t a t e === $ REQUEST [ ’ s t a t e ’ ] ) { // CSRF s t a t e h a s done i t s j o b , s o c l e a r i t $ t h i s −>s t a t e = n u l l ; $ t h i s −>c l e a r P e r s i s t e n t D a t a ( ’ s t a t e ’ ) ; r e t u r n $ REQUEST [ ’ code ’ ] ; } s e l f : : e r r o r L o g ( ’ CSRF s t a t e t o k e n d o e s n o t match one p r o v i d e d . ’ ) ; return false ; } /∗∗ ∗ R e t r i e v e s t h e UID w i t h t h e u n d e r s t a n d i n g t h a t ∗ $ t h i s −>a c c e s s T o k e n h a s a l r e a d y been s e t and i s ∗ seemingly l e g i t i m a t e . I t r e l i e s on Facebook ’ s Graph API ∗ t o r e t r i e v e u s e r i n f o r m a t i o n and t h e n e x t r a c t ∗ t h e u s e r ID . ∗ ∗ @ r e t u r n i n t e g e r R e t u r n s t h e UID o f t h e Facebook u s e r , o r 0 ∗ i f t h e Facebook u s e r c o u l d n o t be d e t e r m i n e d . ∗/ p r o t e c t e d f u n c t i o n getUserFromAccessToken ( ) { try { $ u s e r i n f o = $ t h i s −>a p i ( ’ / me ’ ) ; r e t u r n $ u s e r i n f o [ ’ id ’ ] ; } c a t c h ( FacebookApiException $e ) { return 0; } } /∗∗ ∗ R e t u r n s t h e a c c e s s t o k e n t h a t s h o u l d be u s e d ∗ u s e r s when no a u t h o r i z a t i o n c o d e i s a v a i l a b l e ∗ ∗ @ r e t u r n s t r i n g The a p p l i c a t i o n a c c e s s t o k e n , ∗ p u b l i c i n f o r m a t i o n about u s e r s ∗/ public function getApplicationAccessToken () { r e t u r n $ t h i s −>appId . ’ | ’ . $ t h i s −>a p p S e c r e t ; } for . l o g g e d out useful for gathering and a p p l i c a t i o n s . /∗∗ ∗ Lays down a CSRF s t a t e t o k e n f o r t h i s p r o c e s s . ∗ ∗ @return void ∗/ p r o t e c t e d f u n c t i o n establishCSRFTokenState ( ) { i f ( $ t h i s −>s t a t e === n u l l ) { $ t h i s −>s t a t e = md5 ( u n i q i d ( mt rand ( ) , t r u e ) ) ; $ t h i s −>s e t P e r s i s t e n t D a t a ( ’ s t a t e ’ , $ t h i s −>s t a t e ) ; } } /∗∗ ∗ R e t r i e v e s an a c c e s s t o k e n f o r t h e g i v e n a u t h o r i z a t i o n c o d e ∗ ( p r e v i o u s l y g e n e r a t e d from www. f a c e b o o k . com on b e h a l f o f ∗ a s p e c i f i c user ) . The a u t h o r i z a t i o n c o d e i s s e n t t o g r a p h . f a c e b o o k . com ∗ and a l e g i t i m a t e a c c e s s t o k e n i s g e n e r a t e d p r o v i d e d t h e a c c e s s t o k e n ∗ and t h e u s e r f o r which i t was g e n e r a t e d a l l match , and t h e u s e r i s ∗ e i t h e r l o g g e d i n t o Facebook o r h a s g r a n t e d an o f f l i n e a c c e s s p e r m i s s i o n . ∗ ∗ @param s t r i n g $ c o d e An a u t h o r i z a t i o n c o d e . ∗ @param s t r i n g $ r e d i r e c t u r i O p t i o n a l r e d i r e c t URI . D e f a u l t n u l l ∗ ∗ @ r e t u r n mixed An a c c e s s t o k e n e x c h a n g e d f o r t h e a u t h o r i z a t i o n code , o r ∗ f a l s e i f an a c c e s s t o k e n c o u l d n o t be g e n e r a t e d . ∗/ p r o t e c t e d f u n c t i o n getAccessTokenFromCode ( $code , $ r e d i r e c t u r i = n u l l ) { i f ( empty ( $ c o d e ) ) { return f a l s e ; } if ( $ r e d i r e c t u r i === n u l l ) { 234 $ r e d i r e c t u r i = $ t h i s −>g e t C u r r e n t U r l ( ) ; } try { oauthRequest // need t o c i r c u m v e n t j s o n d e c o d e by c a l l i n g // d i r e c t l y , s i n c e r e s p o n s e i s n ’ t JSON f o r m a t . $access token response = $ t h i s −> o a u t h R e q u e s t ( $ t h i s −>g e t U r l ( ’ graph ’ , ’ / o a u t h / a c c e s s t o k e n ’ ) , $params = a r r a y ( ’ c l i e n t i d ’ => $ t h i s −>getAppId ( ) , ’ c l i e n t s e c r e t ’ => $ t h i s −>g e t A p p S e c r e t ( ) , ’ r e d i r e c t u r i ’ => $ r e d i r e c t u r i , ’ code ’ => $ c o d e ) ) ; } c a t c h ( FacebookApiException $e ) { // most l i k e l y t h a t u s e r v e r y r e c e n t l y r e v o k e d a u t h o r i z a t i o n . // I n any e v e n t , we don ’ t have an a c c e s s t o k e n , s o s a y s o . return f a l s e ; } if ( empty ( $ a c c e s s t o k e n r e s p o n s e ) ) { return f a l s e ; } $response params = array () ; p a r s e s t r ( $access token response , $response params ) ; i f ( ! i s s e t ( $response params [ ’ access token ’ ] ) ) { return f a l s e ; } return $response params [ ’ access token ’ ] ; } /∗∗ ∗ I n v o k e t h e o l d r e s t s e r v e r . php e n d p o i n t . ∗ ∗ @param a r r a y $params Method c a l l o b j e c t ∗ ∗ @ r e t u r n mixed The d e c o d e d r e s p o n s e o b j e c t ∗ @throws F a c e b o o k A p i E x c e p t i o n ∗/ protected function r e s t s e r v e r ( $params ) { // g e n e r i c a p p l i c a t i o n l e v e l p a r a m e t e r s $params [ ’ a p i k e y ’ ] = $ t h i s −>getAppId ( ) ; $params [ ’ f o r m a t ’ ] = ’ j s o n −s t r i n g s ’ ; $ r e s u l t = j s o n d e c o d e ( $ t h i s −> o a u t h R e q u e s t ( $ t h i s −>g e t A p i U r l ( $params [ ’ method ’ ] ) , $params ) , true ) ; // r e s u l t s a r e r e t u r n e d , e r r o r s a r e thrown i f ( i s a r r a y ( $ r e s u l t ) && i s s e t ( $ r e s u l t [ ’ e r r o r c o d e ’ ] ) ) { $ t h i s −>t h r o w A P I E x c e p t i o n ( $ r e s u l t ) ; // @ c o d e C o v e r a g e I g n o r e S t a r t } // @ c o d e C o v e r a g e I g n o r e E n d $method = s t r t o l o w e r ( $params [ ’ method ’ ] ) ; i f ( $method === ’ auth . e x p i r e s e s s i o n ’ | | $method === ’ auth . r e v o k e a u t h o r i z a t i o n ’ ) { $ t h i s −>d e s t r o y S e s s i o n ( ) ; } return $result ; } /∗∗ ∗ Return t r u e i f t h i s i s v i d e o p o s t . ∗ ∗ @param s t r i n g $ p a t h The path ∗ @param s t r i n g $method The h t t p method ( d e f a u l t ’GET’ ) ∗ ∗ @return boolean t r u e i f t h i s i s v id e o post ∗/ p r o t e c t e d f u n c t i o n i s V i d e o P o s t ( $path , $method = ’GET’ ) { i f ( $method == ’POST’ && p r e g m a t c h ( ” / ˆ ( \ / ) ( . + ) ( \ / ) ( v i d e o s ) $ / ” , $ p a t h ) ) { return true ; } return f a l s e ; } /∗∗ ∗ I n v o k e t h e Graph API . ∗ ∗ @param s t r i n g $ p a t h The path ( r e q u i r e d ) ∗ @param s t r i n g $method The h t t p method ( d e f a u l t ’GET’ ) ∗ @param a r r a y $params The q u e r y / p o s t d a t a ∗ ∗ @ r e t u r n mixed The d e c o d e d r e s p o n s e o b j e c t ∗ @throws F a c e b o o k A p i E x c e p t i o n ∗/ protected function g r a p h ( $path , $method = ’GET’ , $params = a r r a y ( ) ) { i f ( i s a r r a y ( $method ) && empty ( $params ) ) { $params = $method ; $method = ’GET’ ; } $params [ ’ method ’ ] = $method ; // method o v e r r i d e a s we a l w a y s do a POST if ( $ t h i s −>i s V i d e o P o s t ( $path , $method ) ) { 235 $domainKey = ’ g r a p h v i d e o ’ ; } else { $domainKey = ’ graph ’ ; } $ r e s u l t = j s o n d e c o d e ( $ t h i s −> o a u t h R e q u e s t ( $ t h i s −>g e t U r l ( $domainKey , $ p a t h ) , $params ) , true ) ; // r e s u l t s a r e r e t u r n e d , e r r o r s a r e thrown i f ( i s a r r a y ( $ r e s u l t ) && i s s e t ( $ r e s u l t [ ’ e r r o r ’ ] ) ) { $ t h i s −>t h r o w A P I E x c e p t i o n ( $ r e s u l t ) ; // @ c o d e C o v e r a g e I g n o r e S t a r t } // @ c o d e C o v e r a g e I g n o r e E n d return $result ; } /∗∗ ∗ Make a OAuth R e q u e s t . ∗ ∗ @param s t r i n g $ u r l The path ( r e q u i r e d ) ∗ @param a r r a y $params The q u e r y / p o s t d a t a ∗ ∗ @ r e t u r n s t r i n g The d e c o d e d r e s p o n s e o b j e c t ∗ @throws F a c e b o o k A p i E x c e p t i o n ∗/ o a u t h R e q u e s t ( $ u r l , $params ) { protected function i f ( ! i s s e t ( $params [ ’ a c c e s s t o k e n ’ ] ) ) { $params [ ’ a c c e s s t o k e n ’ ] = $ t h i s −>g e t A c c e s s T o k e n ( ) ; } if ( i s s e t ( $params [ ’ a c c e s s t o k e n ’ ] ) && ! i s s e t ( $params [ ’ a p p s e c r e t p r o o f ’ ] ) ) { $params [ ’ a p p s e c r e t p r o o f ’ ] = $ t h i s −>g e t A p p S e c r e t P r o o f ( $params [ ’ a c c e s s t o k e n ’ ] ) ; } // j s o n e n c o d e a l l params v a l u e s t h a t a r e n o t s t r i n g s f o r e a c h ( $params a s $key => $ v a l u e ) { i f ( ! i s s t r i n g ( $ v a l u e ) && ! ( $ v a l u e i n s t a n c e o f CURLFile ) ) { $params [ $key ] = j s o n e n c o d e ( $ v a l u e ) ; } } return $ t h i s −>makeRequest ( $ u r l , $params ) ; } /∗∗ ∗ G e n e r a t e a p r o o f o f App S e c r e t ∗ T h i s i s r e q u i r e d f o r a l l API c a l l s o r i g i n a t i n g from a s e r v e r ∗ I t i s a s h a 2 5 6 hash o f t h e a c c e s s t o k e n made u s i n g t h e app s e c r e t ∗ ∗ @param s t r i n g $ a c c e s s t o k e n The a c c e s s t o k e n t o be h a s h e d ( r e q u i r e d ) ∗ ∗ @ r e t u r n s t r i n g The s h a 2 5 6 hash o f t h e a c c e s s t o k e n ∗/ protected function getAppSecretProof ( $access token ) { r e t u r n hash hmac ( ’ sha256 ’ , $ a c c e s s t o k e n , $ t h i s −>g e t A p p S e c r e t ( ) ) ; } /∗∗ ∗ Makes an HTTP r e q u e s t . T h i s method can be o v e r r i d d e n by s u b c l a s s e s i f ∗ d e v e l o p e r s want t o do f a n c i e r t h i n g s o r u s e s o m e t h i n g o t h e r than c u r l ∗ make t h e r e q u e s t . ∗ ∗ @param s t r i n g $ u r l The URL t o make t h e r e q u e s t t o ∗ @param a r r a y $params The p a r a m e t e r s t o u s e f o r t h e POST body ∗ @param C u r l H a n d l e r $ch I n i t i a l i z e d c u r l h a n d l e ∗ ∗ @ r e t u r n s t r i n g The r e s p o n s e t e x t ∗/ p r o t e c t e d f u n c t i o n makeRequest ( $ u r l , $params , $ch=n u l l ) { i f ( ! $ch ) { $ch = c u r l i n i t ( ) ; } $ o p t s = s e l f : : $CURL OPTS ; i f ( $ t h i s −>g e t F i l e U p l o a d S u p p o r t ( ) ) { $ o p t s [ CURLOPT POSTFIELDS ] = $params ; } else { $ o p t s [ CURLOPT POSTFIELDS ] = h t t p b u i l d q u e r y ( $params , } $ o p t s [ CURLOPT URL ] = $ u r l ; null , to ’& ’) ; // d i s a b l e t h e ’ Expect : 100− c o n t i n u e ’ b e h a v i o u r . T h i s c a u s e s CURL t o w a i t // f o r 2 s e c o n d s i f t h e s e r v e r d o e s n o t s u p p o r t t h i s h e a d e r . i f ( i s s e t ( $ o p t s [CURLOPT HTTPHEADER ] ) ) { $ e x i s t i n g h e a d e r s = $ o p t s [CURLOPT HTTPHEADER ] ; $ e x i s t i n g h e a d e r s [ ] = ’ Expect : ’ ; $ o p t s [CURLOPT HTTPHEADER] = $ e x i s t i n g h e a d e r s ; } else { $ o p t s [CURLOPT HTTPHEADER] = a r r a y ( ’ Expect : ’ ) ; } c u r l s e t o p t a r r a y ( $ch , $ o p t s ) ; $ r e s u l t = c u r l e x e c ( $ch ) ; $ e r r n o = c u r l e r r n o ( $ch ) ; 236 // CURLE SSL CACERT | | CURLE SSL CACERT BADFILE i f ( $ e r r n o == 60 | | $ e r r n o == 7 7 ) { s e l f : : e r r o r L o g ( ’ I n v a l i d o r no c e r t i f i c a t e a u t h o r i t y found , ’ . ’ u s i n g bundled i n f o r m a t i o n ’ ) ; c u r l s e t o p t ( $ch , CURLOPT CAINFO, dirname ( F I L E ) . DIRECTORY SEPARATOR . ’ f b c a c h a i n b u n d l e . c r t ’ ) ; $ r e s u l t = c u r l e x e c ( $ch ) ; } // // // // // if With d u a l s t a c k e d DNS r e s p o n s e s , i t ’ s p o s s i b l e f o r a s e r v e r t o have IPv6 e n a b l e d but n o t have IPv6 c o n n e c t i v i t y . If this is t h e c a s e , c u r l w i l l t r y IPv4 f i r s t and i f t h a t f a i l s , t h e n i t w i l l f a l l back t o IPv6 and t h e e r r o r EHOSTUNREACH i s r e t u r n e d by t h e o p e r a t i n g system . ( $ r e s u l t === f a l s e && empty ( $ o p t s [ CURLOPT IPRESOLVE ] ) ) { $ ma t c he s = a r r a y ( ) ; $ r e g e x = ’ / F a i l e d t o c o n n e c t t o ( [ ˆ : ] . ∗ ) : Network i s u n r e a c h a b l e / ’ ; i f ( p r e g m a t c h ( $ r e g e x , c u r l e r r o r ( $ch ) , $ m at c h es ) ) { i f ( s t r l e n ( @ i n e t p t o n ( $ ma t ch e s [ 1 ] ) ) === 1 6 ) { s e l f : : e r r o r L o g ( ’ I n v a l i d IPv6 c o n f i g u r a t i o n on s e r v e r , ’ . ’ P l e a s e d i s a b l e o r g e t n a t i v e IPv6 on y o u r s e r v e r . ’ ) ; s e l f : : $CURL OPTS [ CURLOPT IPRESOLVE ] = CURL IPRESOLVE V4 ; c u r l s e t o p t ( $ch , CURLOPT IPRESOLVE, CURL IPRESOLVE V4 ) ; $ r e s u l t = c u r l e x e c ( $ch ) ; } } } if ( $ r e s u l t === f a l s e ) { $ e = new F a c e b o o k A p i E x c e p t i o n ( a r r a y ( ’ e r r o r c o d e ’ => c u r l e r r n o ( $ch ) , ’ e r r o r ’ => a r r a y ( ’ message ’ => c u r l e r r o r ( $ch ) , ’ type ’ => ’ C u r l E x c e p t i o n ’ , ), )); c u r l c l o s e ( $ch ) ; throw $ e ; } c u r l c l o s e ( $ch ) ; return $result ; } /∗∗ ∗ P a r s e s a s i g n e d r e q u e s t and v a l i d a t e s t h e s i g n a t u r e . ∗ ∗ @param s t r i n g $ s i g n e d r e q u e s t A s i g n e d t o k e n ∗ ∗ @ r e t u r n a r r a y The p a y l o a d i n s i d e i t o r n u l l i f t h e s i g ∗/ protected function parseSignedRequest ( $signed request ) { if is wrong ( ! $ s i g n e d r e q u e s t | | s t r p o s ( $ s i g n e d r e q u e s t , ’ . ’ ) === f a l s e ) { s e l f : : e r r o r L o g ( ’ S i g n e d r e q u e s t was i n v a l i d ! ’ ) ; return null ; } l i s t ( $encoded sig , $payload ) = explode ( ’ . ’ , $signed request , // d e c o d e t h e d a t a $ s i g = s e l f : : base64UrlDecode ( $ e n c o d e d s i g ) ; $data = j s o n d e c o d e ( s e l f : : base64UrlDecode ( $payload ) , if ( ! i s s e t ( $data [ ’ algorithm ’ ] ) | | s t r t o u p p e r ( $ d a t a [ ’ a l g o r i t h m ’ ] ) !== ) { s e l f : : errorLog ( ’ Unknown a l g o r i t h m . return null ; } Expected ’ . 2) ; true ) ; s e l f : : SIGNED REQUEST ALGORITHM s e l f : : SIGNED REQUEST ALGORITHM) ; // c h e c k s i g $ e x p e c t e d s i g = hash hmac ( ’ sha256 ’ , $ p a y l o a d , $ t h i s −>g e t A p p S e c r e t ( ) , $raw = t r u e ) ; if ( s t r l e n ( $ e x p e c t e d s i g ) !== s t r l e n ( $ s i g ) ) { s e l f : : e r r o r L o g ( ’ Bad S i g n e d JSON s i g n a t u r e ! ’ ) ; return null ; } $result = 0; f o r ( $ i = 0 ; $ i < s t r l e n ( $ e x p e c t e d s i g ) ; $ i ++) { $ r e s u l t |= o r d ( $ e x p e c t e d s i g [ $ i ] ) ˆ o r d ( $ s i g [ $ i ] ) ; } i f ( $ r e s u l t == 0 ) { r e t u r n $data ; } else { s e l f : : e r r o r L o g ( ’ Bad S i g n e d JSON s i g n a t u r e ! ’ ) ; return null ; } } /∗∗ ∗ Makes a s i g n e d r e q u e s t b l o b u s i n g t h e g i v e n d a t a . ∗ ∗ @param a r r a y $ d a t a The d a t a a r r a y . ∗ ∗ @ r e t u r n s t r i n g The s i g n e d r e q u e s t . 237 ∗/ p r o t e c t e d f u n c t i o n makeSignedRequest ( $data ) { i f ( ! i s a r r a y ( $data ) ) { throw new I n v a l i d A r g u m e n t E x c e p t i o n ( ’ m a k e S i g n e d R e q u e s t e x p e c t s an a r r a y . Got : ’ . p r i n t r ( $data , t r u e ) ) ; } $ d a t a [ ’ a l g o r i t h m ’ ] = s e l f : : SIGNED REQUEST ALGORITHM ; $data [ ’ i s s u e d a t ’ ] = time ( ) ; $ j s o n = j s o n e n c o d e ( $data ) ; $b64 = s e l f : : b a s e 6 4 U r l E n c o d e ( $ j s o n ) ; $ r a w s i g = hash hmac ( ’ sha256 ’ , $b64 , $ t h i s −>g e t A p p S e c r e t ( ) , $raw = t r u e ) ; $ s i g = s e l f : : base64UrlEncode ( $ r a w s i g ) ; r e t u r n $ s i g . ’ . ’ . $b64 ; } /∗∗ ∗ B u i l d t h e URL f o r a p i g i v e n p a r a m e t e r s . ∗ ∗ @param s t r i n g $method The method name . ∗ ∗ @ r e t u r n s t r i n g The URL f o r t h e g i v e n p a r a m e t e r s ∗/ p r o t e c t e d f u n c t i o n g e t A p i U r l ( $method ) { s t a t i c $READ ONLY CALLS = a r r a y ( ’ admin . g e t a l l o c a t i o n ’ => 1 , ’ admin . g e t a p p p r o p e r t i e s ’ => 1 , ’ admin . g e t b a n n e d u s e r s ’ => 1 , ’ admin . g e t l i v e s t r e a m v i a l i n k ’ => 1 , ’ admin . g e t m e t r i c s ’ => 1 , ’ admin . g e t r e s t r i c t i o n i n f o ’ => 1 , ’ a p p l i c a t i o n . g e t p u b l i c i n f o ’ => 1 , ’ auth . g e t a p p p u b l i c k e y ’ => 1 , ’ auth . g e t s e s s i o n ’ => 1 , ’ auth . g e t s i g n e d p u b l i c s e s s i o n d a t a ’ => 1 , ’ comments . g e t ’ => 1 , ’ c o n n e c t . g e t u n c o n n e c t e d f r i e n d s c o u n t ’ => 1 , ’ d a s h b o a r d . g e t a c t i v i t y ’ => 1 , ’ d a s h b o a r d . g e t c o u n t ’ => 1 , ’ d a s h b o a r d . g e t g l o b a l n e w s ’ => 1 , ’ d a s h b o a r d . g e t n e w s ’ => 1 , ’ d a s h b o a r d . m u l t i g e t c o u n t ’ => 1 , ’ d a s h b o a r d . m u l t i g e t n e w s ’ => 1 , ’ d a t a . g e t c o o k i e s ’ => 1 , ’ e v e n t s . g e t ’ => 1 , ’ e v e n t s . getmembers ’ => 1 , ’ f b m l . g e t c u s t o m t a g s ’ => 1 , ’ f e e d . g e t a p p f r i e n d s t o r i e s ’ => 1 , ’ f e e d . g e t r e g i s t e r e d t e m p l a t e b u n d l e b y i d ’ => 1 , ’ f e e d . g e t r e g i s t e r e d t e m p l a t e b u n d l e s ’ => 1 , ’ f q l . m u l t i q u e r y ’ => 1 , ’ f q l . query ’ => 1 , ’ f r i e n d s . a r e f r i e n d s ’ => 1 , ’ f r i e n d s . g e t ’ => 1 , ’ f r i e n d s . g e t a p p u s e r s ’ => 1 , ’ f r i e n d s . g e t l i s t s ’ => 1 , ’ f r i e n d s . g e t m u t u a l f r i e n d s ’ => 1 , ’ g i f t s . g e t ’ => 1 , ’ g r o u p s . g e t ’ => 1 , ’ g r o u p s . getmembers ’ => 1 , ’ i n t l . g e t t r a n s l a t i o n s ’ => 1 , ’ l i n k s . g e t ’ => 1 , ’ n o t e s . g e t ’ => 1 , ’ n o t i f i c a t i o n s . g e t ’ => 1 , ’ p a g e s . g e t i n f o ’ => 1 , ’ p a g e s . i s a d m i n ’ => 1 , ’ p a g e s . i s a p p a d d e d ’ => 1 , ’ p a g e s . i s f a n ’ => 1 , ’ p e r m i s s i o n s . c h e c k a v a i l a b l e a p i a c c e s s ’ => 1 , ’ p e r m i s s i o n s . c h e c k g r a n t e d a p i a c c e s s ’ => 1 , ’ p h o t o s . g e t ’ => 1 , ’ p h o t o s . g e t a l b u m s ’ => 1 , ’ p h o t o s . g e t t a g s ’ => 1 , ’ p r o f i l e . g e t i n f o ’ => 1 , ’ p r o f i l e . g e t i n f o o p t i o n s ’ => 1 , ’ s t r e a m . g e t ’ => 1 , ’ s t r e a m . getcomments ’ => 1 , ’ s t r e a m . g e t f i l t e r s ’ => 1 , ’ u s e r s . g e t i n f o ’ => 1 , ’ u s e r s . g e t l o g g e d i n u s e r ’ => 1 , ’ u s e r s . g e t s t a n d a r d i n f o ’ => 1 , ’ u s e r s . h a s a p p p e r m i s s i o n ’ => 1 , ’ u s e r s . i s a p p u s e r ’ => 1 , ’ u s e r s . i s v e r i f i e d ’ => 1 , ’ v i d e o . g e t u p l o a d l i m i t s ’ => 1 ) ; $name = ’ a p i ’ ; i f ( i s s e t ($READ ONLY CALLS [ s t r t o l o w e r ( $method ) ] ) ) { $name = ’ a p i r e a d ’ ; } e l s e i f ( s t r t o l o w e r ( $method ) == ’ v i d e o . upload ’ ) { $name = ’ a p i v i d e o ’ ; } r e t u r n s e l f : : g e t U r l ( $name , ’ r e s t s e r v e r . php ’ ) ; } /∗∗ ∗ B u i l d t h e URL ∗ ∗ @param s t r i n g ∗ @param s t r i n g ∗ @param a r r a y for g i v e n domain a l i a s , path and p a r a m e t e r s . $name The name o f t h e domain $path O p t i o n a l path ( w i t h o u t a l e a d i n g $params O p t i o n a l q u e r y p a r a m e t e r s 238 slash ) ∗ ∗ @ r e t u r n s t r i n g The URL f o r t h e g i v e n p a r a m e t e r s ∗/ p r o t e c t e d f u n c t i o n g e t U r l ( $name , $ p a t h = ’ ’ , $params=a r r a y ( ) ) { $ u r l = s e l f : : $DOMAIN MAP [ $name ] ; i f ( $path ) { i f ( $ p a t h [ 0 ] === ’ / ’ ) { $ p a t h = s u b s t r ( $path , 1 ) ; } $ u r l .= $ p a t h ; } i f ( $params ) { $ u r l .= ’ ? ’ . h t t p b u i l d q u e r y ( $params , n u l l , ’ & ’ ) ; } return $url ; } /∗∗ ∗ R e t u r n s t h e HTTP Host ∗ ∗ @ r e t u r n s t r i n g The HTTP Host ∗/ p r o t e c t e d f u n c t i o n getHttpHost ( ) { i f ( $ t h i s −>t r u s t F o r w a r d e d && i s s e t ( $ SERVER [ ’ HTTP X FORWARDED HOST’ ] ) ) { $ f o r w a r d P r o x i e s = e x p l o d e ( ’ , ’ , $ SERVER [ ’ HTTP X FORWARDED HOST’ ] ) ; i f ( ! empty ( $ f o r w a r d P r o x i e s ) ) { return $forwardProxies [ 0 ] ; } } r e t u r n $ SERVER [ ’ HTTP HOST ’ ] ; } /∗∗ ∗ R e t u r n s t h e HTTP P r o t o c o l ∗ ∗ @ r e t u r n s t r i n g The HTTP P r o t o c o l ∗/ protected function getHttpProtocol () { i f ( $ t h i s −>t r u s t F o r w a r d e d && i s s e t ( $ SERVER [ ’HTTP X FORWARDED PROTO’ ] ) ) { i f ( $ SERVER [ ’HTTP X FORWARDED PROTO’ ] === ’ h t t p s ’ ) { return ’ https ’ ; } r e t u r n ’ http ’ ; } /∗ a p a c h e + v a r i a n t s s p e c i f i c way o f c h e c k i n g f o r h t t p s ∗/ i f ( i s s e t ( $ SERVER [ ’ HTTPS ’ ] ) && ( $ SERVER [ ’ HTTPS ’ ] === ’ on ’ | | $ SERVER [ ’ HTTPS ’ ] == 1 ) ) { return ’ https ’ ; } /∗ n g i n x way o f c h e c k i n g f o r h t t p s ∗/ i f ( i s s e t ( $ SERVER [ ’ SERVER PORT ’ ] ) && ( $ SERVER [ ’ SERVER PORT ’ ] === ’ 4 4 3 ’ ) ) { return ’ https ’ ; } r e t u r n ’ http ’ ; } /∗∗ ∗ R e t u r n s t h e b a s e domain u s e d f o r t h e c o o k i e . ∗ ∗ @ r e t u r n s t r i n g The b a s e domain ∗/ p r o t e c t e d f u n c t i o n getBaseDomain ( ) { // The b a s e domain i s s t o r e d i n t h e metadata c o o k i e // t o t h e c u r r e n t hostname $metadata = $ t h i s −>g e t M e t a d a t a C o o k i e ( ) ; i f ( a r r a y k e y e x i s t s ( ’ b a s e d o m a i n ’ , $metadata ) && ! empty ( $metadata [ ’ b a s e d o m a i n ’ ] ) ) { r e t u r n t r i m ( $metadata [ ’ b a s e d o m a i n ’ ] , ’ . ’ ) ; } r e t u r n $ t h i s −>g e t H t t p H o s t ( ) ; } if n o t we f a l l b a c k /∗∗ ∗ R e t u r n s t h e C u r r e n t URL, s t r i p p i n g i t o f known FB p a r a m e t e r s t h a t ∗ not p e r s i s t . ∗ ∗ @ r e t u r n s t r i n g The c u r r e n t URL ∗/ protected function getCurrentUrl () { $ p r o t o c o l = $ t h i s −>g e t H t t p P r o t o c o l ( ) . ’ : / / ’ ; $ h o s t = $ t h i s −>g e t H t t p H o s t ( ) ; $ c u r r e n t U r l = $ p r o t o c o l . $ h o s t . $ SERVER [ ’ REQUEST URI ’ ] ; $parts = parse url ( $currentUrl ) ; $query = ’ ’ ; i f ( ! empty ( $ p a r t s [ ’ query ’ ] ) ) { // drop known f b params $params = e x p l o d e ( ’ & ’ , $ p a r t s [ ’ query ’ ] ) ; $retained params = array () ; f o r e a c h ( $params a s $param ) { i f ( $ t h i s −>s h o u l d R e t a i n P a r a m ( $param ) ) { $ r e t a i n e d p a r a m s [ ] = $param ; } } if ( ! empty ( $ r e t a i n e d p a r a m s ) ) { $query = ’ ? ’ . implode ( $retained params , ’& ’) ; 239 should } } // u s e p o r t i f non d e f a u l t $port = i s s e t ( $ p a r t s [ ’ p o r t ’ ] ) && ( ( $ p r o t o c o l === ’ h t t p : / / ’ && $ p a r t s [ ’ p o r t ’ ] !== 8 0 ) | | ( $ p r o t o c o l === ’ h t t p s : / / ’ && $ p a r t s [ ’ p o r t ’ ] !== 4 4 3 ) ) ? ’ : ’ . $ p a r t s [ ’ port ’ ] : ’ ’ ; // r e b u i l d return $protocol . $ p a r t s [ ’ host ’ ] . $port . $ p a r t s [ ’ path ’ ] . $query ; } /∗∗ ∗ R e t u r n s t r u e i f and o n l y i f t h e key o r key / v a l u e p a i r s h o u l d ∗ be r e t a i n e d a s p a r t o f t h e q u e r y s t r i n g . T h i s amounts t o ∗ a b r u t e −f o r c e s e a r c h o f t h e v e r y s m a l l l i s t o f Facebook− s p e c i f i c ∗ params t h a t s h o u l d be s t r i p p e d o u t . ∗ ∗ @param s t r i n g $param A key o r key / v a l u e p a i r w i t h i n a URL’ s q u e r y ( e . g . ∗ ’ f o o=a ’ , ’ f o o = ’ , o r ’ f o o ’ . ∗ ∗ @return boolean ∗/ p r o t e c t e d f u n c t i o n s h o u l d R e t a i n P a r a m ( $param ) { f o r e a c h ( s e l f : : $DROP QUERY PARAMS a s $ d r o p q u e r y p a r a m ) { i f ( $param === $ d r o p q u e r y p a r a m | | s t r p o s ( $param , $ d r o p q u e r y p a r a m . ’ = ’ ) === 0 ) { return f a l s e ; } } return true ; } /∗∗ ∗ A n a l y z e s t h e s u p p l i e d r e s u l t t o s e e i f i t was thrown ∗ b e c a u s e t h e a c c e s s t o k e n i s no l o n g e r v a l i d . I f that i s ∗ t h e c a s e , t h e n we d e s t r o y t h e s e s s i o n . ∗ ∗ @param a r r a y $ r e s u l t A r e c o r d s t o r i n g t h e e r r o r m e s s a g e r e t u r n e d ∗ by a f a i l e d API c a l l . ∗/ p r o t e c t e d f u n c t i o n throwAPIException ( $ r e s u l t ) { $ e = new F a c e b o o k A p i E x c e p t i o n ( $ r e s u l t ) ; s w i t c h ( $e−>getType ( ) ) { // OAuth 2 . 0 D r a f t 00 s t y l e c a s e ’ OAuthException ’ : // OAuth 2 . 0 D r a f t 10 s t y l e case ’ invalid token ’ : // REST s e r v e r e r r o r s a r e j u s t E x c e p t i o n s c a s e ’ Exception ’ : $ m e s s a g e = $e−>g e t M e s s a g e ( ) ; i f ( ( s t r p o s ( $message , ’ E r r o r v a l i d a t i n g a c c e s s t o k e n ’ ) !== f a l s e ) | | ( s t r p o s ( $message , ’ I n v a l i d OAuth a c c e s s t o k e n ’ ) !== f a l s e ) | | ( s t r p o s ( $message , ’An a c t i v e a c c e s s t o k e n must be used ’ ) !== f a l s e ) ) { $ t h i s −>d e s t r o y S e s s i o n ( ) ; } break ; } throw $ e ; } /∗∗ ∗ P r i n t s t o t h e e r r o r l o g i f you a r e n ’ t i n command l i n e mode . ∗ ∗ @param s t r i n g $msg Log m e s s a g e ∗/ p r o t e c t e d s t a t i c f u n c t i o n e r r o r L o g ( $msg ) { // d i s a b l e e r r o r l o g i f we a r e r u n n i n g i n a CLI e n v i r o n m e n t // @ c o d e C o v e r a g e I g n o r e S t a r t i f ( p h p s a p i n a m e ( ) != ’ c l i ’ ) { e r r o r l o g ( $msg ) ; } // uncomment t h i s i f you want t o s e e t h e e r r o r s on t h e page // p r i n t ’ e r r o r l o g : ’ . $msg . ” \ n ” ; // @ c o d e C o v e r a g e I g n o r e E n d } /∗∗ ∗ Base64 e n c o d i n g t h a t doesn ’ t need t o be u r l e n c o d e ( ) ed . ∗ E x a c t l y t h e same a s b a s e 6 4 e n c o d e e x c e p t i t u s e s ∗ − instead of + ∗ instead of / ∗ No padded = ∗ ∗ @param s t r i n g $ i n p u t b a s e 6 4 U r l E n c o d e d i n p u t ∗ ∗ @ r e t u r n s t r i n g The d e c o d e d s t r i n g ∗/ p r o t e c t e d s t a t i c f u n c t i o n base64UrlDecode ( $input ) { r e t u r n b a s e 6 4 d e c o d e ( s t r t r ( $ i n p u t , ’− ’ , ’ + / ’ ) ) ; } /∗∗ 240 ∗ Base64 e n c o d i n g t h a t doesn ’ t need t o be u r l e n c o d e ( ) ed . ∗ E x a c t l y t h e same a s b a s e 6 4 e n c o d e e x c e p t i t u s e s ∗ − instead of + instead of / ∗ ∗ ∗ @param s t r i n g $ i n p u t The i n p u t t o e n c o d e ∗ @ r e t u r n s t r i n g The b a s e 6 4 U r l e n c o d e d i n p u t , a s a s t r i n g . ∗/ p r o t e c t e d s t a t i c f u n c t i o n base64UrlEncode ( $input ) { $ s t r = s t r t r ( b a s e 6 4 e n c o d e ( $ i n p u t ) , ’ + / ’ , ’− ’ ) ; $ s t r = s t r r e p l a c e ( ’= ’ , ’ ’ , $ s t r ) ; return $str ; } /∗∗ ∗ Destroy the cu rr en t s e s s i o n ∗/ public function destroySession () { $ t h i s −>a c c e s s T o k e n = n u l l ; $ t h i s −>s i g n e d R e q u e s t = n u l l ; $ t h i s −>u s e r = n u l l ; $ t h i s −>c l e a r A l l P e r s i s t e n t D a t a ( ) ; // J a v a s c r i p t s e t s a c o o k i e t h a t w i l l be u s e d i n g e t S i g n e d R e q u e s t t h a t we // need t o c l e a r i f we can $ c o o k i e n a m e = $ t h i s −>g e t S i g n e d R e q u e s t C o o k i e N a m e ( ) ; i f ( a r r a y k e y e x i s t s ( $ c o o k i e n a m e , $ COOKIE ) ) { u n s e t ( $ COOKIE [ $ c o o k i e n a m e ] ) ; i f (! headers sent () ) { $ b a s e d o m a i n = $ t h i s −>getBaseDomain ( ) ; s e t c o o k i e ( $cookie name , ’ ’ , 1 , ’ / ’ , ’ . ’ . $base domain ) ; } else { // @ c o d e C o v e r a g e I g n o r e S t a r t s e l f : : errorLog ( ’ There e x i s t s a c o o k i e t h a t we wanted t o c l e a r t h a t we c o u l d n \ ’ t ’ . ’ c l e a r b e c a u s e h e a d e r s was a l r e a d y s e n t . Make s u r e t o do t h e f i r s t ’ . ’ API c a l l b e f o r e o u t p u t i n g a n y t h i n g . ’ ); // @ c o d e C o v e r a g e I g n o r e E n d } } } /∗∗ ∗ P a r s e s t h e metadata c o o k i e t h a t o u r J a v a s c r i p t API s e t ∗ ∗ @ r e t u r n a r r a y an a r r a y mapping key t o v a l u e ∗/ p r o t e c t e d f u n c t i o n getMetadataCookie ( ) { $ c o o k i e n a m e = $ t h i s −>getMetadataCookieName ( ) ; i f ( ! a r r a y k e y e x i s t s ( $ c o o k i e n a m e , $ COOKIE ) ) { return array () ; } // The c o o k i e v a l u e can be wrapped i n ”− c h a r a c t e r s $ c o o k i e v a l u e = t r i m ( $ COOKIE [ $ c o o k i e n a m e ] , ’ ” ’ ) ; if s o remove them ( empty ( $ c o o k i e v a l u e ) ) { return array () ; } $parts = explode ( ’& ’ , $cookie value ) ; $metadata = a r r a y ( ) ; f or ea c h ( $parts as $part ) { $ p a i r = explode ( ’= ’ , $part , 2) ; i f ( ! empty ( $ p a i r [ 0 ] ) ) { $metadata [ u r l d e c o d e ( $ p a i r [ 0 ] ) ] = ( count ( $ p a i r ) > 1) ? u r l d e c o d e ( $ p a i r [ 1 ] ) } } : ’ ’; r e t u r n $metadata ; } /∗∗ ∗ F i n d s w h e t h e r t h e g i v e n domain i s a l l o w e d o r ∗ ∗ @param s t r i n g $ b i g The v a l u e t o be c h e c k e d ∗ @param s t r i n g $ s m a l l The i n p u t s t r i n g ∗ ∗ @ r e t u r n b o o l e a n R e t u r n s TRUE i f $ b i g matches ∗/ p r o t e c t e d s t a t i c f u n c t i o n isAllowedDomain ( $big , i f ( $ b i g === $ s m a l l ) { return true ; } r e t u r n s e l f : : endsWith ( $ b i g , ’ . ’ . $ s m a l l ) ; } not against $small $small ) { /∗∗ ∗ Checks i f $ b i g s t r i n g e n d s w i t h $ s m a l l s t r i n g ∗ ∗ @param s t r i n g $ b i g The v a l u e t o be c h e c k e d a g a i n s t ∗ @param s t r i n g $ s m a l l The i n p u t s t r i n g ∗ ∗ @ r e t u r n b o o l e a n TRUE i f $ b i g e n d s w i t h $ s m a l l ∗/ p r o t e c t e d s t a t i c f u n c t i o n endsWith ( $ b i g , $ s m a l l ) { $len = s t r l e n ( $small ) ; 241 $small $small if ( $ l e n === 0 ) { return true ; } return s u b s t r ( $ b i g , −$ l e n ) === $ s m a l l ; } /∗∗ ∗ Each o f t h e f o l l o w i n g f o u r methods s h o u l d be o v e r r i d d e n i n ∗ a c o n c r e t e s u b c l a s s , a s t h e y a r e i n t h e p r o v i d e d Facebook c l a s s . ∗ The Facebook c l a s s u s e s PHP s e s s i o n s t o p r o v i d e a p r i m i t i v e ∗ p e r s i s t e n t s t o r e , but a n o t h e r s u b c l a s s −−one t h a t you implement−− ∗ might u s e a d a t a b a s e , memcache , o r an i n −memory c a c h e . ∗ ∗ @see Facebook ∗/ /∗∗ ∗ S t o r e s t h e g i v e n ( $key , $ v a l u e ) p a i r , s o t h a t f u t u r e c a l l s ∗ g e t P e r s i s t e n t D a t a ( $key ) r e t u r n $ v a l u e . T h i s c a l l may be i n ∗ ∗ @param s t r i n g $key ∗ @param a r r a y $ v a l u e ∗ ∗ @return void ∗/ a b s t r a c t p r o t e c t e d f u n c t i o n s e t P e r s i s t e n t D a t a ( $key , $ v a l u e ) ; to another request . /∗∗ ∗ Get t h e d a t a f o r $key , p e r s i s t e d by BaseFacebook : : s e t P e r s i s t e n t D a t a ( ) ∗ ∗ @param s t r i n g $key The key o f t h e d a t a t o r e t r i e v e ∗ @param b o o l e a n $ d e f a u l t The d e f a u l t v a l u e t o r e t u r n i f $key i s n o t f o u n d ∗ ∗ @ r e t u r n mixed ∗/ a b s t r a c t p r o t e c t e d f u n c t i o n g e t P e r s i s t e n t D a t a ( $key , $ d e f a u l t = f a l s e ) ; /∗∗ ∗ C l e a r t h e d a t a w i t h $key from t h e p e r s i s t e n t s t o r a g e ∗ ∗ @param s t r i n g $key ∗ ∗ @return void ∗/ a b s t r a c t p r o t e c t e d f u n c t i o n c l e a r P e r s i s t e n t D a t a ( $key ) ; /∗∗ ∗ C l e a r a l l d a t a from t h e p e r s i s t e n t s t o r a g e ∗ ∗ @return void ∗/ abstract protected function clearAllPersistentData () ; } <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; /∗∗ ∗ C o p y r i g h t 2011 Facebook , I n c . ∗ ∗ L i c e n s e d u n d e r t h e Apache L i c e n s e , V e r s i o n 2 . 0 ( t h e ” L i c e n s e ” ) ; you may ∗ n o t u s e t h i s f i l e e x c e p t i n c o m p l i a n c e w i t h t h e L i c e n s e . You may o b t a i n ∗ a copy o f t h e L i c e n s e a t ∗ ∗ h t t p : / /www. a p a c h e . o r g / l i c e n s e s /LICENSE−2.0 ∗ ∗ U n l e s s r e q u i r e d by a p p l i c a b l e law o r a g r e e d t o i n w r i t i n g , s o f t w a r e ∗ d i s t r i b u t e d u n d e r t h e L i c e n s e i s d i s t r i b u t e d on an ”AS I S ” BASIS , WITHOUT ∗ WARRANTIES OR CONDITIONS OF ANY KIND , e i t h e r e x p r e s s o r i m p l i e d . S e e t h e ∗ L i c e n s e f o r t h e s p e c i f i c l a n g u a g e g o v e r n i n g p e r m i s s i o n s and l i m i t a t i o n s ∗ under the L i c e n s e . ∗/ r e q u i r e o n c e ” b a s e f a c e b o o k . php ” ; /∗∗ ∗ E xte nd s t h e BaseFacebook c l a s s w i t h t h e i n t e n t o f ∗ PHP s e s s i o n s t o s t o r e u s e r i d s and a c c e s s t o k e n s . ∗/ c l a s s Facebook e x t e n d s BaseFacebook { /∗∗ ∗ Cookie p r e f i x ∗/ c o n s t FBSS COOKIE NAME = ’ f b s s ’ ; using /∗∗ ∗ We can s e t t h i s t o a h i g h number b e c a u s e t h e main s e s s i o n ∗ e x p i r a t i o n w i l l trump t h i s . ∗/ c o n s t FBSS COOKIE EXPIRE = 3 1 5 5 6 9 2 6 ; // 1 y e a r /∗∗ ∗ S t o r e s t h e s h a r e d s e s s i o n ID ∗ ∗ @var s t r i n g ∗/ protected $sharedSessionID ; if one is set . /∗∗ 242 ∗ I d e n t i c a l to the parent constructor , except that ∗ we s t a r t a PHP s e s s i o n t o s t o r e t h e u s e r ID and ∗ a c c e s s token i f during the course o f execution ∗ we d i s c o v e r them . ∗ ∗ @param a r r a y $ c o n f i g t h e a p p l i c a t i o n c o n f i g u r a t i o n . A d d i t i o n a l l y ∗ a c c e p t s ” s h a r e d S e s s i o n ” a s a b o o l e a n t o t u r n on a s e c o n d a r y ∗ c o o k i e f o r e n v i r o n m e n t s w i t h a s h a r e d s e s s i o n ( t h a t i s , y o u r app ∗ s h a r e s t h e domain w i t h o t h e r apps ) . ∗ construct ∗ @see BaseFacebook : : ∗/ construct ( $config ) { public function i f (( function exists ( ’ session status ’) && s e s s i o n s t a t u s ( ) !== PHP SESSION ACTIVE ) | | ! s e s s i o n i d ( ) ) { session start () ; } construct ( $config ) ; parent : : i f ( ! empty ( $ c o n f i g [ ’ s h a r e d S e s s i o n ’ ] ) ) { $ t h i s −>i n i t S h a r e d S e s s i o n ( ) ; // r e −l o a d t h e p e r s i s t e d s t a t e , s i n c e p a r e n t // a t t e m p t e d t o r e a d o u t o f non−s h a r e d c o o k i e $ s t a t e = $ t h i s −>g e t P e r s i s t e n t D a t a ( ’ s t a t e ’ ) ; i f ( ! empty ( $ s t a t e ) ) { $ t h i s −>s t a t e = $ s t a t e ; } else { $ t h i s −>s t a t e = n u l l ; } } } /∗∗ ∗ Supported keys f o r p e r s i s t e n t data ∗ ∗ @var a r r a y ∗/ p r o t e c t e d s t a t i c $kSupportedKeys = a r r a y ( ’ s t a t e ’ , ’ code ’ , ’ a c c e s s t o k e n ’ , ’ user id ’ ) ; /∗∗ ∗ I n i t i a t e s Shared S e s s i o n ∗/ protected function initSharedSession () { $ c o o k i e n a m e = $ t h i s −>g e t S h a r e d S e s s i o n C o o k i e N a m e ( ) ; i f ( i s s e t ( $ COOKIE [ $ c o o k i e n a m e ] ) ) { $ d a t a = $ t h i s −>p a r s e S i g n e d R e q u e s t ( $ COOKIE [ $ c o o k i e n a m e ] ) ; i f ( $ d a t a && ! empty ( $ d a t a [ ’ domain ’ ] ) && s e l f : : i s A l l o w e d D o m a i n ( $ t h i s −>g e t H t t p H o s t ( ) , $ d a t a [ ’ domain ’ ] ) ) { // good c a s e $ t h i s −>s h a r e d S e s s i o n I D = $ d a t a [ ’ i d ’ ] ; return ; } // i g n o r i n g p o t e n t i a l l y u n r e a c h a b l e d a t a } // e v i l / c o r r u p t / m i s s i n g c a s e $ b a s e d o m a i n = $ t h i s −>getBaseDomain ( ) ; $ t h i s −>s h a r e d S e s s i o n I D = md5 ( u n i q i d ( mt rand ( ) , t r u e ) ) ; $ c o o k i e v a l u e = $ t h i s −>m a k e S i g n e d R e q u e s t ( array ( ’ domain ’ => $ b a s e d o m a i n , ’ i d ’ => $ t h i s −>s h a r e d S e s s i o n I D , ) ); $ COOKIE [ $ c o o k i e n a m e ] = $ c o o k i e v a l u e ; i f (! headers sent () ) { $ e x p i r e = t i m e ( ) + s e l f : : FBSS COOKIE EXPIRE ; s e t c o o k i e ( $cookie name , $ c o o k i e v a l u e , $expire , ’ / ’ , ’ . ’ . $base domain ) ; } else { // @ c o d e C o v e r a g e I g n o r e S t a r t s e l f : : errorLog ( ’ S h a r e d s e s s i o n ID c o o k i e c o u l d n o t be s e t ! You must e n s u r e you ’ . ’ c r e a t e t h e Facebook i n s t a n c e b e f o r e h e a d e r s have been s e n t . T h i s ’ . ’ w i l l cause a u t h e n t i c a t i o n i s s u e s a f t e r the f i r s t request . ’ ); // @ c o d e C o v e r a g e I g n o r e E n d } } /∗∗ ∗ Provides the implementations of the i n h e r i t e d a b s t r a c t ∗ methods . The i m p l e m e n t a t i o n u s e s PHP s e s s i o n s t o m a i n t a i n ∗ a s t o r e f o r a u t h o r i z a t i o n c o d e s , u s e r i d s , CSRF s t a t e s , and ∗ access tokens . ∗/ /∗∗ ∗ { @inheritdoc } ∗ ∗ @see BaseFacebook : : s e t P e r s i s t e n t D a t a ( ) ∗/ p r o t e c t e d f u n c t i o n s e t P e r s i s t e n t D a t a ( $key , $ v a l u e ) { i f ( ! i n a r r a y ( $key , s e l f : : $ k S u p p o r t e d K e y s ) ) { s e l f : : e r r o r L o g ( ’ Unsupported key p a s s e d t o s e t P e r s i s t e n t D a t a . ’ ) ; return ; } $ s e s s i o n v a r n a m e = $ t h i s −>c o n s t r u c t S e s s i o n V a r i a b l e N a m e ( $key ) ; 243 $ SESSION [ $ s e s s i o n v a r n a m e ] = $ v a l u e ; } /∗∗ ∗ { @inheritdoc } ∗ ∗ @see BaseFacebook : : g e t P e r s i s t e n t D a t a ( ) ∗/ p r o t e c t e d f u n c t i o n g e t P e r s i s t e n t D a t a ( $key , $ d e f a u l t = f a l s e ) { i f ( ! i n a r r a y ( $key , s e l f : : $ k S u p p o r t e d K e y s ) ) { s e l f : : e r r o r L o g ( ’ Unsupported key p a s s e d t o g e t P e r s i s t e n t D a t a . ’ ) ; return $default ; } $ s e s s i o n v a r n a m e = $ t h i s −>c o n s t r u c t S e s s i o n V a r i a b l e N a m e ( $key ) ; r e t u r n i s s e t ( $ SESSION [ $ s e s s i o n v a r n a m e ] ) ? $ SESSION [ $ s e s s i o n v a r n a m e ] : $ d e f a u l t ; } /∗∗ ∗ { @inheritdoc } ∗ ∗ @see BaseFacebook : : c l e a r P e r s i s t e n t D a t a ( ) ∗/ p r o t e c t e d f u n c t i o n c l e a r P e r s i s t e n t D a t a ( $key ) { i f ( ! i n a r r a y ( $key , s e l f : : $ k S u p p o r t e d K e y s ) ) { s e l f : : e r r o r L o g ( ’ Unsupported key p a s s e d t o c l e a r P e r s i s t e n t D a t a . ’ ) ; return ; } $ s e s s i o n v a r n a m e = $ t h i s −>c o n s t r u c t S e s s i o n V a r i a b l e N a m e ( $key ) ; i f ( i s s e t ( $ SESSION [ $ s e s s i o n v a r n a m e ] ) ) { u n s e t ( $ SESSION [ $ s e s s i o n v a r n a m e ] ) ; } } /∗∗ ∗ { @inheritdoc } ∗ ∗ @see BaseFacebook : : c l e a r A l l P e r s i s t e n t D a t a ( ) ∗/ protected function clearAllPersistentData () { f o r e a c h ( s e l f : : $ k S u p p o r t e d K e y s a s $key ) { $ t h i s −>c l e a r P e r s i s t e n t D a t a ( $key ) ; } i f ( $ t h i s −>s h a r e d S e s s i o n I D ) { $ t h i s −>d e l e t e S h a r e d S e s s i o n C o o k i e ( ) ; } } /∗∗ ∗ D e l e t e s Shared s e s s i o n c o o k i e ∗/ protected function deleteSharedSessionCookie () { $ c o o k i e n a m e = $ t h i s −>g e t S h a r e d S e s s i o n C o o k i e N a m e ( ) ; u n s e t ( $ COOKIE [ $ c o o k i e n a m e ] ) ; $ b a s e d o m a i n = $ t h i s −>getBaseDomain ( ) ; s e t c o o k i e ( $cookie name , ’ ’ , 1 , ’ / ’ , ’ . ’ . $base domain ) ; } /∗∗ ∗ R e t u r n s t h e S h a r e d s e s s i o n c o o k i e name ∗ ∗ @ r e t u r n s t r i n g The S h a r e d s e s s i o n c o o k i e name ∗/ p r o t e c t e d f u n c t i o n getSharedSessionCookieName ( ) { r e t u r n s e l f : : FBSS COOKIE NAME . ’ ’ . $ t h i s −>getAppId ( ) ; } /∗∗ ∗ C o n s t r u c t s and r e t u r n s t h e name o f t h e s e s s i o n key . ∗ ∗ @see s e t P e r s i s t e n t D a t a ( ) ∗ @param s t r i n g $key The key f o r which t h e s e s s i o n v a r i a b l e name t o ∗ ∗ @ r e t u r n s t r i n g The name o f t h e s e s s i o n key . ∗/ p r o t e c t e d f u n c t i o n c o n s t r u c t S e s s i o n V a r i a b l e N a m e ( $key ) { $ p a r t s = a r r a y ( ’ f b ’ , $ t h i s −>getAppId ( ) , $key ) ; i f ( $ t h i s −>s h a r e d S e s s i o n I D ) { a r r a y u n s h i f t ( $ p a r t s , $ t h i s −>s h a r e d S e s s i o n I D ) ; } r e t u r n implode ( ’ ’ , $ p a r t s ) ; } construct . } <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t a c c e s s a l l o w e d ’ ) ; /∗∗ ∗ @name MY Pagination . php ∗ @version 1.0 ∗ @author J o o s t van Veen www. a c c e n t i n t e r a c t i v e . n l ∗ @ c r e a t e d : Sun J u l 27 1 6 : 2 7 : 2 6 GMT 2008 1 6 : 2 7 : 2 6 ∗ ∗ A s i m p l e P a g i n a t i o n e x t e n s i o n t o make w o r k i n g w i t h p a g i n a t i o n a b i t e a s i e r . ∗ I c r e a t e d t h i s l i b b e c a u s e I had URIs i n my app i n which t h e p a g i n g e l e m e n t ∗ was n o t a l w a y s i n t h e same segment , which makes i t a p a i n i f you work w i t h ∗ the d e f a u l t pagination c l a s s . 244 ∗ ∗ This simple l i b a c c o m p l i s h e s the f o l l o w i n g : ∗ − I t d e t e r m i n e s waht t h e ’ b a s e u r l ’ i s , s o you don ’ t have t o s e t i t y o u r s e l f ∗ − I t r e m o v e s t h e need f o r you s e t t i n g t h e i n f a m o u s ’ u r i s e g m e n t ’ s e t t i n g ∗ ∗ B a s i c a l l y , i t s e t s p a g i n g a t t h e end o f t h e u r i , w i t h o u t h a v i n g t o p a s s a u r i ∗ segment . The l i b r a r y r e l i e s on a u n i q u e p a g i n a t i o n s e l e c t o r , which i t u s e s t o ∗ d e t e r m i n e i f and where t h e p a g n i t i o n o f f s e t i s l o c a t e d i n t h e URI . ∗ ∗ E . g . / example / p a g i n a t i o n / Page /3 ∗ ∗ The l i b s e a r c h e s f o r t h e p a g i n a t i o n s e l e c t o r ( ’ Page ’ , i n t h e above example ) ∗ and r e t r a c t s t h e p r o p e r o f f s e t v a l u e ( i n t h i s c a s e 3 ) ∗ ∗ The p a g i n a t i o n l i n k s a r e a u t o m a t i c a l l y c r e a t e d , j u s t a s i n CI ’ s d e f a u l t ∗ pagination l i b . ∗ ∗ Requirements ∗ C o d e i g n i t e r 2+ ∗ PHP 5 ∗ A ∗ u n i q u e ∗ p a g i n a t i o n s e l e c t o r ( d e f a u l t i s ’ Page ’ ) − u n i q u e meaning a s t r i n g ∗ you a r e s u r e w i l l n e v e r a p p e a r i n t h e u r i , e x c e p t f o r p a g i n a t i o n . ∗ ∗ I f t h e r e we u s e p a g i n a t i o n , i t must ALWAYS f o l l o w t h e f o l l o w i n g s y n t a x and be ∗ l o c a t e d a t t h e END o f t h e URI : ∗ PAGINATION SELECTOR/ o f f s e t ∗ ∗ The PAGINATION SELECTOR i s a s p e c i a l s t r i n g which we know w i l l ONLY be i n t h e ∗ URI when p a g i n g i s s e t . Let ’ s s a y t h e PAGINATION SELECTOR i s ’ Page ’ ( s i n c e most ∗ c o d e r s n e v e r u s e any c a p i t a l s i n t h e URI , most o f t h e t i m e s any s t r i n g w i t h ∗ a s i n g l e capital character in i t w i l l s u f f i c e ) . ∗ ∗ Example u s e ( i n c o n t r o l l e r ) : ∗ // I n i t i a l i z e p a g i n a t i o n ∗ $ c o n f i g [ ’ t o t a l r o w s ’ ] = $ t h i s −>db−>c o u n t a l l r e s u l t s ( ’ m y t a b l e ’ ) ; ∗ $ c o n f i g [ ’ p e r p a g e ’ ] = 1 0 ; // You ’ d b e s t s e t t h i s i n a c o n f i g f i l e , but hey ∗ $ t h i s −>p a g i n a t i o n −> i n i t i a l i z e ( $ c o n f i g ) ; ∗ $ t h i s −>d a t a [ ’ p a g i n a t i o n ’ ] = $ t h i s −>p a g i n a t i o n −>c r e a t e l i n k s ( ) ; ∗ ∗ // R e t r i e v e p a g i n a t e d r e s u l t s , u s i n g t h e d y n a m i c a l l y d e t e r m i n e d o f f s e t ∗ $ t h i s −>db−>l i m i t ( $ c o n f i g [ ’ p e r p a g e ’ ] , $ t h i s −>p a g i n a t i o n −> o f f s e t ) ; ∗ $ q u e r y = $ t h i s −>db−>g e t ( ’ m y t a b l e ’ ) ; ∗ ∗/ c l a s s MY Pagination e x t e n d s C I P a g i n a t i o n { var $ o f f s e t = 0 ; v a r $ p a g i n a t i o n s e l e c t o r = ’ Page ’ ; var $index page ; f u n c t i o n MY Pagination ( ) { parent : : construct () ; l o g m e s s a g e ( ’ debug ’ , ” MY Pagination C l a s s I n i t i a l i z e d ” ) ; $ t h i s −>i n d e x p a g e = c o n f i g i t e m ( ’ i n d e x p a g e ’ ) : ’ ’; $ t h i s −> s e t p a g i n a t i o n o f f s e t ( ) ; } /∗∗ ∗ S e t dynamic p a g i n a t i o n v a r i a b l e s ∗ ∗/ function set pagination offset () { // I n s t a n t i a t e t h e CI s u p e r $CI = & g e t i n s t a n c e ( ) ; != ’ ’ ? c o n f i g i t e m ( ’ index page ’ ) . ’/ ’ i n $CI−>d a t a [ ’ p a g v a r s ’ ] object s o we have a c c e s s to the uri class // S t o r e p a g i n a t i o n o f f s e t i f i t i s s e t i f ( s t r s t r ( $CI−>u r i −>u r i s t r i n g ( ) , $ t h i s −>p a g i n a t i o n s e l e c t o r ) ) { // Get t h e segment o f f s e t f o r t h e p a g i n a t i o n $ s e g m e n t s = $CI−>u r i −>s e g m e n t a r r a y ( ) ; selector // Loop t h r o u g h s e g m e n t s t o r e t r i e v e p a g i n a t i o n f o r e a c h ( $ s e g m e n t s a s $key => $ v a l u e ) { offset // Find t h e p a g i n a t i o n s e l e c t o r and work from t h e r e i f ( $ v a l u e == $ t h i s −>p a g i n a t i o n s e l e c t o r ) { // S t o r e p a g i n a t i o n o f f s e t $ t h i s −> o f f s e t = $CI−>u r i −>segment ( $key + 1 ) ; // S t o r e p a g i n a t i o n segment $ t h i s −>u r i s e g m e n t = $key + 1 ; // S e t b a s e u r l f o r p a g i n g . T h i s o n l y works i f t h e // p a g i n a t i o n s e l e c t o r and p a g i n g o f f s e t a r e AT THE END o f // t h e URI ! $ u r i = $CI−>u r i −>u r i s t r i n g ( ) ; $ p o s = s t r p o s ( $ u r i , $ t h i s −>p a g i n a t i o n s e l e c t o r ) ; $ t h i s −>b a s e u r l = c o n f i g i t e m ( ’ b a s e u r l ’ ) . $ t h i s −>i n d e x p a g e $ u r i , 0 , $ p o s + s t r l e n ( $ t h i s −>p a g i n a t i o n s e l e c t o r ) ) ; } } } e l s e { // P a g i n a t i o n s e l e c t o r was n o t f o u n d i n URI s t r i n g . So 245 offset is 0 . substr ( $ t h i s −>o f f s e t = 0 ; $ t h i s −>u r i s e g m e n t = 0 ; $ t h i s −>b a s e u r l = c o n f i g i t e m ( ’ b a s e u r l ’ ) . $ t h i s −>i n d e x p a g e u r i s t r i n g ( ) . ’ / ’ . $ t h i s −>p a g i n a t i o n s e l e c t o r ; . $CI−>u r i −> } } } <?php /∗∗ ∗ tmhOAuth ∗ ∗ An OAuth l i b r a r y w r i t t e n i n PHP . ∗ The l i b r a r y s u p p o r t s f i l e u p l o a d i n g u s i n g m u l t i p a r t / form a s w e l l a s g e n e r a l ∗ REST r e q u e s t s . OAuth a u t h e n t i c a t i o n i s s e n t u s i n g an A u t h o r i z a t i o n Header . ∗ ∗ @author t h e m a t t h a r r i s ∗ @version 0 . 8 . 4 ∗ ∗ 06 Aug 2014 ∗/ ’ ) or d e f i n e ( ’ DIR ’ , dirname ( F I L E ) ) ; defined ( ’ DIR c l a s s tmhOAuth { c o n s t VERSION = ’ 0 . 8 . 4 ’ ; var $response = array ( ) ; /∗∗ ∗ C r e a t e s a new tmhOAuth o b j e c t ∗ ∗ @param s t r i n g $ c o n f i g , t h e c o n f i g u r a t i o n t o u s e ∗ @return void ∗/ c o n s t r u c t ( $ c o n f i g=a r r a y ( ) ) { public function $ t h i s −>b u f f e r = n u l l ; $ t h i s −>r e c o n f i g u r e ( $ c o n f i g ) ; $ t h i s −>r e s e t r e q u e s t s e t t i n g s ( ) ; $ t h i s −>s e t u s e r a g e n t ( ) ; } for this p u b l i c f u n c t i o n r e c o n f i g u r e ( $ c o n f i g=a r r a y ( ) ) { // d e f a u l t c o n f i g u r a t i o n o p t i o n s $ t h i s −>c o n f i g = a r r a y m e r g e ( array ( // l e a v e ’ u s e r a g e n t ’ b l a n k f o r d e f a u l t , o t h e r w i s e // s o m e t h i n g t h a t c l e a r l y i d e n t i f i e s y o u r app ’ user agent ’ => ’ ’ , ’ host ’ => ’ a p i . t w i t t e r . com ’ , ’ method ’ => ’GET’ , ’ consumer key ’ ’ consumer secret ’ ’ token ’ ’ secret ’ // OAuth2 b e a r e r ’ bearer ’ => => => => token . ’ ’ ’ ’ ’ ’ ’ ’ set this to , , , , This should => ’ ’ , // o a u t h s i g n i n g v a r i a b l e s ’ oauth version ’ ’ oauth signature method ’ request a l r e a d y be URL e n c o d e d t h a t a r e n o t dynamic => ’ 1 . 0 ’ , => ’HMAC−SHA1 ’ , // you p r o b a b l y don ’ t want t o c h a n g e any o f t h e s e c u r l ’ curl http version ’ => CURL HTTP VERSION 1 1 , ’ curl connecttimeout ’ => 3 0 , ’ curl timeout ’ => 1 0 , // f o r s e c u r i t y t h i s s h o u l d a l w a y s be s e t ’ curl ssl verifyhost ’ => 2 , // f o r s e c u r i t y t h i s s h o u l d a l w a y s be s e t ’ curl ssl verifypeer ’ => t r u e , // f o r s e c u r i t y t h i s s h o u l d a l w a y s be s e t ’ use ssl ’ => t r u e , to values 2. to true . to true . // you can g e t t h e l a t e s t c a c e r t . pem from h e r e h t t p : / / c u r l . haxx . s e / c a / c a c e r t . pem // i f you ’ r e g e t t i n g HTTP 0 r e s p o n s e s , c h e c k c a c e r t . pem e x i s t s and i s r e a d a b l e // w i t h o u t i t c u r l won ’ t be a b l e t o c r e a t e an SSL c o n n e c t i o n ’ curl cainfo ’ => DIR . DIRECTORY SEPARATOR . ’ c a c e r t . pem ’ , ’ curl capath ’ => DIR , // i n some c a s e s ( v e r y v e r y odd o n e s ) t h e SSL v e r s i o n must be s e t m a n u a l l y . // u n l e s s you know why y o u r a r e c h a n g i n g t h i s , you s h o u l d l e a v e i t a s f a l s e // t o a l l o w PHP t o d e t e r m i n e t h e v a l u e f o r t h i s s e t t i n g i t s e l f . ’ curl sslversion ’ => f a l s e , ’ curl followlocation ’ => f a l s e , // s u p p o r t f o r p r o x y s e r v e r s ’ curl proxy ’ => f a l s e , using streaming ’ curl proxyuserpwd ’ => f a l s e , required ’ curl encoding ’ => ’ ’ , use gzip , d e f l a t e , i d e n t i t y etc // w h e t h e r t o // really follow redirects you don ’ t want t o u s e // f o r m a t username : p a s s w o r d // l e a v e // s t r e a m i n g API c o n f i g u r a t i o n 246 blank for all for or not this if proxy , you a r e if supported formats , else ’ is streaming ’ => f a l s e , ’ streaming eol ’ => ”\ r \n ” , ’ s t r e a m i n g m e t r i c s i n t e r v a l ’ => 1 0 , // h e a d e r o r q u e r y s t r i n g . You s h o u l d a l w a y s u s e h e a d e r ! // t h i s i s j u s t t o h e l p me debug o t h e r d e v e l o p e r s i m p l e m e n t a t i o n s => t r u e , ’ as header ’ => f a l s e , // u s e d f o r c h e c k i n g s i g n a t u r e s . ’ force nonce ’ f o r auto => f a l s e , // u s e d f o r c h e c k i n g s i g n a t u r e s . ’ force timestamp ’ f o r auto leave as false leave as false ), $config ); } p r i v a t e f u n c t i o n r e s e t r e q u e s t s e t t i n g s ( $ o p t i o n s=a r r a y ( ) ) { $ t h i s −>r e q u e s t s e t t i n g s = a r r a y ( ’ params ’ => a r r a y ( ) , ’ headers ’ => a r r a y ( ) , ’ w i t h u s e r ’ => t r u e , ’ m u l t i p a r t ’ => f a l s e , ); if ( ! empty ( $ o p t i o n s ) ) $ t h i s −>r e q u e s t s e t t i n g s = a r r a y m e r g e ( $ t h i s −>r e q u e s t s e t t i n g s , $options ) ; } /∗∗ ∗ S e t s t h e u s e r a g e n t f o r PHP t o u s e ∗ I f ’ $ t h i s −>c o n f i g [ ’ u s e r a g e n t ’ ] ’ a l r e a d y h a s a v a l u e i t i s u s e d ∗ being generated . ∗ ∗ @return void v al u e i s s t o r e d to the c o n f i g a r ra y c l a s s v a r i a b l e ∗/ private function set user agent () { i f ( ! empty ( $ t h i s −>c o n f i g [ ’ u s e r a g e n t ’ ] ) ) return ; instead o f one $ s s l = ( $ t h i s −>c o n f i g [ ’ c u r l s s l v e r i f y h o s t ’ ] && $ t h i s −>c o n f i g [ ’ c u r l s s l v e r i f y p e e r ’ ] && $ t h i s −>c o n f i g [ ’ u s e s s l ’ ] ) ? ’+ ’ : ’ − ’ ; $ua = ’ tmhOAuth ’ . s e l f : : VERSION . $ s s l . ’ SSL − // g i t h u b . com/ t h e m a t t h a r r i s /tmhOAuth ’ ; $ t h i s −>c o n f i g [ ’ u s e r a g e n t ’ ] = $ua ; } /∗∗ ∗ G e n e r a t e s a random OAuth n o n c e . ∗ I f ’ f o r c e n o n c e ’ i s f a l s e a n o n c e w i l l be g e n e r a t e d , o t h e r w i s e t h e v a l u e o f ’ $ t h i s −> c o n f i g [ ’ f o r c e n o n c e ’ ] ’ w i l l be u s e d . ∗ ∗ @param s t r i n g $ l e n g t h how many c h a r a c t e r s t h e n o n c e s h o u l d be b e f o r e MD5 h a s h i n g . d e f a u l t 12 ∗ @param s t r i n g $ i n c l u d e t i m e w h e t h e r t o i n c l u d e t i m e a t t h e b e g i n n i n g o f t h e n o n c e . default true ∗ @return $nonce as a s t r i n g ∗/ p r i v a t e f u n c t i o n n o n c e ( $ l e n g t h =12 , $ i n c l u d e t i m e=t r u e ) { i f ( $ t h i s −>c o n f i g [ ’ f o r c e n o n c e ’ ] === f a l s e ) { $ p r e f i x = $ i n c l u d e t i m e ? microtime ( ) : ’ ’ ; r e t u r n md5 ( s u b s t r ( $ p r e f i x . u n i q i d ( ) , 0 , $ l e n g t h ) ) ; } else { r e t u r n $ t h i s −>c o n f i g [ ’ f o r c e n o n c e ’ ] ; } } /∗∗ ∗ G e n e r a t e s a timestamp . ∗ I f ’ f o r c e t i m e s t a m p ’ i s f a l s e a timestamp w i l l be g e n e r a t e d , $ t h i s −>c o n f i g [ ’ f o r c e t i m e s t a m p ’ ] ’ w i l l be u s e d . ∗ ∗ @return $time as a s t r i n g ∗/ p r i v a t e f u n c t i o n timestamp ( ) { i f ( $ t h i s −>c o n f i g [ ’ f o r c e t i m e s t a m p ’ ] === f a l s e ) { $time = time ( ) ; } else { $ t i m e = $ t h i s −>c o n f i g [ ’ f o r c e t i m e s t a m p ’ ] ; } r e t u r n ( s t r i n g ) $time ; } otherwise /∗∗ ∗ Encodes t h e s t r i n g o r a r r a y p a s s e d i n a way c o m p a t i b l e w i t h OAuth . ∗ I f an a r r a y i s p a s s e d e a c h a r r a y v a l u e w i l l w i l l be e n c o d e d . ∗ ∗ @param mixed $ d a t a t h e s c a l a r o r a r r a y t o e n c o d e ∗ @ r e t u r n $ d a t a e n c o d e d i n a way c o m p a t i b l e w i t h OAuth ∗/ p r i v a t e f u n c t i o n s a f e e n c o d e ( $data ) { i f ( i s a r r a y ( $data ) ) { r e t u r n array map ( a r r a y ( $ t h i s , ’ s a f e e n c o d e ’ ) , $data ) ; } e l s e i f ( i s s c a l a r ( $data ) ) { return s t r i r e p l a c e ( a r r a y ( ’ + ’ , ’%7E ’ ) , array ( ’ ’ , ’˜ ’) , rawurlencode ( $data ) ); } else { return ’ ’; 247 the value of ’ } } /∗∗ ∗ D eco de s t h e s t r i n g o r a r r a y from i t ’ s URL e n c o d e d form ∗ I f an a r r a y i s p a s s e d e a c h a r r a y v a l u e w i l l w i l l be d e c o d e d . ∗ ∗ @param mixed $ d a t a t h e s c a l a r o r a r r a y t o d e c o d e ∗ @ r e t u r n s t r i n g $ d a t a d e c o d e d from t h e URL e n c o d e d form ∗/ p r i v a t e f u n c t i o n s a f e d e c o d e ( $data ) { i f ( i s a r r a y ( $data ) ) { r e t u r n array map ( a r r a y ( $ t h i s , ’ s a f e d e c o d e ’ ) , $data ) ; } e l s e i f ( i s s c a l a r ( $data ) ) { r e t u r n rawurldecode ( $data ) ; } else { return ’ ’; } } /∗∗ ∗ P r e p a r e s OAuth1 s i g n i n g p a r a m e t e r s . ∗ ∗ @ r e t u r n v o i d a l l r e q u i r e d OAuth p a r a m e t e r s , s a f e l y encoded , a r e s t o r e d v a r i a b l e ’ $ t h i s −>r e q u e s t s e t t i n g s [ ’ o a u t h 1 p a r a m s ’ ] ’ ∗/ private function prepare oauth1 params () { $defaults = array ( ’ oauth nonce ’ => $ t h i s −>n o n c e ( ) , => $ t h i s −>timestamp ( ) , ’ oauth timestamp ’ ’ oauth version ’ => $ t h i s −>c o n f i g [ ’ o a u t h v e r s i o n ’ ] , ’ oauth consumer key ’ => $ t h i s −>c o n f i g [ ’ c o n s u m e r k e y ’ ] , ’ o a u t h s i g n a t u r e m e t h o d ’ => $ t h i s −>c o n f i g [ ’ o a u t h s i g n a t u r e m e t h o d ’ ] , ); to the class // i n c l u d e t h e u s e r t o k e n i f i t e x i s t s i f ( $ o a u t h t o k e n = $ t h i s −>t o k e n ( ) ) $ d e f a u l t s [ ’ oauth token ’ ] = $oauth token ; $ t h i s −>r e q u e s t s e t t i n g s [ ’ o a u t h 1 p a r a m s ’ ] = a r r a y ( ) ; // s a f e l y e n c o d e f o r e a c h ( $ d e f a u l t s a s $k => $v ) { $ t h i s −>r e q u e s t s e t t i n g s [ ’ o a u t h 1 p a r a m s ’ ] [ $ t h i s −>s a f e e n c o d e ( $k ) ] = $ t h i s −>s a f e e n c o d e ( $v ); } } p r i v a t e f u n c t i o n token ( ) { i f ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ w i t h u s e r ’ ] ) { i f ( i s s e t ( $ t h i s −>c o n f i g [ ’ t o k e n ’ ] ) && ! empty ( $ t h i s −>c o n f i g [ ’ t o k e n ’ ] ) ) r e t u r n $ t h i s −> c o n f i g [ ’ token ’ ] ; e l s e i f ( i s s e t ( $ t h i s −>c o n f i g [ ’ u s e r t o k e n ’ ] ) ) r e t u r n $ t h i s −>c o n f i g [ ’ u s e r t o k e n ’ ] ; } return ’ ’; } private function secret () { i f ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ w i t h u s e r ’ ] ) { i f ( i s s e t ( $ t h i s −>c o n f i g [ ’ s e c r e t ’ ] ) && ! empty ( $ t h i s −>c o n f i g [ ’ s e c r e t ’ ] ) ) r e t u r n $ t h i s −> config [ ’ secret ’ ] ; e l s e i f ( i s s e t ( $ t h i s −>c o n f i g [ ’ u s e r s e c r e t ’ ] ) ) r e t u r n $ t h i s −>c o n f i g [ ’ u s e r s e c r e t ’ ] ; } return ’ ’; } /∗∗ ∗ E x t r a c t s and d e c o d e s OAuth p a r a m e t e r s from t h e p a s s e d s t r i n g ∗ ∗ @param s t r i n g $body t h e r e s p o n s e body from an OAuth f l o w method ∗ @ r e t u r n a r r a y t h e r e s p o n s e body s a f e l y d e c o d e d t o an a r r a y o f key => v a l u e s ∗/ p u b l i c f u n c t i o n e x t r a c t p a r a m s ( $body ) { $ k v s = e x p l o d e ( ’ & ’ , $body ) ; $decoded = array ( ) ; f o r e a c h ( $ k v s a s $kv ) { $kv = e x p l o d e ( ’ = ’ , $kv , 2 ) ; $kv [ 0 ] = $ t h i s −>s a f e d e c o d e ( $kv [ 0 ] ) ; $kv [ 1 ] = $ t h i s −>s a f e d e c o d e ( $kv [ 1 ] ) ; $ d e c o d e d [ $kv [ 0 ] ] = $kv [ 1 ] ; } r e t u r n $decoded ; } /∗∗ ∗ P r e p a r e s t h e HTTP method f o r u s e i n t h e b a s e s t r i n g by c o n v e r t i n g i t t o ∗ uppercase . ∗ ∗ @ r e t u r n v o i d v a l u e i s s t o r e d t o t h e c l a s s v a r i a b l e ’ $ t h i s −>r e q u e s t s e t t i n g s [ ’ method ’ ] ’ ∗/ p r i v a t e f u n c t i o n prepare method ( ) { $ t h i s −>r e q u e s t s e t t i n g s [ ’ method ’ ] = s t r t o u p p e r ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ method ’ ] ) ; } /∗∗ ∗ P r e p a r e s t h e URL f o r ∗ reconstructing it . ∗ ∗ Ref : 3 . 4 . 1 . 2 use in the base s t r i n g by r i p p i n g 248 it a p a r t and ∗ ∗ @return void v al u e i s s t o r e d to the c l a s s a r ra y v a r i a b l e ∗/ private function prepare url () { $ p a r t s = p a r s e u r l ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ u r l ’ ] ) ; $port $scheme $host $path = = = = i s s e t ( $ p a r t s [ ’ port ’ ] ) $ p a r t s [ ’ scheme ’ ] ; $ p a r t s [ ’ host ’ ] ; i s s e t ( $ p a r t s [ ’ path ’ ] ) ? $ p a r t s [ ’ port ’ ] : false ; ? $ p a r t s [ ’ path ’ ] : false ; $ p o r t o r $ p o r t = ( $scheme == ’ h t t p s ’ ) if ( ( $scheme == ’ h t t p s ’ && $ p o r t != $host = ” $host : $port ”; ? ’443 ’ ’443 ’) || : ’ $ t h i s −>r e q u e s t s e t t i n g s [ ’ u r l ’ ] ’ ’80 ’; ( $scheme == ’ h t t p ’ && $ p o r t != ’80 ’) ) { } // t h e scheme and h o s t MUST be l o w e r c a s e $ t h i s −>r e q u e s t s e t t i n g s [ ’ u r l ’ ] = s t r t o l o w e r ( ” $scheme : / / $ h o s t ” ) ; // but n o t t h e path $ t h i s −>r e q u e s t s e t t i n g s [ ’ u r l ’ ] .= $ p a t h ; } /∗∗ ∗ I f t h e r e q u e s t u s e s m u l t i p a r t , and t h e p a r a m e t e r i s n ’ t a f i l e path , p r e p e n d a s p a c e ∗ o t h e r w i s e r e t u r n t h e o r i g i n a l v a l u e . we c h o s e a s p a c e h e r e a s t w i t t e r w h i t e s p a c e t r i m s from ∗ t h e b e g i n n i n g o f t h e t w e e t . we don ’ t u s e \0 h e r e b e c a u s e i t ’ s t h e c h a r a c t e r f o r s t r i n g ∗ termination . ∗ ∗ @param t h e p a r a m e t e r v a l u e ∗ @ r e t u r n s t r i n g t h e o r i g i n a l o r m o d i f i e d s t r i n g , d e p e n d i n g on t h e r e q u e s t and t h e i n p u t parameter ∗/ private function multipart escape ( $value ) { i f ( ! $ t h i s −>r e q u e s t s e t t i n g s [ ’ m u l t i p a r t ’ ] | | s t r p o s ( $ v a l u e , ’@’ ) !== 0 ) return $value ; // s e e i f t h e p a r a m e t e r i s a f i l e . // we s p l i t on t h e semi−c o l o n a s i t ’ s t h e d e l i m i t e r u s e d on media u p l o a d s // f o r f i e l d s w i t h semi−c o l o n s t h i s w i l l r e t u r n t h e o r i g i n a l s t r i n g l i s t ( $ f i l e ) = explode ( ’ ; ’ , s u b s t r ( $value , 1) , 2) ; if ( file exists ( $file )) return $value ; return ” $value ”; } /∗∗ ∗ P r e p a r e s a l l p a r a m e t e r s f o r t h e b a s e s t r i n g and r e q u e s t . ∗ Multipart parameters a re i g n o r e d as they a re not d e f i n e d i n the s p e c i f i c a t i o n , ∗ a l l o t h e r t y p e s o f p a r a m e t e r a r e e n c o d e d f o r c o m p a t i b i l i t y w i t h OAuth . ∗ ∗ @param a r r a y $params t h e p a r a m e t e r s f o r t h e r e q u e s t ∗ @ r e t u r n v o i d p r e p a r e d v a l u e s a r e s t o r e d i n t h e c l a s s a r r a y v a r i a b l e ’ $ t h i s −> request settings ’ ∗/ p ri v a te function prepare params ( ) { $doing oauth1 = f a l s e ; $ t h i s −>r e q u e s t s e t t i n g s [ ’ p r e p a r e d p a r a m s ’ ] = a r r a y ( ) ; $ p r e p a r e d = &$ t h i s −>r e q u e s t s e t t i n g s [ ’ p r e p a r e d p a r a m s ’ ] ; $prepared pairs = array () ; $prepared pairs with oauth = array () ; if ( i s s e t ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ o a u t h 1 p a r a m s ’ ] ) ) { $ o a u t h 1 = &$ t h i s −>r e q u e s t s e t t i n g s [ ’ o a u t h 1 p a r a m s ’ ] ; $doing oauth1 = true ; $params = a r r a y m e r g e ( $oauth1 , $ t h i s −>r e q u e s t s e t t i n g s [ ’ params ’ ] ) ; // Remove o a u t h s i g n a t u r e i f p r e s e n t // Ref : Spec : 9 . 1 . 1 ( ” The o a u t h s i g n a t u r e u n s e t ( $params [ ’ o a u t h s i g n a t u r e ’ ] ) ; p a r a m e t e r MUST be e x c l u d e d . ” ) // empty t h e o a u t h 1 a r r a y . we r e s e t t h e s e v a l u e s $oauth1 = a rr a y ( ) ; } else { $params = $ t h i s −>r e q u e s t s e t t i n g s [ ’ params ’ ] ; } // P a r a m e t e r s a r e s o r t e d by name , // Ref : Spec : 9 . 1 . 1 ( 1 ) u k s o r t ( $params , ’ strcmp ’ ) ; using later lexicographical in t h i s method byte value ordering . // s e t t h i s now s o we ’ r e n o t d o i n g i t on e v e r y p a r a m e t e r $ s u p p o r t s c u r l f i l e = c l a s s e x i s t s ( ’ CurlFile ’ , f a l s e ) ; // e n c o d e params u n l e s s we ’ r e d o i n g m u l t i p a r t f o r e a c h ( $params a s $k => $v ) { $k = $ t h i s −>r e q u e s t s e t t i n g s [ ’ m u l t i p a r t ’ ] ? $k : if $ t h i s −>s a f e e n c o d e ( $k ) ; ( i s a r r a y ( $v ) ) $v = i m p l o d e ( ’ , ’ , $v ) ; // we don ’ t need t o do t h e m u l t i p a r t e s c a p i n g i f we s u p p o r t i f ( $ s u p p o r t s c u r l f i l e && ( $v i n s t a n c e o f C u r l F i l e ) ) { // l e a v e $v a l o n e } e l s e i f ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ m u l t i p a r t ’ ] ) { $v = $ t h i s −>m u l t i p a r t e s c a p e ( $v ) ; 249 curlfile } else { $v = $ t h i s −>s a f e e n c o d e ( $v ) ; } // s p l i t p a r a m e t e r s f o r t h e b a s e s t r i n g and a u t h o r i z a t i o n h e a d e r , and r e c r e a t e t h e o a u t h 1 array i f ( $doing oauth1 ) { // i f we ’ r e d o i n g m u l t i p a r t , o n l y s t o r e t h e o a u t h ∗ params , i g n o r e t h e u s e r s r e q u e s t params i f ( ( s t r p o s ( $k , ’ oauth ’ ) === 0 ) | | ! $ t h i s −>r e q u e s t s e t t i n g s [ ’ m u l t i p a r t ’ ] ) $ p r e p a r e d p a i r s w i t h o a u t h [ ] = ”{ $k}={$v } ” ; if ( s t r p o s ( $k , ’ oauth ’ ) === 0 ) { $ o a u t h 1 [ $k ] = $v ; continue ; } } $ p r e p a r e d [ $k ] = $v ; if ( ! $ t h i s −>r e q u e s t s e t t i n g s [ ’ m u l t i p a r t ’ ] ) $ p r e p a r e d p a i r s [ ] = ”{ $k}={$v } ” ; } if ( $doing oauth1 ) { $ t h i s −>r e q u e s t s e t t i n g s [ ’ b a s e s t r i n g p a r a m s ’ ] = i m p l o d e ( ’ & ’ , $prepared pairs with oauth ) ; } // s e t u p params f o r GET/POST/PUT method h a n d l i n g i f ( ! empty ( $ p r e p a r e d ) ) { $content = implode ( ’& ’ , $ p r e p a r e d p a i r s ) ; s w i t c h ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ method ’ ] ) { c a s e ’PUT’ : // f a l l t h r o u g h t o POST a s PUT s h o u l d be t r e a t e d t h e same c a s e ’POST ’ : $ t h i s −>r e q u e s t s e t t i n g s [ ’ p o s t f i e l d s ’ ] = $ t h i s −>r e q u e s t s e t t i n g s [ ’ m u l t i p a r t ’ ] $prepared : $content ; break ; default : $ t h i s −>r e q u e s t s e t t i n g s [ ’ q u e r y s t r i n g ’ ] = $ c o n t e n t ; break ; } ? } } /∗∗ ∗ P r e p a r e s t h e OAuth s i g n i n g key ∗ ∗ @ r e t u r n v o i d p r e p a r e d s i g n i n g key i s s t o r e d i n t h e c l a s s v a r i a b l e ∗/ private function prepare signing key () { $ l e f t = $ t h i s −>s a f e e n c o d e ( $ t h i s −>c o n f i g [ ’ c o n s u m e r s e c r e t ’ ] ) ; $ r i g h t = $ t h i s −>s a f e e n c o d e ( $ t h i s −>s e c r e t ( ) ) ; $ t h i s −>r e q u e s t s e t t i n g s [ ’ s i g n i n g k e y ’ ] = $ l e f t . ’& ’ . $ r i g h t ; } /∗∗ ∗ Prepare the base s t r i n g . ∗ Ref : Spec : 9 . 1 . 3 ( ” C o n c a t e n a t e R e q u e s t E l e m e n t s ” ) ∗ ∗ @return void prepared base s t r i n g i s s t o r e d i n the ∗/ private function prepare base string () { $ u r l = $ t h i s −>r e q u e s t s e t t i n g s [ ’ u r l ’ ] ; class variable ’ signing key ’ ’ base string ’ # i f t h e h o s t h e a d e r i s s e t we need t o r e w r i t e t h e b a s e s t r i n g t o u s e # t h a t , i n s t e a d o f t h e r e q u e s t h o s t . o t h e r w i s e t h e s i g n a t u r e won ’ t match # on t h e s e r v e r s i d e i f ( ! empty ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ h e a d e r s ’ ] [ ’ Host ’ ] ) ) { $url = s t r i r e p l a c e ( $ t h i s −>c o n f i g [ ’ h o s t ’ ] , $ t h i s −>r e q u e s t s e t t i n g s [ ’ h e a d e r s ’ ] [ ’ Host ’ ] , $url ); } $base = array ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ method ’ ] , $url , $ t h i s −>r e q u e s t s e t t i n g s [ ’ b a s e s t r i n g p a r a m s ’ ] ); $ t h i s −>r e q u e s t s e t t i n g s [ ’ b a s e s t r i n g ’ ] = i m p l o d e ( ’ & ’ , $ t h i s −>s a f e e n c o d e ( $ b a s e ) ) ; } /∗∗ ∗ S i g n s t h e OAuth 1 r e q u e s t ∗ ∗ @ r e t u r n v o i d o a u t h s i g n a t u r e i s added t o t h e p a r a m e t e r s i n t h e c l a s s a r r a y v a r i a b l e ’ $ t h i s −>r e q u e s t s e t t i n g s ’ ∗/ private function prepare oauth signature () { $ t h i s −>r e q u e s t s e t t i n g s [ ’ o a u t h 1 p a r a m s ’ ] [ ’ o a u t h s i g n a t u r e ’ ] = $ t h i s −>s a f e e n c o d e ( base64 encode ( hash hmac ( ’ sha1 ’ , $ t h i s −>r e q u e s t s e t t i n g s [ ’ b a s e s t r i n g ’ ] , $ t h i s −>r e q u e s t s e t t i n g s [ ’ s i g n i n g k e y ’ ] , true ))); } 250 /∗∗ ∗ Prepares the Authorization header ∗ ∗ @return void prepared a u t h o r i z a t i o n header Authorization ’ ] ∗/ private function prepare auth header () { i f ( ! $ t h i s −>c o n f i g [ ’ a s h e a d e r ’ ] ) return ; is stored in the class variable headers [ ’ // o a u t h 1 i f ( i s s e t ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ o a u t h 1 p a r a m s ’ ] ) ) { // s o r t a g a i n a s o a u t h s i g n a t u r e was added p o s t param p r e p a r a t i o n u k s o r t ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ o a u t h 1 p a r a m s ’ ] , ’ strcmp ’ ) ; $encoded quoted pairs = array () ; f o r e a c h ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ o a u t h 1 p a r a m s ’ ] a s $k => $v ) { $ e n c o d e d q u o t e d p a i r s [ ] = ”{ $k }=\”{ $v } \ ” ” ; } $ h e a d e r = ’ OAuth ’ . i m p l o d e ( ’ , ’ , $ e n c o d e d q u o t e d p a i r s ) ; } e l s e i f ( ! empty ( $ t h i s −>c o n f i g [ ’ b e a r e r ’ ] ) ) { $ h e a d e r = ’ B e a r e r ’ . $ t h i s −>c o n f i g [ ’ b e a r e r ’ ] ; } if ( i s s e t ( $header ) ) $ t h i s −>r e q u e s t s e t t i n g s [ ’ h e a d e r s ’ ] [ ’ A u t h o r i z a t i o n ’ ] = $ h e a d e r ; } /∗∗ ∗ C r e a t e t h e b e a r e r t o k e n f o r OAuth2 r e q u e s t s from t h e c o n s u m e r k e y and c o n s u m e r s e c r e t . ∗ ∗ @return s t r i n g the b e a r e r token ∗/ public function bearer token credentials () { $ c r e d e n t i a l s = implode ( ’ : ’ , array ( $ t h i s −>s a f e e n c o d e ( $ t h i s −>c o n f i g [ ’ c o n s u m e r k e y ’ ] ) , $ t h i s −>s a f e e n c o d e ( $ t h i s −>c o n f i g [ ’ c o n s u m e r s e c r e t ’ ] ) )); return base64 encode ( $ c r e d e n t i a l s ) ; } /∗∗ ∗ Make an HTTP r e q u e s t u s i n g t h i s l i b r a r y . T h i s method doesn ’ t r e t u r n a n y t h i n g . ∗ I n s t e a d t h e r e s p o n s e s h o u l d be i n s p e c t e d d i r e c t l y . ∗ ∗ @param s t r i n g $method t h e HTTP method b e i n g u s e d . e . g . POST, GET, HEAD e t c ∗ @param s t r i n g $ u r l t h e r e q u e s t URL w i t h o u t q u e r y s t r i n g p a r a m e t e r s ∗ @param a r r a y $params t h e r e q u e s t p a r a m e t e r s a s an a r r a y o f key=v a l u e p a i r s . D e f a u l t empty array ∗ @param s t r i n g $ u s e a u t h w h e t h e r t o u s e a u t h e n t i c a t i o n when making t h e r e q u e s t . D e f a u l t true ∗ @param s t r i n g $ m u l t i p a r t w h e t h e r t h i s r e q u e s t c o n t a i n s m u l t i p a r t d a t a . D e f a u l t f a l s e ∗ @param a r r a y $ h e a d e r s any custom h e a d e r s t o s e n d w i t h t h e r e q u e s t . D e f a u l t empty a r r a y ∗ @return i n t the http r e s p o n s e code f o r the r e q u e s t . 0 i s r e t u r n e d i f a c o n n e c t i o n could n o t be made ∗/ p u b l i c f u n c t i o n r e q u e s t ( $method , $ u r l , $params=a r r a y ( ) , $ u s e a u t h=t r u e , $ m u l t i p a r t=f a l s e , $ h e a d e r s=a r r a y ( ) ) { $options = array ( ’ method ’ => $method , ’ url ’ => $ u r l , ’ params ’ => $params , ’ w i t h u s e r ’ => t r u e , ’ m u l t i p a r t ’ => $ m u l t i p a r t , ’ headers ’ => $ h e a d e r s ); $ o p t i o n s = a r r a y m e r g e ( $ t h i s −>d e f a u l t o p t i o n s ( ) , $ o p t i o n s ) ; ( $useauth ) { r e t u r n $ t h i s −>u s e r r e q u e s t ( $ o p t i o n s ) ; } else { r e t u r n $ t h i s −>u n a u t h e n t i c a t e d r e q u e s t ( $ o p t i o n s ) ; } if } p u b l i c f u n c t i o n a p p o n l y r e q u e s t ( $ o p t i o n s=a r r a y ( ) ) { $ o p t i o n s = a r r a y m e r g e ( $ t h i s −>d e f a u l t o p t i o n s ( ) , $ o p t i o n s , ’ w i t h u s e r ’ => f a l s e , )); $ t h i s −>r e s e t r e q u e s t s e t t i n g s ( $ o p t i o n s ) ; i f ( $options [ ’ without bearer ’ ] ) { r e t u r n $ t h i s −>o a u t h 1 r e q u e s t ( ) ; } else { $ t h i s −>p r e p a r e m e t h o d ( ) ; $ t h i s −>p r e p a r e u r l ( ) ; $ t h i s −>p r e p a r e p a r a m s ( ) ; $ t h i s −>p r e p a r e a u t h h e a d e r ( ) ; r e t u r n $ t h i s −> c u r l i t ( ) ; } } p u b l i c f u n c t i o n u s e r r e q u e s t ( $ o p t i o n s=a r r a y ( ) ) { $ o p t i o n s = a r r a y m e r g e ( $ t h i s −>d e f a u l t o p t i o n s ( ) , $ o p t i o n s , ’ w i t h u s e r ’ => t r u e , )); $ t h i s −>r e s e t r e q u e s t s e t t i n g s ( $ o p t i o n s ) ; r e t u r n $ t h i s −>o a u t h 1 r e q u e s t ( ) ; } public function u n a u t h e n t i c a t e d r e q u e s t ( $ o p t i o n s=a r r a y ( ) ) { 251 array ( array ( $ o p t i o n s = a r r a y m e r g e ( $ t h i s −>d e f a u l t o p t i o n s ( ) , $ o p t i o n s , ’ w i t h u s e r ’ => f a l s e , )); $ t h i s −>r e s e t r e q u e s t s e t t i n g s ( $ o p t i o n s ) ; $ t h i s −>p r e p a r e m e t h o d ( ) ; $ t h i s −>p r e p a r e u r l ( ) ; $ t h i s −>p r e p a r e p a r a m s ( ) ; r e t u r n $ t h i s −> c u r l i t ( ) ; array ( } /∗∗ ∗ S i g n s t h e r e q u e s t and adds t h e OAuth s i g n a t u r e . T h i s r u n s a l l t h e r e q u e s t ∗ p a r a m e t e r p r e p a r a t i o n methods . ∗ ∗ @param s t r i n g $method t h e HTTP method b e i n g u s e d . e . g . POST, GET, HEAD e t c ∗ @param s t r i n g $ u r l t h e r e q u e s t URL w i t h o u t q u e r y s t r i n g p a r a m e t e r s ∗ @param a r r a y $params t h e r e q u e s t p a r a m e t e r s a s an a r r a y o f key=v a l u e p a i r s ∗ @param b o o l e a n $ w i t h u s e r w h e t h e r t o i n c l u d e t h e u s e r c r e d e n t i a l s when making t h e . ∗ @return void ∗/ private function oauth1 request () { $ t h i s −>p r e p a r e o a u t h 1 p a r a m s ( ) ; $ t h i s −>p r e p a r e m e t h o d ( ) ; $ t h i s −>p r e p a r e u r l ( ) ; $ t h i s −>p r e p a r e p a r a m s ( ) ; $ t h i s −>p r e p a r e b a s e s t r i n g ( ) ; $ t h i s −>p r e p a r e s i g n i n g k e y ( ) ; $ t h i s −>p r e p a r e o a u t h s i g n a t u r e ( ) ; $ t h i s −>p r e p a r e a u t h h e a d e r ( ) ; r e t u r n $ t h i s −> c u r l i t ( ) ; } request private function default options () { return array ( ’ method ’ => ’GET’ , ’ params ’ => a r r a y ( ) , ’ with user ’ => t r u e , ’ multipart ’ => f a l s e , ’ headers ’ => a r r a y ( ) , ’ w i t h o u t b e a r e r ’ => f a l s e , ); } /∗∗ ∗ Make a l o n g p o l l HTTP r e q u e s t u s i n g t h i s l i b r a r y . T h i s method i s ∗ d i f f e r e n t t o t h e o t h e r r e q u e s t methods a s i t i s n ’ t s u p p o s e d t o d i s c o n n e c t ∗ ∗ U s i n g t h i s method e x p e c t s a c a l l b a c k which w i l l r e c e i v e t h e s t r e a m i n g ∗ responses . ∗ ∗ @param s t r i n g $method t h e HTTP method b e i n g u s e d . e . g . POST, GET, HEAD e t c ∗ @param s t r i n g $ u r l t h e r e q u e s t URL w i t h o u t q u e r y s t r i n g p a r a m e t e r s ∗ @param a r r a y $params t h e r e q u e s t p a r a m e t e r s a s an a r r a y o f key=v a l u e p a i r s ∗ @param s t r i n g $ c a l l b a c k t h e c a l l b a c k f u n c t i o n t o s t r e a m t h e b u f f e r t o . ∗ @return void ∗/ p u b l i c f u n c t i o n s t r e a m i n g r e q u e s t ( $method , $ u r l , $params=a r r a y ( ) , $ c a l l b a c k = ’ ’ ) { i f ( ! empty ( $ c a l l b a c k ) ) { i f ( ! i s c a l l a b l e ( $callback ) ) { return f a l s e ; } $ t h i s −>c o n f i g [ ’ s t r e a m i n g c a l l b a c k ’ ] = $ c a l l b a c k ; } $ t h i s −>m e t r i c s [ ’ s t a r t ’ ] = time ( ) ; $ t h i s −>m e t r i c s [ ’ i n t e r v a l s t a r t ’ ] = $ t h i s −>m e t r i c s [ ’ s t a r t ’ ] ; $ t h i s −>m e t r i c s [ ’ m e s s a g e s ’ ] = 0; $ t h i s −>m e t r i c s [ ’ l a s t m e s s a g e s ’ ] = 0; $ t h i s −>m e t r i c s [ ’ b y t e s ’ ] = 0; $ t h i s −>m e t r i c s [ ’ l a s t b y t e s ’ ] = 0; $ t h i s −>c o n f i g [ ’ i s s t r e a m i n g ’ ] = true ; $ t h i s −>r e q u e s t ( $method , $ u r l , $params ) ; } /∗∗ ∗ H a n d l e s t h e u p d a t i n g o f t h e c u r r e n t S t r e a m i n g API m e t r i c s . ∗ ∗ @return ar r ay the m e t r i c s f o r the streaming a p i c o n n e c t i o n ∗/ private function update metrics () { $now = t i m e ( ) ; i f ( ( $ t h i s −>m e t r i c s [ ’ i n t e r v a l s t a r t ’ ] + $ t h i s −>c o n f i g [ ’ s t r e a m i n g m e t r i c s i n t e r v a l ’ ] ) > $now ) return null ; $ t h i s −>m e t r i c s [ ’ mps ’ ] = round ( ( $ t h i s −>m e t r i c s [ ’ m e s s a g e s ’ ] − $ t h i s −>m e t r i c s [ ’ l a s t m e s s a g e s ’ ] ) / $ t h i s −>c o n f i g [ ’ s t r e a m i n g m e t r i c s i n t e r v a l ’ ] , 2 ) ; $ t h i s −>m e t r i c s [ ’ bps ’ ] = round ( ( $ t h i s −>m e t r i c s [ ’ b y t e s ’ ] − $ t h i s −>m e t r i c s [ ’ l a s t b y t e s ’ ] ) / $ t h i s −>c o n f i g [ ’ s t r e a m i n g m e t r i c s i n t e r v a l ’ ] , 2 ) ; $ t h i s −>m e t r i c s [ ’ l a s t b y t e s ’ ] = $ t h i s −>m e t r i c s [ ’ b y t e s ’ ] ; $ t h i s −>m e t r i c s [ ’ l a s t m e s s a g e s ’ ] = $ t h i s −>m e t r i c s [ ’ m e s s a g e s ’ ] ; $ t h i s −>m e t r i c s [ ’ i n t e r v a l s t a r t ’ ] = $now ; r e t u r n $ t h i s −>m e t r i c s ; } /∗∗ ∗ U t i l i t y f u n c t i o n t o c r e a t e t h e r e q u e s t URL i n t h e r e q u e s t e d ∗ I f a f u l l y −q u a l i f i e d URI i s p r o v i d e d , i t w i l l be r e t u r n e d . 252 format . ∗ Any m u l t i −s l a s h e s ( e x c e p t f o r t h e p r o t o c o l ) w i l l be r e p l a c e d w i t h a s i n g l e s l a s h . ∗ ∗ ∗ @param s t r i n g $ r e q u e s t t h e API method w i t h o u t e x t e n s i o n ∗ @param s t r i n g $ e x t e n s i o n t h e f o r m a t o f t h e r e s p o n s e . D e f a u l t j s o n . S e t t o an empty s t r i n g to exclude the format ∗ @ r e t u r n s t r i n g t h e c o n c a t e n a t i o n o f t h e h o s t , API v e r s i o n , API method and f o r m a t , o r $ r e q u e s t i f i t b e g i n s with http ∗/ p u b l i c f u n c t i o n u r l ( $ r e q u e s t , $ e x t e n s i o n =’ j s o n ’ ) { // remove m u l t i −s l a s h e s $ r e q u e s t = p r e g r e p l a c e ( ’ $ ( [ ˆ : ] ) //+$ ’ , ’ $1 / ’ , $ r e q u e s t ) ; if ( s t r i p o s ( $request , return $request ; ’ h t t p ’ ) === 0 || s t r i p o s ( $request , ’ / / ’ ) === 0 ) { } $extension = strlen ( $extension ) > 0 ? ”. $extension ” : ’ ’; $ p r o t o = $ t h i s −>c o n f i g [ ’ u s e s s l ’ ] ? ’ h t t p s : / ’ : ’ h t t p : / ’ ; // t r i m t r a i l i n g s l a s h $request = ltrim ( $request , ’/ ’) ; $pos = s t r l e n ( $ r e q u e s t ) − s t r l e n ( $ e x t e n s i o n ) ; i f ( s u b s t r ( $ r e q u e s t , $ p o s ) === $ e x t e n s i o n ) $ r e q u e s t = s u b s t r r e p l a c e ( $request , ’ ’ , $pos ) ; r e t u r n implode ( ’ / ’ , array ( $proto , $ t h i s −>c o n f i g [ ’ h o s t ’ ] , $request . $extension )); } /∗∗ ∗ P u b l i c a c c e s s t o t h e p r i v a t e s a f e d e c o d e / e n c o d e methods ∗ ∗ @param s t r i n g $ t e x t t h e t e x t t o t r a n s f o r m ∗ @param s t r i n g $mode t h e t r a n s f o r m a t i o n mode . e i t h e r e n c o d e o r d e c o d e ∗ @ r e t u r n s t r i n g $ t e x t t r a n s f o r m e d by t h e g i v e n $mode ∗/ p u b l i c f u n c t i o n t r a n s f o r m T e x t ( $ t e x t , $mode=’ encode ’ ) { r e t u r n $ t h i s −>{”s a f e $ m o d e ” } ( $ t e x t ) ; } /∗∗ ∗ U t i l i t y f u n c t i o n to parse the returned c u r l ∗ c l a s s array variable . ∗ ∗ @param o b j e c t $ch c u r l h a n d l e ∗ @param s t r i n g $ h e a d e r t h e r e s p o n s e h e a d e r s ∗ @return s t r i n g the l e n g t h o f the header ∗/ p r i v a t e f u n c t i o n c u r l H e a d e r ( $ch , $ h e a d e r ) { $ t h i s −>r e s p o n s e [ ’ raw ’ ] .= $ h e a d e r ; l i s t ( $key , $value ) = array pad ( explode ( ’ : ’ , h e a d e r s and s t o r e them i n $header , 2) , 2 , the null ) ; $key = t r i m ( $key ) ; $value = trim ( $value ) ; i f ( ! i s s e t ( $ t h i s −>r e s p o n s e [ ’ h e a d e r s ’ ] [ $key ] ) ) { $ t h i s −>r e s p o n s e [ ’ h e a d e r s ’ ] [ $key ] = $ v a l u e ; } else { i f ( ! i s a r r a y ( $ t h i s −>r e s p o n s e [ ’ h e a d e r s ’ ] [ $key ] ) ) { $ t h i s −>r e s p o n s e [ ’ h e a d e r s ’ ] [ $key ] = a r r a y ( $ t h i s −>r e s p o n s e [ ’ h e a d e r s ’ ] [ $key ] ) ; } $ t h i s −>r e s p o n s e [ ’ h e a d e r s ’ ] [ $key ] [ ] = $ v a l u e ; } return s t r l e n ( $header ) ; } /∗∗ ∗ U t i l i t y f u n c t i o n t o p a r s e t h e r e t u r n e d c u r l b u f f e r and s t o r e them u n t i l ∗ an EOL i s f o u n d . The b u f f e r f o r c u r l i s an u n d e f i n e d s i z e s o we need ∗ t o c o l l e c t t h e c o n t e n t u n t i l an EOL i s f o u n d . ∗ ∗ T h i s f u n c t i o n c a l l s t h e p r e v i o u s l y d e f i n e d s t r e a m i n g c a l l b a c k method . ∗ ∗ @param o b j e c t $ch c u r l h a n d l e ∗ @param s t r i n g $ d a t a t h e c u r r e n t c u r l b u f f e r ∗ @return i n t the l e n g t h o f the data s t r i n g p r o c e s s e d i n t h i s f u n c t i o n ∗/ p r i v a t e f u n c t i o n c u r l W r i t e ( $ch , $ d a t a ) { $ l = s t r l e n ( $data ) ; i f ( s t r p o s ( $data , $ t h i s −>c o n f i g [ ’ s t r e a m i n g e o l ’ ] ) === f a l s e ) { $ t h i s −>b u f f e r .= $ d a t a ; return $l ; } $ b u f f e r e d = e x p l o d e ( $ t h i s −>c o n f i g [ ’ s t r e a m i n g e o l ’ ] , $ c o n t e n t = $ t h i s −>b u f f e r . $ b u f f e r e d [ 0 ] ; $data ) ; $ t h i s −>m e t r i c s [ ’ m e s s a g e s ’ ] + + ; $ t h i s −>m e t r i c s [ ’ b y t e s ’ ] += s t r l e n ( $ c o n t e n t ) ; if ( ! i s c a l l a b l e ( $ t h i s −>c o n f i g [ ’ s t r e a m i n g c a l l b a c k ’ ] ) ) return 0; 253 $ m e t r i c s = $ t h i s −>u p d a t e m e t r i c s ( ) ; $stop = c a l l u s e r f u n c ( $ t h i s −>c o n f i g [ ’ s t r e a m i n g c a l l b a c k ’ ] , $content , s t r l e n ( $content ) , $metrics ); $ t h i s −>b u f f e r = $ b u f f e r e d [ 1 ] ; i f ( $stop ) return 0; return $l ; } /∗∗ ∗ Makes a c u r l r e q u e s t . Takes no p a r a m e t e r s a s a l l s h o u l d have been p r e p a r e d ∗ by t h e r e q u e s t method ∗ ∗ the r e s p o n s e data i s s t o r e d i n the c l a s s v a r i a b l e ’ response ’ ∗ ∗ @return i n t the http r e s p o n s e code f o r the r e q u e s t . 0 i s r e t u r n e d i f a c o n n e c t i o n n o t be made ∗/ private function c u r l i t () { $ t h i s −>r e s p o n s e = a r r a y ( ’ raw ’ => ’ ’ ); could // c o n f i g u r e c u r l $c = c u r l i n i t ( ) ; ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ method ’ ] == ’GET’ && i s s e t ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ querystring ’ ] ) ) { $ t h i s −>r e q u e s t s e t t i n g s [ ’ u r l ’ ] = $ t h i s −>r e q u e s t s e t t i n g s [ ’ u r l ’ ] . ’ ? ’ . $ t h i s −> request settings [ ’ querystring ’ ] ; } e l s e i f ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ method ’ ] == ’POST’ | | $ t h i s −>r e q u e s t s e t t i n g s [ ’ method ’ ] == ’PUT’ ) { $ p o s t f i e l d s = array () ; i f ( i s s e t ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ p o s t f i e l d s ’ ] ) ) $ p o s t f i e l d s = $ t h i s −>r e q u e s t s e t t i n g s [ ’ p o s t f i e l d s ’ ] ; if c u r l s e t o p t ( $c , CURLOPT POSTFIELDS, $postfields ) ; } c u r l s e t o p t ( $c , CURLOPT CUSTOMREQUEST, $ t h i s −>r e q u e s t s e t t i n g s [ ’ method ’ ] ) ; c u r l s e t o p t a r r a y ( $c , a r r a y ( CURLOPT HTTP VERSION => $ t h i s −>c o n f i g CURLOPT USERAGENT => $ t h i s −>c o n f i g CURLOPT CONNECTTIMEOUT => $ t h i s −>c o n f i g CURLOPT TIMEOUT => $ t h i s −>c o n f i g CURLOPT RETURNTRANSFER => t r u e , CURLOPT SSL VERIFYPEER => $ t h i s −>c o n f i g CURLOPT SSL VERIFYHOST => $ t h i s −>c o n f i g CURLOPT FOLLOWLOCATION CURLOPT PROXY CURLOPT ENCODING CURLOPT URL // p r o c e s s t h e h e a d e r s CURLOPT HEADERFUNCTION CURLOPT HEADER CURLINFO HEADER OUT )); => => => => [ [ [ [ ’ ’ ’ ’ http version ’] , agent ’ ] , connecttimeout ’ ] , timeout ’ ] , [ ’ curl ssl verifypeer ’] , [ ’ curl ssl verifyhost ’] , $ t h i s −>c o n f i g [ ’ $ t h i s −>c o n f i g [ ’ $ t h i s −>c o n f i g [ ’ $ t h i s −>r e q u e s t => a r r a y ( $ t h i s , => f a l s e , => t r u e , curl user curl curl curl followlocation ’] , curl proxy ’ ] , curl encoding ’ ] , s e t t i n g s [ ’ url ’ ] , ’ curlHeader ’ ) , if ( $ t h i s −>c o n f i g [ ’ c u r l c a i n f o ’ ] !== f a l s e ) c u r l s e t o p t ( $c , CURLOPT CAINFO, $ t h i s −>c o n f i g [ ’ c u r l c a i n f o ’ ] ) ; if ( $ t h i s −>c o n f i g [ ’ c u r l c a p a t h ’ ] !== f a l s e ) c u r l s e t o p t ( $c , CURLOPT CAPATH, $ t h i s −>c o n f i g [ ’ c u r l c a p a t h ’ ] ) ; if ( $ t h i s −>c o n f i g [ ’ c u r l p r o x y u s e r p w d ’ ] !== f a l s e ) c u r l s e t o p t ( $c , CURLOPT PROXYUSERPWD, $ t h i s −>c o n f i g [ ’ c u r l p r o x y u s e r p w d ’ ] ) ; if ( $ t h i s −>c o n f i g [ ’ c u r l s s l v e r s i o n ’ ] !== f a l s e ) c u r l s e t o p t ( $c , CURLOPT SSLVERSION, $ t h i s −>c o n f i g [ ’ c u r l s s l v e r s i o n ’ ] ) ; if ( $ t h i s −>c o n f i g [ ’ i s s t r e a m i n g ’ ] ) { // p r o c e s s t h e body $ t h i s −>r e s p o n s e [ ’ c o n t e n t −l e n g t h ’ ] = 0 ; c u r l s e t o p t ( $c , CURLOPT TIMEOUT, 0 ) ; c u r l s e t o p t ( $c , CURLOPT WRITEFUNCTION, array ( $this , ’ curlWrite ’ ) ) ; } if ( ! empty ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ h e a d e r s ’ ] ) ) { f o r e a c h ( $ t h i s −>r e q u e s t s e t t i n g s [ ’ h e a d e r s ’ ] a s $k => $v ) { $ h e a d e r s [ ] = t r i m ( $k . ’ : ’ . $v ) ; } c u r l s e t o p t ( $c , CURLOPT HTTPHEADER, $ h e a d e r s ) ; } if ( i s s e t ( $ t h i s −>c o n f i g [ ’ b l o c k ’ ] ) && ( t r u e === $ t h i s −>c o n f i g [ ’ b l o c k ’ ] ) ) return 0; // do i t ! $ r e s p o n s e = c u r l e x e c ( $c ) ; $ c o d e = c u r l g e t i n f o ( $c , CURLINFO HTTP CODE) ; $ i n f o = c u r l g e t i n f o ( $c ) ; 254 $ e r r o r = c u r l e r r o r ( $c ) ; $ e r r n o = c u r l e r r n o ( $c ) ; c u r l c l o s e ( $c ) ; // s t o r e t h e r e s p o n s e $ t h i s −>r e s p o n s e [ ’ code ’ ] = $ c o d e ; $ t h i s −>r e s p o n s e [ ’ r e s p o n s e ’ ] = $ r e s p o n s e ; $ t h i s −>r e s p o n s e [ ’ i n f o ’ ] = $ i n f o ; $ t h i s −>r e s p o n s e [ ’ e r r o r ’ ] = $ e r r o r ; $ t h i s −>r e s p o n s e [ ’ e r r n o ’ ] = $ e r r n o ; i f ( ! i s s e t ( $ t h i s −>r e s p o n s e [ ’ raw ’ ] ) ) { $ t h i s −>r e s p o n s e [ ’ raw ’ ] = ’ ’ ; } $ t h i s −>r e s p o n s e [ ’ raw ’ ] .= $ r e s p o n s e ; r e t u r n $code ; } } <?php i f ( ! d e f i n e d ( ’BASEPATH’ ) ) e x i t ( ’ No d i r e c t s c r i p t access allowed ’ ) ; /∗∗ ∗ CodeIgniter Twitter ∗ ∗ A C o d e I g n i t e r l i b r a r y t o i n t e r a c t w i t h Api T w i t t e r . ∗ O r i g i n a l author : e l l i o t h a u g h i n ∗ ∗ @package CodeIgniter ∗ @category Libraries ∗ @author Marcos Sanz ∗ @link h t t p s : / / g i t h u b . com/ m a r s a n l a / c o d e i g n i t e r −t w i t t e r ∗ @license h t t p : / /www. o p e n s o u r c e . o r g / l i c e n s e s / mit−l i c e n s e . html ∗/ class tweet { private $ o a u t h = NULL ; function construct () { $ t h i s −> o a u t h = new tweetOauth ( ) ; } function if c a l l ( $method , $ a r g s ) { ( m e t h o d e x i s t s ( $ t h i s , $method ) ) { r e t u r n c a l l u s e r f u n c a r r a y ( a r r a y ( $ t h i s , $method ) , $args ) ; } return c a l l u s e r f u n c a r r a y ( a r r a y ( $ t h i s −> o a u t h , $method ) , $args ) ; } function logged in () { r e t u r n $ t h i s −> o a u t h −> l o g g e d I n ( ) ; get header () { r e t u r n $ t h i s −> o a u t h −> g e t H e a d e r ( ) ; } function } function set callback ( $url ) { $ t h i s −> o a u t h −> s e t C a l l b a c k ( $ u r l ) ; } function login ( $sign in twitter = false ) { r e t u r n $ t h i s −> o a u t h −> l o g i n ( $ s i g n i n t w i t t e r ) ; } function logout () { r e t u r n $ t h i s −> o a u t h −> l o g o u t ( ) ; } function get tokens () { $tokens = array ( ’ o a u t h t o k e n ’ => $ t h i s −> o a u t h −> g e t A c c e s s K e y ( ) , ’ o a u t h t o k e n s e c r e t ’ => $ t h i s −> o a u t h −> g e t A c c e s s S e c r e t ( ) ); return $tokens ; } function s e t t o k e n s ( $tokens ) { r e t u r n $ t h i s −> o a u t h −> s e t A c c e s s T o k e n s ( $ t o k e n s ) ; } } class tweetException function extends Exception { construct ( $string ) { parent : : construct ( $string ) ; } public function toString () { return ” exception ’” . CLASS . ” ’ w i t h m e s s a g e ’ ” . $ t h i s −> g e t M e s s a g e ( ) . ” ’ i n ” . $ t h i s −> g e t F i l e ( ) . ” : ” . $ t h i s −> g e t L i n e ( ) . ”\ n S t a c k t r a c e : \ n” . $ t h i s −> g e t T r a c e A s S t r i n g ( ) ; 255 } } class tweetConnection { // Allow m u l t i −t h r e a d i n g . p r i v a t e $ mch = NULL ; private $ p r o p e r t i e s = array () ; public $ h e a d e r = NULL ; function construct () { $ t h i s −> mch = c u r l m u l t i i n i t ( ) ; $ t h i s −> p r o p e r t i e s = array ( ’ code ’ => CURLINFO HTTP CODE, ’ time ’ => CURLINFO TOTAL TIME, ’ l e n g t h ’ => CURLINFO CONTENT LENGTH DOWNLOAD, ’ type ’ => CURLINFO CONTENT TYPE ); } private function initConnection ( $url ) { $ t h i s −> c h = c u r l i n i t ( $ u r l ) ; c u r l s e t o p t ( $ t h i s −> c h , CURLOPT RETURNTRANSFER, TRUE) ; c u r l s e t o p t ( $ t h i s −> c h , CURLOPT VERBOSE, TRUE) ; c u r l s e t o p t ( $ t h i s −> c h , CURLOPT HEADER, TRUE) ; } public f u n c t i o n g e t ( $ u r l , $params ) { i f ( c o u n t ( $params [ ’ r e q u e s t ’ ] ) > 0 ) { $ u r l .= ’ ? ’ ; foreach ( $params [ ’ r e q u e s t ’ ] a s $k => $v ) { $k = s t r i r e p l a c e ( a r r a y ( ’ + ’ , ’%7E ’ ) , r a w u r l e n c o d e ( $k ) ) ; $v = s t r i r e p l a c e ( a r r a y ( ’ + ’ , ’%7E ’ ) , r a w u r l e n c o d e ( $v ) ) ; $ u r l .= ”{ $k}={$v }&”; array ( ’ ’, ’˜ ’) , array ( ’ ’, ’˜ ’) , } $url = substr ( $url , 0 , −1) ; } $ t h i s −> i n i t C o n n e c t i o n ( $ u r l ) ; $ r e s p o n s e = $ t h i s −> a d d C u r l ( $ u r l , return $params ) ; $response ; } public function post ( $url , $post = ’ ’ ; $params ) { ( $params [ ’ r e q u e s t ’ ] a s $k => $v ) { $k = s t r i r e p l a c e ( a r r a y ( ’ + ’ , ’%7E ’ ) , ); $v = s t r i r e p l a c e ( a r r a y ( ’ + ’ , ’%7E ’ ) , ); $ p o s t .= ”{ $k}={$v }&”; foreach array ( ’ ’, ’ ˜ ’ ) , r a w u r l e n c o d e ( $k ) array ( ’ ’, ’ ˜ ’ ) , r a w u r l e n c o d e ( $v ) } $post = s u b s t r ( $post , 0 , −1) ; $ t h i s −> i n i t C o n n e c t i o n ( $ u r l , $params ) ; c u r l s e t o p t ( $ t h i s −> c h , CURLOPT POST, 1 ) ; c u r l s e t o p t ( $ t h i s −> c h , CURLOPT POSTFIELDS, $ r e s p o n s e = $ t h i s −> return addCurl ( $url , $post ) ; $params ) ; $response ; } private function ad dOa uth Hea der s (&$ch , $ u r l , $ h = array ( ’ Expect : ’ , ’ C o n n e c t i o n : Keep−A l i v e ’ , ’ Cache−C o n t r o l : no−c a c h e ’ ); if $oauthHeaders ) { ( i s s e t ( $ SERVER [ ’ HTTP USER AGENT ’ ] ) ) { a r r a y p u s h ( $ h , ’ User−Agent : ’ . $ SERVER [ ’ HTTP USER AGENT ’ ] ) ; } $urlParts = parse url ( $url ) ; $ o a u t h = ’ A u t h o r i z a t i o n : OAuth r e a l m =” ’ . foreach $ u r l P a r t s [ ’ path ’ ] ( $ o a u t h H e a d e r s a s $name => $ v a l u e ) { $ o a u t h .= ”{ $name}=\”{ $ v a l u e } \ ” , ” ; } // A d d i t i o n a l h e a d e r s $ h [ ] = s u b s t r ( $oauth , 0 , −1) ; c u r l s e t o p t ( $ch , CURLOPT HTTPHEADER, $ h); } private function addCurl ( $url , $params = a r r a y ( ) ) { 256 . ’” , ’; if ( ! empty ( $params [ ’ oauth ’ ] ) ) { $ t h i s −> ad dOa uth Hea ders ( $ t h i s −> ch , $url , $params [ ’ oauth ’ ] ) ; } $ch = $ t h i s −> ch ; $key = ( s t r i n g ) $ch ; $ t h i s −> r e q u e s t s [ $key ] = $ch ; $ r e s p o n s e = c u r l m u l t i a d d h a n d l e ( $ t h i s −> if mch , $ch ) ; ( $ r e s p o n s e === CURLM OK | | $ r e s p o n s e === CURLM CALL MULTI PERFORM) { do { $mch = c u r l m u l t i e x e c ( $ t h i s −> mch , $ a c t i v e ) ; } w h i l e ( $mch === CURLM CALL MULTI PERFORM ) ; return $ t h i s −> return $response ; g e t R e s p o n s e ( $key ) ; } else { } } private g e t R e s p o n s e ( $key = NULL) { function i f ( $key == NULL) r e t u r n FALSE ; if ( i s s e t ( $ t h i s −> r e s p o n s e s [ $key ] ) ) { r e t u r n $ t h i s −> r e s p o n s e s [ $key ] ; } $ r u n n i n g = NULL ; do { $ r e s p o n s e = c u r l m u l t i e x e c ( $ t h i s −> if mch , $running curl ) ; ( $ r u n n i n g !== NULL && $ r u n n i n g c u r l != $ r u n n i n g ) { $ t h i s −> s e t R e s p o n s e ( $key ) ; if ( i s s e t ( $ t h i s −> r e s p o n s e s [ $key ] ) ) { $ r e s p o n s e = new t w e e t R e s p o n s e O a u t h ( ( o b j e c t ) $ t h i s −> r e s p o n s e s [ $key ] ) ; if ( i s s e t ( $ r e s p o n s e −> r e s p −> h e a d e r −> s t a t u s ) ) { r e s p −> h e a d e r −> s t a t u s = $ r e s p o n s e −> $ r e s p o n s e −> r e s p −> c o d e ; $ t h i s −> h e a d e r = $ r e s p o n s e −> r e s p −> header ; } if ( $ r e s p o n s e −> r e s p −> c o d e !== 2 0 0 ) { resp throw new t w e e t E x c e p t i o n ( $ r e s p o n s e −> −> c o d e . ’ | R e q u e s t F a i l e d : ’ . r e s p −> d a t a −> e r r o r s [ 0 ] $ r e s p o n s e −> −> m e s s a g e ) ; } return $response ; } } $running = $ r u n n i n g c u r l ; } while ( $r u n ni n g c u rl > 0) ; } private function s e t R e s p o n s e ( $key ) { w h i l e ( $done = c u r l m u l t i i n f o r e a d ( $ t h i s −> $key = ( s t r i n g ) $done [ ’ h a n d l e ’ ] ; mch ) ) { $ h e a d e r s i z e = c u r l g e t i n f o ( $done [ ’ h a n d l e ’ ] , CURLINFO HEADER SIZE) ; $ h e a d e r = s u b s t r ( c u r l m u l t i g e t c o n t e n t ( $done [ ’ h a n d l e ’ ] ) , 0 , $header size ) ; $body = s u b s t r ( c u r l m u l t i g e t c o n t e n t ( $done [ ’ h a n d l e ’ ] ) , $ h e a d e r s i z e ) ; $ t h i s −> $ t h i s −> foreach r e s p o n s e s [ $key ] [ ’ h e a d e r ’ ] = $ h e a d e r ; r e s p o n s e s [ $key ] [ ’ data ’ ] = $body ; ( $ t h i s −> p r o p e r t i e s a s $ c u r l k e y => $ v a l u e ) { $ t h i s −> r e s p o n s e s [ $key ] [ $ c u r l k e y ] = c u r l g e t i n f o ( $done [ ’ handle ’ ] , $value ) ; c u r l m u l t i r e m o v e h a n d l e ( $ t h i s −> mch , $done [ ’ h a n d l e ’ ] ) ; } } } } class tweetResponseOauth { private public $ construct ; function $ t h i s −> if construct ( $resp ) { r e s p = $resp ; ( s t r p o s ( $ t h i s −> r e s p −> type , ’ j s o n ’ ) !== FALSE) { $ t h i s −> r e s p −> d a t a = j s o n d e c o d e ( $ t h i s −> r e s p −> d a t a ) ; 257 $ t h i s −> r e s p −> h e a d e r = ( o b j e c t ) $ t h i s −> r e s p −> h e a d e r ) ; f o r m a t H e a d e r ( $ t h i s −> } } public g e t ( $name ) { function i f ( $ t h i s −> r e s p −> c o d e < 200 r e t u r n FALSE ; || $ t h i s −> r e s p −> d a t a ) ) { ( i s s t r i n g ( $ t h i s −> p a r s e s t r ( $ t h i s −> r e s p −> data , } else { r e s p −> d a t a ; $ r e s u l t = $ t h i s −> } r e s p −> c o d e > 2 9 9 ) if $result ) ; ( $ r e s u l t a s $k => $v ) { $ t h i s −> $k = $v ; foreach } if ( $name === ’ r e s u l t ’ ) { return $result ; } return $ r e s u l t [ $name ] ; } formatHeader ( $header ) { function $ r e s u l t = explode (”\n ” , $header ) ; private $result header = array () ; f o r e a c h ( $ r e s u l t a s $k => $v ) { i f ( $k == 0 | | t r i m ( $v ) == ’ ’ ) continue ; l i s t ( $key , $ v a l u e ) = a r r a y p a d ( e x p l o d e ( ’ : ’ , $v ) , 2 , n u l l ) ; $ r e s u l t h e a d e r [ s t r t o l o w e r ( t r i m ( $key ) ) ] = t r i m ( $ v a l u e ) ; } return $result header ; } } class tweetOauth e x t e n d s t w e e t C o n n e c t i o n { private $ obj ; private $ tokens = array () ; p r i v a t e $ a u t h o r i z a t i o n U r l = ’ h t t p : / / a p i . t w i t t e r . com/ o a u t h / a u t h o r i z e ’ ; // L o g i n e a c h time p r i v a t e $ a u t h e n t i c a t i o n U r l = ’ h t t p : / / a p i . t w i t t e r . com/ o a u t h / a u t h e n t i c a t e ’ ; // Keep logged in p r i v a t e $ r e q u e s t T o k e n U r l = ’ h t t p : / / a p i . t w i t t e r . com/ o a u t h / r e q u e s t t o k e n ’ ; p r i v a t e $ a c c e s s T o k e n U r l = ’ h t t p : / / a p i . t w i t t e r . com/ o a u t h / a c c e s s t o k e n ’ ; p r i v a t e $ s i g n a t u r e M e t h o d = ’HMAC−SHA1 ’ ; private $ version = ’1.0 ’; private $ apiVersion = ’1.1 ’; p r i v a t e $ a p i U r l = ’ h t t p : / / a p i . t w i t t e r . com ’ ; p r i v a t e $ s e a r c h U r l = ’ h t t p : / / s e a r c h . t w i t t e r . com ’ ; p ri v a te $ responseType = ’ json ’ ; p r i v a t e $ c a l l b a c k = NULL ; private $ e r r o r s = array () ; p r i v a t e $ e n a b l e d e b u g = FALSE ; function construct () { parent : : construct () ; $this $this $this $this $this −> −> −> −> −> $ t h i s −> obj obj obj obj obj = &g e t i n s t a n c e ( ) ; −> l o a d −> c o n f i g ( ’ t w e e t ’ ) ; −> l o a d −> l i b r a r y ( ’ s e s s i o n ’ ) ; −> l o a d −> l i b r a r y ( ’ u n i t t e s t ’ ) ; −> l o a d −> h e l p e r ( ’ u r l ’ ) ; tokens = array ( ’ c o n s u m e r k e y ’ => $ t h i s −> o b j −> c o n f i g −> i t e m ( ’ t w e e t c o n s u m e r k e y ’) , ’ c o n s u m e r s e c r e t ’ => $ t h i s −> o b j −> c o n f i g −> i t e m ( ’ tweet consumer secret ’ ) , ’ a c c e s s k e y ’ => $ t h i s −> g e t A c c e s s K e y ( ) , ’ a c c e s s s e c r e t ’ => $ t h i s −> g e t A c c e s s S e c r e t ( ) ); $ t h i s −> checkLogin () ; } function if if destruct () { ( ! $ t h i s −> e n a b l e d e b u g ) return ; ( ! empty ( $ t h i s −> e r r o r s ) ) { f o r e a c h ( $ t h i s −> e r r o r s a s $key => $ e ) { e c h o ’< pre >’ . $ e . ’</ pre > ’ ; } } } public f u n c t i o n e n a b l e d e b u g ( $debug ) { $debug = ( b o o l ) $debug ; $ t h i s −> e n a b l e d e b u g = $debug ; } 258 public f u n c t i o n getHeader ( ) { r e t u r n $ t h i s −> h e a d e r ; } public f u n c t i o n c a l l ( $method , $path , $ a r g s = NULL) { $ r e s p o n s e = $ t h i s −> h t t p R e q u e s t ( s t r t o u p p e r ( $method ) , $ t h i s −> a p i U r l . ’ / ’ . $ t h i s −> a p i V e r s i o n . ’ / ’ . $ p a t h . ’ . ’ . $ t h i s −> r e s p o n s e T y p e , $ a r g s ); // var dump ( $ r e s p o n s e ) ; // d i e ( ) ; return ( $ r e s p o n s e === NULL) ? FALSE : $ r e s p o n s e −> result ; } public f u n c t i o n s e a r c h ( $ a r g s = NULL) { $ r e s p o n s e = $ t h i s −> h t t p R e q u e s t ( ’GET’ , $ t h i s −> r e s p o n s e T y p e , $ a r g s ) ; return ( $ r e s p o n s e === NULL) ? FALSE : $ t h i s −> $ r e s p o n s e −> searchUrl . ’/ search . ’ . result ; } public function loggedIn () { $ a c c e s s k e y = $ t h i s −> g e t A c c e s s K e y ( ) ; $ a c c e s s s e c r e t = $ t h i s −> g e t A c c e s s S e c r e t ( ) ; $ l o g g e d I n = FALSE ; if ( $ t h i s −> g e t A c c e s s K e y ( ) !== NULL && $ t h i s −> { $ l o g g e d I n = TRUE; g e t A c c e s s S e c r e t ( ) !== NULL) } $ t h i s −> o b j −> u n i t −> run ( $ l o g g e d I n , TRUE, return $loggedIn ; ’ Logged In ’ ) ; } private function checkLogin () { i f ( i s s e t ( $ GET [ ’ o a u t h t o k e n ’ ] ) ) { $ t h i s −> s e t A c c e s s K e y ( $ GET [ ’ o a u t h t o k e n ’ ] ) ; $ t o k e n = $ t h i s −> g e t A c c e s s T o k e n ( ) ; $ t o k e n = $ t o k e n −> $token = ( if result ; i s b o o l ( $token ) ) ? $token : ( o b j e c t ) $token ; ( ! empty ( $ t o k e n −> o a u t h t o k e n ) && ! empty ( $ t o k e n −> oauth token secret ) ) { $ t h i s −> s e t A c c e s s K e y ( $ t o k e n −> o a u t h t o k e n ) ; $ t h i s −> s e t A c c e s s S e c r e t ( $ t o k e n −> o a u t h t o k e n s e c r e t ) ; } redirect ( current url () ) ; r e t u r n NULL ; } } public function login ( $sign in twitter = f a l s e ) { i f ( ( $ t h i s −> g e t A c c e s s K e y ( ) === NULL | | $ t h i s −> g e t A c c e s s S e c r e t ( ) === NULL )) { h e a d e r ( ’ L o c a t i o n : ’ . $ t h i s −> g e t A u t h o r i z a t i o n U r l ( $ s i g n i n t w i t t e r ) ) ; return ; } return $ t h i s −> checkLogin () ; } public function logout () { $ t h i s −> o b j −> s e s s i o n −> u n s e t u s e r d a t a ( ’ t w i t t e r o a u t h t o k e n s ’ ) ; } public f u n c t i o n getTokens ( ) { r e t u r n $ t h i s −> t o k e n s ; } private function getConsumerKey ( ) { r e t u r n $ t h i s −> t o k e n s [ ’ c o n s u m e r k e y ’ ] ; } private function getConsumerSecret () { r e t u r n $ t h i s −> t o k e n s [ ’ c o n s u m e r s e c r e t ’ ] ; } public f u n c t i o n getAccessKey ( ) { r e t u r n $ t h i s −> g e t A c c e s s K e y ( ) ; } private function getAccessKey () { $ t o k e n s = $ t h i s −> o b j −> s e s s i o n −> u s e r d a t a ( ’ t w i t t e r o a u t h t o k e n s ’ ) ; r e t u r n ( $ t o k e n s === FALSE | | ! i s s e t ( $ t o k e n s [ ’ a c c e s s k e y ’ ] ) | | empty ( $ t o k e n s [ ’ a c c e s s k e y ’ ] ) ) ? NULL : $ t o k e n s [ ’ a c c e s s k e y ’ ] ; } private function setAccessKey ( $access key ) { $ t o k e n s = $ t h i s −> o b j −> s e s s i o n −> u s e r d a t a ( ’ t w i t t e r o a u t h t o k e n s ’ ) ; if ( $ t o k e n s === FALSE | | ! i s a r r a y ( $tokens ) ) { 259 $ t o k e n s = a r r a y ( ’ a c c e s s k e y ’ => $ a c c e s s k e y ) ; } else { $tokens [ ’ access key ’ ] = $access key ; } $ t h i s −> o b j −> s e s s i o n −> s e t u s e r d a t a ( ’ t w i t t e r o a u t h t o k e n s ’ , $tokens ) ; } public function getAccessSecret () { r e t u r n $ t h i s −> g e t A c c e s s S e c r e t ( ) ; } private function getAccessSecret () { $ t o k e n s = $ t h i s −> o b j −> s e s s i o n −> u s e r d a t a ( ’ t w i t t e r o a u t h t o k e n s ’ ) ; r e t u r n ( $ t o k e n s === FALSE | | ! i s s e t ( $ t o k e n s [ ’ a c c e s s s e c r e t ’ ] ) | | empty ( $ t o k e n s [ ’ a c c e s s s e c r e t ’ ] ) ) ? NULL : $ t o k e n s [ ’ a c c e s s s e c r e t ’ ] ; } private setAccessSecret ( $access secret ) { function $ t o k e n s = $ t h i s −> o b j −> s e s s i o n −> u s e r d a t a ( ’ t w i t t e r o a u t h t o k e n s ’ ) ; ( $ t o k e n s === FALSE | | ! i s a r r a y ( $ t o k e n s ) ) { $ t o k e n s = a r r a y ( ’ a c c e s s s e c r e t ’ => $ a c c e s s s e c r e t ) ; } else { $tokens [ ’ a c c e s s s e c r e t ’ ] = $ a c c e s s s e c r e t ; } if $ t h i s −> o b j −> s e s s i o n −> s e t u s e r d a t a ( ’ t w i t t e r o a u t h t o k e n s ’ , function $ t h i s −> $ t h i s −> setAccessTokens ( $tokens ) { setAccessKey ( $tokens [ ’ oauth token ’ ] ) ; s e t A c c e s s S e c r e t ( $tokens [ ’ oauth token secret ’ ] ) ; $tokens ) ; } private } public function setAccessTokens ( $tokens ) { r e t u r n $ t h i s −> s e t A c c e s s T o k e n s ( $ t o k e n s ) ; } private function getAuthorizationUrl ( $sign in twitter = f a l s e ) { $ t o k e n = $ t h i s −> g e t R e q u e s t T o k e n ( ) ; if ( $sign in twitter ) { r e t u r n $ t h i s −> a u t h e n t i c a t i o n U r l . ’ ? o a u t h t o k e n =’ . $ t o k e n −> oauth token ; } r e t u r n $ t h i s −> a u t h o r i z a t i o n U r l . ’ ? o a u t h t o k e n =’ . $ t o k e n −> o a u t h t o k e n ; } private function getRequestToken ( ) { r e t u r n $ t h i s −> h t t p R e q u e s t ( ’GET’ , $ t h i s −> requestTokenUrl ) ; getAccessToken ( ) { function r e t u r n $ t h i s −> h t t p R e q u e s t ( ’GET’ , $ t h i s −> accessTokenUrl ) ; } private } protected function h t t p R e q u e s t ( $method = n u l l , $ u r l = n u l l , $params = n u l l ) { i f ( empty ( $method ) | | empty ( $ u r l ) ) r e t u r n FALSE ; i f ( empty ( $params [ ’ o a u t h s i g n a t u r e ’ ] ) ) $params = $ t h i s −> p r e p a r e P a r a m e t e r s ( $method , $ u r l , $params ) ; if ( i s s e t ($ REQUEST [ ’ o a u t h v e r i f i e r ’ ] ) ) { $params [ ” o a u t h ” ] [ ” o a u t h v e r i f i e r ” ] = $ REQUEST [ ’ o a u t h v e r i f i e r ’ ] ; } $ t h i s −> c o n n e c t i o n = new t w e e t C o n n e c t i o n ( ) ; try { switch ( $method ) { c a s e ’GET’ : $ r e s p o n s e = $ t h i s −> c o n n e c t i o n −> g e t ( $ u r l , $params ) ; $ t h i s −> h e a d e r = $ t h i s −> c o n n e c t i o n −> h e a d e r ; return $response ; break ; case ’POST’ : $ r e s p o n s e = $ t h i s −> c o n n e c t i o n −> p o s t ( $ u r l , $params ); $ t h i s −> h e a d e r = $ t h i s −> c o n n e c t i o n −> h e a d e r ; return $response ; break ; case ’PUT’ : r e t u r n NULL ; break ; case ’DELETE’ : r e t u r n NULL ; break ; } } c a t c h ( tweetException $e ) { $ t h i s −> e r r o r s [ ] = $ e ; } } private function getCallback () { r e t u r n $ t h i s −> c a l l b a c k ; 260 } public function setCallback ( $url ) { $ t h i s −> c a l l b a c k = $ u r l ; } private p r e p a r e P a r a m e t e r s ( $method = NULL, function i f ( empty ( $method ) | | empty ( $ u r l ) ) r e t u r n FALSE ; $ c a l l b a c k = $ t h i s −> if $ u r l = NULL, $params = NULL) { getCallback () ; ( ! empty ( $ c a l l b a c k ) ) { $oauth [ ’ o a u t h c a l l b a c k ’ ] = $ c a l l b a c k ; } $ t h i s −> s e t C a l l b a c k (NULL) ; $oauth [ $oauth [ $oauth [ $oauth [ $oauth [ $oauth [ ’ ’ ’ ’ ’ ’ oauth oauth oauth oauth oauth oauth c o n s u m e r k e y ’ ] = $ t h i s −> getConsumerKey ( ) ; t o k e n ’ ] = $ t h i s −> g e t A c c e s s K e y ( ) ; n o n c e ’ ] = $ t h i s −> g e n e r a t e N o n c e ( ) ; timestamp ’ ] = time ( ) ; s i g n a t u r e m e t h o d ’ ] = $ t h i s −> s i g n a t u r e M e t h o d ; v e r s i o n ’ ] = $ t h i s −> v e r s i o n ; a r r a y w a l k ( $oauth , if array ( $this , ( i s a r r a y ( $params ) ) { a r r a y w a l k ( $params , ’ encode rfc3986 ’ ) ) ; array ( $this , ’ encode rfc3986 ’ ) ) ; } $encodedParams = a r r a y m e r g e ( $oauth , ( a r r a y ) $params ) ; k s o r t ( $encodedParams ) ; $ o a u t h [ ’ o a u t h s i g n a t u r e ’ ] = $ t h i s −> e n c o d e r f c 3 9 8 6 ( $ t h i s −> g e n e r a t e S i g n a t u r e ( $method , $ u r l , $encodedParams ) ) ; r e t u r n a r r a y ( ’ r e q u e s t ’ => $params , ’ oauth ’ => $ o a u t h ) ; } private function generateNonce () { r e t u r n md5 ( u n i q i d ( rand ( ) , TRUE) ) ; } private function encode rfc3986 ( $string ) { r e t u r n s t r i r e p l a c e ( a r r a y ( ’ + ’ , ’%7E ’ ) , ; array ( ’ ’, ’˜ ’) , rawurlencode ( $ s t r i n g ) ) } private function g e n e r a t e S i g n a t u r e ( $method = n u l l , i f ( empty ( $method ) | | empty ( $ u r l ) ) r e t u r n FALSE ; // c o n c a t e n a t i n g $concatenatedParams = foreach $url = null , $params = n u l l ) { ’ ’; ( $params a s $k => $v ) { $k = $ t h i s −> e n c o d e r f c 3 9 8 6 ( $k ) ; $v = $ t h i s −> e n c o d e r f c 3 9 8 6 ( $v ) ; $ c o n c a t e n a t e d P a r a m s .= ”{ $k}={$v }&”; } $ c o n c a t e n a t e d P a r a m s = $ t h i s −> −1) ) ; e n c o d e r f c 3 9 8 6 ( s u b s t r ( $concatenatedParams , // n o r m a l i z e u r l $ n o r m a l i z e d U r l = $ t h i s −> e n c o d e r f c 3 9 8 6 ( $ t h i s −> $method = $ t h i s −> e n c o d e r f c 3 9 8 6 ( $method ) ; // don ’ t need t h i s but why n o t ? 0, normalizeUrl ( $url ) ) ; $ s i g n a t u r e B a s e S t r i n g = ”{ $method}&{ $ n o r m a l i z e d U r l }&{ $ c o n c a t e n a t e d P a r a m s } ” ; r e t u r n $ t h i s −> s i g n S t r i n g ( $ s i g n a t u r e B a s e S t r i n g ) ; } private n o r m a l i z e U r l ( $ u r l = NULL) { function $urlParts = parse url ( $url ) ; if ( ! i s s e t ( $ u r l P a r t s [ ’ port ’ ] ) ) $ u r l P a r t s [ ’ port ’ ] = 8 0 ; $scheme = s t r t o l o w e r ( $ u r l P a r t s [ ’ scheme ’ ] ) ; $host = s t r t o l o w e r ( $ u r l P a r t s [ ’ host ’ ] ) ; $port = i n t v a l ( $ u r l P a r t s [ ’ port ’ ] ) ; $ r e t v a l = ”{ $scheme } : / / { $ h o s t } ” ; if ( $ p o r t > 0 && ( $scheme === ’ h t t p ’ && $ p o r t !== 8 0 ) && $ p o r t !== 4 4 3 ) ) { $ r e t v a l .= ” : { $ p o r t } ” ; } $ r e t v a l .= $ u r l P a r t s [ ’ path ’ ] ; if ( ! empty ( $ u r l P a r t s [ ’ query ’ ] ) ) { $ r e t v a l .= ”?{ $ u r l P a r t s [ ’ query ’ ] } ” ; } return $retval ; } 261 || ( $scheme === ’ h t t p s ’ private function signString ( $string ) { $ r e t v a l = FALSE ; s w i t c h ( $ t h i s −> s i g n a t u r e M e t h o d ) { c a s e ’HMAC−SHA1 ’ : $key = $ t h i s −> e n c o d e r f c 3 9 8 6 ( $ t h i s −> g e t C o n s u m e r S e c r e t ( ) ) . ’& ’ . $ t h i s −> e n c o d e r f c 3 9 8 6 ( $ t h i s −> getAccessSecret () ) ; $ r e t v a l = b a s e 6 4 e n c o d e ( hash hmac ( ’ sha1 ’ , $ s t r i n g , $key , t r u e ) ); break ; } return $retval ; } } /∗ End o f f i l e t w e e t . php ∗/ /∗ L o c a t i o n : . / a p p l i c a t i o n / l i b r a r i e s / t w e e t . php ∗/ B..5 Layout : : s e l e c t i o n { background−c o l o r : #E13300 ; c o l o r : w h i t e ; } : : moz−s e l e c t i o n { background−c o l o r : #E13300 ; c o l o r : w h i t e ; } : : w e b k i t−s e l e c t i o n { background−c o l o r : #E13300 ; c o l o r : w h i t e ; } body { background−c o l o r : # f f f f f f ; margin−t o p : 10 px ; margin−bottom : 10 px ; margin− l e f t : 100 px ; margin−r i g h t : 100 px ; f o n t : 13 px /20 px normal H e l v e t i c a , c o l o r : #4F5155 ; Arial , sans−s e r i f ; } a { c o l o r : #003399; background−c o l o r : t r a n s p a r e n t ; f o n t −w e i g h t : normal ; } h1 { c o l o r : #f f f ; background−c o l o r : t r a n s p a r e n t ; b o r d e r −bottom : 1 px s o l i d #D0D0D0 ; f o n t −s i z e : 19 px ; f o n t −w e i g h t : normal ; margin : 0 0 14 px 0 ; p a d d i n g : 14 px 15 px 10 px 15 px ; } code { f o n t −f a m i l y : C o n s o l a s , Monaco , f o n t −s i z e : 12 px ; background−c o l o r : #f 9 f 9 f 9 ; b o r d e r : 1 px s o l i d #D0D0D0 ; c o l o r : #002166; display : block ; margin : 14 px 0 14 px 0 ; p a d d i n g : 12 px 10 px 12 px 10 px ; C o u r i e r New , } #body { margin : 0 15 px 0 15 px ; } p. footer{ t e x t −a l i g n : r i g h t ; f o n t −s i z e : 11 px ; b o r d e r −t o p : 1 px s o l i d #D0D0D0 ; l i n e −h e i g h t : 32 px ; p a d d i n g : 0 10 px 0 10 px ; margin : 20 px 0 0 0 ; } #l o g i n M a i n B o x { w i d t h : 860 px ; /∗500 px ∗/ margin−t o p : 10 px ; margin− l e f t : 70 px ; /∗250 px ∗/ −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; −moz−b o r d e r −r a d i u s : 10 px ; b o r d e r −top−l e f t −r a d i u s : 10 px 5 px ; b o r d e r −top−r i g h t −r a d i u s : 10 px ; } #r e s e t P a s s w o r d B o x { w i d t h : 500 px ; margin−t o p : 10 px ; margin− l e f t : 250 px ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; −moz−b o r d e r −r a d i u s : 10 px ; b o r d e r −top−l e f t −r a d i u s : 10 px 5 px ; b o r d e r −top−r i g h t −r a d i u s : 10 px ; } 262 Courier , monospace ; #l o g i n B o x { w i d t h : 300 px ; margin− l e f t : 280 px ; /∗90 px ∗/ } #l o g o u t B o x { w i d t h : 350 px ; margin− l e f t : 750 px ; margin−bottom : 10 px ; } #s i g n u p B o x { w i d t h : 400 px ; margin− l e f t : 50 px ; } #aboutBox { w i d t h : 950 px ; margin− l e f t : 0 px ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } #c o n t a i n e r { w i d t h : 1023 px ; margin−t o p : 10 px ; margin− l e f t : 60 px ; margin−r i g h t : 40 px ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } #h e a d e r { background−image : u r l ( ’ . . / l a y o u t / i m a g e s / HeasFimBanner . j p g ’ ) ; h e i g h t : 142 px ; w i d t h : 1000 px ; margin : 10 px ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; } #manageUserAccountsBox { w i d t h : 999 px ; margin− l e f t : −5px ; margin−t o p : 50 px ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; −moz−b o r d e r −r a d i u s : 10 px ; b o r d e r −top−l e f t −r a d i u s : 10 px 5 px ; b o r d e r −top−r i g h t −r a d i u s : 10 px ; } #manageContentBox { w i d t h : 999 px ; margin− l e f t : −5px ; margin−t o p : 50 px ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; −moz−b o r d e r −r a d i u s : 10 px ; b o r d e r −top−l e f t −r a d i u s : 10 px 5 px ; b o r d e r −top−r i g h t −r a d i u s : 10 px ; } #u s e r C o n t e n t B o x { w i d t h : 999 px ; margin− l e f t : −5px ; margin−t o p : 50 px ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; −moz−b o r d e r −r a d i u s : 10 px ; b o r d e r −top−l e f t −r a d i u s : 10 px 5 px ; b o r d e r −top−r i g h t −r a d i u s : 10 px ; } #manageUserAccountsHeading { background−c o l o r : #CC0000 ; color : #f f f f f f ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } #manageContentHeading { background−c o l o r : #CC0000 ; color : #f f f f f f ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } #u s e r C o n t e n t H e a d i n g { background−c o l o r : #CC0000 ; color : #f f f f f f ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } 263 #l o g i n H e a d i n g { w i d t h : 860 px ; /∗500 px ∗/ margin− l e f t : 0 px ; background−c o l o r : #CC0000 ; color : #f f f f f f ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } #r e g i s t e r H e a d i n g { w i d t h : 860 px ; /∗500 px ∗/ margin− l e f t : 0 px ; background−c o l o r : #CC0000 ; color : #f f f f f f ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } #u s e r R e c i p e s V i e w H e a d i n g { background−c o l o r : # f f f f f f ; c o l o r : #CC0000 ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; /∗ p o s i t i o n : a b s o l u t e ; t o p : 275 px ; w i d t h : 318 px ; ∗ / } #u s e r R e c i p e s B o x { } #u s e r A c h i e v e m e n t s V i e w H e a d i n g { background−c o l o r : # f f f f f f ; c o l o r : #CC0000 ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; /∗ p o s i t i o n : a b s o l u t e ; t o p : 275 px ; w i d t h : 318 px ; ∗ / } #u s e r A c h i e v e m e n t s B o x { } #u s e r H e a l t h T i p s V i e w H e a d i n g { background−c o l o r : # f f f f f f ; c o l o r : #CC0000 ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; /∗ p o s i t i o n : a b s o l u t e ; t o p : 275 px ; w i d t h : 318 px ; ∗ / } #u s e r H e a l t h T i p s B o x { } #addUserBox { margin− l e f t : } 10 px ; #contentMenuBox { margin− l e f t : } 10 px ; #userMenuBox { margin− l e f t : } 10 px ; #v i e w U s e r s B o x { w i d t h : 985 px ; margin− l e f t : 5 px ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } #v i e w U s e r s B o x t a b l e { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; f o n t −s i z e : 10 p t ; c o l o r : #000000; } #v i e w U s e r s B o x t d { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #v i e w U s e r s B o x t h { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; 264 color : white ; } #u s e r F e e d H e a d i n g { w i d t h : 985 px ; margin− l e f t : 5 px ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } #u s e r F e e d H e a d i n g t a b l e { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; f o n t −s i z e : 10 p t ; c o l o r : #000000; w i d t h : 980 px ; } #u s e r F e e d H e a d i n g t d { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #u s e r F e e d H e a d i n g t r { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #u s e r F e e d H e a d i n g t h { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; c o l o r : white ; } #userViewBox { w i d t h : 985 px ; margin− l e f t : 5 px ; b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; } #userViewBox t a b l e { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; f o n t −s i z e : 10 p t ; c o l o r : #000000; w i d t h : 980 px ; } #userViewBox t d { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #userViewBox t r { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #userViewBox t h { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; c o l o r : white ; } #u s e r S e a r c h F E L D i a l o g t a b l e { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; f o n t −s i z e : 10 p t ; c o l o r : #000000; } #u s e r S e a r c h F E L D i a l o g t d { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #u s e r S e a r c h F E L D i a l o g t h { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; c o l o r : white ; } #v i e w F P D i a l o g t a b l e { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; f o n t −s i z e : 10 p t ; 265 color : #000000; } #v i e w F P D i a l o g t d { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #v i e w F P D i a l o g t h { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; c o l o r : white ; } /∗CREATE RECIPE GUIDELINES∗/ #h e a l t h C o n d i t i o n s G u i d e l i n e s M o d a l D i a l o g t a b l e { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; f o n t −s i z e : 10 p t ; c o l o r : #000000; } #h e a l t h C o n d i t i o n s G u i d e l i n e s M o d a l D i a l o g t d { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #h e a l t h C o n d i t i o n s G u i d e l i n e s M o d a l D i a l o g t h { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; c o l o r : white ; } /∗VIEW CREATED RECIPES∗/ #v i e w C r e a t e d R e c i p e s D i a l o g t a b l e { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; f o n t −s i z e : 10 p t ; c o l o r : #000000; } #v i e w C r e a t e d R e c i p e s D i a l o g t d { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #v i e w C r e a t e d R e c i p e s D i a l o g t h { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; c o l o r : white ; } . redbox { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; c o l o r : white ; } /∗ADD MEAL∗/ /∗VIEW CREATED RECIPES∗/ #a d d M e a l D i a l o g t a b l e { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; f o n t −s i z e : 10 p t ; c o l o r : #000000; } #a d d M e a l D i a l o g t d { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #a d d M e a l D i a l o g t h { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; c o l o r : white ; } #addMealButton { w i d t h : 120 px ; } /∗PLAN DAILY MEALS∗/ #p l a n D a i l y M e a l s D i a l o g t a b l e { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; f o n t −f a m i l y : Verdana ; f o n t −s i z e : 10 p t ; 266 color : #000000; } #p l a n D a i l y M e a l s D i a l o g t d { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; t e x t −a l i g n : c e n t e r ; } #p l a n D a i l y M e a l s D i a l o g t h { b o r d e r : 1 px s o l i d #D0D0D0 ; −w e b k i t−box−shadow : 0 0 8 px #D0D0D0 ; background−c o l o r : #CC0000 ; c o l o r : white ; } /∗BREAKFAST RECIPES∗/ #b r e a k f a s t r e c i p e s { b o r d e r : 1 px s o l i d #D0D0D0 ; } #i c o n s { margin : 0 ; padding : 0 ; } #i c o n s li { margin : 2 px ; position : relative ; p a d d i n g : 4 px 0 ; cursor : pointer ; float : left ; l i s t −s t y l e : none ; } #i c o n s span . u i −i c o n { float : left ; margin : 0 4 px ; } a . dp−c h o o s e −d a t e { float : left ; w i d t h : 16 px ; h e i g h t : 16 px ; padding : 0 ; margin : 5 px 3 px 0 ; display : block ; t e x t −i n d e n t : −2000px ; o v e r f l o w : hidden ; b a c k g r o u n d : u r l ( . . / l a y o u t / j q u e r y −u i − 1 . 1 0 . 3 . custom / d e v e l o p m e n t−b u n d l e / demos / d a t e p i c k e r / i m a g e s / c a l e n d a r . g i f ) no−r e p e a t ; } a . dp−c h o o s e −d a t e . dp−d i s a b l e d { background−p o s i t i o n : 0 −20px ; cursor : default ; } /∗ makes t h e i n p u t f i e l d s h o r t e r o n c e t h e d a t e p i c k e r c o d e ∗ h a s run ( t o a l l o w s p a c e f o r t h e c a l e n d a r i c o n ∗/ i n p u t . dp−a p p l i e d { w i d t h : 140 px ; float : left ; } . verify { margin−t o p : −7px ; margin− l e f t : 9 px ; position : absolute ; w i d t h : 402 px ; h e i g h t : 16 px ; } . noclose . u i −d i a l o g −t i t l e b a r −c l o s e { d i s p l a y : none ; } . us−top−nav { width : auto ; position : absolute ; t o p : 175 px ; l e f t : 893 px ; } . s e t t i n g s −p e r s o n { float : left ; } . s e t t i n g s −t r i a n g l e { float : left ; } . us−i n n e r −nav { w i d t h : 172 px ; t e x t −a l i g n : c e n t e r ; position : absolute ; t o p : 30 px ; l e f t : −145px ; } . us−i n n e r −nav−o p t i o n { −w e b k i t−t r a n s i t i o n : . 2 s ; −moz−t r a n s i t i o n : . 2 s ; 267 −o−t r a n s i t i o n : . 2 s ; transition : .2 s ; f o n t −w e i g h t : b o l d ; } . us−i n n e r −nav−o p t i o n : h o v e r { c o l o r :# c c 0 0 0 0 ; } /∗∗∗∗∗∗∗∗∗∗∗/ . cm−top−nav { width : auto ; position : absolute ; t o p : 175 px ; l e f t : 893 px ; } . s e t t i n g s −p e r s o n { float : left ; } . s e t t i n g s −t r i a n g l e { float : left ; } . cm−i n n e r −nav { w i d t h : 172 px ; t e x t −a l i g n : c e n t e r ; position : absolute ; t o p : 30 px ; l e f t : −210px ; } . cm−i n n e r −nav−o p t i o n { −w e b k i t−t r a n s i t i o n : . 2 s ; −moz−t r a n s i t i o n : . 2 s ; −o−t r a n s i t i o n : . 2 s ; transition : .2 s ; f o n t −w e i g h t : b o l d ; } . cm−i n n e r −nav−o p t i o n : h o v e r { c o l o r :# c c 0 0 0 0 ; } /∗∗∗∗∗∗∗∗∗∗∗/ . ad−top−nav { width : auto ; position : absolute ; t o p : 175 px ; l e f t : 893 px ; } . s e t t i n g s −p e r s o n { float : left ; } . s e t t i n g s −t r i a n g l e { float : left ; } . ad−i n n e r −nav { w i d t h : 172 px ; t e x t −a l i g n : c e n t e r ; position : absolute ; t o p : 30 px ; l e f t : −181px ; } . ad−i n n e r −nav−o p t i o n { −w e b k i t−t r a n s i t i o n : . 2 s ; −moz−t r a n s i t i o n : . 2 s ; −o−t r a n s i t i o n : . 2 s ; transition : .2 s ; f o n t −w e i g h t : b o l d ; } . ad−i n n e r −nav−o p t i o n : h o v e r { c o l o r :# c c 0 0 0 0 ; } /∗CONTENT MANAGER NAVIGATION∗/ . c o n t e n t −top−nav { w i d t h : 200 px ; position : absolute ; t o p : 175 px ; l e f t : 170 px ; } . c o n t e n t −t r i a n g l e { float : left ; } . c o n t e n t −p l u s t h i c k { float : left ; } . c o n t e n t −i n n e r −nav { w i d t h : 135 px ; t e x t −a l i g n : c e n t e r ; position : absolute ; 268 t o p : −4px ; l e f t : 0 px ; } . c o n t e n t −i n n e r −nav−o p t i o n { −w e b k i t−t r a n s i t i o n : . 2 s ; −moz−t r a n s i t i o n : . 2 s ; −o−t r a n s i t i o n : . 2 s ; transition : .2 s ; f o n t −w e i g h t : b o l d ; } . c o n t e n t −i n n e r −nav−o p t i o n : h o v e r { c o l o r :# c c 0 0 0 0 ; } . c o n t e n t −c o n t e n t −top−nav { w i d t h : 200 px ; position : absolute ; t o p : 175 px ; l e f t : 307 px ; } . c o n t e n t −c o n t e n t −t r i a n g l e { float : left ; } . c o n t e n t −c o n t e n t −s t a r { float : left ; } . c o n t e n t −c o n t e n t −i n n e r −nav { w i d t h : 150 px ; t e x t −a l i g n : c e n t e r ; position : absolute ; t o p : −4px ; l e f t : 0 px ; } . c o n t e n t −c o n t e n t −i n n e r −nav−o p t i o n { −w e b k i t−t r a n s i t i o n : . 2 s ; −moz−t r a n s i t i o n : . 2 s ; −o−t r a n s i t i o n : . 2 s ; transition : .2 s ; f o n t −w e i g h t : b o l d ; } . c o n t e n t −c o n t e n t −i n n e r −nav−o p t i o n : h o v e r { c o l o r :# c c 0 0 0 0 ; } /∗USER NAVIGATION∗/ . u s e r −top−nav { w i d t h : 200 px ; position : absolute ; t o p : 175 px ; l e f t : 170 px ; } . u s e r −t r i a n g l e { float : left ; } . u s e r −n o t e { float : } left ; . u s e r −i n n e r −nav { w i d t h : 157 px ; t e x t −a l i g n : c e n t e r ; position : absolute ; t o p : −4px ; l e f t : 0 px ; } . u s e r −i n n e r −nav−o p t i o n { −w e b k i t−t r a n s i t i o n : . 2 s ; −moz−t r a n s i t i o n : . 2 s ; −o−t r a n s i t i o n : . 2 s ; transition : .2 s ; f o n t −w e i g h t : b o l d ; } . u s e r −i n n e r −nav−o p t i o n : h o v e r { c o l o r :# c c 0 0 0 0 ; } . u s e r −u s e r −top−nav { w i d t h : 200 px ; position : absolute ; t o p : 175 px ; l e f t : 329 px ; } . u s e r −u s e r −t r i a n g l e { float : left ; } . u s e r −u s e r −c l i p b o a r d { 269 float : left ; } . u s e r −u s e r −i n n e r −nav { w i d t h : 147 px ; t e x t −a l i g n : c e n t e r ; position : absolute ; t o p : −4px ; l e f t : 0 px ; } . u s e r −u s e r −i n n e r −nav−o p t i o n { −w e b k i t−t r a n s i t i o n : . 2 s ; −moz−t r a n s i t i o n : . 2 s ; −o−t r a n s i t i o n : . 2 s ; transition : .2 s ; f o n t −w e i g h t : b o l d ; } . u s e r −u s e r −i n n e r −nav−o p t i o n : h o v e r { c o l o r :# c c 0 0 0 0 ; } . u s e r −u s e r −u s e r −top−nav { w i d t h : 200 px ; position : absolute ; t o p : 175 px ; l e f t : 478 px ; } . u s e r −u s e r −u s e r −t r i a n g l e { float : left ; } . u s e r −u s e r −u s e r −s t a r { float : left ; } . u s e r −u s e r −u s e r −i n n e r −nav { w i d t h : 183 px ; t e x t −a l i g n : c e n t e r ; position : absolute ; t o p : −4px ; l e f t : 0 px ; } . u s e r −u s e r −u s e r −i n n e r −nav−o p t i o n { −w e b k i t−t r a n s i t i o n : . 2 s ; −moz−t r a n s i t i o n : . 2 s ; −o−t r a n s i t i o n : . 2 s ; transition : .2 s ; f o n t −w e i g h t : b o l d ; } . u s e r −u s e r −u s e r −i n n e r −nav−o p t i o n : h o v e r { c o l o r :# c c 0 0 0 0 ; } . u s e r −u s e r −u s e r −u s e r −top−nav { w i d t h : 240 px ; position : absolute ; t o p : 175 px ; l e f t : 663 px ; } . u s e r −u s e r −u s e r −u s e r −t r i a n g l e { float : left ; } . u s e r −u s e r −u s e r −u s e r −s e a r c h { float : left ; } . u s e r −u s e r −u s e r −u s e r −i n n e r −nav { w i d t h : 228 px ; t e x t −a l i g n : c e n t e r ; position : absolute ; t o p : −4px ; l e f t : 0 px ; } . u s e r −u s e r −u s e r −u s e r −i n n e r −nav−o p t i o n { −w e b k i t−t r a n s i t i o n : . 2 s ; −moz−t r a n s i t i o n : . 2 s ; −o−t r a n s i t i o n : . 2 s ; transition : .2 s ; f o n t −w e i g h t : b o l d ; } . u s e r −u s e r −u s e r −u s e r −i n n e r −nav−o p t i o n : h o v e r { c o l o r :# c c 0 0 0 0 ; } /∗NEWSFEED CSS∗/ 270 XII. Acknowledgement Foremost, I would like to express my deepest gratitude to my thesis adviser, Ma’am Avegail D. Carpio for the guidance, patience, and motivation. My thesis would not be feasible without her. Thank you, ma’am Ave. To UP Manila thank you so much for all the experiences that molded me into someone who can possibly stand even the strongest storm. To my fellow Iron Man fan, you are the best! Thank you so much for everything. To all my friends, thank you so much for all these years of friendship. To my parents and my sister, thank you for the unending support and encouragement, for being with me through it all. I am so lucky to have you. I could not ask for more. As a Scholastican would say after every prayer, ”That in All Things, God May Be Glorified!” 271